]>
Commit | Line | Data |
---|---|---|
50a14534 EB |
1 | /* |
2 | * viking -- GPS Data and Topo Analyzer, Explorer, and Manager | |
3 | * | |
4 | * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net> | |
a482007a GB |
5 | * Copyright (C) 2008, Hein Ragas <viking@ragas.nl> |
6 | * Copyright (C) 2010, Rob Norris <rw_norris@hotmail.com> | |
50a14534 EB |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | * | |
22 | */ | |
23 | ||
4c77d5e0 GB |
24 | #ifdef HAVE_CONFIG_H |
25 | #include "config.h" | |
26 | #endif | |
27 | ||
50a14534 EB |
28 | #include "viking.h" |
29 | #include "thumbnails.h" | |
acaf7113 | 30 | #include "garminsymbols.h" |
dfad9456 | 31 | #include "degrees_converters.h" |
e8947958 | 32 | #include "authors.h" |
eb6a42c9 | 33 | #include "documenters.h" |
34e71b99 | 34 | #include "vikgoto.h" |
85beadba | 35 | #include "util.h" |
50a14534 | 36 | |
4c77d5e0 GB |
37 | #include <glib/gi18n.h> |
38 | ||
50a14534 EB |
39 | #include <stdlib.h> |
40 | #include <string.h> | |
41 | #include <ctype.h> | |
42 | ||
43 | void a_dialog_msg ( GtkWindow *parent, gint type, const gchar *info, const gchar *extra ) | |
44 | { | |
45 | GtkWidget *msgbox = gtk_message_dialog_new ( parent, GTK_DIALOG_DESTROY_WITH_PARENT, type, GTK_BUTTONS_OK, info, extra ); | |
46 | gtk_dialog_run ( GTK_DIALOG(msgbox) ); | |
47 | gtk_widget_destroy ( msgbox ); | |
48 | } | |
49 | ||
50 | gboolean a_dialog_goto_latlon ( GtkWindow *parent, struct LatLon *ll, const struct LatLon *old ) | |
51 | { | |
7760b0cf | 52 | GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Go to Lat/Lon"), |
50a14534 EB |
53 | parent, |
54 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
55 | GTK_STOCK_CANCEL, | |
56 | GTK_RESPONSE_REJECT, | |
57 | GTK_STOCK_OK, | |
58 | GTK_RESPONSE_ACCEPT, | |
59 | NULL); | |
60 | GtkWidget *latlabel, *lonlabel; | |
61 | GtkWidget *lat, *lon; | |
62 | gchar *tmp_lat, *tmp_lon; | |
63 | ||
7760b0cf | 64 | latlabel = gtk_label_new (_("Latitude:")); |
50a14534 EB |
65 | lat = gtk_entry_new (); |
66 | tmp_lat = g_strdup_printf ( "%f", old->lat ); | |
67 | gtk_entry_set_text ( GTK_ENTRY(lat), tmp_lat ); | |
68 | g_free ( tmp_lat ); | |
69 | ||
7760b0cf | 70 | lonlabel = gtk_label_new (_("Longitude:")); |
50a14534 EB |
71 | lon = gtk_entry_new (); |
72 | tmp_lon = g_strdup_printf ( "%f", old->lon ); | |
73 | gtk_entry_set_text ( GTK_ENTRY(lon), tmp_lon ); | |
74 | g_free ( tmp_lon ); | |
75 | ||
76 | gtk_widget_show ( latlabel ); | |
77 | gtk_widget_show ( lonlabel ); | |
78 | gtk_widget_show ( lat ); | |
79 | gtk_widget_show ( lon ); | |
80 | ||
81 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), latlabel, FALSE, FALSE, 0); | |
82 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), lat, FALSE, FALSE, 0); | |
83 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), lonlabel, FALSE, FALSE, 0); | |
84 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), lon, FALSE, FALSE, 0); | |
85 | ||
86 | if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) | |
87 | { | |
dfad9456 GB |
88 | ll->lat = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lat) ) ); |
89 | ll->lon = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lon) ) ); | |
50a14534 EB |
90 | gtk_widget_destroy ( dialog ); |
91 | return TRUE; | |
92 | } | |
93 | ||
94 | gtk_widget_destroy ( dialog ); | |
95 | return FALSE; | |
96 | } | |
97 | ||
98 | gboolean a_dialog_goto_utm ( GtkWindow *parent, struct UTM *utm, const struct UTM *old ) | |
99 | { | |
a0f3579f | 100 | GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Go to UTM"), |
50a14534 EB |
101 | parent, |
102 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
103 | GTK_STOCK_CANCEL, | |
104 | GTK_RESPONSE_REJECT, | |
105 | GTK_STOCK_OK, | |
106 | GTK_RESPONSE_ACCEPT, | |
107 | NULL); | |
108 | GtkWidget *norlabel, *easlabel, *nor, *eas; | |
109 | GtkWidget *zonehbox, *zonespin, *letterentry; | |
110 | gchar *tmp_eas, *tmp_nor; | |
111 | gchar tmp_letter[2]; | |
112 | ||
7760b0cf | 113 | norlabel = gtk_label_new (_("Northing:")); |
50a14534 EB |
114 | nor = gtk_entry_new (); |
115 | tmp_nor = g_strdup_printf("%ld", (long) old->northing ); | |
116 | gtk_entry_set_text ( GTK_ENTRY(nor), tmp_nor ); | |
117 | g_free ( tmp_nor ); | |
118 | ||
7760b0cf | 119 | easlabel = gtk_label_new (_("Easting:")); |
50a14534 EB |
120 | eas = gtk_entry_new (); |
121 | tmp_eas = g_strdup_printf("%ld", (long) old->easting ); | |
122 | gtk_entry_set_text ( GTK_ENTRY(eas), tmp_eas ); | |
123 | g_free ( tmp_eas ); | |
124 | ||
125 | zonehbox = gtk_hbox_new ( FALSE, 0 ); | |
7760b0cf | 126 | gtk_box_pack_start ( GTK_BOX(zonehbox), gtk_label_new ( _("Zone:") ), FALSE, FALSE, 5 ); |
ac33062d | 127 | zonespin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( old->zone, 1, 60, 1, 5, 0 ), 1, 0 ); |
50a14534 | 128 | gtk_box_pack_start ( GTK_BOX(zonehbox), zonespin, TRUE, TRUE, 5 ); |
7760b0cf | 129 | gtk_box_pack_start ( GTK_BOX(zonehbox), gtk_label_new ( _("Letter:") ), FALSE, FALSE, 5 ); |
50a14534 EB |
130 | letterentry = gtk_entry_new (); |
131 | gtk_entry_set_max_length ( GTK_ENTRY(letterentry), 1 ); | |
132 | gtk_entry_set_width_chars ( GTK_ENTRY(letterentry), 2 ); | |
133 | tmp_letter[0] = old->letter; | |
134 | tmp_letter[1] = '\0'; | |
135 | gtk_entry_set_text ( GTK_ENTRY(letterentry), tmp_letter ); | |
136 | gtk_box_pack_start ( GTK_BOX(zonehbox), letterentry, FALSE, FALSE, 5 ); | |
137 | ||
138 | gtk_widget_show ( norlabel ); | |
139 | gtk_widget_show ( easlabel ); | |
140 | gtk_widget_show ( nor ); | |
141 | gtk_widget_show ( eas ); | |
142 | ||
143 | gtk_widget_show_all ( zonehbox ); | |
144 | ||
145 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), norlabel, FALSE, FALSE, 0); | |
146 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), nor, FALSE, FALSE, 0); | |
147 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), easlabel, FALSE, FALSE, 0); | |
148 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), eas, FALSE, FALSE, 0); | |
149 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), zonehbox, FALSE, FALSE, 0); | |
150 | ||
151 | if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) | |
152 | { | |
153 | const gchar *letter; | |
154 | utm->northing = atof ( gtk_entry_get_text ( GTK_ENTRY(nor) ) ); | |
155 | utm->easting = atof ( gtk_entry_get_text ( GTK_ENTRY(eas) ) ); | |
156 | utm->zone = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(zonespin) ); | |
157 | letter = gtk_entry_get_text ( GTK_ENTRY(letterentry) ); | |
158 | if (*letter) | |
159 | utm->letter = toupper(*letter); | |
160 | gtk_widget_destroy ( dialog ); | |
161 | return TRUE; | |
162 | } | |
163 | ||
164 | gtk_widget_destroy ( dialog ); | |
165 | return FALSE; | |
166 | } | |
167 | ||
168 | void a_dialog_response_accept ( GtkDialog *dialog ) | |
169 | { | |
170 | gtk_dialog_response ( dialog, GTK_RESPONSE_ACCEPT ); | |
171 | } | |
172 | ||
8eb76f51 QT |
173 | static void symbol_entry_changed_cb(GtkWidget *combo, GtkListStore *store) |
174 | { | |
175 | GtkTreeIter iter; | |
176 | gchar *sym; | |
177 | ||
178 | if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) | |
179 | return; | |
180 | ||
181 | gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 ); | |
182 | /* Note: symm is NULL when "(none)" is select (first cell is empty) */ | |
183 | gtk_widget_set_tooltip_text(combo, sym); | |
184 | g_free(sym); | |
185 | } | |
186 | ||
50a14534 EB |
187 | /* todo: less on this side, like add track */ |
188 | gboolean a_dialog_new_waypoint ( GtkWindow *parent, gchar **dest, VikWaypoint *wp, GHashTable *waypoints, VikCoordMode coord_mode ) | |
189 | { | |
490b1aa6 | 190 | GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Waypoint Properties"), |
50a14534 EB |
191 | parent, |
192 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
193 | GTK_STOCK_CANCEL, | |
194 | GTK_RESPONSE_REJECT, | |
195 | GTK_STOCK_OK, | |
196 | GTK_RESPONSE_ACCEPT, | |
197 | NULL); | |
198 | struct LatLon ll; | |
e1e6f7fa | 199 | GtkWidget *latlabel, *lonlabel, *namelabel, *latentry, *lonentry, *altentry, *altlabel, *nameentry=NULL, *commentlabel, |
acaf7113 AF |
200 | *commententry, *imagelabel, *imageentry, *symbollabel, *symbolentry; |
201 | GtkListStore *store; | |
202 | ||
203 | ||
204 | ||
50a14534 EB |
205 | |
206 | gchar *lat, *lon, *alt; | |
207 | ||
208 | vik_coord_to_latlon ( &(wp->coord), &ll ); | |
209 | ||
210 | lat = g_strdup_printf ( "%f", ll.lat ); | |
211 | lon = g_strdup_printf ( "%f", ll.lon ); | |
6027a9c5 RN |
212 | vik_units_height_t height_units = a_vik_get_units_height (); |
213 | switch (height_units) { | |
214 | case VIK_UNITS_HEIGHT_METRES: | |
215 | alt = g_strdup_printf ( "%f", wp->altitude ); | |
216 | break; | |
217 | case VIK_UNITS_HEIGHT_FEET: | |
6c20e59a | 218 | alt = g_strdup_printf ( "%f", VIK_METERS_TO_FEET(wp->altitude) ); |
6027a9c5 RN |
219 | break; |
220 | default: | |
221 | alt = g_strdup_printf ( "%f", wp->altitude ); | |
222 | g_critical("Houston, we've had a problem. height=%d", height_units); | |
223 | } | |
50a14534 EB |
224 | |
225 | if ( dest != NULL ) | |
226 | { | |
7760b0cf | 227 | namelabel = gtk_label_new (_("Name:")); |
50a14534 | 228 | nameentry = gtk_entry_new (); |
a8fe53f8 EB |
229 | if ( *dest ) { |
230 | gtk_entry_set_text( GTK_ENTRY(nameentry), *dest ); | |
231 | g_free ( *dest ); | |
232 | *dest = NULL; | |
233 | } | |
50a14534 EB |
234 | g_signal_connect_swapped ( nameentry, "activate", G_CALLBACK(a_dialog_response_accept), GTK_DIALOG(dialog) ); |
235 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), namelabel, FALSE, FALSE, 0); | |
236 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), nameentry, FALSE, FALSE, 0); | |
237 | } | |
238 | ||
7760b0cf | 239 | latlabel = gtk_label_new (_("Latitude:")); |
50a14534 EB |
240 | latentry = gtk_entry_new (); |
241 | gtk_entry_set_text ( GTK_ENTRY(latentry), lat ); | |
242 | g_free ( lat ); | |
243 | ||
7760b0cf | 244 | lonlabel = gtk_label_new (_("Longitude:")); |
50a14534 EB |
245 | lonentry = gtk_entry_new (); |
246 | gtk_entry_set_text ( GTK_ENTRY(lonentry), lon ); | |
247 | g_free ( lon ); | |
248 | ||
7760b0cf | 249 | altlabel = gtk_label_new (_("Altitude:")); |
50a14534 EB |
250 | altentry = gtk_entry_new (); |
251 | gtk_entry_set_text ( GTK_ENTRY(altentry), alt ); | |
252 | g_free ( alt ); | |
253 | ||
7760b0cf | 254 | commentlabel = gtk_label_new (_("Comment:")); |
50a14534 | 255 | commententry = gtk_entry_new (); |
ba4a5e11 | 256 | gchar *cmt = NULL; |
34e71b99 | 257 | cmt = a_vik_goto_get_search_string_for_this_place(VIK_WINDOW(parent)); |
014128f6 QT |
258 | if (cmt) |
259 | gtk_entry_set_text(GTK_ENTRY(commententry), cmt); | |
50a14534 | 260 | |
7760b0cf | 261 | imagelabel = gtk_label_new (_("Image:")); |
79672b85 | 262 | imageentry = vik_file_entry_new (GTK_FILE_CHOOSER_ACTION_OPEN); |
50a14534 | 263 | |
acaf7113 AF |
264 | { |
265 | GtkCellRenderer *r; | |
7760b0cf | 266 | symbollabel = gtk_label_new (_("Symbol:")); |
acaf7113 AF |
267 | GtkTreeIter iter; |
268 | ||
ea3933fc | 269 | store = gtk_list_store_new(3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING); |
acaf7113 | 270 | symbolentry = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); |
8eb76f51 | 271 | gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(symbolentry), 6); |
9be0449f RN |
272 | |
273 | g_signal_connect(symbolentry, "changed", G_CALLBACK(symbol_entry_changed_cb), store); | |
acaf7113 | 274 | gtk_list_store_append (store, &iter); |
7760b0cf | 275 | gtk_list_store_set (store, &iter, 0, NULL, 1, NULL, 2, _("(none)"), -1); |
acaf7113 AF |
276 | a_populate_sym_list(store); |
277 | ||
278 | r = gtk_cell_renderer_pixbuf_new (); | |
279 | gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (symbolentry), r, FALSE); | |
280 | gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (symbolentry), r, "pixbuf", 1, NULL); | |
281 | ||
ea3933fc EB |
282 | r = gtk_cell_renderer_text_new (); |
283 | gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (symbolentry), r, FALSE); | |
284 | gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (symbolentry), r, "text", 2, NULL); | |
285 | ||
acaf7113 AF |
286 | if ( dest == NULL && wp->symbol ) { |
287 | gboolean ok; | |
288 | gchar *sym; | |
289 | for (ok = gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &iter ); ok; ok = gtk_tree_model_iter_next ( GTK_TREE_MODEL(store), &iter)) { | |
290 | gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 ); | |
ea3933fc | 291 | if (sym && !strcmp(sym, wp->symbol)) { |
acaf7113 AF |
292 | g_free(sym); |
293 | break; | |
294 | } else { | |
295 | g_free(sym); | |
296 | } | |
297 | } | |
886031df | 298 | gtk_combo_box_set_active_iter(GTK_COMBO_BOX(symbolentry), &iter); |
acaf7113 AF |
299 | } |
300 | } | |
301 | ||
50a14534 EB |
302 | if ( dest == NULL && wp->comment ) |
303 | gtk_entry_set_text ( GTK_ENTRY(commententry), wp->comment ); | |
304 | ||
305 | if ( dest == NULL && wp->image ) | |
306 | vik_file_entry_set_filename ( VIK_FILE_ENTRY(imageentry), wp->image ); | |
307 | ||
50a14534 EB |
308 | |
309 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), latlabel, FALSE, FALSE, 0); | |
310 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), latentry, FALSE, FALSE, 0); | |
311 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), lonlabel, FALSE, FALSE, 0); | |
312 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), lonentry, FALSE, FALSE, 0); | |
313 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), altlabel, FALSE, FALSE, 0); | |
314 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), altentry, FALSE, FALSE, 0); | |
315 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), commentlabel, FALSE, FALSE, 0); | |
316 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), commententry, FALSE, FALSE, 0); | |
317 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), imagelabel, FALSE, FALSE, 0); | |
318 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), imageentry, FALSE, FALSE, 0); | |
acaf7113 AF |
319 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), symbollabel, FALSE, FALSE, 0); |
320 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), GTK_WIDGET(symbolentry), FALSE, FALSE, 0); | |
50a14534 EB |
321 | |
322 | gtk_widget_show_all ( GTK_DIALOG(dialog)->vbox ); | |
acaf7113 | 323 | |
50a14534 EB |
324 | while ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) |
325 | { | |
326 | if ( dest ) | |
327 | { | |
328 | const gchar *constname = gtk_entry_get_text ( GTK_ENTRY(nameentry) ); | |
329 | if ( strlen(constname) == 0 ) /* TODO: other checks (isalpha or whatever ) */ | |
7760b0cf | 330 | a_dialog_info_msg ( parent, _("Please enter a name for the waypoint.") ); |
50a14534 | 331 | else { |
50a14534 EB |
332 | gchar *name = g_strdup ( constname ); |
333 | ||
7760b0cf | 334 | if ( g_hash_table_lookup ( waypoints, name ) && !a_dialog_overwrite ( parent, _("The waypoint \"%s\" exists, do you want to overwrite it?"), name ) ) |
50a14534 EB |
335 | g_free ( name ); |
336 | else | |
337 | { | |
338 | /* Do It */ | |
339 | *dest = name; | |
dfad9456 GB |
340 | ll.lat = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(latentry) ) ); |
341 | ll.lon = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lonentry) ) ); | |
50a14534 | 342 | vik_coord_load_from_latlon ( &(wp->coord), coord_mode, &ll ); |
6027a9c5 RN |
343 | // Always store in metres |
344 | switch (height_units) { | |
345 | case VIK_UNITS_HEIGHT_METRES: | |
346 | wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) ); | |
6027a9c5 RN |
347 | break; |
348 | case VIK_UNITS_HEIGHT_FEET: | |
ab1e0693 | 349 | wp->altitude = VIK_FEET_TO_METERS(atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) )); |
6027a9c5 RN |
350 | break; |
351 | default: | |
352 | wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) ); | |
353 | g_critical("Houston, we've had a problem. height=%d", height_units); | |
354 | } | |
50a14534 EB |
355 | vik_waypoint_set_comment ( wp, gtk_entry_get_text ( GTK_ENTRY(commententry) ) ); |
356 | vik_waypoint_set_image ( wp, vik_file_entry_get_filename ( VIK_FILE_ENTRY(imageentry) ) ); | |
357 | if ( wp->image && *(wp->image) && (!a_thumbnails_exists(wp->image)) ) | |
358 | a_thumbnails_create ( wp->image ); | |
acaf7113 AF |
359 | |
360 | { | |
361 | GtkTreeIter iter, first; | |
362 | gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &first ); | |
886031df | 363 | if ( !gtk_combo_box_get_active_iter ( GTK_COMBO_BOX(symbolentry), &iter ) || !memcmp(&iter, &first, sizeof(GtkTreeIter)) ) { |
acaf7113 AF |
364 | vik_waypoint_set_symbol ( wp, NULL ); |
365 | } else { | |
366 | gchar *sym; | |
367 | gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 ); | |
368 | vik_waypoint_set_symbol ( wp, sym ); | |
369 | g_free(sym); | |
370 | } | |
371 | } | |
372 | ||
50a14534 EB |
373 | gtk_widget_destroy ( dialog ); |
374 | return TRUE; | |
375 | } | |
376 | } /* else (valid name) */ | |
377 | } | |
378 | else | |
379 | { | |
dfad9456 GB |
380 | ll.lat = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(latentry) ) ); |
381 | ll.lon = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lonentry) ) ); | |
50a14534 | 382 | vik_coord_load_from_latlon ( &(wp->coord), coord_mode, &ll ); |
6027a9c5 RN |
383 | switch (height_units) { |
384 | case VIK_UNITS_HEIGHT_METRES: | |
385 | wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) ); | |
6027a9c5 RN |
386 | break; |
387 | case VIK_UNITS_HEIGHT_FEET: | |
ab1e0693 | 388 | wp->altitude = VIK_FEET_TO_METERS(atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) )); |
6027a9c5 RN |
389 | break; |
390 | default: | |
391 | wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) ); | |
392 | g_critical("Houston, we've had a problem. height=%d", height_units); | |
393 | } | |
50a14534 EB |
394 | if ( (! wp->comment) || strcmp ( wp->comment, gtk_entry_get_text ( GTK_ENTRY(commententry) ) ) != 0 ) |
395 | vik_waypoint_set_comment ( wp, gtk_entry_get_text ( GTK_ENTRY(commententry) ) ); | |
396 | if ( (! wp->image) || strcmp ( wp->image, vik_file_entry_get_filename ( VIK_FILE_ENTRY ( imageentry ) ) ) != 0 ) | |
397 | { | |
398 | vik_waypoint_set_image ( wp, vik_file_entry_get_filename ( VIK_FILE_ENTRY(imageentry) ) ); | |
399 | if ( wp->image && *(wp->image) && (!a_thumbnails_exists(wp->image)) ) | |
400 | a_thumbnails_create ( wp->image ); | |
401 | } | |
402 | ||
acaf7113 AF |
403 | { |
404 | GtkTreeIter iter, first; | |
405 | gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &first ); | |
886031df | 406 | if ( !gtk_combo_box_get_active_iter ( GTK_COMBO_BOX(symbolentry), &iter ) || !memcmp(&iter, &first, sizeof(GtkTreeIter)) ) { |
acaf7113 AF |
407 | vik_waypoint_set_symbol ( wp, NULL ); |
408 | } else { | |
409 | gchar *sym; | |
410 | gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 ); | |
411 | vik_waypoint_set_symbol ( wp, sym ); | |
412 | g_free(sym); | |
413 | } | |
414 | } | |
415 | ||
50a14534 EB |
416 | gtk_widget_destroy ( dialog ); |
417 | ||
418 | return TRUE; | |
419 | } | |
420 | } | |
421 | gtk_widget_destroy ( dialog ); | |
422 | return FALSE; | |
423 | } | |
424 | ||
7767aa02 QT |
425 | static void get_selected_foreach_func(GtkTreeModel *model, |
426 | GtkTreePath *path, | |
427 | GtkTreeIter *iter, | |
428 | gpointer data) | |
429 | { | |
430 | GList **list = data; | |
431 | gchar *name; | |
432 | gtk_tree_model_get (model, iter, 0, &name, -1); | |
433 | *list = g_list_prepend(*list, name); | |
434 | } | |
435 | ||
436 | GList *a_dialog_select_from_list ( GtkWindow *parent, GHashTable *tracks, GList *track_names, gboolean multiple_selection_allowed, const gchar *title, const gchar *msg ) | |
291edcab HR |
437 | { |
438 | GtkTreeIter iter; | |
439 | GtkCellRenderer *renderer; | |
440 | GtkWidget *view; | |
441 | ||
7767aa02 | 442 | GtkWidget *dialog = gtk_dialog_new_with_buttons (title, |
291edcab HR |
443 | parent, |
444 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
445 | GTK_STOCK_CANCEL, | |
446 | GTK_RESPONSE_REJECT, | |
447 | GTK_STOCK_OK, | |
448 | GTK_RESPONSE_ACCEPT, | |
449 | NULL); | |
7767aa02 | 450 | GtkWidget *label = gtk_label_new ( msg ); |
291edcab HR |
451 | GtkListStore *store = gtk_list_store_new(1, G_TYPE_STRING); |
452 | ||
291edcab HR |
453 | GList *track_runner = track_names; |
454 | while (track_runner) | |
455 | { | |
15f45edc QT |
456 | gtk_list_store_append(store, &iter); |
457 | gtk_list_store_set(store, &iter, 0, track_runner->data, -1); | |
291edcab HR |
458 | track_runner = g_list_next(track_runner); |
459 | } | |
291edcab HR |
460 | |
461 | view = gtk_tree_view_new(); | |
462 | renderer = gtk_cell_renderer_text_new(); | |
463 | gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW(view), -1, NULL, renderer, "text", 0, NULL); | |
464 | gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store)); | |
465 | gtk_tree_view_set_headers_visible( GTK_TREE_VIEW(view), FALSE); | |
7767aa02 QT |
466 | gtk_tree_selection_set_mode( gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), |
467 | multiple_selection_allowed ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_BROWSE ); | |
291edcab HR |
468 | g_object_unref(store); |
469 | ||
470 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), label, FALSE, FALSE, 0); | |
471 | gtk_widget_show ( label ); | |
472 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), view, FALSE, FALSE, 0); | |
473 | gtk_widget_show ( view ); | |
474 | ||
475 | while ( gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT ) | |
476 | { | |
7767aa02 | 477 | GList *names = NULL; |
291edcab | 478 | GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); |
7767aa02 QT |
479 | gtk_tree_selection_selected_foreach(selection, get_selected_foreach_func, &names); |
480 | if (names) | |
291edcab | 481 | { |
291edcab | 482 | gtk_widget_destroy ( dialog ); |
7767aa02 | 483 | return (names); |
291edcab | 484 | } |
7767aa02 | 485 | a_dialog_error_msg(parent, _("Nothing was selected")); |
291edcab HR |
486 | } |
487 | gtk_widget_destroy ( dialog ); | |
488 | return NULL; | |
489 | } | |
490 | ||
e13ab673 | 491 | gchar *a_dialog_new_track ( GtkWindow *parent, GHashTable *tracks, gchar *default_name ) |
50a14534 | 492 | { |
7760b0cf | 493 | GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Add Track"), |
50a14534 EB |
494 | parent, |
495 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
496 | GTK_STOCK_CANCEL, | |
497 | GTK_RESPONSE_REJECT, | |
498 | GTK_STOCK_OK, | |
499 | GTK_RESPONSE_ACCEPT, | |
500 | NULL); | |
7760b0cf | 501 | GtkWidget *label = gtk_label_new ( _("Track Name:") ); |
50a14534 EB |
502 | GtkWidget *entry = gtk_entry_new (); |
503 | ||
e13ab673 RN |
504 | if (default_name) |
505 | gtk_entry_set_text ( GTK_ENTRY(entry), default_name ); | |
506 | ||
50a14534 EB |
507 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), label, FALSE, FALSE, 0); |
508 | gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry, FALSE, FALSE, 0); | |
509 | ||
510 | g_signal_connect_swapped ( entry, "activate", G_CALLBACK(a_dialog_response_accept), GTK_DIALOG(dialog) ); | |
511 | ||
512 | gtk_widget_show ( label ); | |
513 | gtk_widget_show ( entry ); | |
514 | ||
515 | while ( gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT ) | |
516 | { | |
517 | const gchar *constname = gtk_entry_get_text ( GTK_ENTRY(entry) ); | |
518 | if ( *constname == '\0' ) | |
7760b0cf | 519 | a_dialog_info_msg ( parent, _("Please enter a name for the track.") ); |
50a14534 EB |
520 | else { |
521 | gchar *name = g_strdup ( constname ); | |
50a14534 | 522 | |
7760b0cf | 523 | if ( g_hash_table_lookup( tracks, name ) && !a_dialog_overwrite ( parent, _("The track \"%s\" exists, do you want to overwrite it?"), gtk_entry_get_text ( GTK_ENTRY(entry) ) ) ) |
50a14534 EB |
524 | { |
525 | g_free ( name ); | |
526 | } | |
527 | else | |
528 | { | |
529 | gtk_widget_destroy ( dialog ); | |
530 | return name; | |
531 | } | |
532 | } | |
533 | } | |
534 | gtk_widget_destroy ( dialog ); | |
535 | return NULL; | |
536 | } | |
537 | ||
538 | /* creates a vbox full of labels */ | |
539 | GtkWidget *a_dialog_create_label_vbox ( gchar **texts, int label_count ) | |
540 | { | |
541 | GtkWidget *vbox, *label; | |
542 | int i; | |
543 | vbox = gtk_vbox_new( TRUE, 3 ); | |
544 | ||
545 | for ( i = 0; i < label_count; i++ ) | |
546 | { | |
547 | label = gtk_label_new(NULL); | |
4c77d5e0 | 548 | gtk_label_set_markup ( GTK_LABEL(label), _(texts[i]) ); |
50a14534 EB |
549 | gtk_box_pack_start ( GTK_BOX(vbox), label, FALSE, TRUE, 5 ); |
550 | } | |
551 | return vbox; | |
552 | } | |
553 | ||
554 | gboolean a_dialog_overwrite ( GtkWindow *parent, const gchar *message, const gchar *extra ) | |
555 | { | |
556 | GtkWidget *dia; | |
557 | dia = gtk_message_dialog_new ( parent, | |
558 | GTK_DIALOG_DESTROY_WITH_PARENT, | |
559 | GTK_MESSAGE_QUESTION, | |
560 | GTK_BUTTONS_YES_NO, | |
561 | message, extra ); | |
562 | ||
563 | if ( gtk_dialog_run ( GTK_DIALOG(dia) ) == GTK_RESPONSE_YES ) | |
564 | { | |
565 | gtk_widget_destroy ( dia ); | |
566 | return TRUE; | |
567 | } | |
568 | else | |
569 | { | |
570 | gtk_widget_destroy ( dia ); | |
571 | return FALSE; | |
572 | } | |
573 | } | |
574 | ||
575 | static void zoom_spin_changed ( GtkSpinButton *spin, GtkWidget *pass_along[3] ) | |
576 | { | |
577 | if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(pass_along[2]) ) ) | |
578 | gtk_spin_button_set_value ( | |
579 | GTK_SPIN_BUTTON(pass_along[GTK_WIDGET(spin) == pass_along[0] ? 1 : 0]), | |
580 | gtk_spin_button_get_value ( spin ) ); | |
581 | } | |
582 | ||
583 | gboolean a_dialog_custom_zoom ( GtkWindow *parent, gdouble *xmpp, gdouble *ympp ) | |
584 | { | |
7760b0cf | 585 | GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Zoom Factors..."), |
50a14534 EB |
586 | parent, |
587 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
588 | GTK_STOCK_CANCEL, | |
589 | GTK_RESPONSE_REJECT, | |
590 | GTK_STOCK_OK, | |
591 | GTK_RESPONSE_ACCEPT, | |
592 | NULL); | |
593 | GtkWidget *table, *label, *xlabel, *xspin, *ylabel, *yspin, *samecheck; | |
594 | GtkWidget *pass_along[3]; | |
595 | ||
596 | table = gtk_table_new ( 4, 2, FALSE ); | |
597 | gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 0 ); | |
598 | ||
da0a736b | 599 | label = gtk_label_new ( _("Zoom factor (in meters per pixel):") ); |
7760b0cf JJ |
600 | xlabel = gtk_label_new ( _("X (easting): ")); |
601 | ylabel = gtk_label_new ( _("Y (northing): ")); | |
50a14534 | 602 | |
ac33062d RN |
603 | pass_along[0] = xspin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( *xmpp, VIK_VIEWPORT_MIN_ZOOM, VIK_VIEWPORT_MAX_ZOOM, 1, 5, 0 ), 1, 8 ); |
604 | pass_along[1] = yspin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( *ympp, VIK_VIEWPORT_MIN_ZOOM, VIK_VIEWPORT_MAX_ZOOM, 1, 5, 0 ), 1, 8 ); | |
50a14534 | 605 | |
7760b0cf | 606 | pass_along[2] = samecheck = gtk_check_button_new_with_label ( _("X and Y zoom factors must be equal") ); |
50a14534 EB |
607 | /* TODO -- same factor */ |
608 | /* samecheck = gtk_check_button_new_with_label ( "Same x/y zoom factor" ); */ | |
609 | ||
610 | if ( *xmpp == *ympp ) | |
611 | gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(samecheck), TRUE ); | |
612 | ||
613 | gtk_table_attach_defaults ( GTK_TABLE(table), label, 0, 2, 0, 1 ); | |
614 | gtk_table_attach_defaults ( GTK_TABLE(table), xlabel, 0, 1, 1, 2 ); | |
615 | gtk_table_attach_defaults ( GTK_TABLE(table), xspin, 1, 2, 1, 2 ); | |
616 | gtk_table_attach_defaults ( GTK_TABLE(table), ylabel, 0, 1, 2, 3 ); | |
617 | gtk_table_attach_defaults ( GTK_TABLE(table), yspin, 1, 2, 2, 3 ); | |
618 | gtk_table_attach_defaults ( GTK_TABLE(table), samecheck, 0, 2, 3, 4 ); | |
619 | ||
620 | gtk_widget_show_all ( table ); | |
621 | ||
622 | g_signal_connect ( G_OBJECT(xspin), "value-changed", G_CALLBACK(zoom_spin_changed), pass_along ); | |
623 | g_signal_connect ( G_OBJECT(yspin), "value-changed", G_CALLBACK(zoom_spin_changed), pass_along ); | |
624 | ||
625 | if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) | |
626 | { | |
627 | *xmpp = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(xspin) ); | |
628 | *ympp = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(yspin) ); | |
629 | gtk_widget_destroy ( dialog ); | |
630 | return TRUE; | |
631 | } | |
632 | gtk_widget_destroy ( dialog ); | |
633 | return FALSE; | |
634 | } | |
111fa174 AF |
635 | |
636 | static void split_spin_focused ( GtkSpinButton *spin, GtkWidget *pass_along[1] ) | |
637 | { | |
638 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(pass_along[0]), 1); | |
639 | } | |
640 | ||
641 | gboolean a_dialog_time_threshold ( GtkWindow *parent, gchar *title_text, gchar *label_text, guint *thr ) | |
642 | { | |
643 | GtkWidget *dialog = gtk_dialog_new_with_buttons (title_text, | |
644 | parent, | |
645 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
646 | GTK_STOCK_CANCEL, | |
647 | GTK_RESPONSE_REJECT, | |
648 | GTK_STOCK_OK, | |
649 | GTK_RESPONSE_ACCEPT, | |
650 | NULL); | |
651 | GtkWidget *table, *t1, *t2, *t3, *t4, *spin, *label; | |
652 | GtkWidget *pass_along[1]; | |
653 | ||
654 | table = gtk_table_new ( 4, 2, FALSE ); | |
655 | gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 0 ); | |
656 | ||
657 | label = gtk_label_new (label_text); | |
658 | ||
7760b0cf JJ |
659 | t1 = gtk_radio_button_new_with_label ( NULL, _("1 min") ); |
660 | t2 = gtk_radio_button_new_with_label_from_widget ( GTK_RADIO_BUTTON(t1), _("1 hour") ); | |
661 | t3 = gtk_radio_button_new_with_label_from_widget ( GTK_RADIO_BUTTON(t2), _("1 day") ); | |
662 | t4 = gtk_radio_button_new_with_label_from_widget ( GTK_RADIO_BUTTON(t3), _("Custom (in minutes):") ); | |
111fa174 AF |
663 | |
664 | pass_along[0] = t4; | |
665 | ||
ac33062d | 666 | spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( *thr, 0, 65536, 1, 5, 0 ), 1, 0 ); |
111fa174 AF |
667 | |
668 | gtk_table_attach_defaults ( GTK_TABLE(table), label, 0, 2, 0, 1 ); | |
669 | gtk_table_attach_defaults ( GTK_TABLE(table), t1, 0, 1, 1, 2 ); | |
670 | gtk_table_attach_defaults ( GTK_TABLE(table), t2, 0, 1, 2, 3 ); | |
671 | gtk_table_attach_defaults ( GTK_TABLE(table), t3, 0, 1, 3, 4 ); | |
672 | gtk_table_attach_defaults ( GTK_TABLE(table), t4, 0, 1, 4, 5 ); | |
673 | gtk_table_attach_defaults ( GTK_TABLE(table), spin, 1, 2, 4, 5 ); | |
674 | ||
675 | gtk_widget_show_all ( table ); | |
676 | ||
677 | g_signal_connect ( G_OBJECT(spin), "grab-focus", G_CALLBACK(split_spin_focused), pass_along ); | |
678 | ||
679 | if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) | |
680 | { | |
681 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t1))) { | |
682 | *thr = 1; | |
683 | } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t2))) { | |
684 | *thr = 60; | |
685 | } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t3))) { | |
686 | *thr = 60 * 24; | |
687 | } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t4))) { | |
688 | *thr = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(spin) ); | |
689 | } | |
690 | gtk_widget_destroy ( dialog ); | |
691 | return TRUE; | |
692 | } | |
693 | gtk_widget_destroy ( dialog ); | |
694 | return FALSE; | |
695 | } | |
d0a5f320 | 696 | |
3530c91e GB |
697 | static void about_url_hook (GtkAboutDialog *about, |
698 | const gchar *link, | |
699 | gpointer data) | |
85beadba | 700 | { |
3530c91e GB |
701 | open_url (GTK_WINDOW(about), link); |
702 | } | |
703 | ||
704 | static void about_email_hook (GtkAboutDialog *about, | |
705 | const gchar *email, | |
706 | gpointer data) | |
707 | { | |
708 | new_email (GTK_WINDOW(about), email); | |
85beadba | 709 | } |
d0a5f320 AF |
710 | |
711 | void a_dialog_about ( GtkWindow *parent ) | |
712 | { | |
85beadba GB |
713 | const gchar *program_name = PACKAGE_NAME; |
714 | const gchar *version = VIKING_VERSION; | |
715 | const gchar *website = VIKING_URL; | |
8192ebe3 | 716 | const gchar *copyright = "2003-2008, Evan Battaglia\n2008-2010, Viking's contributors"; |
85beadba GB |
717 | const gchar *comments = _("GPS Data and Topo Analyzer, Explorer, and Manager."); |
718 | const gchar *license = _("This program is free software; you can redistribute it and/or modify " | |
d0a5f320 AF |
719 | "it under the terms of the GNU General Public License as published by " |
720 | "the Free Software Foundation; either version 2 of the License, or " | |
721 | "(at your option) any later version." | |
722 | "\n\n" | |
723 | "This program is distributed in the hope that it will be useful, " | |
724 | "but WITHOUT ANY WARRANTY; without even the implied warranty of " | |
725 | "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " | |
726 | "GNU General Public License for more details." | |
727 | "\n\n" | |
728 | "You should have received a copy of the GNU General Public License " | |
729 | "along with this program; if not, write to the Free Software " | |
85beadba GB |
730 | "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA"); |
731 | ||
3530c91e GB |
732 | gtk_about_dialog_set_url_hook (about_url_hook, NULL, NULL); |
733 | gtk_about_dialog_set_email_hook (about_email_hook, NULL, NULL); | |
85beadba GB |
734 | gtk_show_about_dialog (parent, |
735 | /* TODO do not set program-name and correctly set info for g_get_application_name */ | |
736 | "program-name", program_name, | |
737 | "version", version, | |
738 | "website", website, | |
739 | "comments", comments, | |
740 | "copyright", copyright, | |
741 | "license", license, | |
742 | "wrap-license", TRUE, | |
743 | /* logo automatically retrieved via gtk_window_get_default_icon_list */ | |
744 | "authors", AUTHORS, | |
eb6a42c9 | 745 | "documenters", DOCUMENTERS, |
551e7a38 | 746 | "translator-credits", _("Translation is coordinated on http://launchpad.net/viking"), |
85beadba | 747 | NULL); |
d0a5f320 | 748 | } |
7114e879 QT |
749 | |
750 | gboolean a_dialog_map_n_zoom(GtkWindow *parent, gchar *mapnames[], gint default_map, gchar *zoom_list[], gint default_zoom, gint *selected_map, gint *selected_zoom) | |
751 | { | |
752 | gchar **s; | |
753 | ||
7760b0cf | 754 | GtkWidget *dialog = gtk_dialog_new_with_buttons ( _("Download along track"), parent, 0, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL ); |
7114e879 | 755 | |
7760b0cf | 756 | GtkWidget *map_label = gtk_label_new(_("Map type:")); |
8ece78c0 | 757 | GtkComboBox *map_combo = GTK_COMBO_BOX(gtk_combo_box_new_text()); |
7114e879 QT |
758 | for (s = mapnames; *s; s++) |
759 | gtk_combo_box_append_text(map_combo, *s); | |
760 | gtk_combo_box_set_active (map_combo, default_map); | |
7760b0cf | 761 | GtkWidget *zoom_label = gtk_label_new(_("Zoom level:")); |
8ece78c0 | 762 | GtkComboBox *zoom_combo = GTK_COMBO_BOX(gtk_combo_box_new_text()); |
7114e879 QT |
763 | for (s = zoom_list; *s; s++) |
764 | gtk_combo_box_append_text(zoom_combo, *s); | |
765 | gtk_combo_box_set_active (zoom_combo, default_zoom); | |
766 | ||
767 | GtkTable *box = GTK_TABLE(gtk_table_new(2, 2, FALSE)); | |
768 | gtk_table_attach_defaults(box, GTK_WIDGET(map_label), 0, 1, 0, 1); | |
769 | gtk_table_attach_defaults(box, GTK_WIDGET(map_combo), 1, 2, 0, 1); | |
770 | gtk_table_attach_defaults(box, GTK_WIDGET(zoom_label), 0, 1, 1, 2); | |
771 | gtk_table_attach_defaults(box, GTK_WIDGET(zoom_combo), 1, 2, 1, 2); | |
772 | ||
773 | gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), GTK_WIDGET(box), FALSE, FALSE, 5 ); | |
774 | ||
775 | gtk_widget_show_all ( dialog ); | |
776 | if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) != GTK_RESPONSE_ACCEPT ) { | |
777 | gtk_widget_destroy(dialog); | |
778 | return FALSE; | |
779 | } | |
780 | ||
781 | *selected_map = gtk_combo_box_get_active(map_combo); | |
782 | *selected_zoom = gtk_combo_box_get_active(zoom_combo); | |
783 | ||
784 | gtk_widget_destroy(dialog); | |
785 | return TRUE; | |
786 | } |