summaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-03-01 23:11:41 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-03-01 23:11:41 -0800
commit51d20880210d990e35982137067cda1801460d0a (patch)
treebcbd7c015a526e900d4ae72c9748cbd0d1fb72d0 /gtk-gui.c
parentf7d373bae64627e25dcca219f81362c9f1d1b508 (diff)
parentd1c394e51f7ab792650246dff74677609a9e7ea8 (diff)
downloadsubsurface-51d20880210d990e35982137067cda1801460d0a.tar.gz
Merge branch 'map-providers'
Diffstat (limited to 'gtk-gui.c')
-rw-r--r--gtk-gui.c48
1 files changed, 41 insertions, 7 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index cd26cd635..c438be43d 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -29,6 +29,10 @@
#include <gdk-pixbuf/gdk-pixdata.h>
#include "subsurface-icon.h"
+#if HAVE_OSM_GPS_MAP
+#include <osm-gps-map-source.h>
+#endif
+
GtkWidget *main_window;
GtkWidget *main_vbox;
GtkWidget *error_info_bar;
@@ -643,10 +647,27 @@ static void pick_default_file(GtkWidget *w, GtkButton *button)
gtk_widget_set_sensitive(parent, TRUE);
}
+#if HAVE_OSM_GPS_MAP
+static GtkWidget * map_provider_widget()
+{
+ OsmGpsMapSource_t i;
+ GtkWidget *combobox = gtk_combo_box_text_new();
+
+ /* several of the providers seem to be redundant or non-functional;
+ * we may have to skip more than just the last three eventually */
+ for (i = OSM_GPS_MAP_SOURCE_OPENSTREETMAP; i < OSM_GPS_MAP_SOURCE_LAST; i++)
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), osm_gps_map_source_get_friendly_name(i));
+ /* we don't offer choice 0 (none), so the index here is off by one */
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), prefs.map_provider - 1);
+ return combobox;
+}
+#endif
+
static void preferences_dialog(GtkWidget *w, gpointer data)
{
int result;
- GtkWidget *dialog, *notebook, *font, *frame, *box, *vbox, *button, *xmlfile_button;
+ GtkWidget *dialog, *notebook, *font, *frame, *box, *hbox, *vbox, *button;
+ GtkWidget *xmlfile_button, *map_provider;
GtkWidget *entry_po2, *entry_pn2, *entry_phe, *entry_mod, *entry_gflow, *entry_gfhigh;
const char *current_default, *new_default;
char threshold_text[10], mod_text[10], utf8_buf[128];
@@ -749,14 +770,19 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
frame = gtk_frame_new(_("Default XML Data File"));
gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 5);
- box = gtk_hbox_new(FALSE, 6);
- gtk_container_add(GTK_CONTAINER(frame), box);
+ hbox = gtk_hbox_new(FALSE, 6);
+ gtk_container_add(GTK_CONTAINER(frame), hbox);
current_default = prefs.default_filename;
xmlfile_button = gtk_button_new_with_label(current_default);
g_signal_connect(G_OBJECT(xmlfile_button), "clicked",
G_CALLBACK(pick_default_file), xmlfile_button);
- gtk_box_pack_start(GTK_BOX(box), xmlfile_button, FALSE, FALSE, 6);
-
+ gtk_box_pack_start(GTK_BOX(hbox), xmlfile_button, FALSE, FALSE, 6);
+#if HAVE_OSM_GPS_MAP
+ frame = gtk_frame_new(_("Map provider"));
+ map_provider = map_provider_widget();
+ gtk_container_add(GTK_CONTAINER(frame), map_provider);
+ gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 3);
+#endif
/* vbox that holds the second notebook page */
vbox = gtk_vbox_new(FALSE, 6);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
@@ -944,11 +970,19 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
existing_filename = strdup(new_default);
}
}
-
if (strcmp(current_default, new_default)) {
prefs.default_filename = new_default;
}
-
+#if HAVE_OSM_GPS_MAP
+ /* get the map provider selected */
+ OsmGpsMapSource_t i;
+ char *provider = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(map_provider));
+ for (i = OSM_GPS_MAP_SOURCE_OPENSTREETMAP; i <= OSM_GPS_MAP_SOURCE_YAHOO_STREET; i++)
+ if (!strcmp(provider,osm_gps_map_source_get_friendly_name(i))) {
+ prefs.map_provider = i;
+ break;
+ }
+#endif
save_preferences();
} else if (result == GTK_RESPONSE_CANCEL) {
prefs = oldprefs;