def _on_settings_clicked(self, widget): utils.run_script("sokSettings")
def release(self, button, event_type): run_script("sokSettings")
def press_key(self, key): if not self.vk: return if not key.on: if self.mods[8]: self.altLocked = True self.vk.lock_mod(8) if key.sticky == True: self.stuck.append(key) else: self.active = key #Since only one non-sticky key can be pressed at once. key.on = True self.locked = [] if key.action_type == KeyCommon.CHAR_ACTION: self.vk.press_unicode(self.utf8_to_unicode(key.action)) elif key.action_type == KeyCommon.KEYSYM_ACTION: self.vk.press_keysym(key.action) elif key.action_type == KeyCommon.KEYPRESS_NAME_ACTION: self.vk.press_keysym(get_keysym_from_name(key.action)) elif key.action_type == KeyCommon.MODIFIER_ACTION: mod = key.action if not mod == 8: #Hack since alt puts metacity into move mode and prevents clicks reaching widget. self.vk.lock_mod(mod) self.mods[mod] += 1 elif key.action_type == KeyCommon.MACRO_ACTION: snippet_id = string.atoi(key.action) mlabel, mString = config.snippets.get(snippet_id, (None, None)) if mString: for c in mString: self.vk.press_unicode(ord(c)) self.vk.release_unicode(ord(c)) return if not config.xid_mode: # block dialog in xembed mode dialog = gtk.Dialog(_("New snippet"), self.parent.parent, 0, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, _("_Save snippet"), gtk.RESPONSE_OK)) dialog.set_default_response(gtk.RESPONSE_OK) hbox = gtk.HBox() hbox.pack_end(gtk.Label( _("Please enter a new snippet for this button.")), padding=6) dialog.vbox.add(hbox) label_label = gtk.Label(_("Button label")) text_label = gtk.Label(_("Snippet")) label_entry = gtk.Entry() text_entry = gtk.Entry() label_label.set_alignment(0.0, 0.5) text_label.set_alignment(0.0, 0.5) table = gtk.Table(2,2) table.attach(label_label, 0, 1, 0, 1, \ xoptions=gtk.FILL, xpadding=6) table.attach(text_label, 0, 1, 1, 2, \ xoptions=gtk.FILL, xpadding=6) table.attach(label_entry, 1, 2, 0, 1) table.attach(text_entry, 1, 2, 1, 2) dialog.vbox.pack_end(table, padding=6) dialog.connect("response", self.cb_dialog_response, \ snippet_id, label_entry, text_entry) label_entry.grab_focus() dialog.show_all() elif key.action_type == KeyCommon.KEYCODE_ACTION: self.vk.press_keycode(key.action) elif key.action_type == KeyCommon.SCRIPT_ACTION: if not config.xid_mode: # block settings dialog in xembed mode if key.action: run_script(key.action) else: for k in self.tabKeys: # don't like this. if k.pane == self.activePane: k.on = False k.stuckOn = False self.activePane = key.pane else: if key in self.stuck: key.stuckOn = True self.stuck.remove(key) else: key.stuckOn = False self.release_key(key) self.queue_draw()
def send_press_key(self, key, button, event_type): if key.action_type == KeyCommon.CHAR_ACTION: char = key.action if sys.version_info.major == 2: char = self.utf8_to_unicode(char) self.vk.press_unicode(char) elif key.action_type == KeyCommon.KEYSYM_ACTION: self.vk.press_keysym(key.action) elif key.action_type == KeyCommon.KEYPRESS_NAME_ACTION: self.vk.press_keysym(get_keysym_from_name(key.action)) elif key.action_type == KeyCommon.MODIFIER_ACTION: mod = key.action if not mod == 8: #Hack since alt puts metacity into move mode and prevents clicks reaching widget. self.vk.lock_mod(mod) self.mods[mod] += 1 elif key.action_type == KeyCommon.MACRO_ACTION: snippet_id = int(key.action) mlabel, mString = config.snippets.get(snippet_id, (None, None)) if mString: self.press_key_string(mString) # Block dialog in xembed mode. # Don't allow to open multiple dialogs in force-to-top mode. elif not config.xid_mode and \ not self._editing_snippet: dialog = Gtk.Dialog(_("New snippet"), self.get_toplevel(), 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, _("_Save snippet"), Gtk.ResponseType.OK)) # Don't hide dialog behind the keyboard in force-to-top mode. if config.window.force_to_top: dialog.set_position(Gtk.WindowPosition.NONE) dialog.set_default_response(Gtk.ResponseType.OK) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12, border_width=5) dialog.get_content_area().add(box) msg = Gtk.Label(_("Enter a new snippet for this button:"), xalign=0.0) box.add(msg) label_entry = Gtk.Entry(hexpand=True) text_entry = Gtk.Entry(hexpand=True) label_label = Gtk.Label(_("_Button label:"), xalign=0.0, use_underline=True, mnemonic_widget=label_entry) text_label = Gtk.Label(_("S_nippet:"), xalign=0.0, use_underline=True, mnemonic_widget=text_entry) grid = Gtk.Grid(row_spacing=6, column_spacing=3) grid.attach(label_label, 0, 0, 1, 1) grid.attach(text_label, 0, 1, 1, 1) grid.attach(label_entry, 1, 0, 1, 1) grid.attach(text_entry, 1, 1, 1, 1) box.add(grid) dialog.connect("response", self.cb_dialog_response, \ snippet_id, label_entry, text_entry) label_entry.grab_focus() dialog.show_all() self._editing_snippet = True elif key.action_type == KeyCommon.KEYCODE_ACTION: self.vk.press_keycode(key.action) elif key.action_type == KeyCommon.SCRIPT_ACTION: if not config.xid_mode: # block settings dialog in xembed mode if key.action: run_script(key.action) elif key.action_type == KeyCommon.BUTTON_ACTION: controller = self.button_controllers.get(key) if controller: controller.press(button, event_type)