1 # gpx_trace - zavai GPX trace functions
3 # Copyright (C) 2009 Enrico Zini <enrico@enricozini.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 from gettext import gettext as _
23 class GPXTracer(gtk.ToggleAction):
24 states = [_("Start GPX trace"), _("Stop GPX trace")]
26 def __init__(self, registry, **kw):
28 super(GPXTracer, self).__init__("menu.main.gps.toggle", self.states[self.state], None, None)
30 self.registry = registry
31 self.set_active(False)
33 self.connect("toggled", self.on_toggle)
35 def on_toggle(self, *args):
36 self.state = (self.state + 1) % len(self.states)
37 self.set_property("label", self.states[self.state])
44 zavai.info("GPX trace started")
45 self.registry.resource("gpx").request(self)
48 zavai.info("GPX trace ended")
49 self.registry.resource("gpx").release(self)
51 class GPXWaypoint(gtk.Action):
52 def __init__(self, registry, **kw):
53 super(GPXWaypoint, self).__init__("menu.main.gps.waypoint", _("Take waypoint"), None, None)
54 self.gpx = registry.resource("gpx")
55 self.gpx.add_activity_monitor(self.on_gpx_activity_changed)
56 self.connect("activate", self.on_activate)
58 def on_gpx_activity_changed(self, gpx, state):
59 self.set_sensitive(state)
61 def on_activate(self, *args):
65 def init(conf = None, registry = None, **kw):
66 registry.register(GPXTracer(registry))
67 registry.register(GPXWaypoint(registry))