UI Elements do not go through register_factory
authorEnrico Zini <enrico@enricozini.org>
Mon, 15 Jun 2009 09:10:14 +0000 (17:10 +0800)
committerEnrico Zini <enrico@enricozini.org>
Mon, 15 Jun 2009 09:10:14 +0000 (17:10 +0800)
plugins/50_sat_monitor.py
plugins/99_debug.py
zavai/registry.py

index 7100182e324094c22096662345d60a4551e209fa..243697dea4f9b02092889bae8405a604033777cd 100644 (file)
@@ -37,11 +37,11 @@ class SatelliteMonitor(gtk.VBox, zavai.Applet):
         zavai.Applet.__init__(self, registry, name)
         gtk.VBox.__init__(self)
 
-        self.gps = registry.resource("gps")
+        self.registry = registry
+        self.gps = None
 
         self.store = gtk.ListStore(str, str, str, str, str, str, str, str, str, str, str)
         self.view = gtk.TreeView(self.store)
-
         renderer = gtk.CellRendererText()
         for idx, name in enumerate((_("CH"), _("ID"), _("SN"), _("ELE"), _("AZI"),
                      _("Used"), _("Diff"), _("Alm"), _("Eph"),
@@ -54,7 +54,13 @@ class SatelliteMonitor(gtk.VBox, zavai.Applet):
         self.pack_start(self.view, True, True)
         self.pack_start(self.make_parent_link(), False, False)
 
+
+    def init(self):
+        self.gps = self.registry.resource("gps")
+
     def start(self, *args):
+        if self.gps is None:
+            self.init()
         self.gps.monitor.connect(self.on_ubxdebug_packet)
 
     def stop(self, *args):
@@ -99,4 +105,5 @@ class SatelliteMonitor(gtk.VBox, zavai.Applet):
                 qi])
 
 def init(conf = None, registry = None, **kw):
-    registry.register_factory("menu.main.gps.satellite_monitor", SatelliteMonitor, _("Satellite monitor"))
+    name = "menu.main.gps.satellite_monitor"
+    registry.register(name, SatelliteMonitor(registry, name), _("Satellite monitor"))
index 6ddc17621f8359db2999dbafc1307cd287d369fd..fd34c03edd1c1697f969d31b9ad3cf03ffa2c72a 100644 (file)
@@ -30,4 +30,5 @@ class Quitter(gtk.Label, zavai.Applet):
         gtk.main_quit()
 
 def init(conf = None, registry = None, **kw):
-    registry.register_factory("menu.main.debug.quit", Quitter, _("Quit"))
+    name = "menu.main.debug.quit"
+    registry.register(name, Quitter(registry, name), _("Quit"))
index 63e9412d07ef89506fde50f19adedf568b168763..2e4781ca9b5ac9fd8b4213d759282be4eef13795 100644 (file)
@@ -72,9 +72,6 @@ class Registry(object):
         self.factories[name] = fac
         if label is not None: self.labels[name] = label
 
-        if name.startswith("menu."):
-            self.add_to_menu(name)
-
     def register_action(self, name, obj):
         """Register an object at the given path.