mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Bring back support for GTK versions pre 2.24
The introduction of GtkComboBoxText usage for selecting a map provider, removed support for older versions of GTK on distros like Debian 6.0.4. Parent class (GtkComboBox) methods have to be used instead, around more pre-processor branching. This patch also fixes a small memory leak when retrieving text from said combo box. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e362272edc
commit
6dd31a6cc6
1 changed files with 11 additions and 0 deletions
11
gtk-gui.c
11
gtk-gui.c
|
@ -671,12 +671,18 @@ static void pick_default_file(GtkWidget *w, GtkButton *button)
|
||||||
static GtkWidget * map_provider_widget()
|
static GtkWidget * map_provider_widget()
|
||||||
{
|
{
|
||||||
OsmGpsMapSource_t i;
|
OsmGpsMapSource_t i;
|
||||||
|
#if GTK_CHECK_VERSION(2,24,0)
|
||||||
GtkWidget *combobox = gtk_combo_box_text_new();
|
GtkWidget *combobox = gtk_combo_box_text_new();
|
||||||
|
|
||||||
/* several of the providers seem to be redundant or non-functional;
|
/* several of the providers seem to be redundant or non-functional;
|
||||||
* we may have to skip more than just the last three eventually */
|
* 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++)
|
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));
|
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), osm_gps_map_source_get_friendly_name(i));
|
||||||
|
#else
|
||||||
|
GtkWidget *combobox = gtk_combo_box_new_text();
|
||||||
|
for (i = OSM_GPS_MAP_SOURCE_OPENSTREETMAP; i < OSM_GPS_MAP_SOURCE_LAST; i++)
|
||||||
|
gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), osm_gps_map_source_get_friendly_name(i));
|
||||||
|
#endif
|
||||||
/* we don't offer choice 0 (none), so the index here is off by one */
|
/* 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);
|
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), prefs.map_provider - 1);
|
||||||
return combobox;
|
return combobox;
|
||||||
|
@ -999,12 +1005,17 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
|
||||||
#if HAVE_OSM_GPS_MAP
|
#if HAVE_OSM_GPS_MAP
|
||||||
/* get the map provider selected */
|
/* get the map provider selected */
|
||||||
OsmGpsMapSource_t i;
|
OsmGpsMapSource_t i;
|
||||||
|
#if GTK_CHECK_VERSION(2,24,0)
|
||||||
char *provider = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(map_provider));
|
char *provider = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(map_provider));
|
||||||
|
#else
|
||||||
|
char *provider = gtk_combo_box_get_active_text(GTK_COMBO_BOX(map_provider));
|
||||||
|
#endif
|
||||||
for (i = OSM_GPS_MAP_SOURCE_OPENSTREETMAP; i <= OSM_GPS_MAP_SOURCE_YAHOO_STREET; i++)
|
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))) {
|
if (!strcmp(provider,osm_gps_map_source_get_friendly_name(i))) {
|
||||||
prefs.map_provider = i;
|
prefs.map_provider = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
free((void *)provider);
|
||||||
#endif
|
#endif
|
||||||
save_preferences();
|
save_preferences();
|
||||||
} else if (result == GTK_RESPONSE_CANCEL) {
|
} else if (result == GTK_RESPONSE_CANCEL) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue