553 |
|
|
554 |
static void cb_gps(GtkWidget *item, gpointer data) { |
static void cb_gps(GtkWidget *item, gpointer data) { |
555 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
556 |
|
gint id = (gint)g_object_get_data(G_OBJECT(item), "id"); |
557 |
|
pos_t *pos = NULL; |
558 |
|
|
559 |
|
if(!id) |
560 |
|
pos = gps_get_pos(appdata); |
561 |
|
else if(id == 1) |
562 |
|
pos = &appdata->home; |
563 |
|
else { |
564 |
|
location_t *location = appdata->location; |
565 |
|
while(location && id > 2) { |
566 |
|
location = location->next; |
567 |
|
id--; |
568 |
|
} |
569 |
|
|
570 |
|
if(id == 2) |
571 |
|
pos = &location->pos; |
572 |
|
} |
573 |
|
|
574 |
pos_t *refpos = get_pos(appdata); |
if(!pos) pos_set(item, NAN, NAN); |
575 |
if(!refpos) pos_set(item, NAN, NAN); |
else pos_set(item, pos->lat, pos->lon); |
|
else pos_set(item, refpos->lat, refpos->lon); |
|
576 |
} |
} |
577 |
|
|
578 |
static void cb_geomath(GtkWidget *item, gpointer data) { |
static void cb_geomath(GtkWidget *item, gpointer data) { |
640 |
GtkWidget *menu = gtk_menu_new(); |
GtkWidget *menu = gtk_menu_new(); |
641 |
|
|
642 |
menu_add(menu, appdata, icon_get_widget(ICON_POS, 18), |
menu_add(menu, appdata, icon_get_widget(ICON_POS, 18), |
643 |
_("Current position (GPS)"), cb_gps, 0, lon_entry, lat_entry); |
_("GPS position"), cb_gps, 0, lon_entry, lat_entry); |
644 |
|
|
645 |
|
menu_add(menu, appdata, icon_get_widget(ICON_POS, 21), |
646 |
|
_("Home"), cb_gps, 1, lon_entry, lat_entry); |
647 |
|
|
648 |
|
location_t *location = appdata->location; |
649 |
|
gint id = 2; |
650 |
|
while(location) { |
651 |
|
menu_add(menu, appdata, icon_get_widget(ICON_POS, 21), |
652 |
|
location->name, cb_gps, id++, lon_entry, lat_entry); |
653 |
|
|
654 |
|
location = location->next; |
655 |
|
} |
656 |
|
|
657 |
menu_add(menu, appdata, icon_get_widget(ICON_POS, 19), |
menu_add(menu, appdata, icon_get_widget(ICON_POS, 19), |
658 |
_("Geomath projection"), cb_geomath, 0, lon_entry, lat_entry); |
_("Geomath projection"), cb_geomath, 0, lon_entry, lat_entry); |
659 |
#ifdef ENABLE_OSM_GPS_MAP |
#ifdef ENABLE_OSM_GPS_MAP |
759 |
/* set id on widget as callbacks expect it this way */ |
/* set id on widget as callbacks expect it this way */ |
760 |
g_object_set_data(G_OBJECT(treeview), "id", (gpointer)id); |
g_object_set_data(G_OBJECT(treeview), "id", (gpointer)id); |
761 |
func(GTK_WIDGET(treeview), userdata); |
func(GTK_WIDGET(treeview), userdata); |
762 |
|
|
763 |
|
/* xyz */ |
764 |
|
gtk_dialog_response(GTK_DIALOG(gtk_widget_get_toplevel( |
765 |
|
GTK_WIDGET(treeview))), GTK_RESPONSE_ACCEPT); |
766 |
|
|
767 |
} |
} |
768 |
} |
} |
769 |
|
|
797 |
G_TYPE_POINTER); |
G_TYPE_POINTER); |
798 |
|
|
799 |
picker_add(store, appdata, icon_get(ICON_POS, 18), |
picker_add(store, appdata, icon_get(ICON_POS, 18), |
800 |
_("Current position (GPS)"), cb_gps, 0); |
_("GPS position"), cb_gps, 0); |
801 |
|
|
802 |
|
picker_add(store, appdata, icon_get(ICON_POS, 21), |
803 |
|
_("Home"), cb_gps, 1); |
804 |
|
|
805 |
|
location_t *location = appdata->location; |
806 |
|
gint id = 2; |
807 |
|
while(location) { |
808 |
|
picker_add(store, appdata, icon_get(ICON_POS, 21), |
809 |
|
location->name, cb_gps, id++); |
810 |
|
|
811 |
|
location = location->next; |
812 |
|
} |
813 |
|
|
814 |
picker_add(store, appdata, icon_get(ICON_POS, 19), |
picker_add(store, appdata, icon_get(ICON_POS, 19), |
815 |
_("Geomath projection"), cb_geomath, 0); |
_("Geomath projection"), cb_geomath, 0); |
816 |
#ifdef ENABLE_OSM_GPS_MAP |
#ifdef ENABLE_OSM_GPS_MAP |
884 |
gtk_dialog_new_with_buttons(_("Preset coordinates"), |
gtk_dialog_new_with_buttons(_("Preset coordinates"), |
885 |
GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(button))), |
GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(button))), |
886 |
GTK_DIALOG_MODAL, |
GTK_DIALOG_MODAL, |
|
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
|
887 |
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
888 |
NULL); |
NULL); |
889 |
|
|