Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 def __reload_editors(self, *args, **kwargs):
     editors = EditorRegistry.getInstance()
     editors = list(editors)
     model = self.get_model() 
     model.clear()
     builtin_editors = [self.__hotwire_editor]
     for e in builtin_editors:
         model.append((e,))
     model.append((None,))
     for e in sorted(editors, lambda a,b: locale.strcoll(a.name, b.name)):
         if e in builtin_editors:
             continue
         model.append((e,))
Ejemplo n.º 3
0
 def __reload_editors(self, *args, **kwargs):
     editors = EditorRegistry.getInstance()
     editors = list(editors)
     model = self.get_model()
     model.clear()
     builtin_editors = [self.__hotwire_editor]
     for e in builtin_editors:
         model.append((e, ))
     model.append((None, ))
     for e in sorted(editors, lambda a, b: locale.strcoll(a.name, b.name)):
         if e in builtin_editors:
             continue
         model.append((e, ))
Ejemplo n.º 4
0
 def __init__(self):
     super(PrefEditorCombo, self).__init__(model=gtk.ListStore(gobject.TYPE_PYOBJECT))
     
     editors = EditorRegistry.getInstance()    
     self.__hotwire_editor = editors['c5851b9c-2618-4078-8905-13bf76f0a94f']
     self.__reload_editors()
     self.set_row_separator_func(self.__is_row_separator)
     cell = gtk.CellRendererPixbuf()
     self.pack_start(cell, expand=False)
     self.set_cell_data_func(cell, self.__render_editor_icon)
     cell = hotwidgets.CellRendererText()
     self.pack_start(cell)
     self.set_cell_data_func(cell, self.__render_editor_name)
     
     dispatcher.connect(self.__reload_editors, sender=editors)
     
     self.select_editor_uuid(editors.get_preferred().uuid)
     self.connect('changed', self.__on_changed)
Ejemplo n.º 5
0
    def __init__(self):
        super(PrefEditorCombo,
              self).__init__(model=gtk.ListStore(gobject.TYPE_PYOBJECT))

        editors = EditorRegistry.getInstance()
        self.__hotwire_editor = editors['c5851b9c-2618-4078-8905-13bf76f0a94f']
        self.__reload_editors()
        self.set_row_separator_func(self.__is_row_separator)
        cell = gtk.CellRendererPixbuf()
        self.pack_start(cell, expand=False)
        self.set_cell_data_func(cell, self.__render_editor_icon)
        cell = hotwidgets.CellRendererText()
        self.pack_start(cell)
        self.set_cell_data_func(cell, self.__render_editor_name)

        dispatcher.connect(self.__reload_editors, sender=editors)

        self.select_editor_uuid(editors.get_preferred().uuid)
        self.connect('changed', self.__on_changed)
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
 def execute(self, context, args):
     from hotwire_ui.adaptors.editors import EditorRegistry
     prefeditor = EditorRegistry.getInstance().get_preferred()
     prefeditor.run_many(context.cwd, *args)
     return []
Ejemplo n.º 8
0
 def __on_changed(self, combo):
     active = self.get_active_iter()
     editor = self.get_model().get_value(active, 0)
     editors = EditorRegistry.getInstance()
     editors.set_preferred(editor)
Ejemplo n.º 9
0
Archivo: edit.py Proyecto: zsx/hotwire
    def execute(self, context, args):
        from hotwire_ui.adaptors.editors import EditorRegistry

        prefeditor = EditorRegistry.getInstance().get_preferred()
        prefeditor.run_many(context.cwd, *args)
        return []
Ejemplo n.º 10
0
 def __on_changed(self, combo):
     active = self.get_active_iter()
     editor = self.get_model().get_value(active, 0)
     editors = EditorRegistry.getInstance()
     editors.set_preferred(editor)