--- trunk/src/misc.c 2009/11/26 21:21:03 217 +++ trunk/src/misc.c 2009/11/27 08:58:48 218 @@ -553,10 +553,26 @@ static void cb_gps(GtkWidget *item, gpointer data) { appdata_t *appdata = (appdata_t*)data; + gint id = (gint)g_object_get_data(G_OBJECT(item), "id"); + pos_t *pos = NULL; + + if(!id) + pos = gps_get_pos(appdata); + else if(id == 1) + pos = &appdata->home; + else { + location_t *location = appdata->location; + while(location && id > 2) { + location = location->next; + id--; + } + + if(id == 2) + pos = &location->pos; + } - pos_t *refpos = get_pos(appdata); - if(!refpos) pos_set(item, NAN, NAN); - else pos_set(item, refpos->lat, refpos->lon); + if(!pos) pos_set(item, NAN, NAN); + else pos_set(item, pos->lat, pos->lon); } static void cb_geomath(GtkWidget *item, gpointer data) { @@ -624,7 +640,20 @@ GtkWidget *menu = gtk_menu_new(); menu_add(menu, appdata, icon_get_widget(ICON_POS, 18), - _("Current position (GPS)"), cb_gps, 0, lon_entry, lat_entry); + _("GPS position"), cb_gps, 0, lon_entry, lat_entry); + + menu_add(menu, appdata, icon_get_widget(ICON_POS, 21), + _("Home"), cb_gps, 1, lon_entry, lat_entry); + + location_t *location = appdata->location; + gint id = 2; + while(location) { + menu_add(menu, appdata, icon_get_widget(ICON_POS, 21), + location->name, cb_gps, id++, lon_entry, lat_entry); + + location = location->next; + } + menu_add(menu, appdata, icon_get_widget(ICON_POS, 19), _("Geomath projection"), cb_geomath, 0, lon_entry, lat_entry); #ifdef ENABLE_OSM_GPS_MAP @@ -730,6 +759,11 @@ /* set id on widget as callbacks expect it this way */ g_object_set_data(G_OBJECT(treeview), "id", (gpointer)id); func(GTK_WIDGET(treeview), userdata); + + /* xyz */ + gtk_dialog_response(GTK_DIALOG(gtk_widget_get_toplevel( + GTK_WIDGET(treeview))), GTK_RESPONSE_ACCEPT); + } } @@ -763,7 +797,20 @@ G_TYPE_POINTER); picker_add(store, appdata, icon_get(ICON_POS, 18), - _("Current position (GPS)"), cb_gps, 0); + _("GPS position"), cb_gps, 0); + + picker_add(store, appdata, icon_get(ICON_POS, 21), + _("Home"), cb_gps, 1); + + location_t *location = appdata->location; + gint id = 2; + while(location) { + picker_add(store, appdata, icon_get(ICON_POS, 21), + location->name, cb_gps, id++); + + location = location->next; + } + picker_add(store, appdata, icon_get(ICON_POS, 19), _("Geomath projection"), cb_geomath, 0); #ifdef ENABLE_OSM_GPS_MAP @@ -837,7 +884,6 @@ gtk_dialog_new_with_buttons(_("Preset coordinates"), GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(button))), GTK_DIALOG_MODAL, - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);