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