21 |
|
|
22 |
#ifdef ENABLE_OSM_GPS_MAP |
#ifdef ENABLE_OSM_GPS_MAP |
23 |
#include "osm-gps-map.h" |
#include "osm-gps-map.h" |
24 |
#include "osm-gps-map-osd-classic.h" |
#include "osm-gps-map-osd-select.h" |
25 |
#endif |
#endif |
26 |
|
|
27 |
#define TAB_LABEL_MAP "Map" |
#define TAB_LABEL_MAP "Map" |
41 |
GtkWidget *dialog, *notebook; |
GtkWidget *dialog, *notebook; |
42 |
area_edit_t *area; |
area_edit_t *area; |
43 |
pos_t min, max; /* local copy to work on */ |
pos_t min, max; /* local copy to work on */ |
|
GtkWidget *minlat, *maxlat, *minlon, *maxlon; |
|
44 |
GtkWidget *warning; |
GtkWidget *warning; |
45 |
|
|
46 |
struct { |
struct { |
83 |
} |
} |
84 |
|
|
85 |
static gboolean current_tab_is(context_t *context, gint page_num, char *str) { |
static gboolean current_tab_is(context_t *context, gint page_num, char *str) { |
86 |
|
GtkWidget *nb = notebook_get_gtk_notebook(context->notebook); |
87 |
|
|
88 |
if(page_num < 0) |
if(page_num < 0) |
89 |
page_num = |
page_num = |
90 |
gtk_notebook_get_current_page(GTK_NOTEBOOK(context->notebook)); |
gtk_notebook_get_current_page(GTK_NOTEBOOK(nb)); |
91 |
|
|
92 |
if(page_num < 0) return FALSE; |
if(page_num < 0) return FALSE; |
93 |
|
|
94 |
GtkWidget *w = |
GtkWidget *w = |
95 |
gtk_notebook_get_nth_page(GTK_NOTEBOOK(context->notebook), page_num); |
gtk_notebook_get_nth_page(GTK_NOTEBOOK(nb), page_num); |
96 |
const char *name = |
const char *name = |
97 |
gtk_notebook_get_tab_label_text(GTK_NOTEBOOK(context->notebook), w); |
gtk_notebook_get_tab_label_text(GTK_NOTEBOOK(nb), w); |
98 |
|
|
99 |
return(strcasecmp(name, _(str)) == 0); |
return(strcasecmp(name, _(str)) == 0); |
100 |
} |
} |
152 |
} |
} |
153 |
|
|
154 |
static void area_main_update(context_t *context) { |
static void area_main_update(context_t *context) { |
|
pos_lat_label_set(context->minlat, context->min.lat); |
|
|
pos_lat_label_set(context->maxlat, context->max.lat); |
|
|
pos_lon_label_set(context->minlon, context->min.lon); |
|
|
pos_lon_label_set(context->maxlon, context->max.lon); |
|
|
|
|
155 |
/* also setup the local error messages here, so they are */ |
/* also setup the local error messages here, so they are */ |
156 |
/* updated for all entries at once */ |
/* updated for all entries at once */ |
157 |
if(isnan(context->min.lat) || isnan(context->min.lon) || |
if(isnan(context->min.lat) || isnan(context->min.lon) || |
524 |
return TRUE; |
return TRUE; |
525 |
} |
} |
526 |
|
|
|
static void |
|
|
cb_map_gps(osd_button_t but, context_t *context) { |
|
|
if(but == OSD_GPS) { |
|
|
pos_t pos; |
|
|
|
|
|
/* user clicked "gps" button -> jump to position */ |
|
|
gboolean gps_on = |
|
|
context->area->appdata->settings && |
|
|
context->area->appdata->settings->enable_gps; |
|
|
|
|
|
if(gps_on && gps_get_pos(context->area->appdata, &pos, NULL)) { |
|
|
osm_gps_map_set_center(OSM_GPS_MAP(context->map.widget), |
|
|
pos.lat, pos.lon); |
|
|
|
|
|
/* re-enable centering */ |
|
|
g_object_set(context->map.widget, "auto-center", TRUE, NULL); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
527 |
static void on_page_switch(GtkNotebook *notebook, GtkNotebookPage *page, |
static void on_page_switch(GtkNotebook *notebook, GtkNotebookPage *page, |
528 |
guint page_num, context_t *context) { |
guint page_num, context_t *context) { |
529 |
|
|
546 |
gboolean gps_fix = gps_on && |
gboolean gps_fix = gps_on && |
547 |
gps_get_pos(context->area->appdata, &pos, NULL); |
gps_get_pos(context->area->appdata, &pos, NULL); |
548 |
|
|
|
/* ... and enable "goto" button if it's valid */ |
|
|
osm_gps_map_osd_enable_gps(OSM_GPS_MAP(context->map.widget), |
|
|
OSM_GPS_MAP_OSD_CALLBACK(gps_fix?cb_map_gps:NULL), context); |
|
|
|
|
549 |
if(gps_fix) { |
if(gps_fix) { |
550 |
g_object_set(context->map.widget, "gps-track-highlight-radius", 0, NULL); |
g_object_set(context->map.widget, "gps-track-highlight-radius", 0, NULL); |
551 |
osm_gps_map_draw_gps(OSM_GPS_MAP(context->map.widget), |
osm_gps_map_draw_gps(OSM_GPS_MAP(context->map.widget), |
578 |
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
579 |
NULL); |
NULL); |
580 |
|
|
581 |
GtkWidget *table = gtk_table_new(5, 2, FALSE); // x, y |
context.warning = |
582 |
|
gtk_dialog_add_button(GTK_DIALOG(context.dialog), _("Warning"), |
583 |
GtkWidget *label = gtk_label_new(_("Latitude:")); |
GTK_RESPONSE_HELP); |
|
misc_table_attach(table, label, 0, 0); |
|
|
context.minlat = pos_lat_label_new(area->min->lat); |
|
|
misc_table_attach(table, context.minlat, 1, 0); |
|
|
label = gtk_label_new(_("to")); |
|
|
misc_table_attach(table, label, 2, 0); |
|
|
context.maxlat = pos_lat_label_new(area->max->lat); |
|
|
misc_table_attach(table, context.maxlat, 3, 0); |
|
|
|
|
|
label = gtk_label_new(_("Longitude:")); |
|
|
misc_table_attach(table, label, 0, 1); |
|
|
context.minlon = pos_lon_label_new(area->min->lon); |
|
|
misc_table_attach(table, context.minlon, 1, 1); |
|
|
label = gtk_label_new(_("to")); |
|
|
misc_table_attach(table, label, 2, 1); |
|
|
context.maxlon = pos_lon_label_new(area->max->lon); |
|
|
misc_table_attach(table, context.maxlon, 3, 1); |
|
584 |
|
|
|
context.warning = gtk_button_new(); |
|
585 |
gtk_button_set_image(GTK_BUTTON(context.warning), |
gtk_button_set_image(GTK_BUTTON(context.warning), |
586 |
gtk_image_new_from_stock(GTK_STOCK_DIALOG_WARNING, |
gtk_image_new_from_stock(GTK_STOCK_DIALOG_WARNING, |
587 |
GTK_ICON_SIZE_BUTTON)); |
GTK_ICON_SIZE_BUTTON)); |
588 |
g_signal_connect(context.warning, "clicked", |
g_signal_connect(context.warning, "clicked", |
589 |
G_CALLBACK(on_area_warning_clicked), &context); |
G_CALLBACK(on_area_warning_clicked), &context); |
|
gtk_table_attach_defaults(GTK_TABLE(table), context.warning, 4, 5, 0, 2); |
|
590 |
|
|
591 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context.dialog)->vbox), |
context.notebook = notebook_new(); |
|
table, FALSE, FALSE, 0); |
|
|
|
|
|
context.notebook = gtk_notebook_new(); |
|
592 |
|
|
593 |
#ifdef ENABLE_OSM_GPS_MAP |
#ifdef ENABLE_OSM_GPS_MAP |
594 |
/* ------------- fetch from map ------------------------ */ |
/* ------------- fetch from map ------------------------ */ |
601 |
"tile-cache", NULL, |
"tile-cache", NULL, |
602 |
NULL); |
NULL); |
603 |
|
|
604 |
osm_gps_map_osd_classic_init(OSM_GPS_MAP(context.map.widget)); |
osm_gps_map_osd_select_init(OSM_GPS_MAP(context.map.widget)); |
605 |
|
|
606 |
g_signal_connect(G_OBJECT(context.map.widget), "configure-event", |
g_signal_connect(G_OBJECT(context.map.widget), "configure-event", |
607 |
G_CALLBACK(on_map_configure), &context); |
G_CALLBACK(on_map_configure), &context); |
616 |
context.map.handler_id = gtk_timeout_add(1000, map_gps_update, &context); |
context.map.handler_id = gtk_timeout_add(1000, map_gps_update, &context); |
617 |
context.map.start.rlon = context.map.start.rlat = NAN; |
context.map.start.rlon = context.map.start.rlat = NAN; |
618 |
|
|
619 |
gtk_notebook_append_page(GTK_NOTEBOOK(context.notebook), |
notebook_append_page(context.notebook, context.map.widget, _(TAB_LABEL_MAP)); |
|
context.map.widget, gtk_label_new(_(TAB_LABEL_MAP))); |
|
620 |
#endif |
#endif |
621 |
|
|
622 |
/* ------------ direct min/max edit --------------- */ |
/* ------------ direct min/max edit --------------- */ |
623 |
|
|
624 |
vbox = gtk_vbox_new(FALSE, 10); |
vbox = gtk_vbox_new(FALSE, 10); |
625 |
table = gtk_table_new(3, 4, FALSE); // x, y |
|
626 |
|
GtkWidget *table = gtk_table_new(3, 4, FALSE); // x, y |
627 |
gtk_table_set_col_spacings(GTK_TABLE(table), 10); |
gtk_table_set_col_spacings(GTK_TABLE(table), 10); |
628 |
gtk_table_set_row_spacings(GTK_TABLE(table), 5); |
gtk_table_set_row_spacings(GTK_TABLE(table), 5); |
629 |
|
|
630 |
context.direct.minlat = pos_lat_entry_new(0.0); |
context.direct.minlat = pos_lat_entry_new(0.0); |
631 |
misc_table_attach(table, context.direct.minlat, 0, 0); |
misc_table_attach(table, context.direct.minlat, 0, 0); |
632 |
label = gtk_label_new(_("to")); |
GtkWidget *label = gtk_label_new(_("to")); |
633 |
misc_table_attach(table, label, 1, 0); |
misc_table_attach(table, label, 1, 0); |
634 |
context.direct.maxlat = pos_lat_entry_new(0.0); |
context.direct.maxlat = pos_lat_entry_new(0.0); |
635 |
misc_table_attach(table, context.direct.maxlat, 2, 0); |
misc_table_attach(table, context.direct.maxlat, 2, 0); |
664 |
gtk_table_attach_defaults(GTK_TABLE(table), context.direct.error, 0, 3, 3, 4); |
gtk_table_attach_defaults(GTK_TABLE(table), context.direct.error, 0, 3, 3, 4); |
665 |
|
|
666 |
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
667 |
gtk_notebook_append_page(GTK_NOTEBOOK(context.notebook), |
notebook_append_page(context.notebook, vbox, _(TAB_LABEL_DIRECT)); |
|
vbox, gtk_label_new(_(TAB_LABEL_DIRECT))); |
|
668 |
|
|
669 |
/* ------------- center/extent edit ------------------------ */ |
/* ------------- center/extent edit ------------------------ */ |
670 |
|
|
686 |
label = gtk_label_new(_("Width:")); |
label = gtk_label_new(_("Width:")); |
687 |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
688 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
689 |
context.extent.width = gtk_entry_new(); |
context.extent.width = entry_new(); |
690 |
gtk_table_attach_defaults(GTK_TABLE(table), context.extent.width, 1, 2, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), context.extent.width, 1, 2, 1, 2); |
691 |
|
|
692 |
label = gtk_label_new(_("Height:")); |
label = gtk_label_new(_("Height:")); |
693 |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
694 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); |
695 |
context.extent.height = gtk_entry_new(); |
context.extent.height = entry_new(); |
696 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
697 |
context.extent.height, 1, 2, 2, 3); |
context.extent.height, 1, 2, 2, 3); |
698 |
|
|
729 |
gtk_table_attach_defaults(GTK_TABLE(table), context.extent.error, 0, 3, 4, 5); |
gtk_table_attach_defaults(GTK_TABLE(table), context.extent.error, 0, 3, 4, 5); |
730 |
|
|
731 |
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
732 |
gtk_notebook_append_page(GTK_NOTEBOOK(context.notebook), |
notebook_append_page(context.notebook, vbox, _(TAB_LABEL_EXTENT)); |
|
vbox, gtk_label_new(_(TAB_LABEL_EXTENT))); |
|
733 |
|
|
734 |
#ifdef HAS_MAEMO_MAPPER |
#ifdef HAS_MAEMO_MAPPER |
735 |
/* ------------- fetch from maemo mapper ------------------------ */ |
/* ------------- fetch from maemo mapper ------------------------ */ |
747 |
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
748 |
|
|
749 |
|
|
750 |
gtk_notebook_append_page(GTK_NOTEBOOK(context.notebook), |
notebook_append_page(context.notebook, vbox, gtk_label_new(_(TAB_LABEL_MM))); |
|
vbox, gtk_label_new(_(TAB_LABEL_MM))); |
|
751 |
#endif |
#endif |
752 |
|
|
753 |
/* ------------------------------------------------------ */ |
/* ------------------------------------------------------ */ |
766 |
|
|
767 |
gboolean leave = FALSE, ok = FALSE; |
gboolean leave = FALSE, ok = FALSE; |
768 |
do { |
do { |
769 |
if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(context.dialog))) { |
int response = gtk_dialog_run(GTK_DIALOG(context.dialog)); |
770 |
|
|
771 |
|
if(GTK_RESPONSE_ACCEPT == response) { |
772 |
if(area_warning(&context)) { |
if(area_warning(&context)) { |
773 |
leave = TRUE; |
leave = TRUE; |
774 |
ok = TRUE; |
ok = TRUE; |
775 |
} |
} |
776 |
} else |
} else if(response != GTK_RESPONSE_HELP) |
777 |
leave = TRUE; |
leave = TRUE; |
778 |
} while(!leave); |
} while(!leave); |
779 |
|
|