Skip to content

Commit

Permalink
auto load tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
heldersepu committed Dec 11, 2013
1 parent 2a10d39 commit d8cabdb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
11 changes: 11 additions & 0 deletions gmapcatcher/fileUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions gmapcatcher/mapUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
17 changes: 14 additions & 3 deletions maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d8cabdb

Please sign in to comment.