summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--portato/gui/templates/MainWindow.ui1
-rw-r--r--portato/gui/windows/main.py7
-rw-r--r--portato/plugin.py26
3 files changed, 28 insertions, 6 deletions
diff --git a/portato/gui/templates/MainWindow.ui b/portato/gui/templates/MainWindow.ui
index 383011e..473821d 100644
--- a/portato/gui/templates/MainWindow.ui
+++ b/portato/gui/templates/MainWindow.ui
@@ -8,6 +8,7 @@
<object class="GtkAction" id="pluginMenuAction">
<property name="name">pluginMenuAction</property>
<property name="label" translatable="yes">Plu_gins</property>
+ <property name="is_important">True</property>
</object>
</child>
</object>
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index cb463c8..0259fc7 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -63,14 +63,19 @@ class PluginMenuSlot (plugin.WidgetSlot):
aname = "plugin%d" % self.ctr
a = gtk.Action(aname, label, None, None)
self.ctr += 1
+
+ return a
- def add (self, action):
+ def add (self, widget):
+ action = widget.widget
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)
+ self.uim.ensure_update()
+
class PackageTable:
"""A window with data about a specfic package."""
diff --git a/portato/plugin.py b/portato/plugin.py
index 50cc29f..4914f25 100644
--- a/portato/plugin.py
+++ b/portato/plugin.py
@@ -115,8 +115,16 @@ class WidgetSlot (object):
self.widget = widget
self.name = name
self.max = max
- self.init = init
- self.add = add
+
+ # we might be subclassed
+ # in this case do not overwrite
+
+ if not hasattr(self, "init"):
+ self.init = init
+
+ if not hasattr(self, "add"):
+ self.add = add
+
self._inited = False
debug("Registering new WidgetSlot '%s'.", name)
@@ -128,7 +136,8 @@ class WidgetSlot (object):
self.init()
self._inited = True
- self.add(w)
+ if self.add is not None:
+ self.add(w)
class Widget (object):
"""
@@ -295,6 +304,10 @@ class Plugin (object):
:see: `Widget`
"""
+
+ if not slot in WidgetSlot.slots:
+ raise PluginLoadException, "Could not find specified widget slot: %s" % slot
+
self.__widgets.append(Widget(slot, widget))
def create_widget (self, slot, args, **kwargs):
@@ -318,7 +331,10 @@ class Plugin (object):
except KeyError:
raise PluginLoadException, "Could not find specified widget slot: %s" % slot
- w = widget(*args)
+ if not hasattr(args, "__iter__"):
+ w = widget(args)
+ else:
+ w = widget(*args)
for k,v in kwargs.iteritems():
w.connect(k, v)
@@ -410,7 +426,7 @@ class PluginQueue (object):
for p in self.plugins:
for w in p.widgets:
- WidgetSlot[w.slot].add_widget(w)
+ WidgetSlot.slots[w.slot].add_widget(w)
def add (self, plugin, disable = False):
"""