diff options
author | sleske <sleske@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2013-04-23 06:31:31 +0000 |
---|---|---|
committer | sleske <sleske@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2013-04-23 06:31:31 +0000 |
commit | 8e98a45b0154aeb7f657ebc3eca709a084828ac8 (patch) | |
tree | 4b4c7fb4b1cc473b902fd12c8fb60c5c0e148dd1 /navit/popup.c | |
parent | 1571ac00287ed883c8d2455ffe74155c1800a0f2 (diff) | |
download | navit-svn-8e98a45b0154aeb7f657ebc3eca709a084828ac8.tar.gz |
Add:gui/gtk:Add context menu item "Visit before a destination".|Fixes #1100. Thanks, me.yahoo.com/a/_ij44v97roulszbeztrzcqzaaiyvlg--#9d14a !
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5444 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/popup.c')
-rw-r--r-- | navit/popup.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/navit/popup.c b/navit/popup.c index fb716adb..16855892 100644 --- a/navit/popup.c +++ b/navit/popup.c @@ -134,6 +134,27 @@ popup_set_destination(struct navit *nav, struct pcoord *pc) navit_set_destination(nav, pc, buffer, 1); } + +static void +popup_set_visitbefore(struct navit *nav, struct pcoord *pc,int visitbefore) +{ + struct pcoord *dst; + char buffer[1024]; + int i, dstcount; + sprintf(buffer, _("Waypoint %d"), visitbefore+1); + dstcount=navit_get_destination_count(nav)+1; + dst=g_alloca(dstcount*sizeof(struct pcoord)); + dstcount=navit_get_destinations(nav,dst,dstcount); + for (i=dstcount;i>visitbefore;i--){ + dst[i]=dst[i-1]; + } + dst[visitbefore]=*pc; + navit_add_destination_description(nav,pc,buffer); + navit_set_destinations(nav, dst, dstcount+1, buffer, 1); +} + + + static void popup_set_bookmark(struct navit *nav, struct pcoord *pc) { @@ -219,6 +240,24 @@ popup_printf_cb(void *menu, enum menu_type type, struct callback *cb, const char return ret; } + + +static void +popup_show_visitbefore(struct navit *nav,struct pcoord *pc, void *menu) +{ + void *menuvisitbefore; + char buffer[100]; + int i, dstcount; + dstcount=navit_get_destination_count(nav); + if (dstcount>=1){ + menuvisitbefore=popup_printf(menu, menu_type_submenu, _("Visit before...")); + for (i=0;i<dstcount;i++){ + sprintf(buffer,_("Waypoint %d"),i+1); + popup_printf_cb(menuvisitbefore, menu_type_menu, callback_new_3(callback_cast(popup_set_visitbefore), nav, pc,i), buffer); + } + } +} + static void popup_show_attr_val(struct map *map, void *menu, struct attr *attr) { @@ -393,6 +432,7 @@ popup(struct navit *nav, int button, struct point *p) c.y = co.y; popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_position), nav, &c), _("Set as position")); popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, &c), _("Set as destination")); + popup_show_visitbefore(nav,&c,men); popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, &c), _("Add as bookmark")); popup_display(nav, popup, p); menu_popup(popup); |