From 9511c8be14a0466d1da13498d2f667071f54b1b3 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Thu, 9 Aug 2007 13:07:58 +0300 Subject: [PATCH] Add setting and jumping to a destination. Not used for anyhting nice just yet. --- src/cb.c | 24 ++++++++++++++++++++++++ src/cb.h | 2 ++ src/mapper-types.h | 3 +++ src/ui-common.c | 8 ++++++++ src/ui-common.h | 3 +++ 5 files changed, 40 insertions(+) diff --git a/src/cb.c b/src/cb.c index d43a3c1..ab40f32 100644 --- a/src/cb.c +++ b/src/cb.c @@ -450,6 +450,20 @@ gboolean menu_cb_goto_home(GtkAction * action) return TRUE; } +gboolean menu_cb_goto_destination(GtkAction *action) +{ +guint unitx, unity; + +if (_dest.valid==FALSE) { + MACRO_BANNER_SHOW_INFO(_window, _("Destination not set.")); + return TRUE; +} +latlon2unit(_dest.lat, _dest.lon, unitx, unity); +map_center_unit(unitx, unity); +map_set_autozoom(FALSE); +return TRUE; +} + gboolean menu_cb_goto_gps(GtkAction * action) { printf("%s()\n", __PRETTY_FUNCTION__); @@ -1241,11 +1255,21 @@ gboolean cmenu_cb_loc_set_home(GtkAction * action) _pos.unitx = x2unit(_cmenu_position_x); _pos.unity = y2unit(_cmenu_position_y); unit2latlon(_pos.unitx, _pos.unity, _home.lat, _home.lon); +_home.valid=TRUE; config_save_home(); return TRUE; } +gboolean cmenu_cb_loc_set_destination(GtkAction *action) +{ +_pos.unitx = x2unit(_cmenu_position_x); +_pos.unity = y2unit(_cmenu_position_y); +unit2latlon(_pos.unitx, _pos.unity, _dest.lat, _dest.lon); +_dest.valid=TRUE; +return TRUE; +} + gboolean cmenu_cb_loc_set_gps(GtkAction * action) { _pos.unitx = x2unit(_cmenu_position_x); diff --git a/src/cb.h b/src/cb.h index 9ec84cf..db088b0 100644 --- a/src/cb.h +++ b/src/cb.h @@ -73,6 +73,7 @@ gboolean menu_cb_ac_none(GtkAction * action); gboolean menu_cb_goto_latlon(GtkAction * action); gboolean menu_cb_goto_gps(GtkAction * action); gboolean menu_cb_goto_home(GtkAction * action); +gboolean menu_cb_goto_destination(GtkAction *action); gboolean menu_cb_goto_nextway(GtkAction * action); gboolean menu_cb_goto_nearpoi(GtkAction * action); @@ -97,6 +98,7 @@ gboolean cmenu_cb_loc_add_way(GtkAction * action); gboolean cmenu_cb_loc_add_poi(GtkAction * action); gboolean cmenu_cb_loc_set_gps(GtkAction * action); gboolean cmenu_cb_loc_set_home(GtkAction * action); +gboolean cmenu_cb_loc_set_destination(GtkAction *action); gboolean cb_add_poi(GtkAction * action); diff --git a/src/mapper-types.h b/src/mapper-types.h index 434aacc..ba2ec77 100644 --- a/src/mapper-types.h +++ b/src/mapper-types.h @@ -185,6 +185,7 @@ struct _Position { gdouble lat; gdouble lon; gfloat altitude; + gdouble valid; }; /** A general definition of a point in the Mapper unit system. */ @@ -276,6 +277,8 @@ struct _BrowseInfo { }; Point _point_null; + Position _home; +Position _dest; #endif diff --git a/src/ui-common.c b/src/ui-common.c index 2e8afaa..8c0808f 100644 --- a/src/ui-common.c +++ b/src/ui-common.c @@ -372,6 +372,8 @@ static void menu_init() #endif gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu = gtk_menu_new()); gtk_menu_append(submenu, _menu_goto_home = gtk_menu_item_new_with_label(_("Home"))); + gtk_menu_append(submenu, _menu_goto_destination = gtk_menu_item_new_with_label(_("Destination"))); + gtk_menu_append(submenu, _menu_goto_address = gtk_menu_item_new_with_label(_("Address..."))); gtk_menu_append(submenu, _menu_goto_latlon = gtk_menu_item_new_with_label(_("Lat/Lon..."))); gtk_menu_append(submenu, _menu_goto_gps = gtk_menu_item_new_with_label(_("GPS Location"))); gtk_menu_append(submenu, _menu_goto_nextway = gtk_menu_item_new_with_label(_("Next Waypoint"))); @@ -473,6 +475,8 @@ static void menu_init() /* Connect the "Go to" signals. */ g_signal_connect(G_OBJECT(_menu_goto_home), "activate", G_CALLBACK(menu_cb_goto_home), NULL); + g_signal_connect(G_OBJECT(_menu_goto_destination), "activate", + G_CALLBACK(menu_cb_goto_destination), NULL); g_signal_connect(G_OBJECT(_menu_goto_latlon), "activate", G_CALLBACK(menu_cb_goto_latlon), NULL); g_signal_connect(G_OBJECT(_menu_goto_gps), "activate", @@ -520,6 +524,8 @@ static void menu_init() gtk_menu_append(submenu, _cmenu_loc_clip_latlon_item = gtk_menu_item_new_with_label(_("Copy Lat/Lon"))); gtk_menu_append(submenu, gtk_separator_menu_item_new()); + gtk_menu_append(submenu, _cmenu_loc_set_destination + = gtk_menu_item_new_with_label(_("Set destination"))); gtk_menu_append(submenu, _cmenu_loc_distance_to_item = gtk_menu_item_new_with_label(_("Show Distance to"))); gtk_menu_append(submenu, _cmenu_loc_route_to_item @@ -605,6 +611,8 @@ static void menu_init() G_CALLBACK(cmenu_cb_loc_set_gps), NULL); g_signal_connect(G_OBJECT(_cmenu_loc_set_home), "activate", G_CALLBACK(cmenu_cb_loc_set_home), NULL); + g_signal_connect(G_OBJECT(_cmenu_loc_set_destination), "activate", + G_CALLBACK(cmenu_cb_loc_set_destination), NULL); g_signal_connect(G_OBJECT(_cmenu_way_show_latlon_item), "activate", G_CALLBACK(cmenu_cb_way_show_latlon), NULL); diff --git a/src/ui-common.h b/src/ui-common.h index 728ba00..208f36f 100644 --- a/src/ui-common.h +++ b/src/ui-common.h @@ -140,6 +140,8 @@ GtkWidget *_menu_ac_none_item; /* Menu items for the "Go to" submenu. */ GtkWidget *_menu_goto_home; +GtkWidget *_menu_goto_destination; +GtkWidget *_menu_goto_address; GtkWidget *_menu_goto_latlon; GtkWidget *_menu_goto_gps; GtkWidget *_menu_goto_nextway; @@ -166,6 +168,7 @@ GtkWidget *_cmenu_loc_add_route; GtkWidget *_cmenu_loc_add_way; GtkWidget *_cmenu_loc_add_poi; GtkWidget *_cmenu_loc_set_gps; +GtkWidget *_cmenu_loc_set_destination; GtkWidget *_cmenu_loc_set_home; /* Menu items for the "Waypoint" context menu. */ -- 2.39.5