def create_ui(self): self.grepper_dir = '' self.matches_list.set_columns([ Column( 'linenumber', editable=False, title="#", ), Column('path', editable=False, use_markup=True, sorted=True), Column('line', expand=True, editable=False, use_markup=True), ]) # we should set this to the current project I think self.path_chooser.set_filename(os.path.expanduser('~/')) self._history = gtk.ListStore(gobject.TYPE_STRING) self.pattern_combo.set_model(self._history) self.pattern_combo.set_text_column(0) self.recursive.set_active(True) self.re_check.set_active(True) self.pattern_entry = self.pattern_combo.child self.pattern_entry.connect('activate', self._on_pattern_entry_activate) self.task = GeneratorTask(self.svc.grep, self.append_to_matches_list, self.grep_complete, pass_generator=True) self.running = False
def create_ui(self): self.selection_tree.set_columns([ Column( 'customized', title=' ', format_func=edited, use_stock=True, justify=gtk.JUSTIFY_RIGHT, ), Column( 'display', title=_('Category'), expand=True, searchable=True, sorted=True, ) ]) self.priority_list.set_columns([ Column('display', title=_('Name'), width=125), Column('plugin', title=_('Plugin')), Column('description', title=_('Description'), expand=True) ]) if self.simple: self.category_splitter.set_position(0) self.selection_tree.hide() else: self.selection_tree.show()
def create_ui(self): self.document = None self.tasks = {} self.restart = False self.source_tree.set_columns([ Column(title='name', cells=[ Cell('icon_name', use_stock=True), Cell('markup', use_markup=True, expand=True) ]), Column('type_markup', use_markup=True), Column('sort_by_type_by_name', visible=False), Column('sort_by_type_by_line', visible=False), Column('sort_by_line', visible=False), ]) self.source_tree.set_headers_visible(False) # faster lookups on the id property self.source_tree_ids = {} self.sort_box = AttrSortCombo(self.source_tree, [ ('sort_by_type_by_name', _('Alphabetical by type')), ('sort_by_type_by_line', _('By type by line number')), ('sort_by_line', _('By line number')), ], 'sort_by_type_by_name') self.sort_box.show() self.sort_vbox.pack_start(self.sort_box, expand=False) self.filter_model = self.source_tree.model_filter #FIXME this causes a total crash on win32 self.source_tree.set_visible_func(self._visible_func) self._last_expanded = None self._last_outliner = None
def create_list(self): self.notify_list = ObjectList([ Column('stock', use_stock=True), Column('time', sorted=True), Column('markup', use_markup=True, expand=True), ]) self.notify_list.set_headers_visible(False) self._hbox.pack_start(self.notify_list)
def create_ui(self): self.todo_list = ObjectList([ Column('line', sorted=True), Column('todo', resizable=True, width=200, tooltip_attr='todo'), Column('marker', width=50), ]) self.add_main_widget(self.todo_list) self.todo_list.show_all()
def create_ui(): from pygtkhelpers.ui.objectlist import ObjectTree, Column source_tree = ObjectTree() source_tree.set_columns([ Column('rendered', use_markup=True, expand=True), Column('sort_hack', visible=False, sorted=True), ]) source_tree.set_headers_visible(False) return source_tree
def create_ui(self): self.items_ol.set_columns([ Column('name', title=_('Name')), Column('command', title=_('Command')), Column('glob', title=_('Glob')), Column('terminal', title=_('Terminal'), radio=True, data_type=bool), ]) self._current = None self._block_changed = False
def create_list(self): self._list = ObjectList([ Column('symbol', title=_('Symbol'), use_markup=True), Column('filename', title=_('Location'), use_markup=True), Column('dataline', title=_('Data'), use_markup=True), ]) self._scroll = gtk.ScrolledWindow() self._scroll.add(self._list) self._list.connect('item-double-clicked', self._on_list_double_click) self._vbox.pack_start(self._scroll) self._scroll.show_all()
def create_ui(self): self.tickets_list.set_columns([ Column('ticket', sorted=True, type=int), Column('summary'), ]) self.tickets_list.connect('item-double-clicked', self.on_tickets_list__item_double_clicked) self.set_base_address('http://pida.co.uk/trac/') self.item_text = webkit.WebView() self.item_text_holder.add(self.item_text) self.item_text.show()
def create_list(self): self._list = ObjectList( [ Column('number', title=_('Number')), Column('description', title=_('Description')) ] ) self._scroll = gtk.ScrolledWindow() self._scroll.add(self._list) self._list.connect('item-activated', self._on_list_double_click) self._vbox.pack_start(self._scroll) self._list.show_all()
def create_ui(self): self.shortcuts_list = ObjectTree([ Column('stock_id', use_stock=True), Column('no_mnemomic_label', sorted=True, searchable=True), Column('value', searchable=True), Column('doc', searchable=True), ]) self.shortcuts_list.set_headers_visible(False) self._current = None self.shortcuts_list.connect('selection-changed', self._on_selection_changed) self.shortcuts_list.connect('item-activated', self._on_list_double_click) vbox = gtk.VBox(spacing=6) vbox.set_border_width(6) self.add_main_widget(vbox) self.update() self.shortcuts_list.show_all() hbox = gtk.VBox(spacing=6) bbox = gtk.HBox(spacing=6) l = gtk.Label(_('Capture Shortcut')) hbox.pack_start(l, expand=False) self._capture_entry = gtk.Entry() hbox.pack_start(self._capture_entry) self._capture_entry.connect('key-press-event', self._on_capture_keypress) self._capture_entry.connect('focus-in-event', self._on_focus_in) self._capture_entry.connect('focus-out-event', self._on_focus_out) self._capture_entry.set_sensitive(False) self._default_button = gtk.Button(_('Default')) self._default_button.connect('clicked', self._on_default_clicked) self._clear_button = gtk.Button(_('Clear')) self._clear_button.connect('clicked', self._on_clear_clicked) self._full_button = gtk.ToggleButton(_('Allow All')) self._full_button.set_tooltip_markup( _("This allows you to bind all/confusing keys to a shortcut (be warned :-))")) hbox.pack_start(bbox) bbox.pack_start(self._default_button) bbox.pack_start(self._clear_button) bbox.pack_start(self._full_button) vbox.pack_start(self.shortcuts_list) vbox.pack_start(hbox, expand=False) vbox.show_all() self.get_toplevel().set_size_request(350, 0)
def create_ui(self): self._last_selected = None self.document = None self.tasks = {} self.restart = False self.errors_ol = ObjectList([Column('markup', use_markup=True)]) self.errors_ol.set_headers_visible(False) self.scrolled_window = gtk.ScrolledWindow() self.scrolled_window.show() self.scrolled_window.add(self.errors_ol) self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.add_main_widget(self.scrolled_window) self.errors_ol.show_all() self.sort_combo = AttrSortCombo( self.errors_ol, [ ('lineno', _('Line Number')), ('message', _('Message')), ('type_', _('Type')), ], 'lineno', ) self.sort_combo.show() self.add_main_widget(self.sort_combo, expand=False)
def create_ui(self): def format_default(obj): return obj and _('<i>default</i>') or '' self.targets_list.set_columns([ Column('name', editable=True, expand=True), Column('is_default', format_func=format_default, use_markup=True, title='Default'), Column('action_count', title='Actions'), ]) self.targets_list.set_headers_visible(False) self.acts_list.set_columns([ Column('type', expand=False), Column('value', expand=True, ellipsize=True), ]) self.acts_list.set_headers_visible(False) self.acts_type.set_choices(action_types, None) self.proxy = GtkComboBoxProxy(self.acts_type) self.proxy.connect_widget() self.target_changed(None) self.action_changed(None) self.action_views = {} self.create_action_views() m = self._create_menu(self.TargetMenu, self.AddTarget, None, self.AddShellTarget, self.AddPythonTarget, None, self.AddImportTarget, None, self.ExecuteTargets) self.menu.add(m) for mi in self.AddImportTarget.get_proxies(): menu = gtk.Menu() for (name, key) in external_system_types: m = gtk.MenuItem(name) menu.append(m) m.connect('activate', self._on_import_target_activate, key) menu.show_all() mi.set_submenu(menu) m = self._create_menu(self.ActsMenu, self.AddActs) self.menu.add(m) self.menu.show_all()
def create_ui(self): self.tester = None self._group = execnet.Group() self.source_tree.set_columns([Column(title='Result', cells=[ Cell('icon', use_stock=True, expand=False), Cell('short_name', title='status',), ])]) self.source_tree.set_headers_visible(False) self.clear()
def create_ui(self): self.project_ol.set_columns( [Column(title='Ignored', mappers=[project_mapper])]) self._sort_combo = AttrSortCombo(self.project_ol, [ ('display_name', 'Name'), ('source_directory', 'Full Path'), ('name', 'Directory Name'), ], 'display_name') self._sort_combo.show() self.main_vbox.pack_start(self._sort_combo, expand=False)
def create_ui(self): self.vbox = gtk.VBox(spacing=3) self.vbox.set_border_width(6) self.hbox = gtk.HBox() self.entry = gtk.Entry() self.check = gtk.CheckButton(label='-k') self.list = ObjectList([ Column('markup', title=_('Man page'), sorted=True, use_markup=True), Column('description', title=_('Description'), use_markup=True), ]) self.scroll = gtk.ScrolledWindow() self.scroll.add(self.list) self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.hbox.pack_start(self.entry) self.hbox.pack_start(self.check, expand=False) self.vbox.pack_start(self.hbox, expand=False) self.vbox.pack_start(self.scroll) self.add_main_widget(self.vbox) self.vbox.show_all()
def create_ui(self): self._project = None self.list.set_columns([ Column('icon_name', title=' ', width=35, use_stock=True, expand=False), Column('signature', data_type=str, title=_('Symbol'), format_func=self.format_signature, expander=True, searchable=True), Column('file_name', data_type=str, title=_('Filename'), format_func=self.format_path, expander=True, searchable=True), Column('line', data_type=int, title=_('Line')) ])
def create_ui(self): self.history_tree = ObjectList( [Column('markup', use_markup=True, expand=True)]) self.history_tree.set_headers_visible(False) self.add_main_widget(self.history_tree) self.x11_clipboard = gtk.Clipboard(selection="PRIMARY") self.gnome_clipboard = gtk.Clipboard(selection="CLIPBOARD") self.history_tree.connect('item-right-clicked', self.on_paste_rclick) self.__pulse_bar = gtk.ProgressBar() self.add_main_widget(self.__pulse_bar, expand=False) # only show pulse bar if working self.__pulse_bar.hide() self.__pulse_bar.set_size_request(-1, 12) self.__pulse_bar.set_pulse_step(0.01) self.history_tree.show_all()
def __init__(self, parent): BaseDialog.__init__(self, 'preferences', parent, 'core.glade') ctx.logger.debug('initalizing preferences dialog') # init some data mapping = self.mail_cfg = { 'smtp_host': 'text', 'smtp_user': '******', 'smtp_password': '******', 'mail_encoding': 'text', 'mail_default_from': 'text', 'smtp_port': 'value', 'smtp_use_tls': 'active', 'smtp_raise_error': 'active', 'debug': 'active', 'log_timeformat': 'text', } cfg, w = ctx.settings, self.widgets # load values from the preferences module and visualize # them in the preferences dialog for widget, property in mapping.iteritems(): w[widget].set_property(property, cfg[widget]) ctx.logger.debug('loaded preferences from database') # the combo box to change the active project self._themes = ObjectList([ Column('display_name', str, 'Name'), Column('author', str, 'Autor') ]) self._themes.connect('item-activated', self.on_theme_choice_changed) self._themes.set_border_width(10) self.widgets.theme_vbox.pack_end(self._themes) # add all themes to the combo self._refresh_themes() # init the recipients ObjectList vbox = self.widgets.recipients_vbox self._recipients = ObjectList([ Column('name', str, 'Name', editable=True), Column('mail', str, 'E-Mail', editable=True), Column('active', str, 'Mail senden', editable=True), Column('comment', str, 'Bemerkung', editable=True) ], sortable=True) self._recipients.connect('item-changed', self._on_recipient_edited) vbox.pack_start(self._recipients) self._update_recipients() self._recipients.show() ctx.logger.debug('inialized recipients preferences dialog-page')
def __init__(self, command=None): """ The WorkspaceWindow is displayed whenever the user should choose a workspace to run. @fire_command: dbus command to send to an already running @command: run command when one workspace is choosen @spawn_new: on the default handle. spawn a new process """ #self.set_role('workspace') #self.set_name('Pidaworkspace') self.workspaces = [] self.command = command self.list_complete = False self.new_workspace = "" self.user_action = None super(WorkspaceWindow, self).__init__() #self.set_role('workspace') self.widget.set_name('Pidaworkspace') import pida #XXX: not zip save base = os.path.join(pida.__path__[0], 'resources', 'pixmaps') self.pic_on = gtk.gdk.pixbuf_new_from_file( os.path.join(base, 'online.png')) self.pic_off = gtk.gdk.pixbuf_new_from_file( os.path.join(base, 'offline.png')) self.workspace_view.set_columns([ Column('id', visible=False), Column('pid', visible=False), Column('status', title=' ', width=30, type=gtk.gdk.Pixbuf), #, expand=False, expander=False), Column( 'workspace', title=_('Workspace'), ), # searchable=True, sorted=True, expand=True), Column('project', title=_('Project'), expand=True), Column('open_files', title=_('Open Files'), type=int), ]) gcall(self.update_workspaces)
class FilemanagerView(PidaView): _columns = [ Column("icon_stock_id", use_stock=True), Column("state_markup", use_markup=True), Column("markup", use_markup=True), Column("lower_name", visible=False, searchable=True), ] label_text = _('Files') icon_name = 'file-manager' key = 'filemanager.list' def create_ui(self): self._vbox = gtk.VBox() self._vbox.show() self.create_toolbar() self._file_hidden_check_actions = {} self._create_file_hidden_check_toolbar() self.create_file_list() self._clipboard_file = None self._fix_paste_sensitivity() self.add_main_widget(self._vbox) def create_file_list(self): self.file_list = ObjectList() self.file_list.set_headers_visible(False) def visible_func(item): return item is not None and item.visible self.file_list.set_visible_func(visible_func) self.file_list.set_columns(self._columns) self.file_list.connect('selection-changed', self.on_selection_changed) self.file_list.connect('item-activated', self.on_file_activated) self.file_list.connect('item-right-clicked', self.on_file_right_click) self.entries = {} self.update_to_path(self.svc.path) self.file_list.show() self._file_scroll = gtk.ScrolledWindow( hadjustment=self.file_list.props.hadjustment, vadjustment=self.file_list.props.vadjustment, ) self._file_scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self._file_scroll.add(self.file_list) self._file_scroll.show() self._vbox.pack_start(self._file_scroll) self._sort_combo = AttrSortCombo(self.file_list, [ ('is_dir_sort', _('Directories First')), ('path', _('File Path')), ('lower_name', _('File Name')), ('name', _('File Name (Case Sensitive)')), ('extension_sort', _('Extension')), ('state', _('Version Control Status')), ], 'is_dir_sort') self._sort_combo.show() self._vbox.pack_start(self._sort_combo, expand=False) self.on_selection_changed(self.file_list) def create_toolbar(self): self._uim = gtk.UIManager() self._uim.insert_action_group(self.svc.get_action_group(), 0) self._uim.add_ui_from_string( pkgutil.get_data(__name__, 'uidef/filemanager-toolbar.xml')) self._uim.ensure_update() self._toolbar = self._uim.get_toplevels('toolbar')[0] self._toolbar.set_style(gtk.TOOLBAR_ICONS) self._toolbar.set_icon_size(gtk.ICON_SIZE_MENU) self._vbox.pack_start(self._toolbar, expand=False) self._toolbar.show_all() def add_or_update_file(self, name, basepath, state, select=False, parent_link=False): if basepath != self.path and not parent_link: return entry = self.entries.setdefault( name, FileEntry(name, basepath, self, parent_link=parent_link)) entry.state = state self.show_or_hide(entry, select=select) def show_or_hide(self, entry, select=False): def check(checker): if (checker.identifier in self._file_hidden_check_actions) and \ (self._file_hidden_check_actions[checker.identifier].get_active()): return checker( name=entry.name, path=entry.parent_path, state=entry.state, ) else: return True if self.svc.opt('show_hidden') or entry.parent_link: show = True else: show = all( check(x) for x in self.svc.features['file_hidden_check']) entry.visible = show if entry not in self.file_list: self.file_list.append(entry) self.file_list.update(entry) if show and select: self.file_list.selected_item = entry def update_to_path(self, new_path=None, select=None): if new_path is None: new_path = self.path else: self.path = check_or_home(new_path) self.file_list.clear() self.entries.clear() if self.svc.opt('show_parent'): parent = os.path.normpath(os.path.join(new_path, os.path.pardir)) # skip if we are already on the root if parent != new_path: self.add_or_update_file(os.pardir, parent, 'normal', parent_link=True) def work(basepath): dir_content = listdir(basepath) # add all files from vcs and remove the corresponding items # from dir_content for item in self.svc.boss.cmd('versioncontrol', 'list_file_states', path=self.path): if (item[1] == self.path): try: dir_content.remove(item[0]) except: pass yield item # handle remaining files for filename in dir_content: if (path.isdir(path.join(basepath, filename))): state = 'normal' else: state = 'unknown' yield filename, basepath, state # wrap add_or_update_file to set select accordingly def _add_or_update_file(name, basepath, state): self.add_or_update_file(name, basepath, state, select=(name == select)) GeneratorTask(work, _add_or_update_file).start(self.path) self.create_ancest_tree() def update_single_file(self, name, basepath, select=False): if basepath != self.path: return if name not in self.entries: self.add_or_update_file(name, basepath, 'normal', select=select) def update_removed_file(self, filename): entry = self.entries.pop(filename, None) if entry is not None and entry.visible: self.file_list.remove(entry) def create_dir(self, name=None): if not name: #XXX: inputdialog or filechooser name = dialogs.input('Create New Directory', label=_("Directory name")) if name: npath = os.path.join(self.path, name) if not os.path.exists(npath): os.mkdir(npath) self.update_single_file(name, self.path, select=True) def on_file_activated(self, ol, fileentry): if os.path.exists(fileentry.path): if fileentry.is_dir: self.svc.browse(fileentry.path) else: self.svc.boss.cmd('buffer', 'open_file', file_name=fileentry.path) else: self.update_removed_file(fileentry.name) def on_file_right_click(self, ol, item, event=None): if item.is_dir: self.svc.boss.cmd('contexts', 'popup_menu', context='dir-menu', dir_name=item.path, event=event, filemanager=True) else: self.svc.boss.cmd('contexts', 'popup_menu', context='file-menu', file_name=item.path, event=event, filemanager=True) def on_selection_changed(self, ol): for act_name in ['toolbar_copy', 'toolbar_delete']: self.svc.get_action(act_name).set_sensitive( ol.selected_item is not None) def rename_file(self, old, new, entry): print 'renaming', old, 'to', new def create_ancest_tree(self): task = AsyncTask(self._get_ancestors, self._show_ancestors) task.start(self.path) def _on_act_up_ancestor(self, action, directory): self.svc.browse(directory) def _show_ancestors(self, ancs): toolitem = self.svc.get_action('toolbar_up').get_proxies()[0] menu = gtk.Menu() for anc in ancs: action = gtk.Action(anc, anc, anc, 'directory') action.connect('activate', self._on_act_up_ancestor, anc) menuitem = action.create_menu_item() menu.add(menuitem) menu.show_all() toolitem.set_menu(menu) def _get_ancestors(self, directory): ancs = [directory] parent = None while True: parent = os.path.dirname(directory) if parent == directory: break ancs.append(parent) directory = parent return ancs def _on_act_file_hidden_check(self, action, check): if (check.scope == filehiddencheck.SCOPE_GLOBAL): # global active_checker = self.svc.opt('file_hidden_check') if (action.get_active()): active_checker.append(check.identifier) else: active_checker.remove(check.identifier) self.svc.set_opt('file_hidden_check', active_checker) else: # project if (self.svc.current_project is not None): section = self.svc.current_project.options.get( 'file_hidden_check', {}) section[check.identifier] = action.get_active() self.svc.current_project.options['file_hidden_check'] = section self.update_to_path() def __file_hidden_check_scope_project_set_active(self, action): """sets active state of a file hidden check action with scope = project relies on action name = identifier of checker""" if (self.svc.current_project is not None): section = self.svc.current_project.options.get('file_hidden_check') action.set_active((section is not None) and (action.get_name() in section) and (section[action.get_name()] == 'True')) else: action.set_active(False) def refresh_file_hidden_check(self): """refreshes active status of actions of project scope checker""" for checker in self.svc.features['file_hidden_check']: if (checker.scope == filehiddencheck.SCOPE_PROJECT): action = self._file_hidden_check_actions[checker.identifier] self.__file_hidden_check_scope_project_set_active(action) def _create_file_hidden_check_toolbar(self): self._file_hidden_check_actions = {} menu = gtk.Menu() separator = gtk.SeparatorMenuItem() project_scope_count = 0 menu.append(separator) for checker in self.svc.features['file_hidden_check']: action = gtk.ToggleAction(checker.identifier, checker.label, checker.label, None) # active? if (checker.scope == filehiddencheck.SCOPE_GLOBAL): action.set_active( checker.identifier in self.svc.opt('file_hidden_check')) else: self.__file_hidden_check_scope_project_set_active(action) action.connect('activate', self._on_act_file_hidden_check, checker) self._file_hidden_check_actions[checker.identifier] = action menuitem = action.create_menu_item() if (checker.scope == filehiddencheck.SCOPE_GLOBAL): menu.prepend(menuitem) else: menu.append(menuitem) project_scope_count += 1 menu.show_all() if (project_scope_count == 0): separator.hide() toolitem = None for proxy in self.svc.get_action('toolbar_hidden_menu').get_proxies(): if (isinstance(proxy, DropDownMenuToolButton)): toolitem = proxy break if (toolitem is not None): toolitem.set_menu(menu) def get_selected_filename(self): fileentry = self.file_list.selected_item if fileentry is not None: return fileentry.path def copy_clipboard(self): current = self.get_selected_filename() if os.path.exists(current): self._clipboard_file = current else: self._clipboard_file = None self._fix_paste_sensitivity() def _fix_paste_sensitivity(self): self.svc.get_action('toolbar_paste').set_sensitive( self._clipboard_file is not None) def paste_clipboard(self): newname = os.path.join(self.path, os.path.basename(self._clipboard_file)) if newname == self._clipboard_file: self.svc.error_dlg(_('Cannot copy files to themselves.')) return if not os.path.exists(self._clipboard_file): self.svc.error_dlg(_('Source file has vanished.')) return if os.path.exists(newname): self.svc.error_dlg(_('Destination already exists.')) return task = AsyncTask(self._paste_clipboard, lambda: None) task.start() def _paste_clipboard(self): #XXX: in thread newname = os.path.join(self.path, os.path.basename(self._clipboard_file)) #XXX: GIO? if os.path.isdir(self._clipboard_file): shutil.copytree(self._clipboard_file, newname) else: shutil.copy2(self._clipboard_file, newname) def remove_path(self, path): task = AsyncTask(self._remove_path, lambda: None) task.start(path) def _remove_path(self, path): if os.path.isdir(path): shutil.rmtree(path) else: os.remove(path) if path == self._clipboard_file: self._clipboard_file = None gcall(self._fix_paste_sensitivity)