From d8cabdbc6ca7f8e8b7060a1e55b65146220d3c90 Mon Sep 17 00:00:00 2001 From: heldersepu Date: Wed, 11 Dec 2013 17:37:42 +0000 Subject: [PATCH] auto load tracks --- gmapcatcher/fileUtils.py | 11 +++++++++++ gmapcatcher/mapUtils.py | 5 +++-- maps.py | 17 ++++++++++++++--- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/gmapcatcher/fileUtils.py b/gmapcatcher/fileUtils.py index d7c7b5f3..5c29c9cd 100644 --- a/gmapcatcher/fileUtils.py +++ b/gmapcatcher/fileUtils.py @@ -133,6 +133,17 @@ def get_themes(): return myThemes +## Returns all the available tracks +def get_tracks(): + tracksPath = './tracks' + myTracks = [] + if os.path.isdir(tracksPath): + for l in os.listdir(tracksPath): + #if os.path.isdir(tracksPath + l): + myTracks += [tracksPath + '/' + l] + return myTracks + + ## Checks if a directory exist if not it will be created def check_dir(strPath, strSubPath=None): if (strSubPath is not None): diff --git a/gmapcatcher/mapUtils.py b/gmapcatcher/mapUtils.py index 12798b5f..cdbdd04f 100644 --- a/gmapcatcher/mapUtils.py +++ b/gmapcatcher/mapUtils.py @@ -259,9 +259,10 @@ def saveGPX(trackSegments): f.close() -def openGPX(): +def openGPX(f_name = None): tracks = None - f_name = FileChooser(USER_PATH, strTitle="Select File") + if (f_name is None): + f_name = FileChooser(USER_PATH, strTitle="Select File") if f_name: f = open(f_name, 'r') tracks = list() diff --git a/maps.py b/maps.py index e01c68b9..60bda756 100755 --- a/maps.py +++ b/maps.py @@ -12,10 +12,12 @@ import gobject import gmapcatcher.mapGPS as mapGPS import gmapcatcher.mapUtils as mapUtils +import gmapcatcher.fileUtils as fileUtils import gmapcatcher.widgets.mapPixbuf as mapPixbuf from threading import Timer from gmapcatcher.mapConst import * +from gmapcatcher.mapUtils import openGPX from gmapcatcher.widgets.mapTools import mapTools from gmapcatcher.gtkThread import gui_callback, webbrowser_open from gmapcatcher.mapConf import MapConf @@ -465,9 +467,9 @@ def __create_left_paned(self, conf): scale.connect("change-value", self.scale_change_value) vbox.pack_start(scale) self.scale = scale - + oSpin = SpinBtn(conf.opacity*10, 0, 9,1,1) - oSpin.connect('value-changed', self.scale_opacity_change_value) + oSpin.connect('value-changed', self.scale_opacity_change_value) vbox.pack_start(oSpin, False, True) return vbox @@ -635,7 +637,7 @@ def export_done(self, text): if (text[:6] == "error="): rect = self.drawing_area.get_allocation() self.drawing_area.draw_message(text[6:], 10, rect.height / 2, 'red') - time.sleep(2) + time.sleep(2) self.export_panel.export_pbar.off() self.export_panel.export_box.show() @@ -1179,6 +1181,14 @@ def pane_notify(self, pane, gparamspec, intPos): elif (panePos > intPos + 2): pane.set_position(intPos + 2) + def load_tracks(self, tracks): + if (len(tracks) > 0): + for track in tracks: + dtrack = openGPX(track) + if dtrack: + self.tracks.extend(dtrack) + self.shown_tracks.extend(dtrack) + def __init__(self, parent=None, config_path=None): self.conf = MapConf(config_path) self.crossPixbuf = mapPixbuf.cross() @@ -1281,6 +1291,7 @@ def __init__(self, parent=None, config_path=None): self.entry.grab_focus() if self.conf.auto_refresh > 0: gobject.timeout_add(self.conf.auto_refresh, self.refresh) + self.load_tracks(fileUtils.get_tracks()) def main(conf_path):