示例#1
0
    def __init__(self, parent=None):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
        self.parent = parent
        
        # toolbar
        toolbar = Gtk.Toolbar()
        toolbar.set_icon_size(Gtk.IconSize.MENU)
        
        button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_REFRESH)
        button.connect("clicked", self._on_refresh_clicked)
        toolbar.insert(button, -1)
        
        toolbar.insert(Gtk.SeparatorToolItem.new(), -1)

        button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_PREFERENCES)
        button.set_sensitive(False)
        toolbar.insert(button, -1)
        
        button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_ABOUT)
        button.set_sensitive(True)
        button.connect("clicked", self._on_about_clicked)
        toolbar.insert(button, -1)
        
        self.pack_start(toolbar, False, True, 0)
        
        # plugin list
        self._list = PluginList()
        sw = Gtk.ScrolledWindow()
        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        sw.add(self._list)
        
        self.pack_start(sw, True, True, 0)
        self.show_all()
示例#2
0
class PluginManager(Gtk.Box):
    __gtype_name__ = "MykissPluginManager"

    def __init__(self, parent=None):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
        self.parent = parent
        
        # toolbar
        toolbar = Gtk.Toolbar()
        toolbar.set_icon_size(Gtk.IconSize.MENU)
        
        button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_REFRESH)
        button.connect("clicked", self._on_refresh_clicked)
        toolbar.insert(button, -1)
        
        toolbar.insert(Gtk.SeparatorToolItem.new(), -1)

        button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_PREFERENCES)
        button.set_sensitive(False)
        toolbar.insert(button, -1)
        
        button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_ABOUT)
        button.set_sensitive(True)
        button.connect("clicked", self._on_about_clicked)
        toolbar.insert(button, -1)
        
        self.pack_start(toolbar, False, True, 0)
        
        # plugin list
        self._list = PluginList()
        sw = Gtk.ScrolledWindow()
        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        sw.add(self._list)
        
        self.pack_start(sw, True, True, 0)
        self.show_all()
        
    def _on_about_clicked(self, toolbutton, data=None):
        """ Show an 'About' dialog. """
        selection = self._list.get_selection()
        model, iter = selection.get_selected()
        if iter:
            info = model[iter][5]
            pixbuf = self.render_icon_pixbuf(info.plugin_object.icon_name, 
                                             Gtk.IconSize.DIALOG)
            dialog = Gtk.AboutDialog()
            dialog.set_transient_for(self.parent)
            dialog.set_modal(True)
            
            dialog.set_authors((info.author,))
            dialog.set_website(info.website)
            dialog.set_website_label(info.website)
            dialog.set_logo(pixbuf)
            dialog.set_program_name(info.name)
            dialog.set_version(str(info.version))
            dialog.set_comments(info.description)
            dialog.run()
            dialog.destroy()

        
        
    def _on_refresh_clicked(self, toolbutton, data=None):
        self._list.refresh()