2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
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.
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.
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
27 #include "thumbnails.h"
28 #include "garminsymbols.h"
29 #include "degrees_converters.h"
31 #include "googlesearch.h"
33 #include <glib/gi18n.h>
39 void a_dialog_msg ( GtkWindow *parent, gint type, const gchar *info, const gchar *extra )
41 GtkWidget *msgbox = gtk_message_dialog_new ( parent, GTK_DIALOG_DESTROY_WITH_PARENT, type, GTK_BUTTONS_OK, info, extra );
42 gtk_dialog_run ( GTK_DIALOG(msgbox) );
43 gtk_widget_destroy ( msgbox );
46 gboolean a_dialog_goto_latlon ( GtkWindow *parent, struct LatLon *ll, const struct LatLon *old )
48 GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Go to Lat/Lon"),
50 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
56 GtkWidget *latlabel, *lonlabel;
58 gchar *tmp_lat, *tmp_lon;
60 latlabel = gtk_label_new (_("Latitude:"));
61 lat = gtk_entry_new ();
62 tmp_lat = g_strdup_printf ( "%f", old->lat );
63 gtk_entry_set_text ( GTK_ENTRY(lat), tmp_lat );
66 lonlabel = gtk_label_new (_("Longitude:"));
67 lon = gtk_entry_new ();
68 tmp_lon = g_strdup_printf ( "%f", old->lon );
69 gtk_entry_set_text ( GTK_ENTRY(lon), tmp_lon );
72 gtk_widget_show ( latlabel );
73 gtk_widget_show ( lonlabel );
74 gtk_widget_show ( lat );
75 gtk_widget_show ( lon );
77 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), latlabel, FALSE, FALSE, 0);
78 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), lat, FALSE, FALSE, 0);
79 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), lonlabel, FALSE, FALSE, 0);
80 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), lon, FALSE, FALSE, 0);
82 if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
84 ll->lat = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lat) ) );
85 ll->lon = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lon) ) );
86 gtk_widget_destroy ( dialog );
90 gtk_widget_destroy ( dialog );
94 gboolean a_dialog_goto_utm ( GtkWindow *parent, struct UTM *utm, const struct UTM *old )
96 GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Go to Lat/Lon"),
98 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
104 GtkWidget *norlabel, *easlabel, *nor, *eas;
105 GtkWidget *zonehbox, *zonespin, *letterentry;
106 gchar *tmp_eas, *tmp_nor;
109 norlabel = gtk_label_new (_("Northing:"));
110 nor = gtk_entry_new ();
111 tmp_nor = g_strdup_printf("%ld", (long) old->northing );
112 gtk_entry_set_text ( GTK_ENTRY(nor), tmp_nor );
115 easlabel = gtk_label_new (_("Easting:"));
116 eas = gtk_entry_new ();
117 tmp_eas = g_strdup_printf("%ld", (long) old->easting );
118 gtk_entry_set_text ( GTK_ENTRY(eas), tmp_eas );
121 zonehbox = gtk_hbox_new ( FALSE, 0 );
122 gtk_box_pack_start ( GTK_BOX(zonehbox), gtk_label_new ( _("Zone:") ), FALSE, FALSE, 5 );
123 zonespin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( old->zone, 1, 60, 1, 5, 5 ), 1, 0 );
124 gtk_box_pack_start ( GTK_BOX(zonehbox), zonespin, TRUE, TRUE, 5 );
125 gtk_box_pack_start ( GTK_BOX(zonehbox), gtk_label_new ( _("Letter:") ), FALSE, FALSE, 5 );
126 letterentry = gtk_entry_new ();
127 gtk_entry_set_max_length ( GTK_ENTRY(letterentry), 1 );
128 gtk_entry_set_width_chars ( GTK_ENTRY(letterentry), 2 );
129 tmp_letter[0] = old->letter;
130 tmp_letter[1] = '\0';
131 gtk_entry_set_text ( GTK_ENTRY(letterentry), tmp_letter );
132 gtk_box_pack_start ( GTK_BOX(zonehbox), letterentry, FALSE, FALSE, 5 );
134 gtk_widget_show ( norlabel );
135 gtk_widget_show ( easlabel );
136 gtk_widget_show ( nor );
137 gtk_widget_show ( eas );
139 gtk_widget_show_all ( zonehbox );
141 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), norlabel, FALSE, FALSE, 0);
142 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), nor, FALSE, FALSE, 0);
143 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), easlabel, FALSE, FALSE, 0);
144 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), eas, FALSE, FALSE, 0);
145 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), zonehbox, FALSE, FALSE, 0);
147 if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
150 utm->northing = atof ( gtk_entry_get_text ( GTK_ENTRY(nor) ) );
151 utm->easting = atof ( gtk_entry_get_text ( GTK_ENTRY(eas) ) );
152 utm->zone = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(zonespin) );
153 letter = gtk_entry_get_text ( GTK_ENTRY(letterentry) );
155 utm->letter = toupper(*letter);
156 gtk_widget_destroy ( dialog );
160 gtk_widget_destroy ( dialog );
164 void a_dialog_response_accept ( GtkDialog *dialog )
166 gtk_dialog_response ( dialog, GTK_RESPONSE_ACCEPT );
169 /* todo: less on this side, like add track */
170 gboolean a_dialog_new_waypoint ( GtkWindow *parent, gchar **dest, VikWaypoint *wp, GHashTable *waypoints, VikCoordMode coord_mode )
172 GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Create"),
174 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
181 GtkWidget *latlabel, *lonlabel, *namelabel, *latentry, *lonentry, *altentry, *altlabel, *nameentry=NULL, *commentlabel,
182 *commententry, *imagelabel, *imageentry, *symbollabel, *symbolentry;
188 gchar *lat, *lon, *alt;
190 vik_coord_to_latlon ( &(wp->coord), &ll );
192 lat = g_strdup_printf ( "%f", ll.lat );
193 lon = g_strdup_printf ( "%f", ll.lon );
194 alt = g_strdup_printf ( "%f", wp->altitude );
198 namelabel = gtk_label_new (_("Name:"));
199 nameentry = gtk_entry_new ();
200 g_signal_connect_swapped ( nameentry, "activate", G_CALLBACK(a_dialog_response_accept), GTK_DIALOG(dialog) );
201 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), namelabel, FALSE, FALSE, 0);
202 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), nameentry, FALSE, FALSE, 0);
205 latlabel = gtk_label_new (_("Latitude:"));
206 latentry = gtk_entry_new ();
207 gtk_entry_set_text ( GTK_ENTRY(latentry), lat );
210 lonlabel = gtk_label_new (_("Longitude:"));
211 lonentry = gtk_entry_new ();
212 gtk_entry_set_text ( GTK_ENTRY(lonentry), lon );
215 altlabel = gtk_label_new (_("Altitude:"));
216 altentry = gtk_entry_new ();
217 gtk_entry_set_text ( GTK_ENTRY(altentry), alt );
220 commentlabel = gtk_label_new (_("Comment:"));
221 commententry = gtk_entry_new ();
222 gchar *cmt = a_googlesearch_get_search_string_for_this_place(VIK_WINDOW(parent));
224 gtk_entry_set_text(GTK_ENTRY(commententry), cmt);
226 imagelabel = gtk_label_new (_("Image:"));
227 imageentry = vik_file_entry_new ();
231 symbollabel = gtk_label_new (_("Symbol:"));
234 store = gtk_list_store_new(3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING);
235 symbolentry = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
236 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(symbolentry), 3);
237 gtk_list_store_append (store, &iter);
238 gtk_list_store_set (store, &iter, 0, NULL, 1, NULL, 2, _("(none)"), -1);
239 a_populate_sym_list(store);
241 r = gtk_cell_renderer_pixbuf_new ();
242 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (symbolentry), r, FALSE);
243 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (symbolentry), r, "pixbuf", 1, NULL);
245 r = gtk_cell_renderer_text_new ();
246 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (symbolentry), r, FALSE);
247 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (symbolentry), r, "text", 2, NULL);
249 if ( dest == NULL && wp->symbol ) {
252 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)) {
253 gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 );
254 if (sym && !strcmp(sym, wp->symbol)) {
261 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(symbolentry), &iter);
265 if ( dest == NULL && wp->comment )
266 gtk_entry_set_text ( GTK_ENTRY(commententry), wp->comment );
268 if ( dest == NULL && wp->image )
269 vik_file_entry_set_filename ( VIK_FILE_ENTRY(imageentry), wp->image );
272 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), latlabel, FALSE, FALSE, 0);
273 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), latentry, FALSE, FALSE, 0);
274 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), lonlabel, FALSE, FALSE, 0);
275 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), lonentry, FALSE, FALSE, 0);
276 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), altlabel, FALSE, FALSE, 0);
277 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), altentry, FALSE, FALSE, 0);
278 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), commentlabel, FALSE, FALSE, 0);
279 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), commententry, FALSE, FALSE, 0);
280 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), imagelabel, FALSE, FALSE, 0);
281 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), imageentry, FALSE, FALSE, 0);
282 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), symbollabel, FALSE, FALSE, 0);
283 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), GTK_WIDGET(symbolentry), FALSE, FALSE, 0);
285 gtk_widget_show_all ( GTK_DIALOG(dialog)->vbox );
287 while ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
291 const gchar *constname = gtk_entry_get_text ( GTK_ENTRY(nameentry) );
292 if ( strlen(constname) == 0 ) /* TODO: other checks (isalpha or whatever ) */
293 a_dialog_info_msg ( parent, _("Please enter a name for the waypoint.") );
296 gchar *name = g_strdup ( constname );
298 for ( i = strlen ( name ) - 1; i >= 0; i-- )
299 name[i] = toupper(name[i]); /* all caps for stardandization */
301 if ( g_hash_table_lookup ( waypoints, name ) && !a_dialog_overwrite ( parent, _("The waypoint \"%s\" exists, do you want to overwrite it?"), name ) )
307 ll.lat = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(latentry) ) );
308 ll.lon = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lonentry) ) );
309 vik_coord_load_from_latlon ( &(wp->coord), coord_mode, &ll );
310 wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) );
311 vik_waypoint_set_comment ( wp, gtk_entry_get_text ( GTK_ENTRY(commententry) ) );
312 vik_waypoint_set_image ( wp, vik_file_entry_get_filename ( VIK_FILE_ENTRY(imageentry) ) );
313 if ( wp->image && *(wp->image) && (!a_thumbnails_exists(wp->image)) )
314 a_thumbnails_create ( wp->image );
317 GtkTreeIter iter, first;
318 gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &first );
319 if ( !gtk_combo_box_get_active_iter ( GTK_COMBO_BOX(symbolentry), &iter ) || !memcmp(&iter, &first, sizeof(GtkTreeIter)) ) {
320 vik_waypoint_set_symbol ( wp, NULL );
323 gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 );
324 vik_waypoint_set_symbol ( wp, sym );
329 gtk_widget_destroy ( dialog );
332 } /* else (valid name) */
336 ll.lat = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(latentry) ) );
337 ll.lon = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lonentry) ) );
338 vik_coord_load_from_latlon ( &(wp->coord), coord_mode, &ll );
339 wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) );
340 if ( (! wp->comment) || strcmp ( wp->comment, gtk_entry_get_text ( GTK_ENTRY(commententry) ) ) != 0 )
341 vik_waypoint_set_comment ( wp, gtk_entry_get_text ( GTK_ENTRY(commententry) ) );
342 if ( (! wp->image) || strcmp ( wp->image, vik_file_entry_get_filename ( VIK_FILE_ENTRY ( imageentry ) ) ) != 0 )
344 vik_waypoint_set_image ( wp, vik_file_entry_get_filename ( VIK_FILE_ENTRY(imageentry) ) );
345 if ( wp->image && *(wp->image) && (!a_thumbnails_exists(wp->image)) )
346 a_thumbnails_create ( wp->image );
350 GtkTreeIter iter, first;
351 gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &first );
352 if ( !gtk_combo_box_get_active_iter ( GTK_COMBO_BOX(symbolentry), &iter ) || !memcmp(&iter, &first, sizeof(GtkTreeIter)) ) {
353 vik_waypoint_set_symbol ( wp, NULL );
356 gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 );
357 vik_waypoint_set_symbol ( wp, sym );
362 gtk_widget_destroy ( dialog );
367 gtk_widget_destroy ( dialog );
371 gchar *a_dialog_new_track ( GtkWindow *parent, GHashTable *tracks )
373 GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Add Track"),
375 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
381 GtkWidget *label = gtk_label_new ( _("Track Name:") );
382 GtkWidget *entry = gtk_entry_new ();
384 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), label, FALSE, FALSE, 0);
385 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry, FALSE, FALSE, 0);
387 g_signal_connect_swapped ( entry, "activate", G_CALLBACK(a_dialog_response_accept), GTK_DIALOG(dialog) );
389 gtk_widget_show ( label );
390 gtk_widget_show ( entry );
392 while ( gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT )
394 const gchar *constname = gtk_entry_get_text ( GTK_ENTRY(entry) );
395 if ( *constname == '\0' )
396 a_dialog_info_msg ( parent, _("Please enter a name for the track.") );
398 gchar *name = g_strdup ( constname );
401 for ( i = strlen ( name ) - 1; i >= 0; i-- )
402 name[i] = toupper(name[i]); /* all caps for stardandization */
404 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) ) ) )
410 gtk_widget_destroy ( dialog );
415 gtk_widget_destroy ( dialog );
419 /* creates a vbox full of labels */
420 GtkWidget *a_dialog_create_label_vbox ( gchar **texts, int label_count )
422 GtkWidget *vbox, *label;
424 vbox = gtk_vbox_new( TRUE, 3 );
426 for ( i = 0; i < label_count; i++ )
428 label = gtk_label_new(NULL);
429 gtk_label_set_markup ( GTK_LABEL(label), _(texts[i]) );
430 gtk_box_pack_start ( GTK_BOX(vbox), label, FALSE, TRUE, 5 );
435 gboolean a_dialog_overwrite ( GtkWindow *parent, const gchar *message, const gchar *extra )
438 dia = gtk_message_dialog_new ( parent,
439 GTK_DIALOG_DESTROY_WITH_PARENT,
440 GTK_MESSAGE_QUESTION,
444 if ( gtk_dialog_run ( GTK_DIALOG(dia) ) == GTK_RESPONSE_YES )
446 gtk_widget_destroy ( dia );
451 gtk_widget_destroy ( dia );
456 static void zoom_spin_changed ( GtkSpinButton *spin, GtkWidget *pass_along[3] )
458 if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(pass_along[2]) ) )
459 gtk_spin_button_set_value (
460 GTK_SPIN_BUTTON(pass_along[GTK_WIDGET(spin) == pass_along[0] ? 1 : 0]),
461 gtk_spin_button_get_value ( spin ) );
464 gboolean a_dialog_custom_zoom ( GtkWindow *parent, gdouble *xmpp, gdouble *ympp )
466 GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Zoom Factors..."),
468 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
474 GtkWidget *table, *label, *xlabel, *xspin, *ylabel, *yspin, *samecheck;
475 GtkWidget *pass_along[3];
477 table = gtk_table_new ( 4, 2, FALSE );
478 gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 0 );
480 label = gtk_label_new ( _("Zoom factor (in meters per pixel:") );
481 xlabel = gtk_label_new ( _("X (easting): "));
482 ylabel = gtk_label_new ( _("Y (northing): "));
484 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 );
485 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 );
487 pass_along[2] = samecheck = gtk_check_button_new_with_label ( _("X and Y zoom factors must be equal") );
488 /* TODO -- same factor */
489 /* samecheck = gtk_check_button_new_with_label ( "Same x/y zoom factor" ); */
491 if ( *xmpp == *ympp )
492 gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(samecheck), TRUE );
494 gtk_table_attach_defaults ( GTK_TABLE(table), label, 0, 2, 0, 1 );
495 gtk_table_attach_defaults ( GTK_TABLE(table), xlabel, 0, 1, 1, 2 );
496 gtk_table_attach_defaults ( GTK_TABLE(table), xspin, 1, 2, 1, 2 );
497 gtk_table_attach_defaults ( GTK_TABLE(table), ylabel, 0, 1, 2, 3 );
498 gtk_table_attach_defaults ( GTK_TABLE(table), yspin, 1, 2, 2, 3 );
499 gtk_table_attach_defaults ( GTK_TABLE(table), samecheck, 0, 2, 3, 4 );
501 gtk_widget_show_all ( table );
503 g_signal_connect ( G_OBJECT(xspin), "value-changed", G_CALLBACK(zoom_spin_changed), pass_along );
504 g_signal_connect ( G_OBJECT(yspin), "value-changed", G_CALLBACK(zoom_spin_changed), pass_along );
506 if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
508 *xmpp = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(xspin) );
509 *ympp = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(yspin) );
510 gtk_widget_destroy ( dialog );
513 gtk_widget_destroy ( dialog );
517 static void split_spin_focused ( GtkSpinButton *spin, GtkWidget *pass_along[1] )
519 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(pass_along[0]), 1);
522 gboolean a_dialog_time_threshold ( GtkWindow *parent, gchar *title_text, gchar *label_text, guint *thr )
524 GtkWidget *dialog = gtk_dialog_new_with_buttons (title_text,
526 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
532 GtkWidget *table, *t1, *t2, *t3, *t4, *spin, *label;
533 GtkWidget *pass_along[1];
535 table = gtk_table_new ( 4, 2, FALSE );
536 gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 0 );
538 label = gtk_label_new (label_text);
540 t1 = gtk_radio_button_new_with_label ( NULL, _("1 min") );
541 t2 = gtk_radio_button_new_with_label_from_widget ( GTK_RADIO_BUTTON(t1), _("1 hour") );
542 t3 = gtk_radio_button_new_with_label_from_widget ( GTK_RADIO_BUTTON(t2), _("1 day") );
543 t4 = gtk_radio_button_new_with_label_from_widget ( GTK_RADIO_BUTTON(t3), _("Custom (in minutes):") );
547 spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( *thr, 0, 65536, 1, 5, 5 ), 1, 0 );
549 gtk_table_attach_defaults ( GTK_TABLE(table), label, 0, 2, 0, 1 );
550 gtk_table_attach_defaults ( GTK_TABLE(table), t1, 0, 1, 1, 2 );
551 gtk_table_attach_defaults ( GTK_TABLE(table), t2, 0, 1, 2, 3 );
552 gtk_table_attach_defaults ( GTK_TABLE(table), t3, 0, 1, 3, 4 );
553 gtk_table_attach_defaults ( GTK_TABLE(table), t4, 0, 1, 4, 5 );
554 gtk_table_attach_defaults ( GTK_TABLE(table), spin, 1, 2, 4, 5 );
556 gtk_widget_show_all ( table );
558 g_signal_connect ( G_OBJECT(spin), "grab-focus", G_CALLBACK(split_spin_focused), pass_along );
560 if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
562 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t1))) {
564 } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t2))) {
566 } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t3))) {
568 } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t4))) {
569 *thr = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(spin) );
571 gtk_widget_destroy ( dialog );
574 gtk_widget_destroy ( dialog );
579 void a_dialog_about ( GtkWindow *parent )
582 char *msg = g_markup_printf_escaped (
583 _(_("<span font_desc='20' weight='bold'>Viking %s</span>\n\n"
584 "GPS Data and Topo Analyzer, Explorer, and Manager.\n\n"
585 "<small>(C) 2003-2007, Evan Battaglia</small>\n\n"
586 "<small>Web site: %s</small>")),
587 VIKING_VERSION, VIKING_URL);
588 GtkWidget *msgbox = gtk_message_dialog_new_with_markup ( parent,
589 GTK_DIALOG_DESTROY_WITH_PARENT,
594 gtk_dialog_add_buttons (GTK_DIALOG(msgbox), _("Credits"), 1, _("License"), 2, _("Close"), 3, NULL, NULL);
596 while ((re = gtk_dialog_run ( GTK_DIALOG(msgbox))) != 3) {
599 a_dialog_info_msg(parent, AUTHORS);
602 a_dialog_info_msg(parent, _("\n\n"
603 "This program is free software; you can redistribute it and/or modify "
604 "it under the terms of the GNU General Public License as published by "
605 "the Free Software Foundation; either version 2 of the License, or "
606 "(at your option) any later version."
608 "This program is distributed in the hope that it will be useful, "
609 "but WITHOUT ANY WARRANTY; without even the implied warranty of "
610 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
611 "GNU General Public License for more details."
613 "You should have received a copy of the GNU General Public License "
614 "along with this program; if not, write to the Free Software "
615 "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA"));
618 gtk_widget_destroy ( msgbox );
621 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)
625 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 );
627 GtkWidget *map_label = gtk_label_new(_("Map type:"));
628 GtkComboBox *map_combo = GTK_COMBO_BOX(gtk_combo_box_new_text());
629 for (s = mapnames; *s; s++)
630 gtk_combo_box_append_text(map_combo, *s);
631 gtk_combo_box_set_active (map_combo, default_map);
632 GtkWidget *zoom_label = gtk_label_new(_("Zoom level:"));
633 GtkComboBox *zoom_combo = GTK_COMBO_BOX(gtk_combo_box_new_text());
634 for (s = zoom_list; *s; s++)
635 gtk_combo_box_append_text(zoom_combo, *s);
636 gtk_combo_box_set_active (zoom_combo, default_zoom);
638 GtkTable *box = GTK_TABLE(gtk_table_new(2, 2, FALSE));
639 gtk_table_attach_defaults(box, GTK_WIDGET(map_label), 0, 1, 0, 1);
640 gtk_table_attach_defaults(box, GTK_WIDGET(map_combo), 1, 2, 0, 1);
641 gtk_table_attach_defaults(box, GTK_WIDGET(zoom_label), 0, 1, 1, 2);
642 gtk_table_attach_defaults(box, GTK_WIDGET(zoom_combo), 1, 2, 1, 2);
644 gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), GTK_WIDGET(box), FALSE, FALSE, 5 );
646 gtk_widget_show_all ( dialog );
647 if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) != GTK_RESPONSE_ACCEPT ) {
648 gtk_widget_destroy(dialog);
652 *selected_map = gtk_combo_box_get_active(map_combo);
653 *selected_zoom = gtk_combo_box_get_active(zoom_combo);
655 gtk_widget_destroy(dialog);