Simplified applets
authorEnrico Zini <enrico@enricozini.org>
Mon, 15 Jun 2009 09:17:13 +0000 (17:17 +0800)
committerEnrico Zini <enrico@enricozini.org>
Mon, 15 Jun 2009 09:17:13 +0000 (17:17 +0800)
plugins/50_sat_monitor.py
plugins/99_debug.py
zavai/app.py

index 243697dea4f9b02092889bae8405a604033777cd..de173fc351dbef17eba2cde5b992f875d09d7340 100644 (file)
@@ -32,12 +32,10 @@ SAT_QI_NAMES = {
     7: _("receiving data")
 }
 
-class SatelliteMonitor(gtk.VBox, zavai.Applet):
+class SatelliteMonitor(zavai.Applet):
     def __init__(self, registry, name, **kw):
-        zavai.Applet.__init__(self, registry, name)
-        gtk.VBox.__init__(self)
+        super(SatelliteMonitor, self).__init__(registry, name)
 
-        self.registry = registry
         self.gps = None
 
         self.store = gtk.ListStore(str, str, str, str, str, str, str, str, str, str, str)
@@ -50,13 +48,10 @@ class SatelliteMonitor(gtk.VBox, zavai.Applet):
             col.pack_start(renderer, False)
             col.add_attribute(renderer, "text", idx)
             self.view.append_column(col)
-
-        self.pack_start(self.view, True, True)
-        self.pack_start(self.make_parent_link(), False, False)
-
+        self.add(self.view)
 
     def init(self):
-        self.gps = self.registry.resource("gps")
+        self.gps = self.zavai_registry.resource("gps")
 
     def start(self, *args):
         if self.gps is None:
index fd34c03edd1c1697f969d31b9ad3cf03ffa2c72a..ae4ab024e38db32fe0fe7ac24c5c6859c27de959 100644 (file)
@@ -21,6 +21,11 @@ import sys
 from gettext import gettext as _
 import zavai
 
+class Useless(zavai.Applet):
+    def __init__(self, registry, name, **kw):
+        zavai.Applet.__init__(self, registry, name)
+        self.add(gtk.Label(_("This has no use")))
+
 class Quitter(gtk.Label, zavai.Applet):
     def __init__(self, registry, name, **kw):
         zavai.Applet.__init__(self, registry, name)
@@ -30,5 +35,7 @@ class Quitter(gtk.Label, zavai.Applet):
         gtk.main_quit()
 
 def init(conf = None, registry = None, **kw):
+    name = "menu.main.debug.useless"
+    registry.register(name, Useless(registry, name), _("Useless"))
     name = "menu.main.debug.quit"
     registry.register(name, Quitter(registry, name), _("Quit"))
index 29311de8ff6ad1279a81f5306d0f71b71cde9977..b8b3b62646d24a24cf143ebd4fd5ae4b6a3bbd3c 100644 (file)
@@ -59,14 +59,16 @@ class Zavai(gtk.Window, zavai.Resource):
         self.show_all()
         gtk.main()
 
-class Applet(zavai.Resource):
+class Applet(gtk.VBox):
     def __init__(self, registry, name):
         super(Applet, self).__init__()
         self.zavai_registry = registry
         self.zavai_name = name
+        self.back_link = zavai.LinkButton(registry, zavai.get_parent(name), _("Back"))
+        self.pack_end(self.back_link, False, False)
 
-    def make_parent_link(self):
-        return zavai.LinkButton(self.zavai_registry, zavai.get_parent(self.zavai_name), _("Back"))
+    def add(self, widget):
+        self.pack_start(widget, True, True)
 
     def shutdown(self):
         self.stop()