zavai.info("GPX trace ended")
self.registry.resource("gpx").release(self)
+class GPXWaypoint(gtk.Action):
+ def __init__(self, registry, **kw):
+ super(GPXWaypoint, self).__init__("menu.main.gps.waypoint", _("Take waypoint"), None, None)
+ self.gpx = registry.resource("gpx")
+ self.gpx.add_activity_monitor(self.on_gpx_activity_changed)
+ self.connect("activate", self.on_activate)
+
+ def on_gpx_activity_changed(self, gpx, state):
+ self.set_sensitive(state)
+
+ def on_activate(self, *args):
+ self.gpx.waypoint()
+
+
def init(conf = None, registry = None, **kw):
registry.register(GPXTracer(registry))
+ registry.register(GPXWaypoint(registry))
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"
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:
self.wpt.close()
self.wpt = None
self.last_pos = None
+ self.notify_activity_monitors()
def shutdown(self):
self.stop()