From 4c1d61cb71a396f09969ed264c91ebfff29145c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Fri, 24 Apr 2009 18:34:21 +0200 Subject: Create PluginMenuSlot --- portato/gui/windows/main.py | 22 ++++++++++++++++++++++ portato/plugin.py | 1 + 2 files changed, 23 insertions(+) diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py index 6a65d2e..cb463c8 100644 --- a/portato/gui/windows/main.py +++ b/portato/gui/windows/main.py @@ -50,6 +50,27 @@ from .preference import PreferenceWindow from .search import SearchWindow from .update import UpdateWindow +class PluginMenuSlot (plugin.WidgetSlot): + + def __init__ (self, tree): + plugin.WidgetSlot.__init__(self, self.create_action, "Plugin Menu") + + self.ctr = 0 # counter for the plugin actions + self.uim = tree.get_widget("uimanager") + self.ag = tree.get_widget("pluginActionGroup") + + def create_action (self, label): + aname = "plugin%d" % self.ctr + a = gtk.Action(aname, label, None, None) + self.ctr += 1 + + def add (self, action): + self.ag.add_action(action) + + # add to UI + mid = self.uim.new_merge_id() + self.uim.add_ui(mid, "ui/menubar/pluginMenu", action.get_name(), action.get_name(), gtk.UI_MANAGER_MENUITEM, False) + class PackageTable: """A window with data about a specfic package.""" @@ -559,6 +580,7 @@ class MainWindow (Window): # set plugins and plugin-menu splash(_("Loading Plugins")) + PluginMenuSlot(self.tree) plugin.load_plugins() # session diff --git a/portato/plugin.py b/portato/plugin.py index 9efe396..50cc29f 100644 --- a/portato/plugin.py +++ b/portato/plugin.py @@ -119,6 +119,7 @@ class WidgetSlot (object): self.add = add self._inited = False + debug("Registering new WidgetSlot '%s'.", name) WidgetSlot.slots[name] = self def add_widget (self, w): -- cgit v1.2.3