No need to fullscreen: matchbox does it for us
[gregoa/zavai.git] / zavai / gps.py
index ff97253bd589c2d5f240bba2f14fbe298b09f142..47af68fb9f76e6b7970c3cba824be53e12ffa571 100755 (executable)
@@ -256,6 +256,18 @@ class GPX(zavai.Resource):
         if not os.path.isdir(self.trackdir):
             zavai.info("Creating directory", self.trackdir)
             os.makedirs(self.trackdir)
+        self.activity_monitors = set()
+
+    def add_activity_monitor(self, cb):
+        self.activity_monitors.add(cb)
+        cb(self, self.last_pos is not None)
+
+    def del_activity_monitor(self, cb):
+        self.activity_monitors.discard(cb)
+
+    def notify_activity_monitors(self):
+        for mon in self.activity_monitors:
+            mon(self, self.last_pos is not None)
 
     def request(self, tag):
         "Request the GPX trace to be taken"
@@ -307,6 +319,7 @@ class GPX(zavai.Resource):
     xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">""" % VERSION
 
         self.wpt_seq = 1;
+        self.notify_activity_monitors()
 
     def stop(self):
         if self.trk is not None:
@@ -318,6 +331,7 @@ class GPX(zavai.Resource):
             self.wpt.close()
             self.wpt = None
         self.last_pos = None
+        self.notify_activity_monitors()
 
     def shutdown(self):
         self.stop()