def add_open_project(self, titer, projectpath): open_project_name = [] while titer: open_project_name.insert(0, self.model[titer][0]) titer = self.model.iter_parent(titer) open_project_name = '/'.join(open_project_name) for row in self.model_open: if projectpath == row[1]: break else: self.model_open.append( [open_project_name, projectpath, Pango.Weight.NORMAL, projectpath.lower(), Gedit.utils_replace_home_dir_with_tilde(projectpath)])
def _update_recent_menu(self): max_recents = self.app_data.config.max_recents for action in self.actiongroup_recent.list_actions(): i = int(action.props.name.rsplit('_', 1)[1]) if i >= max_recents: action.props.visible = False continue try: projectpath = self.app_data.config.recent_projects[i] except IndexError: projectpath = None if projectpath: action.props.label = Gedit.utils_replace_home_dir_with_tilde(projectpath) action.props.visible = bool(projectpath)
def _update_window_menu_idle(self, window, data): self._clear_window_menu(window, data) closed_files = self._closed_files ui_manager = window.get_ui_manager() if closed_files: reopen_ui_id = ui_manager.new_merge_id() action_group = data['reopen_action_group'] max_items = self._max_reopen_items num = 0 for f in closed_files: if num >= max_items: break location = f['location'] content_type = Gio.content_type_from_mime_type(f['mime_type']) name = 'NecronomiconPluginReopenFile_%d' % num label = Gedit.utils_escape_underscores(location.get_basename(), -1) # Translators: %s is a URI tooltip = _("Reopen '%s'") % Gedit.utils_replace_home_dir_with_tilde(location.get_parse_name()) action = Gtk.Action(name, label, tooltip, None) action.set_always_show_image(True) if content_type: action.set_gicon(Gio.content_type_get_icon(content_type)) connect_handlers(self, action, ('activate',), 'reopen_action', window, f) if num == 0: action_group.add_action_with_accel(action, self.REOPEN_ACCELERATOR) else: action_group.add_action(action) ui_manager.add_ui(reopen_ui_id, self.REOPEN_MENU_PATH, name, name, Gtk.UIManagerItemType.MENUITEM, False) num += 1 ui_manager.insert_action_group(action_group, -1) data['menu_action'].set_sensitive(True) data['reopen_ui_id'] = reopen_ui_id ui_manager.ensure_update() data['update_menu_id'] = 0 return False
def _append_path(self, titer, path): titer = self.model.append(titer, [os.path.basename(path), path, Pango.Weight.NORMAL, path.lower(), Gedit.utils_replace_home_dir_with_tilde(path)]) return titer