Ejemplo n.º 1
0
 def _bind_term(self):
     """Bindea la terminal si tenemos el modulo necesario para hacerlo."""
     try:
         keybinder = KeybinderGtk()
         keybinder.register('<Ctrl>x', self.abrir_terminal)
         keybinder.start()
     except (KeyError, NameError):
         pass
Ejemplo n.º 2
0
    def __init__(self):
        super().__init__()

        self.set_application_id(version.APP_ID)
        self.set_flags(Gio.ApplicationFlags.HANDLES_COMMAND_LINE)

        screen = Gdk.Screen.get_default()
        css_provider = Gtk.CssProvider()
        css_provider.load_from_path(common.CSS_PATH)
        style_context = Gtk.StyleContext()
        style_context.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)

        gtk_settings = Gtk.Settings.get_default()
        gtk_settings.props.gtk_application_prefer_dark_theme = True

        self._window = None
        self._editor = editor.Editor()
        self._previewer = previewer.Previewer()
        self._merger = merger.Merger()
        self._merger.connect("merge", self.merge_items)
        self._items_processors = ItemsProcessors()
        self._items_processors.add_processor(self._editor)
        self._items_processors.add_processor(self._previewer)
        self._items_processors.add_processor(self._merger)

        self._main_toolbox = MainToolbox()
        self._main_toolbox.prefs_btn.connect("clicked", lambda b: self.show_prefs())
        self._main_toolbox.about_btn.connect("clicked", lambda b: self.show_about())
        self._main_toolbox.quit_btn.connect("clicked", lambda b: self.quit())
        self._main_toolbox.restart_btn.connect("clicked", self._restart_daemon)
        self._main_toolbox.close_btn.connect("clicked", lambda b: self.hide(reset_search=True))
        self._main_toolbox.track_btn.connect("clicked", lambda b: gpaste_client.track(b.get_active()))
        self._main_toolbox.track_btn.set_active(gpaste_client.get_prop("Active"))
        self._main_toolbox.help_btn.connect("clicked", lambda b: shortcuts_window.show_or_false(self._window))

        self._history_items = HistoryItems()

        self._search_box = SearchBox()
        self._search_box.connect("search-changed", self._on_search_changed)
        self._search_box.connect("search-index", lambda sb, i: self._on_search_changed(sb, search_index=i))
        self._search_box.entry.connect("activate", self._on_entry_activated)

        self._items_view = ItemsView()
        self._items_view.connect("item-activated", self._on_item_activated)
        self._items_view.connect("item-entered", self._on_item_entered)
        self._items_view.connect("item-left", lambda iv, i: self.selection_changed())
        self._items_view.listbox.connect("selected-rows-changed", lambda iv: self.selection_changed())
        self._items_view.bind(self._history_items)

        gpaste_client.connect("ShowHistory", self.toggle)
        gpaste_client.connect("Tracking", lambda t: self._main_toolbox.track_btn.set_active(t))
        common.APPLICATION = self

        keybinder = KeybinderGtk()
        keybinder.register(
            common.SETTINGS[common.SHOW_CLIPBOARD_PREVIEW], lambda *_, **__: GLib.idle_add(clipboard_preview.toggle)
        )
        keybinder.start()
Ejemplo n.º 3
0
def server(opacity):

    dimmed = Dimmed(opacity)

    keybinder = KeybinderGtk()
    keybinder.register('<Ctrl>Escape', Gtk.main_quit)
    keybinder.start()

    signal.signal(signal.SIGTERM, Gtk.main_quit)
    signal.signal(signal.SIGINT, Gtk.main_quit)

    ControlReader(dimmed).start()
    Gtk.main()
Ejemplo n.º 4
0
    def __init__(self, player):
        self.player = player

        self.callbacks = {
            'VolumeUp': self.volume_up,
            'VolumeDown': self.volume_down,
            'Mute': lambda *args: player.toggle_mute_cb(),
            'Previous': lambda *args: player.load_prev_cb(),
            'Next': lambda *args: player.load_next_cb(),
            'Pause': lambda *args: player.play_pause_cb(),
            'Play': lambda *args: player.play_pause_cb(),
            'Stop': lambda *args: player.stop_player_cb(),
            'Launch': self.present_window,
        }

        if keybinder_imported:
            self.keybinder = KeybinderGtk()
            self.bind_keys()
            self.keybinder.start()
Ejemplo n.º 5
0
 def _bind_term(self):
     """Bindea la terminal si tenemos el modulo necesario para hacerlo."""
     try:
         keybinder = KeybinderGtk()
         keybinder.register('<Ctrl>x', self.abrir_terminal)
         keybinder.start()
     except (KeyError, NameError):
         pass
Ejemplo n.º 6
0
class Shortcut:
    def __init__(self, player):
        self.player = player

        self.callbacks = {
                'VolumeUp': self.volume_up,
                'VolumeDown': self.volume_down,
                'Mute':
                    lambda *args: player.toggle_mute_cb(),
                'Previous': lambda *args: player.load_prev_cb(),
                'Next': lambda *args: player.load_next_cb(),
                'Pause': lambda *args: player.play_pause_cb(),
                'Play': lambda *args: player.play_pause_cb(),
                'Stop': lambda *args: player.stop_player_cb(),
                'Launch': self.present_window,
                }

        if keybinder_imported:
            self.keybinder = KeybinderGtk()
            self.bind_keys()
            self.keybinder.start()
            
    def volume_up(self, *args):
        volume = self.player.volume.get_value() + 0.15
        if volume > 1:
            volume = 1
        self.player.set_volume_cb(volume)

    def volume_down(self, *args):
        volume = self.player.volume.get_value() - 0.15
        if volume < 0:
            volume = 0
        self.player.set_volume_cb(volume)

    def present_window(self, *args):
        GLib.idle_add(self.player.app.window.present)

    def bind_keys(self):
        if not keybinder_imported:
            return
        curr_mode = self.player.app.conf['shortcut-mode']
        if curr_mode == ShortcutMode.NONE:
            return
        if curr_mode == ShortcutMode.DEFAULT:
            shortcut_keys = self.player.app.conf['default-shortcut']
        elif curr_mode == ShortcutMode.CUSTOM:
            shortcut_keys = self.player.app.conf['custom-shortcut']
        for name, key in shortcut_keys.items():
            self.keybinder.register(key, self.callbacks[name])

    def rebind_keys(self):
        self.bind_keys()

    def quit(self):
        print('Shortcut.quit')
        if keybinder_imported:
            self.keybinder.stop()
Ejemplo n.º 7
0
class Shortcut:
    def __init__(self, player):
        self.player = player

        self.callbacks = {
            'VolumeUp': self.volume_up,
            'VolumeDown': self.volume_down,
            'Mute': lambda *args: player.toggle_mute_cb(),
            'Previous': lambda *args: player.load_prev_cb(),
            'Next': lambda *args: player.load_next_cb(),
            'Pause': lambda *args: player.play_pause_cb(),
            'Play': lambda *args: player.play_pause_cb(),
            'Stop': lambda *args: player.stop_player_cb(),
            'Launch': self.present_window,
        }

        if keybinder_imported:
            self.keybinder = KeybinderGtk()
            self.bind_keys()
            self.keybinder.start()

    def volume_up(self, *args):
        volume = self.player.volume.get_value() + 0.15
        if volume > 1:
            volume = 1
        self.player.set_volume_cb(volume)

    def volume_down(self, *args):
        volume = self.player.volume.get_value() - 0.15
        if volume < 0:
            volume = 0
        self.player.set_volume_cb(volume)

    def present_window(self, *args):
        GLib.idle_add(self.player.app.window.present)

    def bind_keys(self):
        if not keybinder_imported:
            return
        curr_mode = self.player.app.conf['shortcut-mode']
        if curr_mode == ShortcutMode.NONE:
            return
        if curr_mode == ShortcutMode.DEFAULT:
            shortcut_keys = self.player.app.conf['default-shortcut']
        elif curr_mode == ShortcutMode.CUSTOM:
            shortcut_keys = self.player.app.conf['custom-shortcut']
        for name, key in shortcut_keys.items():
            self.keybinder.register(key, self.callbacks[name])

    def rebind_keys(self):
        self.bind_keys()

    def quit(self):
        if keybinder_imported:
            self.keybinder.stop()
Ejemplo n.º 8
0
    def __init__(self, player):
        self.player = player

        self.callbacks = {
            'VolumeUp': self.volume_up,
            'VolumeDown': self.volume_down,
            'Mute': lambda *args: player.toggle_mute_cb(),
            'Previous': lambda *args: player.load_prev_cb(),
            'Next': lambda *args: player.load_next_cb(),
            'Pause': lambda *args: player.play_pause_cb(),
            'Play': lambda *args: player.play_pause_cb(),
            'Stop': lambda *args: player.stop_player_cb(),
            'Launch': self.present_window,
        }

        if keybinder_imported:
            self.keybinder = KeybinderGtk()
            self.bind_keys()
            self.keybinder.start()
Ejemplo n.º 9
0
    def __init__(self):
        super().__init__()

        self.set_application_id(version.APP_ID)
        self.set_flags(Gio.ApplicationFlags.HANDLES_COMMAND_LINE)

        screen = Gdk.Screen.get_default()
        css_provider = Gtk.CssProvider()
        css_provider.load_from_path(common.CSS_PATH)
        style_context = Gtk.StyleContext()
        style_context.add_provider_for_screen(screen, css_provider,
                                              Gtk.STYLE_PROVIDER_PRIORITY_USER)

        gtk_settings = Gtk.Settings.get_default()
        gtk_settings.props.gtk_application_prefer_dark_theme = True

        self._window = None
        self._editor = editor.Editor()
        self._previewer = previewer.Previewer()
        self._merger = merger.Merger()
        self._merger.connect('merge', self.merge_items)
        self._items_processors = ItemsProcessors()
        self._items_processors.add_processor(self._editor)
        self._items_processors.add_processor(self._previewer)
        self._items_processors.add_processor(self._merger)

        self._main_toolbox = MainToolbox()
        self._main_toolbox.prefs_btn.connect('clicked',
                                             lambda b: self.show_prefs())
        self._main_toolbox.about_btn.connect('clicked',
                                             lambda b: self.show_about())
        self._main_toolbox.quit_btn.connect('clicked', lambda b: self.quit())
        self._main_toolbox.restart_btn.connect('clicked', self._restart_daemon)
        self._main_toolbox.close_btn.connect(
            'clicked', lambda b: self.hide(reset_search=True))
        self._main_toolbox.track_btn.connect(
            'clicked', lambda b: gpaste_client.track(b.get_active()))
        self._main_toolbox.track_btn.set_active(
            gpaste_client.get_prop('Active'))
        self._main_toolbox.help_btn.connect(
            'clicked', lambda b: shortcuts_window.show_or_false(self._window))

        self._history_items = HistoryItems()

        self._search_box = SearchBox()
        self._search_box.connect('search-changed', self._on_search_changed)
        self._search_box.connect(
            'search-index',
            lambda sb, i: self._on_search_changed(sb, search_index=i))
        self._search_box.entry.connect('activate', self._on_entry_activated)

        self._items_view = ItemsView()
        self._items_view.connect('item-activated', self._on_item_activated)
        self._items_view.connect('item-entered', self._on_item_entered)
        self._items_view.connect('item-left',
                                 lambda iv, i: self.selection_changed())
        self._items_view.listbox.connect('selected-rows-changed',
                                         lambda iv: self.selection_changed())
        self._items_view.bind(self._history_items)

        gpaste_client.connect('ShowHistory', self.toggle)
        gpaste_client.connect(
            'Tracking', lambda t: self._main_toolbox.track_btn.set_active(t))
        common.APPLICATION = self

        keybinder = KeybinderGtk()
        keybinder.register(
            common.SETTINGS[common.SHOW_CLIPBOARD_PREVIEW],
            lambda *_, **__: GLib.idle_add(clipboard_preview.toggle))
        keybinder.start()
Ejemplo n.º 10
0
 def __init__(self, player, gui):
     self.player = player
     self.gui = gui
     self.get_keybindings()
     self.binder = KeybinderGtk()
Ejemplo n.º 11
0
class keybind:
    def __init__(self, player, gui):
        self.player = player
        self.gui = gui
        self.get_keybindings()
        self.binder = KeybinderGtk()

    def get_keybindings(self):
        logging.debug("getting the keybindings from config file")
        self.play_keystr = str(configuration.get_conf("keybindings", "play", "string"))
        self.pause_keystr = str(configuration.get_conf("keybindings", "pause", "string"))
        self.next_keystr = str(configuration.get_conf("keybindings", "next", "string"))
        self.prev_keystr = str(configuration.get_conf("keybindings", "prev", "string"))
        self.volup_upkeystr = str(configuration.get_conf("keybindings", "volup", "string"))
        self.voldown_keystr = str(configuration.get_conf("keybindings", "voldown", "string"))
        self.file_keystr = str(configuration.get_conf("keybindings", "file_show", "string"))

    def bind_keys(self):
        logging.debug("binding the keys to the related functions")
        # call_play =lambda *args: self.gui.player_controls__.play_button_pressed()
        call_play = lambda *args: print("hahahhaha")
        call_pause = lambda *args: self.player.pause_track()
        call_next = lambda *args: self.player.start_next_track_from_playlist()
        call_prev = lambda *args: self.player.start_previous_track_from_playlist()
        call_volup = lambda *args: self.player.volume_track_up()
        call_voldown = lambda *args: self.player.volume_track_down()
        try:
            # play
            self.binder.register(self.play_keystr, call_play)
        except:
            logging.debug("binding failed")

        try:
            # pause
            self.binder.register(self.pause_keystr, call_pause)
        except:
            logging.debug("binding failed")

        try:
            # next
            self.binder.register(self.next_keystr, call_next)
        except:
            logging.debug("binding failed")

        try:
            # prev
            self.binder.register(self.prev_keystr, call_prev)
        except:
            logging.debug("binding failed")

        try:
            # vol-up
            self.binder.register(self.volup_upkeystr, call_volup)
        except:
            logging.debug("binding failed")

        try:
            # vol-down
            self.binder.register(self.voldown_keystr, call_voldown)
        except:
            logging.debug("binding failed")
        self.binder.start()