Beispiel #1
0
	def _create_accelerators(self, primary=True):
		"""Create accelerators from specified list"""
		accelerator_list = (self._secondary, self._primary)[primary]

		# connect all methods in list
		for method_name in self._methods.keys():
			if method_name in self._disabled:
				continue  # skip if method is disabled

			# try to get saved key combination from manager
			accelerator = self._manager.get_accelerator(self._name, method_name, primary)

			# if we don't have saved key combination, use default
			if accelerator is None and method_name in accelerator_list:
				accelerator = accelerator_list[method_name]

			# finally connect accelerator to specified method
			if accelerator is not None and accelerator[0] > 0:
				keyval = accelerator[0]
				modifier = accelerator[1]

				# create method name cache based on key combination
				label = Gtk.accelerator_get_label(keyval, modifier)
				self._method_names[label] = method_name

				# connect accelerator
				self._accel_group.connect(keyval, modifier, 0, self._handle_activate)
Beispiel #2
0
 def _is_good_keystr(self, keystr):
     # Reject single letters so you can't bind 'A' etc
     if keystr is None:
         return
     label = Gtk.accelerator_get_label(*Gtk.accelerator_parse(keystr))
     ulabel = kupferstring.tounicode(label)
     return not (len(ulabel) == 1 and ulabel.isalnum())
    def testAllMenuItemsAreDocumented(self):
        def menuitems(parent, level=0):
            for mi in parent.get_children():
                if isinstance(mi, ImageMenuItem):
                    yield mi, level
                sm = mi.get_submenu()
                if sm:
                    for mi_sm in menuitems(sm, level + 1):
                        yield mi_sm

        for menuitem, level in menuitems(self.mainwindow.menubar):
            label = menuitem.get_label().replace('_', '').rstrip('.')
            accel_path = menuitem.get_accel_path()
            accel_label = Gtk.accelerator_get_label(
                Gtk.AccelMap().lookup_entry(accel_path).key.accel_key,
                Gtk.AccelMap().lookup_entry(accel_path).key.accel_mods)
            if accel_label:
                if '++' in accel_label:
                    label += ' <' + accel_label.replace('++', '><+') + '>'
                else:
                    label += ' <' + accel_label.replace('+', '><') + '>'
            if level:
                label = '**' + label + '**'
            else:
                label = '===== ' + label + ' ====='
            self.assertTrue(label in self.manual,
                            'Menu item "{}" not documented'.format(label))
Beispiel #4
0
 def update_accelerator_label(self):
     if self.current_node.shortcut:
         key, mods = Gtk.accelerator_parse(self.current_node.shortcut)
         label = Gtk.accelerator_get_label(key, mods)
         self['accelerator'].set_text(label)
     else:
         self['accelerator'].set_text('')
Beispiel #5
0
 def _init_from_accel_map(self):
     """Initializes from the app UIManager and the global AccelMap"""
     if self.ui_manager is None:
         import application
         app = application.get_app()
         self.ui_manager = app.ui_manager
     assert self.ui_manager is not None
     self._action_labels.clear()
     self._store.clear()
     accel_labels = {}
     for path, key, mods, changed in self._get_accel_map_entries():
         accel_labels[path] = Gtk.accelerator_get_label(key, mods)
     for group in self.ui_manager.get_action_groups():
         group_name = group.get_name()
         for action in group.list_actions():
             action_name = action.get_name()
             path = "<Actions>/%s/%s" % (group_name, action_name)
             action_label = action.get_label()
             if not action_label:
                 continue
             self._action_labels[path] = action_label
             accel_label = accel_labels.get(path)
             row = [None for t in self._COLUMN_TYPES]
             row[self._PATH_COLUMN] = path
             row[self._ACTION_LABEL_COLUMN] = action_label
             row[self._ACCEL_LABEL_COLUMN] = accel_label
             self._store.append(row)
Beispiel #6
0
    def on_key_press(self, _, event):
        # remove GDK_MOD2_MASK, because it seems unnecessary
        mask = event.state
        if mask & Gdk.ModifierType.MOD2_MASK:
            mask ^= Gdk.ModifierType.MOD2_MASK
        if mask & Gdk.ModifierType.MOD4_MASK:
            mask ^= Gdk.ModifierType.MOD4_MASK

        accel_name = Gtk.accelerator_name(event.keyval, mask)
        display_name = Gtk.accelerator_get_label(event.keyval, mask)

        if accel_name == 'Return':
            # emit hotkey-set signal
            self.emit('hotkey-set', self._accel_name, self._display_name)
            self.hide()

        if accel_name == 'Escape':
            self.hide()
            return

        # do nothing for invalid hotkeys
        if not self.is_valid_hotkey(display_name, accel_name):
            logger.debug("Invalid hotkey '%s', ('%s') is not allowed",
                         display_name, accel_name)
            return

        self._accel_name = accel_name
        self._display_name = display_name
        self._hotkey_input.set_text(display_name)
 def update_accelerator_label(self):
     if self.current_node.shortcut:
         key, mods = Gtk.accelerator_parse(self.current_node.shortcut)
         label = Gtk.accelerator_get_label(key, mods)
         self['accelerator'].set_text(label)
     else:
         self['accelerator'].set_text('')
Beispiel #8
0
    def on_key_edited(self, renderer, path, keycode, mask, keyval, model):
        """Callback that handles key edition in cellrenderer. It makes
        some tests to validate the key, like looking for already in
        use keys and look for [A-Z][a-z][0-9] to avoid problems with
        these common keys. If all tests are ok, the value will be
        stored in gconf.
        """
        giter = model.get_iter(path)
        gconf_path = model.get_value(giter, 0)

        oldkey = model.get_value(giter, 2)
        hotkey = KeyEntry(keycode, mask)
        key = Gtk.accelerator_name(keycode, mask)
        keylabel = Gtk.accelerator_get_label(keycode, mask)

        # we needn't to change anything, the user is trying to set the
        # same key that is already set.
        if oldkey == hotkey:
            return False

        # looking for already used keybindings
        def each_key(model, path, subiter):
            keyentry = model.get_value(subiter, 2)
            if keyentry and keyentry == hotkey:
                msg = _("The shortcut \"%s\" is already in use.") % keylabel
                ShowableError(self.window, _('Error setting keybinding.'), msg,
                              -1)
                raise Exception(
                    'This is ok, we just use it to break the foreach loop!')

        model.foreach(each_key)

        # avoiding problems with common keys
        if ((mask == 0 and keycode != 0)
                and ((keycode >= ord('a') and keycode <= ord('z')) or
                     (keycode >= ord('A') and keycode <= ord('Z')) or
                     (keycode >= ord('0') and keycode <= ord('9')))):
            dialog = Gtk.MessageDialog(
                self.get_widget('config-window'),
                Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                Gtk.MessageType.WARNING, Gtk.ButtonsType.OK,
                _("The shortcut \"%s\" cannot be used "
                  "because it will become impossible to "
                  "type using this key.\n\n"
                  "Please try with a key such as "
                  "Control, Alt or Shift at the same "
                  "time.\n") % key)
            dialog.run()
            dialog.destroy()
            return False

        # setting new value in ui
        giter = model.get_iter(path)
        model.set_value(giter, 2, hotkey)

        # setting the new value in gconf
        if gconf_path == "show-hide":
            self.settings.keybindingsGlobal.set_string(gconf_path, key)
        else:
            self.settings.keybindingsLocal.set_string(gconf_path, key)
    def get_cell_data_cb(self, column, cell, model, piter, user_data=None):
        tool = model.get_value(piter, self.TOOL_COLUMN)

        if tool == None or not isinstance(tool, Tool):
            if tool == None:
                label = _('All Languages')
            elif not isinstance(tool, GtkSource.Language):
                label = _('Plain Text')
            else:
                label = tool.get_name()

            markup = saxutils.escape(label)
            editable = False
        else:
            escaped = saxutils.escape(tool.name)

            if tool.shortcut:
                key, mods = Gtk.accelerator_parse(tool.shortcut)
                label = Gtk.accelerator_get_label(key, mods)
                markup = '%s (<b>%s</b>)' % (escaped, label)
            else:
                markup = escaped

            editable = True

        cell.set_properties(markup=markup, editable=editable)
Beispiel #10
0
 def on_key_press(self, target, event):
     mod = Gtk.accelerator_get_label(event.keyval, event.state)
     #name = Gdk.keyval_name(event.keyval)
     if mod == "Strg+S":
         self.save()
     elif mod == "Umschalt+Strg+S":
         self.save_as()
Beispiel #11
0
    def reload_global(self, settings, key, user_data):
        value = settings.get_string(key)
        if value == 'disabled':
            return

        try:
            self.guake.hotkeys.unbind(self.globalhotkeys[key])
        except Exception as e:
            pass

        self.globalhotkeys[key] = value
        if key == "show-hide":
            log.debug("reload_global: %r", value)
            if not self.guake.hotkeys.bind(value, self.guake.show_hide):
                keyval, mask = Gtk.accelerator_parse(value)
                label = Gtk.accelerator_get_label(keyval, mask)
                filename = pixmapfile('guake-notification.png')
                notifier.showMessage(
                    _('Guake Terminal'),
                    _(
                        'A problem happened when binding <b>%s</b> key.\n'
                        'Please use Guake Preferences dialog to choose another '
                        'key'
                    ) % label, filename
                )
        elif key == "show-focus":
            if not self.guake.hotkeys.bind(value, self.guake.show_focus):
                log.warn("can't bind show-focus key")
                return
Beispiel #12
0
    def refresh_accel(self):
        """ Refreshes the accelerator """

        if not shortcut.is_gsettings_present():
            self.button.set_sensitive(False)
            iter1 = self.liststore.get_iter_first()
            self.liststore.set_value(iter1, 1, "Disabled")
            self.cell.set_sensitive(False)

            if not self.gsettings_install_label_shown:
                self._show_gsettings_install_label()
                self.gsettings_install_label_shown = True
            return

        iter1 = self.liststore.get_iter_first()
        self.new_task_binding = shortcut.get_saved_binding()
        self.binding_backup = self.new_task_binding
        if self.new_task_binding == "":
            # User had set a shortcut, but has now disabled it
            self.button.set_active(False)
            self.liststore.set_value(iter1, 1, "Disabled")
            return
        elif self.new_task_binding is None:
            # User hasn't set a shortcut ever
            self.button.set_active(False)
            self.new_task_binding = self.new_task_default_binding
            self.binding_backup = self.new_task_binding
        else:
            # There exists a shortcut
            self.button.set_active(True)
        (accel_key, accel_mods) = Gtk.accelerator_parse(self.new_task_binding)
        self.show_input = Gtk.accelerator_get_label(accel_key, accel_mods)
        self.liststore.set_value(iter1, 1, self.show_input)
Beispiel #13
0
def button_press_displayname(button, mods, shorten=False):
    """Converts a button number & modifier mask to a localized unicode string.
    """
    button = int(button)
    mods = int(mods)
    if button <= 0:
        return None
    mods = Gdk.ModifierType(mods)
    modif_label = Gtk.accelerator_get_label(0, mods)
    modif_label = unicode(modif_label)
    separator = ""
    if modif_label:
        separator = u"+"
    # TRANSLATORS: "Button" refers to a mouse button
    # TRANSLATORS: It is part of a button map label.
    mouse_button_label = _("Button")
    if shorten:
        # TRANSLATORS: abbreviated "Button <number>" for forms like "Alt+Btn1"
        mouse_button_label = _("Btn")
    return "{modifiers}{plus}{btn}{button_number}".format(
        modifiers=modif_label,
        plus=separator,
        btn=mouse_button_label,
        button_number=button,
    )
Beispiel #14
0
    def do_key_press_event(self, event):
        """Handles key press events and detects valid accelerators."""
        keyval = event.keyval
        mask = event.state

        if keyval == Gdk.KEY_Escape:
            self.destroy()
            return

        self.accelerator = Gtk.accelerator_name(keyval, mask)

        accelerator = Gtk.accelerator_get_label(keyval, mask)
        self.accelerator_label.set_markup(
            "<span size='20000'><b>%s</b></span>" % accelerator)
        valid = Gtk.accelerator_valid(keyval, mask)

        self.conflicting_action = self.app.shortcuts.get_conflicting_action(
            self.customised_item.action_name, keyval, mask)
        if valid and self.conflicting_action:
            title = self.app.shortcuts.titles[self.conflicting_action]
            self.conflict_label.set_markup(
                _("This key combination is already used by <b>%s</b>."
                  " Press Replace to use it for <b>%s</b> instead.") %
                (title, self.customised_item.title))

        # Set visibility according to the booleans set above.
        self.apply_button.set_visible(valid
                                      and not bool(self.conflicting_action))
        self.accelerator_label.set_visible(valid)
        self.conflict_label.set_visible(valid
                                        and bool(self.conflicting_action))
        self.replace_button.set_visible(valid
                                        and bool(self.conflicting_action))
        self.invalid_label.set_visible(not valid)
Beispiel #15
0
    def reload_global(self, settings, key, user_data):
        value = settings.get_string(key)
        if value == 'disabled':
            return

        try:
            self.guake.hotkeys.unbind(self.globalhotkeys[key])
        except Exception as e:
            pass

        self.globalhotkeys[key] = value
        if key == "show-hide":
            log.debug("reload_global: %r", value)
            if not self.guake.hotkeys.bind(value, self.guake.show_hide):
                keyval, mask = Gtk.accelerator_parse(value)
                label = Gtk.accelerator_get_label(keyval, mask)
                filename = pixmapfile('guake-notification.png')
                notifier.showMessage(
                    _('Guake Terminal'),
                    _('A problem happened when binding <b>%s</b> key.\n'
                      'Please use Guake Preferences dialog to choose another '
                      'key') % label, filename)
        elif key == "show-focus":
            if not self.guake.hotkeys.bind(value, self.guake.show_focus):
                log.warn("can't bind show-focus key")
                return
Beispiel #16
0
 def _action_tooltip(self, action, tooltip):
     action_id = action.get_id()
     accels = self.get_application().get_accels_for_action(action_id)
     if accels:
         key, mods = Gtk.accelerator_parse(accels[0])
         tooltip += ' ({})'.format(Gtk.accelerator_get_label(key, mods))
     return tooltip
Beispiel #17
0
    def get_all(self, _):
        logger.info('API call /get/all')
        settings = self.settings.get_all()
        themes = [
            dict(value=th.get_name(), text=th.get_display_name())
            for th in load_available_themes().values()
        ]

        hotkey_accelerator = settings.get('hotkey_show_app')
        hotkey_caption = "Ctrl+Space"
        try:
            hotkey_caption = Gtk.accelerator_get_label(
                *Gtk.accelerator_parse(hotkey_accelerator))
        # pylint: disable=broad-except
        except Exception:
            logger.warning('Unable to parse accelerator "%s". Use Ctrl+Space',
                           hotkey_accelerator)

        settings.update({
            'autostart_allowed': self.autostart_pref.is_allowed(),
            'autostart_enabled': self.autostart_pref.is_enabled(),
            'available_themes': themes,
            'hotkey_show_app': hotkey_caption,
            'env': {
                'version': VERSION,
                'api_version': API_VERSION,
                'user_home': os.path.expanduser('~'),
                'is_x11': IS_X11,
            }
        })
        return settings
Beispiel #18
0
 def _show_keybindings(self, setctl):
     names = self.KEYBINDING_NAMES
     self.keybind_store.clear()
     for binding in sorted(names, key=lambda k: names[k]):
         accel = setctl.get_global_keybinding(binding) or ""
         label = Gtk.accelerator_get_label(*Gtk.accelerator_parse(accel))
         self.keybind_store.append((names[binding], label, binding))
Beispiel #19
0
 def _show_gkeybindings(self, setctl):
     names = accelerators.ACCELERATOR_NAMES
     self.gkeybind_store.clear()
     for binding in sorted(names, key=lambda k: names[k]):
         accel = setctl.get_accelerator(binding) or ""
         label = Gtk.accelerator_get_label(*Gtk.accelerator_parse(accel))
         self.gkeybind_store.append((names[binding], label, binding))
Beispiel #20
0
    def send_prv_msg(self, widget, event):
        keyval = event.keyval
        name = Gdk.keyval_name(keyval)
        mod = Gtk.accelerator_get_label(keyval, event.state)
        if mod == "Ctrl+Mod2+Return":
            pass
        elif event.keyval == 65293:
            widget.emit_stop_by_name("key-press-event")
            text_buffer = widget.get_buffer()
            start_sel = text_buffer.get_start_iter()
            end_sel = text_buffer.get_end_iter()
            msg = text_buffer.get_text(start_sel, end_sel, False)
            if not msg:
                return
            msg_lines = msg.split("\n")
            if len(msg_lines) > 5:
                self.pastebin_barnamy(msg, text_buffer)
            else:

                chat_buffer = self.barnamy_widget_prv_chat[self.selected_prv_chat]["chat_view"].get_buffer()

                data = {"type":"private", "from_" : self.nick, "to_" : self.selected_prv_chat, "token_id" :  self.token_id, "msg" : msg}
                self.BarnamyBase.barnamy_actions['send_prv_msg'](data)
                if self.EmoticonsFilter(msg):
                    msg = self.EmoticonsFilter(msg)

                self.smart_barnamy_msg(chat_buffer, msg, True)

                text_buffer.set_text("")                
            return True
        return False
Beispiel #21
0
    def do_key_press_event(self, event):
        """Handles key press events and detects valid accelerators."""
        keyval = event.keyval
        mask = event.state

        if keyval == Gdk.KEY_Escape:
            self.destroy()
            return

        self.accelerator = Gtk.accelerator_name(keyval, mask)

        accelerator = Gtk.accelerator_get_label(keyval, mask)
        self.accelerator_label.set_markup("<span size='20000'><b>%s</b></span>"
                                          % accelerator)
        valid = Gtk.accelerator_valid(keyval, mask)

        self.conflicting_action = self.app.shortcuts.get_conflicting_action(
            self.customised_item.action_name, keyval, mask)
        if valid and self.conflicting_action:
            title = self.app.shortcuts.titles[self.conflicting_action]
            self.conflict_label.set_markup(
                _("This key combination is already used by <b>%s</b>."
                  " Press Replace to use it for <b>%s</b> instead.")
                % (title, self.customised_item.title))

        # Set visibility according to the booleans set above.
        self.apply_button.set_visible(valid and not bool(self.conflicting_action))
        self.accelerator_label.set_visible(valid)
        self.conflict_label.set_visible(valid and bool(self.conflicting_action))
        self.replace_button.set_visible(valid and bool(self.conflicting_action))
        self.invalid_label.set_visible(not valid)
Beispiel #22
0
    def refresh_accel(self):
        """ Refreshes the accelerator """

        if not shortcut.is_gsettings_present():
            self.button.set_sensitive(False)
            iter1 = self.liststore.get_iter_first()
            self.liststore.set_value(iter1, 1, "Disabled")
            self.cell.set_sensitive(False)

            if not self.gsettings_install_label_shown:
                self._show_gsettings_install_label()
                self.gsettings_install_label_shown = True
            return

        iter1 = self.liststore.get_iter_first()
        self.new_task_binding = shortcut.get_saved_binding()
        self.binding_backup = self.new_task_binding
        if self.new_task_binding == "":
            # User had set a shortcut, but has now disabled it
            self.button.set_active(False)
            self.liststore.set_value(iter1, 1, "Disabled")
            return
        elif self.new_task_binding is None:
            # User hasn't set a shortcut ever
            self.button.set_active(False)
            self.new_task_binding = self.new_task_default_binding
            self.binding_backup = self.new_task_binding
        else:
            # There exists a shortcut
            self.button.set_active(True)
        (accel_key, accel_mods) = Gtk.accelerator_parse(self.new_task_binding)
        self.show_input = Gtk.accelerator_get_label(accel_key, accel_mods)
        self.liststore.set_value(iter1, 1, self.show_input)
Beispiel #23
0
 def on_key_press(self,target,event):
     mod = Gtk.accelerator_get_label(event.keyval,event.state)
     #name = Gdk.keyval_name(event.keyval)
     if mod=="Strg+S":
         self.save()
     elif mod=="Umschalt+Strg+S":
         self.save_as()
Beispiel #24
0
def on_button_clicked2(self, event, column, treesortable):
    keyval = event.keyval
    name = Gdk.keyval_name(keyval)
    mod = Gtk.accelerator_get_label(keyval, event.state)

    if mod == "Mod2+Enter" or mod == "Mod2+Return":
        nome = self.nometxt.get_text()
        connb = sqlite3.connect(path + 'turbo.db')
        a = connb.cursor()
        a.execute("SELECT nome FROM contacts WHERE upper(nome) = upper('" +
                  nome + "')")
        contactsName = a.fetchone()
        connb.close()
        if not contactsName:
            try:
                IP = socket.gethostbyname(nome)
                addcontacts(nome, IP)
                self.listmodel.append([pixbuf1, nome.upper(), IP])
                treesortable.set_sort_column_id(2, Gtk.SortType.ASCENDING)
            except socket.gaierror, err:
                msgerror = "I can't ping this host name!\\nPlease chech the host name and try again!"
                command = "notify-send --hint=int:transient:1 \"TurboNote Gnome3\" \"" + (
                    msgerror).decode('iso-8859-1').encode(
                        'utf8') + "\" -i " + path_icon + "turbo.png"
                os.system(command)
        else:
            msgerror = "This contact already exists!\\nPlease chech the host name and try again!"
            command = "notify-send --hint=int:transient:1 \"TurboNote Gnome3\" \"" + (
                msgerror).decode('iso-8859-1').encode(
                    'utf8') + "\" -i " + path_icon + "turbo.png"
            os.system(command)
def on_button_clicked2(self, event,column,treesortable):
        keyval = event.keyval
        name = Gdk.keyval_name(keyval)
        mod = Gtk.accelerator_get_label(keyval,event.state)        
	print mod
        if mod == "Mod2+Enter" or mod == "Mod2+Return":             
            nome = self.nometxt.get_text()    
            connb = sqlite3.connect(path + 'turbo.db')
            a = connb.cursor()
            a.execute("SELECT nome FROM contacts WHERE upper(nome) = upper('" + nome + "')")
            contactsName =  a.fetchone()
            connb.close()
            if not contactsName:
                try:                          
                    IP = socket.gethostbyname(nome)
                    addcontacts(nome,IP)
                    self.listmodel.append([nome.upper(),IP])
                    treesortable.set_sort_column_id(1, Gtk.SortType.ASCENDING)
                except socket.gaierror, err:    
                        msgerror = "I can't ping this host name!\\nPlease chech the host name and try again!";                      
                        command = "notify-send --hint=int:transient:1 \"TurboNote Gnome3\" \"" + (msgerror).decode('iso-8859-1').encode('utf8') + "\" -i " + path_icon + "turbo.png"                  
                        os.system(command)                          
            else:     
                msgerror = "This contact already exists!\\nPlease chech the host name and try again!";                    
                command = "notify-send --hint=int:transient:1 \"TurboNote Gnome3\" \"" + (msgerror).decode('iso-8859-1').encode('utf8') + "\" -i " + path_icon + "turbo.png"                  
                os.system(command)
Beispiel #26
0
 def _init_from_accel_map(self):
     """Initializes from the app UIManager and the global AccelMap"""
     if self.ui_manager is None:
         import application
         app = application.get_app()
         self.ui_manager = app.ui_manager
     assert self.ui_manager is not None
     self._action_labels.clear()
     self._store.clear()
     accel_labels = {}
     for path, key, mods, changed in self._get_accel_map_entries():
         accel_labels[path] = Gtk.accelerator_get_label(key, mods)
     for group in self.ui_manager.get_action_groups():
         group_name = group.get_name()
         for action in group.list_actions():
             action_name = action.get_name()
             path = "<Actions>/%s/%s" % (group_name, action_name)
             action_label = action.get_label()
             if not action_label:
                 continue
             self._action_labels[path] = action_label
             accel_label = accel_labels.get(path)
             row = [None for t in self._COLUMN_TYPES]
             row[self._PATH_COLUMN] = path
             row[self._ACTION_LABEL_COLUMN] = action_label
             row[self._ACCEL_LABEL_COLUMN] = accel_label
             self._store.append(row)
Beispiel #27
0
 def get_app_hotkey(self):
     app_hotkey_current_accel_name = self.settings.get_property('hotkey-show-app')
     try:
         (key, mode) = Gtk.accelerator_parse(app_hotkey_current_accel_name)
     except Exception:
         logger.warning('Unable to parse accelerator "%s". Use Ctrl+Space' % app_hotkey_current_accel_name)
         (key, mode) = Gtk.accelerator_parse("<Primary>space")
     return Gtk.accelerator_get_label(key, mode)
    def on_key_event(self, widget, event):
        shortcut = Gtk.accelerator_get_label(event.keyval, event.state)

        if shortcut in ("Ctrl+F", "Ctrl+Mod2+F"):
            if self.searchbar.get_search_mode():
                self.searchbar.set_search_mode(False)
            else:
                self.searchbar.set_search_mode(True)
Beispiel #29
0
    def on_key_event(self, widget, event):
        shortcut = Gtk.accelerator_get_label(event.keyval, event.state)

        if shortcut in ("Ctrl+F", "Ctrl+Mod2+F"):
            if self.searchbar.get_search_mode():
                self.searchbar.set_search_mode(False)
            else:
                self.searchbar.set_search_mode(True)
Beispiel #30
0
    def accelerator_display(self):
        accel = self['accelerator']

        if accel:
            keyval, mod = Gtk.accelerator_parse(accel)
            accel = Gtk.accelerator_get_label(keyval, mod)

        return accel or ''
    def on_key_event(self, widget, event):
        mod = Gtk.accelerator_get_label(event.keyval, event.state)

        if mod == "Ctrl+F" or mod == "Ctrl+Mod2+F":
            if self.searchbar.get_search_mode():
                self.searchbar.set_search_mode(False)
            else:
                self.searchbar.set_search_mode(True)
Beispiel #32
0
 def notify_hotkey_change(self, accel_name):
     (key, mode) = Gtk.accelerator_parse(accel_name)
     display_name = Gtk.accelerator_get_label(key, mode)
     app_cache_db = AppCacheDb.get_instance()
     if not app_cache_db.find('startup_hotkey_notification'):
         app_cache_db.put('startup_hotkey_notification', True)
         app_cache_db.commit()
         show_notification("Ulauncher", "Hotkey is set to %s" % display_name)
Beispiel #33
0
 def notify_hotkey_change(self, accel_name):
     (key, mode) = Gtk.accelerator_parse(accel_name)
     display_name = Gtk.accelerator_get_label(key, mode)
     app_cache_db = AppCacheDb.get_instance()
     if not app_cache_db.find('startup_hotkey_notification'):
         show_notification("Ulauncher", "Hotkey is set to %s" % display_name)
         app_cache_db.put('startup_hotkey_notification', True)
         app_cache_db.commit()
 def get_app_hotkey(self):
     app_hotkey_current_accel_name = self.settings.get_property('hotkey-show-app')
     try:
         (key, mode) = Gtk.accelerator_parse(app_hotkey_current_accel_name)
     except Exception:
         logger.warning('Unable to parse accelerator "%s". Use Ctrl+Space' % app_hotkey_current_accel_name)
         (key, mode) = Gtk.accelerator_parse("<Primary>space")
     return Gtk.accelerator_get_label(key, mode)
Beispiel #35
0
 def on_key_press(self,target,event):
     mod = Gtk.accelerator_get_label(event.keyval, event.state)
     if mod=="F11":
         if self.fullscreen_bool:
             self.unfullscreen()
         else:
             self.fullscreen()
         self.fullscreen_bool = not self.fullscreen_bool
Beispiel #36
0
    def accelerator_display(self):
        accel = self['accelerator']

        if accel:
            keyval, mod = Gtk.accelerator_parse(accel)
            accel = Gtk.accelerator_get_label(keyval, mod)

        return accel or ''
Beispiel #37
0
    def get_accel(self):
        """Returns the corresponding accelerator in a viewable format."""
        try:
            accels = self.app.get_accels_for_action(self.action_name)[0]
        except IndexError:
            accels = ""

        keyval, mods = Gtk.accelerator_parse(accels)
        return Gtk.accelerator_get_label(keyval, mods)
Beispiel #38
0
 def dump(self, window):
     keyval, mods = Gtk.accelerator_parse(catapult.conf.toggle_key)
     label = Gtk.accelerator_get_label(keyval, mods)
     self.widget.catapult_key = catapult.conf.toggle_key
     self.widget.set_text(label)
     self.widget.set_position(-1)
     if window is not None:
         # Avoid the main window popping up.
         window.unbind_toggle_key()
Beispiel #39
0
    def get_accel(self):
        """Returns the corresponding accelerator in a viewable format."""
        try:
            accels = self.app.get_accels_for_action(self.action_name)[0]
        except IndexError:
            accels = ""

        keyval, mods = Gtk.accelerator_parse(accels)
        return Gtk.accelerator_get_label(keyval, mods)
Beispiel #40
0
def try_bind_key(keystr):
    label = Gtk.accelerator_get_label(*Gtk.accelerator_parse(keystr))
    ulabel = kupferstring.tounicode(label)
    if len(ulabel) == 1 and ulabel.isalnum():
        return False
    target = keybindings.KEYRANGE_TRIGGERS[-1] - 1
    succ = keybindings.bind_key(keystr, target)
    if succ:
        keybindings.bind_key(None, target)
    return succ
Beispiel #41
0
def find_event(widget, event=None):
    keyval = event.keyval
    name = Gdk.keyval_name(keyval)
    mod = Gtk.accelerator_get_label(keyval, event.state)

    if mod == "Ctrl+F" or mod == "Ctrl+Mod2+F":
        if searchbar.get_search_mode():
            searchbar.set_search_mode(False)
        else:
            searchbar.set_search_mode(True)
Beispiel #42
0
 def do_update_accel_store(self, iter):
     while iter != None:
         if self.accel_store.iter_has_child(iter):
             self.do_update_accel_store(self.accel_store.iter_children(iter))
         else:
             known, key = Gtk.AccelMap.lookup_entry(
                 self.convert_tree_iter_to_accel_path(iter))
             if known:
                 self.accel_store[iter][1] = Gtk.accelerator_get_label(
                     key.accel_key, key.accel_mods)
         iter = self.accel_store.iter_next(iter)
Beispiel #43
0
 def _update_from_accel_map(self):
     """Updates the list from the global AccelMap, logging changes"""
     accel_labels = {}
     for path, key, mods, changed in self._get_accel_map_entries():
         accel_labels[path] = Gtk.accelerator_get_label(key, mods)
     for row in self._store:
         path = row[self._PATH_COLUMN]
         new_label = accel_labels.get(path)
         old_label = row[self._ACCEL_LABEL_COLUMN]
         if new_label != old_label:
             logger.debug("update: %r now uses %r", path, new_label)
             row[self._ACCEL_LABEL_COLUMN] = new_label
Beispiel #44
0
 def _update_from_accel_map(self):
     """Updates the list from the global AccelMap, logging changes"""
     accel_labels = {}
     for path, key, mods, changed in self._get_accel_map_entries():
         accel_labels[path] = Gtk.accelerator_get_label(key, mods)
     for row in self._store:
         path = row[self._PATH_COLUMN]
         new_label = accel_labels.get(path)
         old_label = row[self._ACCEL_LABEL_COLUMN]
         if new_label != old_label:
             logger.debug("update: %r now uses %r", path, new_label)
             row[self._ACCEL_LABEL_COLUMN] = new_label
Beispiel #45
0
	def trigger_accelerator(self, keyval, modifier):
		"""Manually trigger accelerator"""
		result = False

		modifier = modifier & Gtk.accelerator_get_default_mod_mask() # filter out unneeded mods
		label = Gtk.accelerator_get_label(keyval, modifier)

		# trigger accelerator only if we have method connected
		if label in self._method_names:
			result = self._handle_activate(self._accel_group, self._window, keyval, modifier)

		return result
Beispiel #46
0
 def add_accel(data, accel_path, key, mods, changed):
     label = Gtk.accelerator_get_label(key, mods)
     split_path = accel_path.split("/")
     parent = None
     for i in range(len(split_path) - 1):
         subpath = "/".join(split_path[:i + 1])
         iter = iters.get(subpath)
         if iter == None:
             iter = self.accel_store.append(
                 parent, [split_path[i], "", False])
             iters[subpath] = iter
         parent = iter
     self.accel_store.append(parent, [split_path[-1], label, True])
Beispiel #47
0
 def _cellAccelEdit(self, cell, path, accel_key, accel_mods, code, model):
     """ Accelerator is modified """
     self.show_input = Gtk.accelerator_get_label(accel_key, accel_mods)
     self.new_task_binding = Gtk.accelerator_name(accel_key, accel_mods)
     if shortcut.check_invalidity(self.new_task_binding, accel_key,
                                  accel_mods):
         self._show_warning(self.show_input)
         return
     self.binding_backup = self.new_task_binding
     iter = model.get_iter(path)
     model.set_value(iter, 1, self.show_input)
     shortcut.save_new_binding(self.new_task_binding,
                               self.button.get_active())
Beispiel #48
0
 def on_reset_shortcuts_clicked(self, button):
     for i in self.store:
         for j in i.iterchildren():
             default = self.shortcuts.get_default_value(j[2])
             accel_name = default.get_string()
             if j[4] == "app.show":
                 self.set_app_show(accel_name)
             else:
                 self.set_accel(accel_name, j[4])
             accel_key, accel_mods = Gtk.accelerator_parse(accel_name)
             accel_label = Gtk.accelerator_get_label(accel_key, accel_mods)
             j[1] = accel_label
             self.shortcuts.set_value(j[2], default)
Beispiel #49
0
 def _cellAccelEdit(self, cell, path, accel_key, accel_mods, code, model):
     """ Accelerator is modified """
     self.show_input = Gtk.accelerator_get_label(accel_key, accel_mods)
     self.new_task_binding = Gtk.accelerator_name(accel_key, accel_mods)
     if shortcut.check_invalidity(self.new_task_binding, accel_key,
                                  accel_mods):
         self._show_warning(self.show_input)
         return
     self.binding_backup = self.new_task_binding
     iter = model.get_iter(path)
     model.set_value(iter, 1, self.show_input)
     shortcut.save_new_binding(self.new_task_binding,
                               self.button.get_active())
Beispiel #50
0
 def on_accel_edited(self, cell_renderer_accel, path_string, accel_key, accel_mods, hardware_keycode):
     cell_iter = self.store.get_iter_from_string(path_string)
     accel_name = Gtk.accelerator_name(accel_key, accel_mods)
     label = Gtk.accelerator_get_label(accel_key, accel_mods)
     for row in self.store:
         if label in [child[1] for child in row.iterchildren()]:
             self.dialog_repeated_shortcut(label)
             return
     self.store[cell_iter][1] = label
     if self.store[cell_iter][4] == "app.show":
         self.set_app_show(accel_name)
     else:
         self.set_accel(accel_name, self.store[cell_iter][4])
     value = self.store[cell_iter][2]
     self.shortcuts.set_value(value, GLib.Variant("s", accel_name))
Beispiel #51
0
 def populate_keys_tree(self):
     """Reads the HOTKEYS global variable and insert all data in
     the TreeStore used by the preferences window treeview.
     """
     for group in HOTKEYS:
         parent = self.store.append(None, [None, group['label'], None, None])
         for item in group['keys']:
             if item['key'] == "show-hide" or item['key'] == "show-focus":
                 accel = self.settings.keybindingsGlobal.get_string(item['key'])
             else:
                 accel = self.settings.keybindingsLocal.get_string(item['key'])
             gsettings_path = item['key']
             keycode, mask = Gtk.accelerator_parse(accel)
             keylabel = Gtk.accelerator_get_label(keycode, mask)
             self.store.append(parent, [gsettings_path, item['label'], keylabel, accel])
     self.get_widget('treeview-keys').expand_all()
Beispiel #52
0
 def _set_accelmap_entry(cls, path, keyval, mods):
     cls._delete_clashing_accelmap_entries(keyval, mods, path)
     accel_label = Gtk.accelerator_get_label(keyval, mods)
     accel_name = Gtk.accelerator_name(keyval, mods)
     entry_exists, junk = Gtk.AccelMap.lookup_entry(path)
     if entry_exists:
         logger.info("Changing entry %r: %r", accel_name, path)
         if Gtk.AccelMap.change_entry(path, keyval, mods, True):
             logger.debug("Updated %r successfully", path)
         else:
             logger.error("Failed to update %r", path)
     else:
         logger.info("Adding new entry %r: %r", accel_name, path)
         Gtk.AccelMap.add_entry(path, keyval, mods)
     entry_exists, junk = Gtk.AccelMap.lookup_entry(path)
     assert entry_exists
Beispiel #53
0
 def on_reset_shortcuts_clicked(self, button):
     '''
     This method will reset all preferences on the shortcuts page.
     '''
     for i in self.store:
         for j in i.iterchildren():
             default = self.shortcuts.get_default_value(j[2])
             accel_name = default.get_string()
             if j[4] == 'app.show':
                 self.set_app_show(accel_name)
             else:
                 self.set_accel(accel_name, j[4])
             accel_key, accel_mods = Gtk.accelerator_parse(accel_name)
             accel_label = Gtk.accelerator_get_label(accel_key, accel_mods)
             j[1] = accel_label
             self.shortcuts.set_value(j[2], default)
def on_button_clicked2(self, event):
	keyval = event.keyval
	name = Gdk.keyval_name(keyval)
	mod = Gtk.accelerator_get_label(keyval,event.state)
	if mod == "Ctrl+Mod2+Return" or mod == "Ctrl+Mod2+Enter":
		buf  = self.textview.get_buffer()
		text = buf.get_text(buf.get_start_iter(),buf.get_end_iter(),True)

		#fix windows
		text.replace("\\","\\\\");

		try:
			send_turbo(text.decode('utf-8').encode('windows-1252'),self.titulotxt.get_text(),attFile,self.get_size()[0],self.get_size()[1])
		except Exception, e:
			msgerror = "Unable to send to " + name.upper() + "\\nInvalid Characters!"
			command = "notify-send --hint=int:transient:1 \"TurboNote Gnome3\" \"" + (msgerror).decode('iso-8859-1').encode('utf8') + "\" -i " + path_icon + "turbo.png"
			os.system(command)
Beispiel #55
0
def on_button_clicked2(self, event,nome):
	keyval = event.keyval
	name = Gdk.keyval_name(keyval)
	mod = Gtk.accelerator_get_label(keyval,event.state)

	if mod == "Ctrl+Mod2+Return" or mod == "Ctrl+Mod2+Enter":
		buf  = self.textview.get_buffer()
		text = buf.get_text(buf.get_start_iter(),buf.get_end_iter(),True)
		win = MyWindow(text.decode('utf-8').encode('windows-1252'),stay,attFile,str(self.get_size()[0]),str(self.get_size()[1]))
		win.connect("delete-event", Gtk.main_quit)
		win.show_all()
		Gtk.main()
	if mod == "Ctrl+Mod2+R":
		buf  = self.textview.get_buffer()
		text = buf.get_text(buf.get_start_iter(),buf.get_end_iter(),True)
		s = threading.Thread(target=send_turbo ,args=(text,ip,nome,str(self.get_size()[0]),str(self.get_size()[1])))
		s.start()
		Gtk.main_quit() 
Beispiel #56
0
    def __init__(self, toolbar, win, uibuilder):
        self.log = logging.getLogger('MiscToolbarController')

        # Accelerators
        accelerators = Gtk.AccelGroup()
        win.add_accel_group(accelerators)

        closebtn = uibuilder.find_widget_recursive(toolbar, 'close')
        closebtn.set_visible(Config.getboolean('misc', 'close'))
        closebtn.connect('clicked', self.on_closebtn_clicked)

        cutbtn = uibuilder.find_widget_recursive(toolbar, 'cut')
        cutbtn.set_visible(Config.getboolean('misc', 'cut'))
        cutbtn.connect('clicked', self.on_cutbtn_clicked)

        key, mod = Gtk.accelerator_parse('t')
        cutbtn.add_accelerator('clicked', accelerators,
                               key, mod, Gtk.AccelFlags.VISIBLE)
        tooltip = Gtk.accelerator_get_label(key, mod)
        cutbtn.set_tooltip_text(tooltip)