From f4b4fd9a9a5d58b1662b12a14edaabf7e0149726 Mon Sep 17 00:00:00 2001 From: Enrico Zini Date: Mon, 15 Jun 2009 18:23:03 +0800 Subject: [PATCH] Added GPX trace plugin --- plugins/55_gpx_trace.py | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 plugins/55_gpx_trace.py diff --git a/plugins/55_gpx_trace.py b/plugins/55_gpx_trace.py new file mode 100644 index 0000000..1c84c69 --- /dev/null +++ b/plugins/55_gpx_trace.py @@ -0,0 +1,52 @@ +# gpx_trace - zavai GPX trace functions +# +# Copyright (C) 2009 Enrico Zini +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +from gettext import gettext as _ +import gtk +import zavai + +class GPXTracer(gtk.ToggleAction): + states = [_("Start GPX trace"), _("Stop GPX trace")] + + def __init__(self, registry, **kw): + self.state = 0 + super(GPXTracer, self).__init__("menu.main.gps.toggle", self.states[self.state], None, None) + + self.registry = registry + self.set_active(False) + + self.connect("toggled", self.on_toggle) + + def on_toggle(self, *args): + self.state = (self.state + 1) % len(self.states) + self.set_property("label", self.states[self.state]) + if self.get_active(): + self.start() + else: + self.stop() + + def start(self): + zavai.info("GPX trace started") + self.registry.resource("gpx").request(self) + + def stop(self): + zavai.info("GPX trace ended") + self.registry.resource("gpx").release(self) + +def init(conf = None, registry = None, **kw): + registry.register(GPXTracer(registry)) -- 2.39.5