66 |
GtkWidget *view; |
GtkWidget *view; |
67 |
} log; |
} log; |
68 |
|
|
69 |
GtkWidget *username, *password, *filename; |
GtkWidget *username, *password; |
70 |
GtkWidget *lat, *lon, *dst; |
GtkWidget *lat, *lon, *dst; |
71 |
|
char *filename; |
72 |
|
|
73 |
int use_cnt; |
int use_cnt; |
74 |
|
|
93 |
g_ptr_array_free (context->argv, TRUE); |
g_ptr_array_free (context->argv, TRUE); |
94 |
} |
} |
95 |
|
|
96 |
|
if(context->filename) g_free(context->filename); |
97 |
|
|
98 |
g_free(context); |
g_free(context); |
99 |
} |
} |
100 |
} |
} |
422 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
423 |
} |
} |
424 |
|
|
425 |
static void on_browse(GtkWidget *widget, gpointer data) { |
static void table_attach(GtkWidget *table, GtkWidget *child, int left, int top) { |
426 |
gt_context_t *context = (gt_context_t*)data; |
gtk_table_attach_defaults(GTK_TABLE(table), child, left, left+1, top, top+1); |
|
|
|
|
printf("Browse %p\n", context->dialog); |
|
|
|
|
|
#ifdef USE_MAEMO |
|
|
GtkWidget *dialog = hildon_file_chooser_dialog_new(GTK_WINDOW(context->dialog), |
|
|
GTK_FILE_CHOOSER_ACTION_SAVE); |
|
|
#else |
|
|
GtkWidget *dialog = gtk_file_chooser_dialog_new(_("Save GPX file"), |
|
|
GTK_WINDOW(context->dialog), |
|
|
GTK_FILE_CHOOSER_ACTION_SAVE, |
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
|
|
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, |
|
|
NULL); |
|
|
#endif |
|
|
|
|
|
printf("set filename <%s>\n", context->appdata->gt.filename); |
|
|
|
|
|
if(!g_file_test(context->appdata->gt.filename, G_FILE_TEST_EXISTS)) { |
|
|
char *last_sep = strrchr(context->appdata->gt.filename, '/'); |
|
|
if(last_sep) { |
|
|
*last_sep = 0; // seperate path from file |
|
|
|
|
|
/* the user just created a new document */ |
|
|
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), |
|
|
context->appdata->gt.filename); |
|
|
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), last_sep+1); |
|
|
|
|
|
/* restore full filename */ |
|
|
*last_sep = '/'; |
|
|
} |
|
|
} else |
|
|
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), |
|
|
context->appdata->gt.filename); |
|
|
|
|
|
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
|
|
gchar *name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
|
|
gtk_label_set_text(GTK_LABEL(context->filename), name); |
|
|
} |
|
|
|
|
|
gtk_widget_destroy (dialog); |
|
427 |
} |
} |
428 |
|
|
429 |
|
|
430 |
static gboolean gui_setup(gt_context_t *context) { |
static gboolean gui_setup(gt_context_t *context) { |
431 |
appdata_t *appdata = context->appdata; |
appdata_t *appdata = context->appdata; |
432 |
gboolean ok = FALSE; |
gboolean ok = FALSE; |
438 |
g_strdup_printf("%s/gtoad.gpx", appdata->path); |
g_strdup_printf("%s/gtoad.gpx", appdata->path); |
439 |
} |
} |
440 |
|
|
441 |
|
if(appdata->gt.filename) |
442 |
|
context->filename = g_strdup(appdata->gt.filename); |
443 |
|
|
444 |
context->dialog = gtk_dialog_new_with_buttons(_("GeoToad - Setup"), |
context->dialog = gtk_dialog_new_with_buttons(_("GeoToad - Setup"), |
445 |
GTK_WINDOW(appdata->window), |
GTK_WINDOW(appdata->window), |
446 |
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, |
448 |
GTK_STOCK_OK, GTK_RESPONSE_OK, |
GTK_STOCK_OK, GTK_RESPONSE_OK, |
449 |
NULL); |
NULL); |
450 |
|
|
451 |
|
GtkWidget *table = gtk_table_new(5, 2, FALSE); |
452 |
|
|
453 |
/* ------------------- Coordinates ------------------------- */ |
/* ------------------- Coordinates ------------------------- */ |
|
GtkWidget *hbox = gtk_hbox_new(FALSE, 0); |
|
454 |
|
|
455 |
GtkWidget *vbox = gtk_vbox_new(FALSE, 0); |
table_attach(table, left_label_new(_("Position:")), 0, 0); |
456 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), left_label_new(_("Position:"))); |
table_attach(table, left_label_new(_("Distance:")), 0, 1); |
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), left_label_new(_("Distance:"))); |
|
|
gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); |
|
457 |
|
|
458 |
/* setup default positions */ |
/* setup default positions */ |
459 |
pos_t *refpos = get_pos(appdata); |
pos_t *refpos = get_pos(appdata); |
462 |
appdata->gt.lon = refpos->lon; |
appdata->gt.lon = refpos->lon; |
463 |
} |
} |
464 |
|
|
465 |
vbox = gtk_vbox_new(FALSE, 0); |
GtkWidget *hbox = gtk_hbox_new(FALSE, 0); |
|
GtkWidget *ihbox = gtk_hbox_new(FALSE, 0); |
|
466 |
context->lat = lat_entry_new(appdata->gt.lat); |
context->lat = lat_entry_new(appdata->gt.lat); |
467 |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), context->lat); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context->lat); |
468 |
context->lon = lon_entry_new(appdata->gt.lon); |
context->lon = lon_entry_new(appdata->gt.lon); |
469 |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), context->lon); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context->lon); |
470 |
GtkWidget *popup = preset_coordinate_picker(appdata, context->lat, context->lon); |
GtkWidget *popup = preset_coordinate_picker(appdata, context->lat, context->lon); |
471 |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), popup); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), popup); |
472 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), ihbox); |
table_attach(table, hbox, 1, 0); |
473 |
|
|
474 |
float dst = appdata->gt.distance; // distance is given in kilometers |
float dst = appdata->gt.distance; // distance is given in kilometers |
475 |
if(appdata->imperial) dst /= 1.609344; |
if(appdata->imperial) dst /= 1.609344; |
476 |
context->dst = dist_entry_new(dst, appdata->imperial); |
context->dst = dist_entry_new(dst, appdata->imperial); |
477 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), context->dst); |
table_attach(table, context->dst, 1, 1); |
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), vbox); |
|
|
|
|
|
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), hbox); |
|
|
|
|
|
/* ------------------- file name ------------------------- */ |
|
|
hbox = gtk_hbox_new(FALSE, 0); |
|
|
|
|
|
context->filename = gtk_label_new(appdata->gt.filename); |
|
|
gtk_misc_set_alignment(GTK_MISC(context->filename), 0.f, 0.5f); |
|
|
gtk_label_set_ellipsize(GTK_LABEL(context->filename), PANGO_ELLIPSIZE_MIDDLE); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), context->filename); |
|
|
|
|
|
GtkWidget *button = gtk_button_new_with_label(_("Browse")); |
|
|
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5) |
|
|
hildon_gtk_widget_set_theme_size(button, |
|
|
(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH)); |
|
|
#endif |
|
|
gtk_signal_connect(GTK_OBJECT(button), "clicked", |
|
|
GTK_SIGNAL_FUNC(on_browse), context); |
|
|
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
|
|
|
|
|
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), hbox); |
|
|
|
|
478 |
|
|
479 |
/* ------------------- Username/Password ------------------------- */ |
/* ------------------- Username/Password ------------------------- */ |
480 |
hbox = gtk_hbox_new(FALSE, 0); |
table_attach(table, left_label_new(_("Username:")), 0, 2); |
481 |
vbox = gtk_vbox_new(FALSE, 0); |
table_attach(table, left_label_new(_("Password:")), 0, 3); |
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), left_label_new(_("Username:"))); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), left_label_new(_("Password:"))); |
|
|
gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); |
|
482 |
|
|
|
vbox = gtk_vbox_new(FALSE, 0); |
|
483 |
context->username = entry_new(); |
context->username = entry_new(); |
484 |
context->password = entry_new(); |
context->password = entry_new(); |
485 |
gtk_entry_set_visibility(GTK_ENTRY(context->password), FALSE); |
gtk_entry_set_visibility(GTK_ENTRY(context->password), FALSE); |
493 |
gtk_entry_set_text(GTK_ENTRY(context->password), |
gtk_entry_set_text(GTK_ENTRY(context->password), |
494 |
appdata->gt.password); |
appdata->gt.password); |
495 |
|
|
496 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), context->username); |
table_attach(table, context->username, 1, 2); |
497 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), context->password); |
table_attach(table, context->password, 1, 3); |
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), vbox); |
|
498 |
|
|
499 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), hbox); |
/* ------------------- file name ------------------------- */ |
500 |
|
gtk_table_attach_defaults(GTK_TABLE(table), |
501 |
|
export_file(_("Save GPX file"), &context->filename), |
502 |
|
0, 2, 4, 5); |
503 |
|
|
504 |
|
/* ---------------------------------------------------------------- */ |
505 |
|
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), |
506 |
|
table); |
507 |
|
|
508 |
gtk_dialog_set_default_response(GTK_DIALOG(context->dialog), GTK_RESPONSE_OK); |
gtk_dialog_set_default_response(GTK_DIALOG(context->dialog), |
509 |
|
GTK_RESPONSE_OK); |
510 |
|
|
511 |
gtk_widget_show_all(context->dialog); |
gtk_widget_show_all(context->dialog); |
512 |
|
|
526 |
g_strdup(gtk_entry_get_text(GTK_ENTRY(context->password))); |
g_strdup(gtk_entry_get_text(GTK_ENTRY(context->password))); |
527 |
|
|
528 |
if(appdata->gt.filename) g_free(appdata->gt.filename); |
if(appdata->gt.filename) g_free(appdata->gt.filename); |
529 |
appdata->gt.filename = |
if(context->filename) |
530 |
g_strdup(gtk_label_get_text(GTK_LABEL(context->filename))); |
appdata->gt.filename = g_strdup(context->filename); |
531 |
|
|
532 |
/* get distance in kilometers */ |
/* get distance in kilometers */ |
533 |
appdata->gt.distance = dist_entry_get(context->dst, FALSE); |
appdata->gt.distance = dist_entry_get(context->dst, FALSE); |