def copy_cmd(self): if self._password: return if self._multiline: gtk_textbuffer = self._gtk_textbuffer start_iter, end_iter = self._gtk_get_sel_iters() text = gtk_textbuffer.get_text(start_iter, end_iter, 1) else: start, end = self._gtk_get_sel_positions() text = self._gtk_entry.get_chars(start, end) if text: application().set_clipboard(text)
def _gtk_update_menubar(self): # # Update the contents of the menubar after either the application # menu list or this window's menu list has changed. We only add # the menu titles at this stage; the menus themselves are attached # during menu setup. We also attach the accel groups associated # with the new menus. # # Things would be simpler if we could attach the menus here, # but attempting to share menus between menubar items provokes # a warning from Gtk, even though it otherwise appears to work. # gtk_menubar = self._gtk_menubar gtk_window = self._gtk_outer_widget # Remove old accel groups for menu in self._all_menus: gtk_window.remove_accel_group(menu._gtk_accel_group) # Detach any existing menus and remove old menu titles if gtk_menubar: for gtk_menubar_item in gtk_menubar.get_children(): gtk_menubar_item.set_submenu(None) gtk_menubar_item.destroy() # Install new menu list #all_menus = application().menus + self.menus all_menus = application()._effective_menus_for_window(self) self._all_menus = all_menus # Create new menu titles and attach accel groups for menu in all_menus: if gtk_menubar: gtk_menubar_item = Gtk.MenuItem.new_with_label(menu._title) gtk_menubar_item.show() gtk_menubar.append(gtk_menubar_item) gtk_window.add_accel_group(menu._gtk_accel_group) self._need_menubar_update = 0
def paste_cmd(self): text = application().get_clipboard() self.clear_cmd() if self._multiline: self._gtk_textbuffer.insert_at_cursor(text) else: gtk_entry = self._gtk_entry pos = gtk_entry.get_position() gtk_entry.insert_text(text, pos) gtk_entry.set_position(pos + len(text))
def _gtk_menu_setup(self): #print "Windows: enter _gtk_menu_setup" ### application()._perform_menu_setup(self._all_menus)