def __add_display(self, output_spec, force=False): if output_spec != 'any': self.__display = ClassRendererMapping.getInstance().lookup(output_spec, self.__context) if not self.__display and force: self.__display = DefaultObjectsRenderer(self.__context) if self.__display: self.__display.connect('status-changed', self.__on_status_changed) self.__display_widget = self.__display.get_widget() self.__display_widget.show_all() self.__scroll.add(self.__display_widget) self.__output_type = output_spec
def __add_display(self, output_spec, force=False): if output_spec != 'any': self.__display = ClassRendererMapping.getInstance().lookup( output_spec, self.__context) if not self.__display and force: self.__display = DefaultObjectsRenderer(self.__context) if self.__display: self.__display.connect('status-changed', self.__on_status_changed) self.__display_widget = self.__display.get_widget() self.__display_widget.show_all() self.__scroll.add(self.__display_widget) self.__output_type = output_spec
menu.prepend(menuitem) menuitem = gtk.ImageMenuItem(_('Save Output As...')) menu.prepend(menuitem) menuitem.set_property( 'image', gtk.image_new_from_stock('gtk-save', gtk.ICON_SIZE_MENU)) menuitem.connect("activate", self.__on_save_output) menuitem.show_all() menuitem = gtk.SeparatorMenuItem() menuitem.show_all() menu.prepend(menuitem) menuitem = gtk.CheckMenuItem(label=_('_Wrap lines'), use_underline=True) menuitem.set_active(self.__wrap_lines) menuitem.connect("activate", self.__on_toggle_wrap) menuitem.show_all() menu.prepend(menuitem) menuitem = self.context.get_ui().get_action( '/Menubar/EditMenu/EditMenuAdditions/Input').create_menu_item() menuitem.show_all() menu.prepend(menuitem) def supports_input(self): return True def get_input(self): return self.__inputarea ClassRendererMapping.getInstance().register(unicode, UnicodeRenderer) ClassRendererMapping.getInstance().register(str, UnicodeRenderer) # for now
def __sync_visible_columns(self): if (self._table == None): return prefs = Preferences.getInstance() for colname in [ 'size', 'last_modified', 'owner', 'group', 'permissions', 'mime' ]: try: col = self._get_propcol_by_name(colname) except KeyError, e: _logger.debug("failed to find col %r", colname, exc_info=True) continue pref = prefs.get_pref('hotwire.ui.render.File.columns.' + colname, default=True) col.set_visible(pref) def __on_visible_columns_changed(self, prefs, key, value): self.__sync_visible_columns() def __on_folders_before_files_changed(self, prefs, key, value): prefs = Preferences.getInstance() self.__folders_before_files = prefs.get_pref( 'hotwire.ui.render.File.general.foldersbeforefiles', default=True) # Redo sort self._model.set_sort_column_id(1, gtk.SORT_ASCENDING) ClassRendererMapping.getInstance().register(File, FilePathRenderer) ClassRendererMapping.getInstance().register(FilePath, FilePathRenderer)
model = tv.get_model() sel_data = selection.data from hotwire_ui.shell import locate_current_shell hw = locate_current_shell(self._table) hw.do_copy_url_drag_to_dir(sel_data, self.context.get_cwd()) def __sync_visible_columns(self): if (self._table == None): return prefs = Preferences.getInstance() for colname in ['size', 'last_modified', 'owner', 'group', 'permissions', 'mime']: try: col = self._get_propcol_by_name(colname) except KeyError, e: _logger.debug("failed to find col %r", colname, exc_info=True) continue pref = prefs.get_pref('hotwire.ui.render.File.columns.' + colname, default=True) col.set_visible(pref) def __on_visible_columns_changed(self, prefs, key, value): self.__sync_visible_columns() def __on_folders_before_files_changed(self, prefs, key, value): prefs = Preferences.getInstance() self.__folders_before_files = prefs.get_pref('hotwire.ui.render.File.general.foldersbeforefiles', default=True) # Redo sort self._model.set_sort_column_id(1, gtk.SORT_ASCENDING) ClassRendererMapping.getInstance().register(File, FilePathRenderer) ClassRendererMapping.getInstance().register(FilePath, FilePathRenderer)
argstr = ' '.join(map(lambda x: ','.join(x), builtin.options)) self._buf.insert_markup(' %s: ' % (_('Options'),)) self._buf.insert_markup('<tt>' + gobject.markup_escape_text(argstr) + '</tt>') self._buf.insert_markup('\n') def __help_items(self, items): builtins = BuiltinRegistry.getInstance() for name in items: builtin = builtins[name] self.__append_builtin_base_help(builtin) self.__append_builtin_aliases(builtin) self.__append_builtin_arghelp(builtin) self.__append_builtin_doc(builtin) def get_status_str(self): return '' def append_obj(self, o): if len(o.items) == 0: self.__help_all() else: self.__help_items(o.items) def get_autoscroll(self): return False def supports_input(self): return False ClassRendererMapping.getInstance().register(HelpItem, HelpItemRenderer)
super(DictRenderer, self).__init__(*args, **kwargs) self.__obj = None def _setup_view_columns(self): colidx = self._table.insert_column_with_data_func(-1, 'Key', hotwidgets.CellRendererText(), self.__render_tuple_slice, 0) colidx = self._table.insert_column_with_data_func(-1, 'Value', hotwidgets.CellRendererText(ellipsize=True), self.__render_tuple_slice, 1) @log_except() def __render_tuple_slice(self, col, cell, model, iter, idx): tup = model.get_value(iter, 0) v = tup[idx] valrepr = unicode(repr(v)) cell.set_property('text', valrepr) def get_objects(self): yield self.__obj def append_obj(self, o): if self.__obj is not None: return self.__obj = o superappend = super(DictRenderer, self).append_obj for k,v in o.iteritems(): superappend((k, v)) ClassRendererMapping.getInstance().register(dict, DictRenderer)
self.__obj = None def _setup_view_columns(self): colidx = self._table.insert_column_with_data_func( -1, 'Index', hotwidgets.CellRendererText(), self.__render_tuple_slice, 0) colidx = self._table.insert_column_with_data_func( -1, 'Value', hotwidgets.CellRendererText(ellipsize=True), self.__render_tuple_slice, 1) @log_except() def __render_tuple_slice(self, col, cell, model, iter, idx): tup = model.get_value(iter, 0) v = tup[idx] valrepr = unicode(repr(v)) cell.set_property('text', valrepr) def get_objects(self): yield self.__obj def append_obj(self, o): if self.__obj is not None: return self.__obj = o superappend = super(ListRenderer, self).append_obj for i, v in enumerate(o): superappend((i, v)) ClassRendererMapping.getInstance().register(list, ListRenderer)
super(ListRenderer, self).__init__(*args, **kwargs) self.__obj = None def _setup_view_columns(self): colidx = self._table.insert_column_with_data_func(-1, 'Index', hotwidgets.CellRendererText(), self.__render_tuple_slice, 0) colidx = self._table.insert_column_with_data_func(-1, 'Value', hotwidgets.CellRendererText(ellipsize=True), self.__render_tuple_slice, 1) @log_except() def __render_tuple_slice(self, col, cell, model, iter, idx): tup = model.get_value(iter, 0) v = tup[idx] valrepr = unicode(repr(v)) cell.set_property('text', valrepr) def get_objects(self): yield self.__obj def append_obj(self, o): if self.__obj is not None: return self.__obj = o superappend = super(ListRenderer, self).append_obj for i,v in enumerate(o): superappend((i, v)) ClassRendererMapping.getInstance().register(list, ListRenderer)
import gtk, gobject, pango import hotwire import hotwire_ui.widgets as hotwidgets from hotwire_ui.renderers.file import FilePathRenderer from hotwire_ui.render import ClassRendererMapping, TreeObjectsRenderer from hotwire.builtins.fsearch import FileStringMatch from hotwire.util import markup_for_match class FileStringMatchRenderer(TreeObjectsRenderer): def __init__(self, *args, **kwargs): super(FileStringMatchRenderer, self).__init__(*args, **kwargs) def _setup_view_columns(self): self._insert_column('path', title=_('Path')) self._insert_column('line_num', title=_('Line')) colidx = self._table.insert_column_with_data_func(-1, 'Match', hotwidgets.CellRendererText(), self._render_match) col = self._table.get_column(colidx-1) col.set_spacing(0) def _render_match(self, col, cell, model, iter): obj = model.get_value(iter, 0) matchmarkup = markup_for_match(obj.line, obj.match_start, obj.match_end) cell.set_property('markup', matchmarkup) ClassRendererMapping.getInstance().register(FileStringMatch, FileStringMatchRenderer)
def __on_populate_popup(self, textview, menu): menuitem = gtk.SeparatorMenuItem() menuitem.show_all() menu.prepend(menuitem) menuitem = gtk.ImageMenuItem(_('Save Output As...')) menu.prepend(menuitem) menuitem.set_property('image', gtk.image_new_from_stock('gtk-save', gtk.ICON_SIZE_MENU)) menuitem.connect("activate", self.__on_save_output) menuitem.show_all() menuitem = gtk.SeparatorMenuItem() menuitem.show_all() menu.prepend(menuitem) menuitem = gtk.CheckMenuItem(label=_('_Wrap lines'), use_underline=True) menuitem.set_active(self.__wrap_lines) menuitem.connect("activate", self.__on_toggle_wrap) menuitem.show_all() menu.prepend(menuitem) menuitem = self.context.get_ui().get_action('/Menubar/EditMenu/EditMenuAdditions/Input').create_menu_item() menuitem.show_all() menu.prepend(menuitem) def supports_input(self): return True def get_input(self): return self.__inputarea ClassRendererMapping.getInstance().register(str, UnicodeRenderer) ClassRendererMapping.getInstance().register(str, UnicodeRenderer) # for now
# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA from hotwire_ui.render import ClassRendererMapping, TreeObjectsRenderer, menuitem from hotwire.sysdep.proc import Process class ProcessRenderer(TreeObjectsRenderer): def _setup_view_columns(self): self._insert_propcol('pid', title=_('PID'), ellipsize=False) self._insert_proptext('owner_name', title=_('Owner'), ellipsize=False) cmdcol = self._insert_proptext('cmd', title=_('Command'), ellipsize=False) self._set_search_column(cmdcol) @menuitem() def kill(self, iter): proc = self._model.get_value(iter, 0) proc.kill() ClassRendererMapping.getInstance().register(Process, ProcessRenderer)
# This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA from hotwire_ui.render import ClassRendererMapping, TreeObjectsRenderer, menuitem from hotwire.sysdep.proc import Process class ProcessRenderer(TreeObjectsRenderer): def _setup_view_columns(self): self._insert_propcol('pid', title=_('PID'), ellipsize=False) self._insert_proptext('owner_name', title=_('Owner'), ellipsize=False) cmdcol = self._insert_proptext('cmd', title=_('Command'), ellipsize=False) self._set_search_column(cmdcol) @menuitem() def kill(self, iter): proc = self._model.get_value(iter, 0) proc.kill() ClassRendererMapping.getInstance().register(Process, ProcessRenderer)