def _add_item_to_platform_menu(self, item, name, command=None, index=None): checked = item.checked if checked is None: gtk_item = Gtk.MenuItem.new_with_label(name) else: gtk_item = Gtk.CheckMenuItem.new_with_label(name) self._gtk_add_item(gtk_item) if not item.enabled: gtk_item.set_sensitive(0) if checked: gtk_item.set_active(1) if command: app = application() if index is not None: action = lambda widget: app.dispatch(command, index) else: action = lambda widget: app.dispatch(command) gtk_item.connect('activate', action) key = item._key if key: gtk_modifiers = Gdk.ModifierType.CONTROL_MASK if item._shift: gtk_modifiers |= Gdk.ModifierType.SHIFT_MASK if item._option: gtk_modifiers |= Gdk.ModifierType.MOD1_MASK gtk_item.add_accelerator('activate', self._gtk_accel_group, ord(key), gtk_modifiers, Gtk.AccelFlags.VISIBLE)
def _add_item_to_platform_menu(self, item, name, command = None, index = None): checked = item.checked if checked is None: gtk_item = Gtk.MenuItem.new_with_label(name) else: gtk_item = Gtk.CheckMenuItem.new_with_label(name) self._gtk_add_item(gtk_item) if not item.enabled: gtk_item.set_sensitive(0) if checked: gtk_item.set_active(1) if command: app = application() if index is not None: action = lambda widget: app.dispatch(command, index) else: action = lambda widget: app.dispatch(command) gtk_item.connect('activate', action) key = item._key if key: gtk_modifiers = Gdk.ModifierType.CONTROL_MASK if item._shift: gtk_modifiers |= Gdk.ModifierType.SHIFT_MASK if item._option: gtk_modifiers |= Gdk.ModifierType.MOD1_MASK gtk_item.add_accelerator('activate', self._gtk_accel_group, ord(key), gtk_modifiers, Gtk.AccelFlags.VISIBLE)
def paste_cmd(self): text = application().get_clipboard() self.clear_cmd() self._gtk_textbuffer.insert_at_cursor(text)
def copy_cmd(self): gtk_textbuffer = self._gtk_textbuffer start_iter, end_iter = self._gtk_get_sel_iters() text = gtk_textbuffer.get_text(start_iter, end_iter, 1) if text: application().set_clipboard(text)