Added window list
[gregoa/zavai.git] / zavai / menu.py
index 424ee07bfcdd32b7d36a23714219a4f42be63c1a..629495afda2c6551230517e45191ffe292032332 100644 (file)
@@ -42,11 +42,27 @@ class Menu(gtk.VBox, zavai.Resource):
         self.vbox.pack_start(widget, False, False)
 
 class LinkButton(MenuButton, zavai.Resource):
-    def __init__(self, registry, targetName, label):
-        super(LinkButton, self).__init__(label)
-        self.target = targetName
-        self.registry = registry
-        self.connect("clicked", self.on_click)
+    def __init__(self, registry, targetName, label=None, action=None):
+        if action is not None:
+            super(LinkButton, self).__init__()
+            self.target = targetName
+            self.registry = registry
+            self.action = action
+            action.connect_proxy(self)
+            self.connect("clicked", self.on_click)
+        else:
+            super(LinkButton, self).__init__(label)
+            self.target = targetName
+            self.registry = registry
+            self.action = None
+            self.connect("clicked", self.on_click)
 
     def on_click(self, *args):
-        self.registry.resource("app").show_widget(self.target)
+        self.registry.resource("app").activate_resource(self.target)
+
+class ToggleButton(gtk.ToggleButton):
+    def __init__(self, registry, targetName, action, *args, **kw):
+        super(ToggleButton, self).__init__()
+        # TODO: take this from the configuration
+        self.set_size_request(0, 80)
+        action.connect_proxy(self)