Пример #1
0
 def unbinder(self, items):
     for keystring in items:
         try:
             Keybinder.unbind(items[keystring])
         except:
             pass
     HotKeysConfig.binded = False
Пример #2
0
 def unbinder(self, items):
     for keystring in items:
         try:
             Keybinder.unbind(items[keystring])
         except:
             pass
     HotKeysConfig.binded = False
Пример #3
0
def bind_key(keystr, keybinding_target=KEYBINDING_DEFAULT):
    """
    Bind @keystr, unbinding any previous key for @keybinding_target.
    If @keystr is a false value, any previous key will be unbound.
    """
    keybinding_target = int(keybinding_target)

    if Keybinder is None:
        return False

    def callback(keystr):
        return GetKeyboundObject()._keybinding(keybinding_target)

    if not _is_sane_keybinding(keystr):
        pretty.print_error(__name__, "Refusing to bind key", repr(keystr))
        return False

    succ = True
    if keystr:
        try:
            succ = Keybinder.bind(keystr, callback)
            pretty.print_debug(__name__, "binding", repr(keystr))
            GetKeyboundObject().emit_bound_key_changed(keystr, True)
        except KeyError as exc:
            pretty.print_error(__name__, exc)
            succ = False
    if succ:
        old_keystr = get_currently_bound_key(keybinding_target)
        if old_keystr and old_keystr != keystr:
            Keybinder.unbind(old_keystr)
            pretty.print_debug(__name__, "unbinding", repr(old_keystr))
            GetKeyboundObject().emit_bound_key_changed(old_keystr, False)
        _register_bound_key(keystr, keybinding_target)
    return succ
Пример #4
0
 def cancel(self):
     if not self._callback:
         return
     for keystring in self._worked:
         Keybinder.unbind(keystring)
     del self._worked[:]
     self._callback = None
Пример #5
0
def bind_key(keystr, keybinding_target=KEYBINDING_DEFAULT):
    """
    Bind @keystr, unbinding any previous key for @keybinding_target.
    If @keystr is a false value, any previous key will be unbound.
    """
    keybinding_target = int(keybinding_target)

    if Keybinder is None:
        return False

    def callback(keystr):
        return GetKeyboundObject()._keybinding(keybinding_target)

    if not _is_sane_keybinding(keystr):
        pretty.print_error(__name__, "Refusing to bind key", repr(keystr))
        return False

    succ = True
    if keystr:
        try:
            succ = Keybinder.bind(keystr, callback)
            pretty.print_debug(__name__, "binding", repr(keystr))
            GetKeyboundObject().emit_bound_key_changed(keystr, True)
        except KeyError as exc:
            pretty.print_error(__name__, exc)
            succ = False
    if succ:
        old_keystr = get_currently_bound_key(keybinding_target)
        if old_keystr and old_keystr != keystr:
            Keybinder.unbind(old_keystr)
            pretty.print_debug(__name__, "unbinding", repr(old_keystr))
            GetKeyboundObject().emit_bound_key_changed(old_keystr, False)
        _register_bound_key(keystr, keybinding_target)
    return succ
Пример #6
0
 def cancel(self):
     if not self._callback:
         return
     for keystring in self._worked:
         Keybinder.unbind(keystring)
     del self._worked[:]
     self._callback = None
Пример #7
0
    def set_hotkey(self, accel_name):
        if self._current_accel_name:
            Keybinder.unbind(self._current_accel_name)
            self._current_accel_name = None

        Keybinder.bind(accel_name, self.on_hotkey_press)
        self._current_accel_name = accel_name
Пример #8
0
def rebind_key(keystring, is_bound):
    if is_bound:
        print("binding", keystring)
        keybinder.bind(keystring, relay_key, keystring)
    else:
        print("unbinding", keystring)
        keybinder.unbind(keystring)
Пример #9
0
 def unbind(self):
     try:
         keybinder.unbind(self.prevbinding)
         self.bound = False
     except KeyError:
         # if the requested keybinding is not bound, a KeyError will be thrown
         pass
Пример #10
0
 def initialize(self):
     """
     Unbind previous hotkeys, re-read config & bind new hotkeys.
     """
     for operation, key in self.hotkeys.items():
         Keybinder.unbind(key)
     self.hotkeys = self.load_keys()
     for operation, key in self.hotkeys.items():
         Keybinder.bind(key, self.fire_hook, operation)
Пример #11
0
 def bind_key(cls):
     Keybinder.init()
     shortcut = MetaData.get_snapshoot_shortcut()
     if Keybinder.bind(shortcut,cls.callback,""):
         if cls.old_key_shortcut is not None:
             Keybinder.unbind(cls.old_key_shortcut)
         cls.old_key_shortcut = shortcut
     else:
         logging.error("Bind shortcut key failed ")
Пример #12
0
 def bind_key(cls):
     Keybinder.init()
     shortcut = MetaData.get_snapshoot_shortcut()
     if Keybinder.bind(shortcut, cls.callback, ""):
         if cls.old_key_shortcut is not None:
             Keybinder.unbind(cls.old_key_shortcut)
         cls.old_key_shortcut = shortcut
     else:
         logging.error("Bind shortcut key failed ")
Пример #13
0
 def on_child_exit(self, pid, errcode, proc):
     Keybinder.unbind(conf.get(proc.name, 'KEY'))
     Process.__instances__.remove(proc)
     if errcode != 0:
         raise OSError('Terminal {} crashed'.format(self.name))
     if conf.getboolean(self.name, 'Restart'):
         Process(self.name)
         del self
     else:
         sys.exit()
Пример #14
0
    def bind_show_app_hotkey(self, accel_name):
        if self._current_accel_name == accel_name:
            return

        if self._current_accel_name:
            Keybinder.unbind(self._current_accel_name)
            self._current_accel_name = None

        logger.info("Trying to bind app hotkey: %s" % accel_name)
        Keybinder.bind(accel_name, self.cb_toggle_visibility)
        self._current_accel_name = accel_name
Пример #15
0
def bind(binding, func, *args, **kwargs):
    """Wrapper for keybinder.bind() allowing kwargs."""

    def run(_, __): func(*args, **kwargs)
    try:
        Keybinder.unbind(binding)
    except:
        pass
    success = Keybinder.bind(binding, run, None)
    if not success:
        print "Error binding '%s'" % binding
Пример #16
0
 def set_app_show(self, new):
     '''
     This is a specific method to set just the show accelerator.
     We use the value from gsettings to first unbind the current
     key, so in the process of changing the hotkey, we expect the
     API user to first call this method and later change gsettings.
     '''
     if platform.system() == 'Windows':
         self.app.set_hotkey(new)
     else:
         Keybinder.unbind(self.shortcuts['app-show'])
         Keybinder.bind(new, self.app.on_show)
Пример #17
0
 def show_preferences(self, widget):
     widget.set_sensitive(False)
     preferences = Preferences()
     Keybinder.unbind(self.new_task_keybind)
     Keybinder.unbind(self.show_tasks_keybind)
     response = preferences.run()
     if response == Gtk.ResponseType.ACCEPT:
         preferences.save()
         self.load_preferences()
         self.load_todos()
         self.set_icon()
     widget.set_sensitive(True)
     preferences.destroy()
Пример #18
0
    def bind_hotkey(self, accel_name):
        if not IS_X11 or self._current_accel_name == accel_name:
            return

        if self._current_accel_name:
            Keybinder.unbind(self._current_accel_name)
            self._current_accel_name = None

        logger.info("Trying to bind app hotkey: %s", accel_name)
        Keybinder.bind(accel_name, lambda _: self.window.show_window())
        self._current_accel_name = accel_name
        if FIRST_RUN:
            display_name = Gtk.accelerator_get_label(*Gtk.accelerator_parse(accel_name))
            show_notification("Ulauncher", f"Hotkey is set to {display_name}")
Пример #19
0
    def bind_show_app_hotkey(self, accel_name):
        if is_wayland_compatibility_on():
            return

        if self._current_accel_name == accel_name:
            return

        if self._current_accel_name:
            Keybinder.unbind(self._current_accel_name)
            self._current_accel_name = None

        logger.info("Trying to bind app hotkey: %s" % accel_name)
        Keybinder.bind(accel_name, self.toggle_window)
        self._current_accel_name = accel_name
        self.notify_hotkey_change(accel_name)
Пример #20
0
    def bind_show_app_hotkey(self, accel_name):
        if is_wayland_compatibility_on():
            return

        if self._current_accel_name == accel_name:
            return

        if self._current_accel_name:
            Keybinder.unbind(self._current_accel_name)
            self._current_accel_name = None

        logger.info("Trying to bind app hotkey: %s", accel_name)
        Keybinder.bind(accel_name, self.toggle_window)
        self._current_accel_name = accel_name
        self.notify_hotkey_change(accel_name)
Пример #21
0
    def bind_tab(self, bind=True):
        if bind:
            Keybinder.bind(self.super + 'Tab', self.tab_key, False)
            Keybinder.bind(self.super + '<Shift>Tab', self.tab_key, True)

            for i, key in enumerate(self.monkeys):
                Keybinder.bind(self.super + '<Ctrl>' + key, self.tab_key,
                               False, i)
                Keybinder.bind(self.super + '<Ctrl><Shift>' + key,
                               self.tab_key, False, i)
        else:
            Keybinder.unbind(self.super + 'Tab')
            Keybinder.unbind(self.super + '<Shift>Tab')

            for i, key in enumerate(self.monkeys):
                Keybinder.unbind(self.super + '<Ctrl>' + key)
                Keybinder.unbind(self.super + '<Ctrl><Shift>' + key)
Пример #22
0
    def bind_tab(self, bind=True):
        if bind:
            Keybinder.bind(self.super + 'Tab', self.tab_key, False)
            Keybinder.bind(self.super + '<Shift>Tab', self.tab_key, True)

            for i, key in enumerate(self.monkeys):
                Keybinder.bind(self.super + '<Ctrl>' + key,
                               self.tab_key, False, i)
                Keybinder.bind(self.super + '<Ctrl><Shift>' + key,
                               self.tab_key, False, i)
        else:
            Keybinder.unbind(self.super + 'Tab')
            Keybinder.unbind(self.super + '<Shift>Tab')

            for i, key in enumerate(self.monkeys):
                Keybinder.unbind(self.super + '<Ctrl>' + key)
                Keybinder.unbind(self.super + '<Ctrl><Shift>' + key)
Пример #23
0
 def unbind(self, accel_name):
     Keybinder.unbind(accel_name)
Пример #24
0
	def remove_all_keybindings(self):
		for k in self.keybinding_strings:
			Keybinder.unbind(k)
		self.keybinding_strings = []
 def teardown(self):
     Keybinder.unbind(self._params['hotkey'])
Пример #26
0
 def teardown(self, exaile):
     for k in KEYS:
         Keybinder.unbind(k)
Пример #27
0
 def unbind_keys(self):
     for keystring in self.bound_keys:
         Keybinder.unbind(keystring)
     self.bound_keys = []
Пример #28
0
 def _unbind(self, hotkey):
     Keybinder.unbind(self._gtk_hotkey(hotkey))
Пример #29
0
 def set_app_show(self, new):
     """
     We expect gsettings hasn't been changed yet.
     """
     Keybinder.unbind(self.shortcuts["app-show"])
     Keybinder.bind(new, self.app.on_show)
Пример #30
0
    def unset_accelerator(self):
        old_accel_string, _ = user_data.load_accelerator()

        if old_accel_string:
            Keybinder.unbind(old_accel_string)
Пример #31
0
 def unbind_toggle_key(self):
     if not self._toggle_key: return
     self.debug(f"Unbinding toggle key {self._toggle_key}")
     Keybinder.unbind(self._toggle_key)
     self._toggle_key = None
Пример #32
0
 def teardown(self):
     for k in KEYS:
         Keybinder.unbind(k)
Пример #33
0
def disable(exaile):
    for k in KEYS:
        Keybinder.unbind(k)