From: <jb...@us...> - 2010-05-15 07:15:22
|
Revision: 578 http://pytrainer.svn.sourceforge.net/pytrainer/?rev=578&view=rev Author: jblance Date: 2010-05-15 07:15:15 +0000 (Sat, 15 May 2010) Log Message: ----------- Modifications to support OSM as a map viewer - added preference to chose default, changes to map screen to allow viewer selection. OSM not implemented yet Modified Paths: -------------- pytrainer/trunk/glade/profile.glade pytrainer/trunk/pytrainer/gui/windowmain.py pytrainer/trunk/pytrainer/gui/windowprofile.py pytrainer/trunk/pytrainer/main.py pytrainer/trunk/pytrainer/profile.py Modified: pytrainer/trunk/glade/profile.glade =================================================================== --- pytrainer/trunk/glade/profile.glade 2010-05-15 06:05:28 UTC (rev 577) +++ pytrainer/trunk/glade/profile.glade 2010-05-15 07:15:15 UTC (rev 578) @@ -10,7 +10,6 @@ <child> <widget class="GtkVBox" id="vbox4"> <property name="visible">True</property> - <property name="orientation">vertical</property> <child> <widget class="GtkNotebook" id="notebook3"> <property name="visible">True</property> @@ -20,7 +19,6 @@ <child> <widget class="GtkVBox" id="vbox24"> <property name="visible">True</property> - <property name="orientation">vertical</property> <child> <widget class="GtkFrame" id="frame14"> <property name="visible">True</property> @@ -32,12 +30,8 @@ <property name="visible">True</property> <property name="left_padding">12</property> <child> - <widget class="GtkTable" id="table19"> + <widget class="GtkHBox" id="hbox2"> <property name="visible">True</property> - <property name="border_width">5</property> - <property name="n_columns">2</property> - <property name="column_spacing">5</property> - <property name="row_spacing">5</property> <child> <widget class="GtkRadioButton" id="prf_metric_system"> <property name="label" translatable="yes">Metric system</property> @@ -45,11 +39,13 @@ <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="use_underline">True</property> + <property name="active">True</property> <property name="draw_indicator">True</property> </widget> <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> + <property name="expand">False</property> + <property name="padding">5</property> + <property name="position">0</property> </packing> </child> <child> @@ -63,10 +59,9 @@ <property name="group">prf_metric_system</property> </widget> <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> + <property name="expand">False</property> + <property name="padding">5</property> + <property name="position">1</property> </packing> </child> </widget> @@ -91,6 +86,72 @@ </packing> </child> <child> + <widget class="GtkFrame" id="frameDefaultMapViewer"> + <property name="visible">True</property> + <property name="border_width">5</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <widget class="GtkAlignment" id="alignment2"> + <property name="visible">True</property> + <property name="left_padding">12</property> + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <child> + <widget class="GtkRadioButton" id="radiobuttonDefaultGMap"> + <property name="label" translatable="yes">Google</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="padding">5</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkRadioButton" id="radiobuttonDefaultOSM"> + <property name="label" translatable="yes">Open Street Map</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + <property name="group">radiobuttonDefaultGMap</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkLabel" id="labelDefaultMapViewer"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Default Map Viewer</b></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> <widget class="GtkFrame" id="frame13"> <property name="visible">True</property> <property name="border_width">5</property> @@ -174,7 +235,7 @@ <child> <widget class="GtkComboBoxEntry" id="prf_ddbb"> <property name="visible">True</property> - <property name="items" translatable="no"></property> + <property name="items"></property> <signal name="changed" handler="on_prf_ddbb_changed"/> </widget> <packing> @@ -265,7 +326,7 @@ <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> <child> @@ -344,7 +405,7 @@ <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">2</property> + <property name="position">3</property> </packing> </child> </widget> @@ -404,7 +465,7 @@ <child> <widget class="GtkComboBoxEntry" id="prf_gender"> <property name="visible">True</property> - <property name="items" translatable="no"></property> + <property name="items"></property> </widget> <packing> <property name="left_attach">1</property> @@ -596,7 +657,6 @@ <widget class="GtkVBox" id="sportlist_"> <property name="visible">True</property> <property name="border_width">5</property> - <property name="orientation">vertical</property> <child> <widget class="GtkScrolledWindow" id="sportScrollWindow"> <property name="height_request">170</property> @@ -717,7 +777,6 @@ <widget class="GtkVBox" id="addsport_"> <property name="visible">True</property> <property name="border_width">5</property> - <property name="orientation">vertical</property> <child> <widget class="GtkTable" id="table18"> <property name="visible">True</property> @@ -934,14 +993,12 @@ <widget class="GtkVBox" id="deletesport_"> <property name="visible">True</property> <property name="border_width">5</property> - <property name="orientation">vertical</property> <child> <placeholder/> </child> <child> <widget class="GtkVBox" id="vbox17"> <property name="visible">True</property> - <property name="orientation">vertical</property> <child> <widget class="GtkLabel" id="label144"> <property name="visible">True</property> @@ -1038,7 +1095,7 @@ </child> <child> <widget class="GtkLabel" id="sportnamedel"> - <property name="label" translatable="no">label-2147483648</property> + <property name="label">label-2147483648</property> </widget> <packing> <property name="expand">False</property> @@ -1081,7 +1138,6 @@ <widget class="GtkVBox" id="editsport_"> <property name="visible">True</property> <property name="border_width">5</property> - <property name="orientation">vertical</property> <child> <widget class="GtkTable" id="table17"> <property name="visible">True</property> @@ -1309,7 +1365,6 @@ <child> <widget class="GtkVBox" id="vbox25"> <property name="visible">True</property> - <property name="orientation">vertical</property> <child> <widget class="GtkFrame" id="frame17"> <property name="visible">True</property> @@ -1597,7 +1652,6 @@ <child> <widget class="GtkVBox" id="vbox_startup_params"> <property name="visible">True</property> - <property name="orientation">vertical</property> <child> <widget class="GtkAlignment" id="alignment1"> <property name="visible">True</property> @@ -1662,7 +1716,7 @@ </child> <child> <widget class="GtkCheckButton" id="checkbuttonValidate"> - <property name="label" translatable="no">--valid</property> + <property name="label">--valid</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> @@ -1708,7 +1762,7 @@ </child> <child> <widget class="GtkCheckButton" id="checkbuttonCheck"> - <property name="label" translatable="no">--check</property> + <property name="label">--check</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> @@ -1754,7 +1808,7 @@ </child> <child> <widget class="GtkCheckButton" id="checkbuttonGM3"> - <property name="label" translatable="no">--gmaps2*</property> + <property name="label">--gmaps2*</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> @@ -1801,7 +1855,7 @@ </child> <child> <widget class="GtkCheckButton" id="checkbuttonUnifiedImport"> - <property name="label" translatable="no">--testimport</property> + <property name="label">--testimport</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> @@ -1847,7 +1901,7 @@ </child> <child> <widget class="GtkCheckButton" id="checkbuttonEquip"> - <property name="label" translatable="no">--equip</property> + <property name="label">--equip</property> <property name="visible">True</property> <property name="sensitive">False</property> <property name="can_focus">False</property> Modified: pytrainer/trunk/pytrainer/gui/windowmain.py =================================================================== --- pytrainer/trunk/pytrainer/gui/windowmain.py 2010-05-15 06:05:28 UTC (rev 577) +++ pytrainer/trunk/pytrainer/gui/windowmain.py 2010-05-15 07:15:15 UTC (rev 578) @@ -85,8 +85,10 @@ self.set_unified_import(self.testimport) #Set correct map viewer - #self.radiobuttonOSM.set_active(0) - self.radiobuttonGMap.set_active(1) + if self.pytrainer_main.profile.getValue("pytraining","default_viewer") == "1": + self.radiobuttonOSM.set_active(1) + else: + self.radiobuttonGMap.set_active(1) def set_unified_import(self, status=False): self.menu_importdata.set_sensitive(status) @@ -398,18 +400,19 @@ logging.debug(">>") #Check which type of map viewer to use if self.radiobuttonOSM.get_active(): - map_view = "OSM" + #Use OSM to draw map + logging.debug("Using OSM to draw map....") + self.googlemaps.drawMap(-9999) #TODO placeholder for OSM code elif self.radiobuttonGMap.get_active(): - map_view = "GMAP" + #Use Google to draw map + logging.debug("Using Google to draw map") + if full_screen: + self.googlemaps_old.drawMap(id_record) #TODO - sort this to be more generic, maybe pass map target? + else: + self.googlemaps.drawMap(id_record) #TODO - sort this to be more generic, maybe pass map target? else: - map_view = "GMAP" - print map_view - - if full_screen: - self.googlemaps_old.drawMap(id_record) - else: - - self.googlemaps.drawMap(id_record) + #Unknown map type... + logging.error("Unknown map viewer requested") logging.debug("<<") def actualize_weekview(self, record_list, date_ini, date_end): @@ -835,7 +838,7 @@ ###################### def on_buttonRedrawMap_clicked(self, widget): - print 'on_buttonRedrawMap_clicked' + logging.debug('on_buttonRedrawMap_clicked') self.parent.refreshMapView() def on_radiobuttonMap_toggled(self, widget): Modified: pytrainer/trunk/pytrainer/gui/windowprofile.py =================================================================== --- pytrainer/trunk/pytrainer/gui/windowprofile.py 2010-05-15 06:05:28 UTC (rev 577) +++ pytrainer/trunk/pytrainer/gui/windowprofile.py 2010-05-15 07:15:15 UTC (rev 578) @@ -32,22 +32,6 @@ self.data_path = data_path SimpleGladeApp.__init__(self, data_path+glade_path, root, domain) self.conf_options = parent.profile_options - ''''self.conf_options = [ - "prf_name", - "prf_gender", - "prf_weight", - "prf_height", - "prf_age", - "prf_ddbb", - "prf_ddbbhost", - "prf_ddbbname", - "prf_ddbbuser", - "prf_ddbbpass", - "prf_maxhr", - "prf_minhr", - "prf_hrzones_karvonen", - "prf_us_system" - ]''' def new(self): self.gender_options = { @@ -64,7 +48,7 @@ for i in self.gender_options: self.prf_gender.insert_text(i,self.gender_options[i]) - #hacemos lo propio para el combobox ddbb + #hacemos lo propio para el combobox ddbb for i in self.ddbb_type: self.prf_ddbb.insert_text(i,self.ddbb_type[i]) @@ -73,55 +57,66 @@ for column_index, column_name in enumerate(column_names): column = gtk.TreeViewColumn(column_name, gtk.CellRendererText(), text=column_index) column.set_resizable(True) - self.sportTreeView.append_column(column) - + self.sportTreeView.append_column(column) def setValues(self,list_options): for i in self.conf_options.keys(): if not list_options.has_key(i): + print 'no list options for: ' + i continue - try: - var = getattr(self,i) - except AttributeError as e: - continue - if i != "prf_gender" and i != "prf_ddbb" and i !="prf_hrzones_karvonen" and i!="prf_us_system": - var.set_text(list_options[i]) - elif i == "prf_hrzones_karvonen" or i == "prf_us_system": - if list_options[i]=="True": - var.set_active(True) - elif i == "prf_gender": - for j in self.gender_options: - if self.gender_options[j]==list_options[i]: - var.set_active(j) - elif i == "prf_ddbb": - for j in self.ddbb_type: - if self.ddbb_type[j]==list_options[i]: - var.set_active(j) - if j==0: - self._ddbb_value_deactive() - else: - self._ddbb_value_active() + if i == "default_viewer": + if list_options[i] == "1": + logging.debug("Setting defult map viewer to OSM") + self.radiobuttonDefaultOSM.set_active(1) + else: + logging.debug("Setting defult map viewer to Google") + self.radiobuttonDefaultGMap.set_active(1) + else: + try: + var = getattr(self,i) + except AttributeError as e: + continue + if i == "prf_hrzones_karvonen" or i == "prf_us_system": + if list_options[i]=="True": + var.set_active(True) + elif i == "prf_gender": + for j in self.gender_options: + if self.gender_options[j]==list_options[i]: + var.set_active(j) + elif i == "prf_ddbb": + for j in self.ddbb_type: + if self.ddbb_type[j]==list_options[i]: + var.set_active(j) + if j==0: + self._ddbb_value_deactive() + else: + self._ddbb_value_active() + else: + var.set_text(list_options[i]) + def saveOptions(self): list_options = {} for i in self.conf_options.keys(): - try: - var = getattr(self,i) - except AttributeError as e: - continue - if i != "prf_gender" and i != "prf_ddbb" and i != "prf_hrzones_karvonen" and i != "prf_us_system": - #list_options.append((i,var.get_text())) - list_options[i] = var.get_text() - elif i == "prf_hrzones_karvonen" or i == "prf_us_system": - if var.get_active(): - #list_options.append((i,"True")) - list_options[i] = "True" + if i == "default_viewer": + if self.radiobuttonDefaultOSM.get_active(): + list_options[i] = "1" else: - #list_options.append((i,"False")) - list_options[i] = "False" + list_options[i] = "0" else: - #list_options.append((i,var.get_active_text())) - list_options[i] = var.get_active_text() + try: + var = getattr(self,i) + except AttributeError as e: + continue + if i == "prf_hrzones_karvonen" or i == "prf_us_system": + if var.get_active(): + list_options[i] = "True" + else: + list_options[i] = "False" + elif i == "prf_gender" or i == "prf_ddbb": + list_options[i] = var.get_active_text() + else: + list_options[i] = var.get_text() self.parent.setProfile(list_options) def on_calendar_clicked(self,widget): Modified: pytrainer/trunk/pytrainer/main.py =================================================================== --- pytrainer/trunk/pytrainer/main.py 2010-05-15 06:05:28 UTC (rev 577) +++ pytrainer/trunk/pytrainer/main.py 2010-05-15 07:15:15 UTC (rev 578) @@ -59,7 +59,7 @@ class pyTrainer: def __init__(self,filename = None, data_path = None): #Version constants - self.version ="1.7.2_svn#577" + self.version ="1.7.2_svn#578" self.DB_version = 3 #Process command line options self.startup_options = self.get_options() @@ -318,6 +318,10 @@ def refreshMapView(self, full_screen=False): logging.debug('>>') + if self.windowmain is None: + logging.debug('Called before windowmain initialisation') + logging.debug('<<') + return selected,iter = self.windowmain.recordTreeView.get_selection().get_selected() id_record = selected.get_value(iter,0) logging.debug('Trying to show map for record '+str(id_record)) Modified: pytrainer/trunk/pytrainer/profile.py =================================================================== --- pytrainer/trunk/pytrainer/profile.py 2010-05-15 06:05:28 UTC (rev 577) +++ pytrainer/trunk/pytrainer/profile.py 2010-05-15 07:15:15 UTC (rev 578) @@ -68,6 +68,7 @@ "prf_minhr":"", "auto_launch_file_selection":"False", "import_default_tab":"0", + "default_viewer":"0", } #Parse pytrainer configuration file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |