def get_file_menuitems(self, file_obj, context=None): uri = gnomevfs.get_uri_from_local_path(file_obj.path) if file_obj.test_directory(follow_link=True): return [] apps = gnomevfs.mime_get_all_applications(file_obj.mimetype) menuitems = [] pbcache = PixbufCache.getInstance() def add_menuitem(app): _logger.debug("adding app %r", app) if have_gnomedesktop: desktop = gnomedesktop.item_new_from_basename(app[0], 0) iconpath = desktop.get_icon(self.__itheme) else: iconpath = None menuitem = gtk.ImageMenuItem(_('Open with %s') % (app[1],)) if iconpath: pbuf = pbcache.get(iconpath, trystock=True, stocksize=gtk.ICON_SIZE_MENU) img = gtk.image_new_from_pixbuf(pbuf) menuitem.set_property('image', img) menuitem.connect("activate", self.__on_appmenu_activated, app, uri, context) menuitems.append(menuitem) for app in apps: add_menuitem(app) return menuitems
def __render_icon(self, col, cell, model, iter): icon_name = model.get_value(iter, 2) if icon_name: pbcache = PixbufCache.getInstance() pixbuf = pbcache.get(icon_name, size=16, trystock=True, stocksize=gtk.ICON_SIZE_MENU) cell.set_property('pixbuf', pixbuf) else: cell.set_property('icon-name', None)
def _render_member_icon(member, cell): pbcache = PixbufCache.getInstance() if inspect.ismethod(member) or inspect.ismethoddescriptor(member): pbname = 'dfeet-method.png' elif inspect.isdatadescriptor(member) or (hasattr(inspect, 'ismemberdescriptor') and inspect.ismemberdescriptor(member)): pbname = 'dfeet-property.png' else: pbname = 'dfeet-object.png' pixbuf = pbcache.get(pbname, size=16, trystock=True, stocksize=gtk.ICON_SIZE_MENU) cell.set_property('pixbuf', pixbuf)
def __render_editor_icon(self, celllayout, cell, model, iter): e = model.get_value(iter, 0) if e is None: return if e.icon is None: cell.set_property('pixbuf', None) else: pbcache = PixbufCache.getInstance() # Right now use 16 since that's favicon size pixbuf = pbcache.get(e.icon, size=16, trystock=True, stocksize=gtk.ICON_SIZE_MENU) cell.set_property('pixbuf', pixbuf)
def _render_icon(self, col, cell, model, iter, data): (prop, idx) = data obj = model.get_value(iter, idx) icon_name = getattr(obj, prop) if icon_name: if icon_name.startswith(os.sep): pixbuf = PixbufCache.getInstance().get(icon_name) cell.set_property('pixbuf', pixbuf) else: cell.set_property('icon-name', icon_name) else: cell.set_property('icon-name', None)
def __append_language(self, language): pbcache = PixbufCache.getInstance() self._buf.insert_markup(' ') if language.icon: lang_pixbuf = pbcache.get(language.icon, size=16, trystock=True, stocksize=gtk.ICON_SIZE_MENU) self._buf.insert_pixbuf(self._buf.get_end_iter(), lang_pixbuf) else: self._buf.insert_markup(' ') self.append_inspectlink(language.langname, language) if language.prefix is not None: self._buf.insert_markup(' - prefix: <tt>%s</tt>' \ % (gobject.markup_escape_text(language.prefix),)) self._buf.insert_markup('\n')
def _get_menuitems(self, iter): fobj = self._file_for_iter(self._model, iter) items = self.__fs.get_file_menuitems(fobj, context=self.context) if items: items.append(gtk.SeparatorMenuItem()) if fobj.is_directory: menuitem = gtk.ImageMenuItem(_('Open Folder in New Tab')) menuitem.set_property( 'image', gtk.image_new_from_stock('gtk-new', gtk.ICON_SIZE_MENU)) menuitem.connect('activate', self.__on_new_tab_activated, fobj.path) items.append(menuitem) menuitem = gtk.ImageMenuItem(_('Open Folder in New Window')) menuitem.set_property( 'image', gtk.image_new_from_stock('gtk-new', gtk.ICON_SIZE_MENU)) menuitem.connect('activate', self.__on_new_window_activated, fobj.path) items.append(menuitem) sysenv = SystemEnvironment.getInstance() if isinstance(sysenv, GnomeSystemEnvironment): items.append(gtk.SeparatorMenuItem()) menuitem = gtk.MenuItem(_('Open with File Manager')) menuitem.connect('activate', self.__on_file_manager_activated, ['nautilus', fobj.path]) items.append(menuitem) items.append(gtk.SeparatorMenuItem()) else: prefeditor = EditorRegistry.getInstance().get_preferred() if prefeditor is not None: menuitem = gtk.ImageMenuItem( _('Edit with %s') % (prefeditor.name, )) menuitem.connect('activate', self.__on_edit_activated, self.context.get_cwd(), prefeditor, fobj.path) pbcache = PixbufCache.getInstance() pixbuf = pbcache.get(prefeditor.icon, size=16, trystock=True, stocksize=gtk.ICON_SIZE_MENU) if pixbuf: img = gtk.image_new_from_pixbuf(pixbuf) menuitem.set_property('image', img) items.append(menuitem) menuitem = gtk.ImageMenuItem(_('Copy Path to Input')) menuitem.set_property( 'image', gtk.image_new_from_stock('gtk-copy', gtk.ICON_SIZE_MENU)) menuitem.connect("activate", self.__on_copypath_activated, fobj.path) items.append(menuitem) return items
def __render_icon(self, col, cell, model, itr): compl = model.get_value(itr, 0) icon_name = compl.icon if (not icon_name) and compl.target: ifunc = self.__get_icon_func_for_klass(compl.target) if ifunc: icon_name = ifunc(compl.target) if icon_name: if icon_name.startswith(os.sep): pixbuf = PixbufCache.getInstance().get(icon_name) cell.set_property('pixbuf', pixbuf) else: cell.set_property('icon-name', icon_name) else: cell.set_property('icon-name', None)
def _render_member_icon(member, cell): pbcache = PixbufCache.getInstance() if inspect.ismethod(member) or inspect.ismethoddescriptor(member): pbname = 'dfeet-method.png' elif inspect.isdatadescriptor(member) or ( hasattr(inspect, 'ismemberdescriptor') and inspect.ismemberdescriptor(member)): pbname = 'dfeet-property.png' else: pbname = 'dfeet-object.png' pixbuf = pbcache.get(pbname, size=16, trystock=True, stocksize=gtk.ICON_SIZE_MENU) cell.set_property('pixbuf', pixbuf)
def __init__(self, outputs, overview_action): super(OverviewButton, self).__init__() self.__outputs = outputs self.__tooltips = gtk.Tooltips() self.__image = gtk.Image() self.__image.set_property('pixbuf', PixbufCache.getInstance().get('throbber-done.gif', size=None)) self.set_property('image', self.__image) self.set_focus_on_click(False) outputs.connect('notify::pipeline-count', self.__on_pipeline_count_changed) self.__cached_unseen_count = 0 self.__orig_bg = self.style.bg[gtk.STATE_NORMAL] self.__idle_flash_count = 0 self.__idle_flash_id = 0 outputs.connect('notify::executing-pipeline-count', self.__on_pipeline_count_changed) self.__on_pipeline_count_changed() self.__overview_action = overview_action overview_action.connect('notify::active', self.__on_overview_active_changed) self.connect('notify::active', self.__on_self_active_changed)
def __help_all(self): pbcache = PixbufCache.getInstance() self._buf.insert_markup('Hotwire <i>%s</i>\n\n' % (__version__,)) self._buf.insert_markup(_('Documentation on the web: ')) self._buf.insert_markup(' ') self.append_link(_('Tutorial'), 'http://code.google.com/p/hotwire-shell/wiki/GettingStarted0700') self._buf.insert_markup(' ') external_pixbuf = pbcache.get('external.png', size=10) self._buf.insert_pixbuf(self._buf.get_end_iter(), external_pixbuf) self._buf.insert_markup('\n\n') registry = BuiltinRegistry.getInstance() for (setname,builtins) in zip((_('User'), _('Standard'), _('System')), map(list, [registry.user_set, registry.hotwire_set, registry.system_set])): if len(builtins) == 0: continue self._buf.insert_markup('<larger>%s:</larger>\n' % (_('%s Builtin Commands' % (setname,)),)) builtins.sort(lambda a,b: cmp(a.name, b.name)) for builtin in builtins: self.__append_builtin_base_help(builtin) self.__append_builtin_aliases(builtin) self.__append_builtin_arghelp(builtin) self.__append_builtin_doc(builtin) self._buf.insert_markup('\n') self._buf.insert_markup('<larger>%s:</larger>\n' % (_('Languages'),)) langreg = PipelineLanguageRegistry.getInstance() hotwire_lang = langreg['62270c40-a94a-44dd-aaa0-689f882acf34'] python_lang = langreg['da3343a0-8bce-46ed-a463-2d17ab09d9b4'] self.__append_language(hotwire_lang) self.__append_language(python_lang) languages = list(langreg) languages.sort(lambda a,b: cmp(a.langname, b.langname)) for language in languages: if language in [hotwire_lang, python_lang]: continue self.__append_language(language) self._buf.insert_markup('\n<larger>%s:</larger>\n' % (_('Aliases'),)) aliases = list(AliasRegistry.getInstance()) aliases.sort(lambda a,b: cmp(a.name,b.name)) for alias in aliases: self._buf.insert_markup(' <b>%s</b> - %s\n' % tuple(map(gobject.markup_escape_text, (alias.name, alias.target))))
def __append_builtin_base_help(self, builtin): self._buf.insert_markup(' ') pbcache = PixbufCache.getInstance() hotwire_pixbuf = pbcache.get('hotwire', size=16, trystock=True, stocksize=gtk.ICON_SIZE_MENU) self._buf.insert_pixbuf(self._buf.get_end_iter(), hotwire_pixbuf) self.append_inspectlink(builtin.name, builtin) self._buf.insert_markup(' - %s%s ' \ % (_('in'), builtin.input_is_optional and ' (opt):' or ':')) def append_type(t): if isinstance(t, type): self.append_inspectlink(str(t), t) else: self._buf.insert_markup(str(t)) itype = builtin.input_type append_type(itype) self._buf.insert_markup(' %s: ' % (_('out'),)) otype = builtin.output_type append_type(otype) self._buf.insert_markup('\n')
def _get_menuitems(self, iter): fobj = self._file_for_iter(self._model, iter) items = self.__fs.get_file_menuitems(fobj, context=self.context) if items: items.append(gtk.SeparatorMenuItem()) if fobj.is_directory: menuitem = gtk.ImageMenuItem(_('Open Folder in New Tab')) menuitem.set_property('image', gtk.image_new_from_stock('gtk-new', gtk.ICON_SIZE_MENU)) menuitem.connect('activate', self.__on_new_tab_activated, fobj.path) items.append(menuitem) menuitem = gtk.ImageMenuItem(_('Open Folder in New Window')) menuitem.set_property('image', gtk.image_new_from_stock('gtk-new', gtk.ICON_SIZE_MENU)) menuitem.connect('activate', self.__on_new_window_activated, fobj.path) items.append(menuitem) sysenv = SystemEnvironment.getInstance() if isinstance(sysenv, GnomeSystemEnvironment): items.append(gtk.SeparatorMenuItem()) menuitem = gtk.MenuItem(_('Open with File Manager')) menuitem.connect('activate', self.__on_file_manager_activated, ['nautilus', fobj.path]) items.append(menuitem) items.append(gtk.SeparatorMenuItem()) else: prefeditor = EditorRegistry.getInstance().get_preferred() if prefeditor is not None: menuitem = gtk.ImageMenuItem(_('Edit with %s') % (prefeditor.name,)) menuitem.connect('activate', self.__on_edit_activated, self.context.get_cwd(), prefeditor, fobj.path) pbcache = PixbufCache.getInstance() if prefeditor.icon: pixbuf = pbcache.get(prefeditor.icon, size=16, trystock=True, stocksize=gtk.ICON_SIZE_MENU) else: pixbuf = None if pixbuf: img = gtk.image_new_from_pixbuf(pixbuf) menuitem.set_property('image', img) items.append(menuitem) menuitem = gtk.ImageMenuItem(_('Copy Path to Input')) menuitem.set_property('image', gtk.image_new_from_stock('gtk-copy', gtk.ICON_SIZE_MENU)) menuitem.connect("activate", self.__on_copypath_activated, fobj.path) items.append(menuitem) return items
def __init__(self, context, pipeline, odisp, overview_mode=True, **args): super(CommandExecutionHeader, self).__init__(**args) self.__context = context self.__pipeline = pipeline self.__overview_mode = overview_mode self.__primary_complete = False self.__complete_unseen = False self.__last_view_time = None self.__visible = True self.__prev_pipeline_state = None self.__cancelled = False self.__undone = False self.__exception = False self.__mouse_hovering = False self.__throbber_pixbuf_done = PixbufCache.getInstance().get('throbber-done.gif', size=None) self.__throbber_pixbuf_ani = PixbufCache.getInstance().get('throbber.gif', size=None, animation=True) self.__tooltips = gtk.Tooltips() dispatcher.connect(self.__on_pipeline_state_change, 'state-changed', self.__pipeline) dispatcher.connect(self.__on_pipeline_metadata, 'metadata', self.__pipeline) self.__main_hbox = gtk.HBox() self.pack_start(self.__main_hbox, expand=True) self.__cmdstatus_vbox = gtk.VBox() self.__main_hbox.pack_start(self.__cmdstatus_vbox, expand=True) self.__titlebox_ebox = gtk.EventBox() self.__titlebox_ebox.set_visible_window(False) if overview_mode: self.__titlebox_ebox.add_events(gtk.gdk.BUTTON_PRESS_MASK & gtk.gdk.ENTER_NOTIFY_MASK & gtk.gdk.LEAVE_NOTIFY_MASK) self.__titlebox_ebox.connect("enter_notify_event", self.__on_enter) self.__titlebox_ebox.connect("leave_notify_event", self.__on_leave) self.__titlebox_ebox.connect("button-press-event", lambda eb, e: self.__on_button_press(e)) self.__titlebox = gtk.HBox() self.__titlebox_ebox.add(self.__titlebox) self.__cmdstatus_vbox.pack_start(hotwidgets.Align(self.__titlebox_ebox), expand=False) self.__pipeline_str = self.__pipeline.__str__() self.__title = gtk.Label() self.__title.set_alignment(0, 0.5) #self.__title.set_selectable(True) self.__title.set_ellipsize(True) self.__state_image = gtk.Image() self.__titlebox.pack_start(self.__state_image, expand=False) self.__titlebox.pack_start(hotwidgets.Align(self.__title, padding_left=4), expand=True) self.__statusbox = gtk.HBox() self.__cmdstatus_vbox.pack_start(self.__statusbox, expand=False) self.__status_left = gtk.Label() self.__status_right = gtk.Label() self.__statusbox.pack_start(hotwidgets.Align(self.__status_left, padding_left=4), expand=False) self.__action = hotwidgets.Link() self.__action.connect("clicked", self.__on_action) self.__statusbox.pack_start(hotwidgets.Align(self.__action), expand=False) self.__statusbox.pack_start(hotwidgets.Align(self.__status_right), expand=False) self.__undoable = self.__pipeline.get_undoable() and (not self.__pipeline.get_idempotent()) status_cmds = list(pipeline.get_status_commands()) self.__pipeline_status_visible = False if status_cmds: self.__cmd_statuses = gtk.HBox(spacing=8) show_cmd_name = len(status_cmds) > 1 for cmdname in status_cmds: self.__cmd_statuses.pack_start(CommandStatusDisplay(show_cmd_name and cmdname or None), expand=True) self.__statusbox.pack_start(hotwidgets.Align(self.__cmd_statuses), expand=False) else: self.__cmd_statuses = None self.__cmd_status_show_cmd = False self.__objects = odisp self.__objects.connect("primary-complete", self.__on_primary_complete) self.__objects.connect("changed", lambda o: self.__update_titlebox()) self.__exception_box = gtk.HBox() self.__exception_link = hotwidgets.Link() self.__exception_link.set_alignment(0.0, 0.5) self.__exception_link.set_ellipsize(True) self.__exception_link.connect('clicked', self.__on_exception_clicked) self.__exception_box.pack_start(self.__exception_link, expand=True) self.__cmdstatus_vbox.pack_start(hotwidgets.Align(self.__exception_box, padding_left=4), expand=False) if overview_mode: self.__cmdstatus_vbox.pack_start(gtk.HSeparator(), expand=False) self.__otype_expander = None else: self.__otype_expander = gtk.Expander('') self.__otype_expander.unset_flags(gtk.CAN_FOCUS); self.__otype_expander.set_use_markup(True) self.__otype_expander.connect('notify::expanded', self.__on_otype_expander_toggled) self.__main_hbox.pack_start(self.__otype_expander, expand=False)
def __render_item_icon(self, col, cell, model, itr): (lang, histitem) = model.get_value(itr, 0) langs = PipelineLanguageRegistry.getInstance() pbcache = PixbufCache.getInstance() pixbuf = pbcache.get(langs[lang].icon, size=16, trystock=True, stocksize=gtk.ICON_SIZE_MENU) cell.set_property('pixbuf', pixbuf)
def __init__(self, context, pipeline, odisp, overview_mode=True, **args): super(CommandExecutionHeader, self).__init__(**args) self.__context = context self.__pipeline = pipeline self.__overview_mode = overview_mode self.__primary_complete = False self.__complete_unseen = False self.__last_view_time = None self.__visible = True self.__prev_pipeline_state = None self.__cancelled = False self.__undone = False self.__exception = False self.__mouse_hovering = False self.__throbber_pixbuf_done = PixbufCache.getInstance().get('throbber-done.gif', size=None) self.__throbber_pixbuf_ani = PixbufCache.getInstance().get('throbber.gif', size=None, animation=True) self.__tooltips = gtk.Tooltips() self.__pipeline.connect("state-changed", self.__on_pipeline_state_change) self.__pipeline.connect("metadata", self.__on_pipeline_metadata) self.__main_hbox = gtk.HBox() self.pack_start(self.__main_hbox, expand=True) self.__cmdstatus_vbox = gtk.VBox() self.__main_hbox.pack_start(self.__cmdstatus_vbox, expand=True) self.__titlebox_ebox = gtk.EventBox() self.__titlebox_ebox.set_visible_window(False) if overview_mode: self.__titlebox_ebox.add_events(gtk.gdk.BUTTON_PRESS_MASK & gtk.gdk.ENTER_NOTIFY_MASK & gtk.gdk.LEAVE_NOTIFY_MASK) self.__titlebox_ebox.connect("enter_notify_event", self.__on_enter) self.__titlebox_ebox.connect("leave_notify_event", self.__on_leave) self.__titlebox_ebox.connect("button-press-event", lambda eb, e: self.__on_button_press(e)) self.__titlebox = gtk.HBox() self.__titlebox_ebox.add(self.__titlebox) self.__cmdstatus_vbox.pack_start(hotwidgets.Align(self.__titlebox_ebox), expand=False) self.__pipeline_str = self.__pipeline.__str__() self.__title = gtk.Label() self.__title.set_alignment(0, 0.5) #self.__title.set_selectable(True) self.__title.set_ellipsize(True) self.__state_image = gtk.Image() self.__titlebox.pack_start(self.__state_image, expand=False) self.__titlebox.pack_start(hotwidgets.Align(self.__title, padding_left=4), expand=True) self.__statusbox = gtk.HBox() self.__cmdstatus_vbox.pack_start(self.__statusbox, expand=False) self.__status_left = gtk.Label() self.__status_right = gtk.Label() self.__statusbox.pack_start(hotwidgets.Align(self.__status_left, padding_left=4), expand=False) self.__action = hotwidgets.Link() self.__action.connect("clicked", self.__on_action) self.__statusbox.pack_start(hotwidgets.Align(self.__action), expand=False) self.__statusbox.pack_start(hotwidgets.Align(self.__status_right), expand=False) self.__undoable = self.__pipeline.get_undoable() and (not self.__pipeline.get_idempotent()) status_cmds = list(pipeline.get_status_commands()) self.__pipeline_status_visible = False if status_cmds: self.__cmd_statuses = gtk.HBox(spacing=8) show_cmd_name = len(status_cmds) > 1 for cmdname in status_cmds: self.__cmd_statuses.pack_start(CommandStatusDisplay(show_cmd_name and cmdname or None), expand=True) self.__statusbox.pack_start(hotwidgets.Align(self.__cmd_statuses), expand=False) else: self.__cmd_statuses = None self.__cmd_status_show_cmd = False self.__objects = odisp self.__objects.connect("primary-complete", self.__on_primary_complete) self.__objects.connect("changed", lambda o: self.__update_titlebox()) self.__exception_box = gtk.HBox() self.__exception_link = hotwidgets.Link() self.__exception_link.set_alignment(0.0, 0.5) self.__exception_link.set_ellipsize(True) self.__exception_link.connect('clicked', self.__on_exception_clicked) self.__exception_box.pack_start(self.__exception_link, expand=True) self.__cmdstatus_vbox.pack_start(hotwidgets.Align(self.__exception_box, padding_left=4), expand=False) if overview_mode: self.__cmdstatus_vbox.pack_start(gtk.HSeparator(), expand=False) self.__otype_expander = None else: self.__otype_expander = gtk.Expander('') self.__otype_expander.unset_flags(gtk.CAN_FOCUS); self.__otype_expander.set_use_markup(True) self.__otype_expander.connect('notify::expanded', self.__on_otype_expander_toggled) self.__main_hbox.pack_start(self.__otype_expander, expand=False)