From ba8c7a19f05f6491eb7f191d44a5af8506f619cf Mon Sep 17 00:00:00 2001 From: martin-s Date: Fri, 2 Dec 2005 10:41:56 +0000 Subject: Reorganisation git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@8 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 306 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 306 insertions(+) create mode 100644 popup.c (limited to 'popup.c') diff --git a/popup.c b/popup.c new file mode 100644 index 00000000..f0fc5883 --- /dev/null +++ b/popup.c @@ -0,0 +1,306 @@ +#include +#include +#include +#include +#include +#include "coord.h" +#include "param.h" +#include "map_data.h" +#include "block.h" +#include "display.h" +#include "town.h" +#include "street.h" +#include "poly.h" +#include "log.h" +#include "popup.h" +#include "plugin.h" +#include "vehicle.h" +#include "route.h" +#include "cursor.h" +#include "statusbar.h" +#include "container.h" + +void +popup_item_destroy_text(struct popup_item *item) +{ + g_free(item->text); + g_free(item); +} + +struct popup_item * +popup_item_new_text(struct popup_item **last, char *text, int priority) +{ + struct popup_item *curr; + curr=g_new(struct popup_item,1); + memset(curr, 0, sizeof(*curr)); + curr->text=g_strdup(text); + curr->priority=priority; + curr->destroy=popup_item_destroy_text; + if (last) { + curr->next=*last; + *last=curr; + } + return curr; +} + +struct popup_item * +popup_item_new_func(struct popup_item **last, char *text, int priority, void (*func)(struct popup_item *, void *), void *param) +{ + struct popup_item *curr=popup_item_new_text(last, text, priority); + curr->func=func; + curr->param=param; + return curr; +} + +struct popup_item * +param_to_menu_new(char *name,struct param_list *plist, int c, int iso) +{ + struct popup_item *last, *curr, *ret; + int i; + + ret=popup_item_new_text(NULL,name,1); + last=NULL; + for (i = 0 ; i < c ; i++) { + char name_buffer[strlen(plist[i].name)+strlen(plist[i].value)+2]; + char *text=name_buffer; + + sprintf(name_buffer,"%s:%s", plist[i].name, plist[i].value); + if (iso) { + text=g_convert(name_buffer,-1,"utf-8","iso8859-1",NULL,NULL,NULL); + if (! text) { + printf("problem converting '%s'\n", name_buffer); + } + } + curr=popup_item_new_text(&last, text, i); + if (iso) + free(text); + } + ret->submenu=last; + return ret; +} + +void +popup_set_no_passing(struct popup_item *item, void *param) +{ + struct display_list *l=param; + struct segment *seg=(struct segment *)(l->data); + struct street_str *str=(struct street_str *)(seg->data[0]); + char log[256]; + int segid=str->segid; + if (segid < 0) + segid=-segid; + + sprintf(log,"Attributes Street 0x%x updated: limit=0x%x(0x%x)", segid, 0x33, str->limit); + str->limit=0x33; + log_write(log, seg->blk_inf.file, str, sizeof(*str)); +} + +void +popup_set_destination(struct popup_item *item, void *param) +{ + struct popup_item *ref=param; + struct popup *popup=ref->param; + struct container *co=popup->co; + printf("Destination %s\n", ref->text); + route_set_position(co->route, cursor_pos_get(co->cursor)); + route_set_destination(co->route, &popup->c); + graphics_redraw(popup->co); + if (co->statusbar && co->statusbar->statusbar_route_update) + co->statusbar->statusbar_route_update(co->statusbar, co->route); +} + +extern void *vehicle; + +void +popup_set_position(struct popup_item *item, void *param) +{ + struct popup_item *ref=param; + struct popup *popup=ref->param; + printf("Position %s\n", ref->text); + vehicle_set_position(popup->co->vehicle, &popup->c); +} + +void +popup_break_crossing(struct display_list *l) +{ + struct segment *seg=(struct segment *)(l->data); + struct street_str *str=(struct street_str *)(seg->data[0]); + char log[256]; + int segid=str->segid; + if (segid < 0) + segid=-segid; + + sprintf(log,"Coordinates Street 0x%x updated: limit=0x%x(0x%x)", segid, 0x33, str->limit); + str->limit=0x33; + log_write(log, seg->blk_inf.file, str, sizeof(*str)); +} + +void +popup_call_func(GtkObject *obj, void *parm) +{ + struct popup_item *curr=parm; + curr->func(curr, curr->param); +} + +GtkWidget * +popup_menu(struct popup_item *list) +{ + int min_prio,curr_prio; + struct popup_item *curr; + GtkWidget *item,*menu,*submenu; + + curr_prio=0; + menu=gtk_menu_new(); + do { + min_prio=INT_MAX; + curr=list; + while (curr) { + if (curr->priority == curr_prio) { + item=gtk_menu_item_new_with_label(curr->text); + gtk_menu_append(GTK_MENU(menu), item); + if (curr->submenu) { + submenu=popup_menu(curr->submenu); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); + } else if (curr->func) { + gtk_signal_connect(GTK_OBJECT(item), "activate", + GTK_SIGNAL_FUNC (popup_call_func), curr); + } + } + if (curr->priority > curr_prio && curr->priority < min_prio) + min_prio=curr->priority; + curr=curr->next; + } + curr_prio=min_prio; + } while (min_prio != INT_MAX); + return menu; +} + +void +popup_display_list_default(struct display_list *d, struct popup_item **popup_list) +{ + struct segment *seg; + char *desc,*text,*item_text; + struct popup_item *curr_item,*submenu; + struct param_list plist[100]; + + desc=NULL; + if (d->type == 0) desc="Polygon"; + if (d->type == 1) desc="Polyline"; + if (d->type == 2) desc="Street"; + if (d->type == 3) desc="Label"; + if (d->type == 4) desc="Point"; + seg=(struct segment *)(d->data); + if (seg) { + if (d->label && strlen(d->label)) { + item_text=malloc(strlen(desc)+strlen(d->label)+2); + strcpy(item_text, desc); + strcat(item_text," "); + strcat(item_text, d->label); + } else { + item_text=desc; + } + text=g_convert(item_text,-1,"utf-8","iso8859-1",NULL,NULL,NULL); + curr_item=popup_item_new_text(popup_list,text,1); + g_free(text); + + curr_item->submenu=param_to_menu_new("File", plist, file_get_param(seg->blk_inf.file, plist, 100), 1); + submenu=curr_item->submenu; + submenu->next=param_to_menu_new("Block", plist, block_get_param(&seg->blk_inf, plist, 100), 1); + submenu=submenu->next; + + if (d->type == 0 || d->type == 1) { + submenu->next=param_to_menu_new(desc, plist, poly_get_param(seg, plist, 100), 1); + } + if (d->type == 2) { + submenu->next=param_to_menu_new(desc, plist, street_get_param(seg, plist, 100, 1), 1); + popup_item_new_func(&submenu->next,"Set no passing", 1000, popup_set_no_passing, d); + } + if (d->type == 3) { + submenu->next=param_to_menu_new(desc, plist, town_get_param(seg, plist, 100), 1); + } + if (d->type == 4) { + submenu->next=param_to_menu_new(desc, plist, street_bti_get_param(seg, plist, 100), 1); + } + } +} + +void +popup_display_list(struct container *co, struct popup *popup, struct popup_item **popup_list) +{ + GtkWidget *menu, *item; + struct display_list *list[100],**p=list; + + menu=gtk_menu_new(); + item=gtk_menu_item_new_with_label("Selection"); + gtk_menu_append (GTK_MENU(menu), item); + display_find(&popup->pnt, co->disp, display_end, 3, list, 100); + while (*p) { + if (! (*p)->info) + popup_display_list_default(*p, popup_list); + else + (*(*p)->info)(*p, popup_list); + p++; + } +} + +void +popup_destroy_items(struct popup_item *item) +{ + struct popup_item *next; + while (item) { + if (item->active && item->func) + item->func(item, item->param); + if (item->submenu) + popup_destroy_items(item->submenu); + next=item->next; + assert(item->destroy != NULL); + item->destroy(item); + item=next; + } +} + +void +popup_destroy(GtkObject *obj, void *parm) +{ + struct popup *popup=parm; + + popup_destroy_items(popup->items); + g_free(popup); +} + +void +popup(struct container *co, int x, int y, int button) +{ + GtkWidget *menu; + struct popup *popup=g_new(struct popup,1); + struct popup_item *list=NULL; + struct popup_item *descr; + struct coord_geo g; + char buffer[256]; + + popup->co=co; + popup->pnt.x=x; + popup->pnt.y=y; + transform_reverse(co->trans, &popup->pnt, &popup->c); + popup_display_list(co, popup, &list); + plugin_call_popup(co, popup, &list); + transform_lng_lat(&popup->c, &g); + strcpy(buffer,"Map Point "); + transform_geo_text(&g, buffer+strlen(buffer)); + descr=popup_item_new_text(&list,buffer, 0); + descr->param=popup; + + popup_item_new_func(&list,"Set as Position", 1000, popup_set_position, descr); + popup_item_new_func(&list,"Set as Destination", 1001, popup_set_destination, descr); + + popup->items=list; + menu=popup_menu(list); + gtk_widget_show_all(menu); + popup->gui_data=menu; + + + gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, button, gtk_get_current_event_time()); + gtk_signal_connect(GTK_OBJECT(menu), "selection-done", GTK_SIGNAL_FUNC (popup_destroy), popup); +} + + -- cgit v1.2.1 From 5ac825f5bbde3067d1ced565163fc5c21a006574 Mon Sep 17 00:00:00 2001 From: martin-s Date: Sun, 11 Dec 2005 13:41:26 +0000 Subject: Fixed some warnings git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@25 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index f0fc5883..c61c5d34 100644 --- a/popup.c +++ b/popup.c @@ -4,7 +4,7 @@ #include #include #include "coord.h" -#include "param.h" +#include "file.h" #include "map_data.h" #include "block.h" #include "display.h" @@ -19,8 +19,9 @@ #include "cursor.h" #include "statusbar.h" #include "container.h" +#include "graphics.h" -void +static void popup_item_destroy_text(struct popup_item *item) { g_free(item->text); @@ -43,7 +44,7 @@ popup_item_new_text(struct popup_item **last, char *text, int priority) return curr; } -struct popup_item * +static struct popup_item * popup_item_new_func(struct popup_item **last, char *text, int priority, void (*func)(struct popup_item *, void *), void *param) { struct popup_item *curr=popup_item_new_text(last, text, priority); @@ -52,7 +53,7 @@ popup_item_new_func(struct popup_item **last, char *text, int priority, void (*f return curr; } -struct popup_item * +static struct popup_item * param_to_menu_new(char *name,struct param_list *plist, int c, int iso) { struct popup_item *last, *curr, *ret; @@ -79,7 +80,7 @@ param_to_menu_new(char *name,struct param_list *plist, int c, int iso) return ret; } -void +static void popup_set_no_passing(struct popup_item *item, void *param) { struct display_list *l=param; @@ -95,7 +96,7 @@ popup_set_no_passing(struct popup_item *item, void *param) log_write(log, seg->blk_inf.file, str, sizeof(*str)); } -void +static void popup_set_destination(struct popup_item *item, void *param) { struct popup_item *ref=param; @@ -111,7 +112,7 @@ popup_set_destination(struct popup_item *item, void *param) extern void *vehicle; -void +static void popup_set_position(struct popup_item *item, void *param) { struct popup_item *ref=param; @@ -120,7 +121,8 @@ popup_set_position(struct popup_item *item, void *param) vehicle_set_position(popup->co->vehicle, &popup->c); } -void +#if 0 +static void popup_break_crossing(struct display_list *l) { struct segment *seg=(struct segment *)(l->data); @@ -134,15 +136,16 @@ popup_break_crossing(struct display_list *l) str->limit=0x33; log_write(log, seg->blk_inf.file, str, sizeof(*str)); } +#endif -void +static void popup_call_func(GtkObject *obj, void *parm) { struct popup_item *curr=parm; curr->func(curr, curr->param); } -GtkWidget * +static GtkWidget * popup_menu(struct popup_item *list) { int min_prio,curr_prio; @@ -175,7 +178,7 @@ popup_menu(struct popup_item *list) return menu; } -void +static void popup_display_list_default(struct display_list *d, struct popup_item **popup_list) { struct segment *seg; @@ -224,7 +227,7 @@ popup_display_list_default(struct display_list *d, struct popup_item **popup_lis } } -void +static void popup_display_list(struct container *co, struct popup *popup, struct popup_item **popup_list) { GtkWidget *menu, *item; @@ -243,7 +246,7 @@ popup_display_list(struct container *co, struct popup *popup, struct popup_item } } -void +static void popup_destroy_items(struct popup_item *item) { struct popup_item *next; @@ -259,7 +262,7 @@ popup_destroy_items(struct popup_item *item) } } -void +static void popup_destroy(GtkObject *obj, void *parm) { struct popup *popup=parm; -- cgit v1.2.1 From 47e10fe9ce9033d82472162b32b347e7cb1977ba Mon Sep 17 00:00:00 2001 From: horwitz Date: Thu, 15 Dec 2005 21:18:29 +0000 Subject: remove deprecated gtk stuff git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@34 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index c61c5d34..af9c01c0 100644 --- a/popup.c +++ b/popup.c @@ -165,8 +165,8 @@ popup_menu(struct popup_item *list) submenu=popup_menu(curr->submenu); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); } else if (curr->func) { - gtk_signal_connect(GTK_OBJECT(item), "activate", - GTK_SIGNAL_FUNC (popup_call_func), curr); + g_signal_connect(G_OBJECT(item), "activate", + G_CALLBACK (popup_call_func), curr); } } if (curr->priority > curr_prio && curr->priority < min_prio) @@ -303,7 +303,7 @@ popup(struct container *co, int x, int y, int button) gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, button, gtk_get_current_event_time()); - gtk_signal_connect(GTK_OBJECT(menu), "selection-done", GTK_SIGNAL_FUNC (popup_destroy), popup); + g_signal_connect(G_OBJECT(menu), "selection-done", G_CALLBACK (popup_destroy), popup); } -- cgit v1.2.1 From 09971fecdc51d82b58d1e4c4fa4702348bb9dc6f Mon Sep 17 00:00:00 2001 From: martin-s Date: Sun, 1 Jan 2006 16:33:20 +0000 Subject: Also display native coordinates in popup menu git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@45 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 1 + 1 file changed, 1 insertion(+) (limited to 'popup.c') diff --git a/popup.c b/popup.c index af9c01c0..cec4d601 100644 --- a/popup.c +++ b/popup.c @@ -290,6 +290,7 @@ popup(struct container *co, int x, int y, int button) transform_lng_lat(&popup->c, &g); strcpy(buffer,"Map Point "); transform_geo_text(&g, buffer+strlen(buffer)); + sprintf(buffer+strlen(buffer), " (0x%x,0x%x)", popup->c.x, popup->c.y); descr=popup_item_new_text(&list,buffer, 0); descr->param=popup; -- cgit v1.2.1 From 1226f5d4a7856cd3aad90fb7e10990669c53847e Mon Sep 17 00:00:00 2001 From: martin-s Date: Sun, 1 Jan 2006 23:11:16 +0000 Subject: First try on tracking git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@49 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index cec4d601..b55ed86a 100644 --- a/popup.c +++ b/popup.c @@ -290,7 +290,7 @@ popup(struct container *co, int x, int y, int button) transform_lng_lat(&popup->c, &g); strcpy(buffer,"Map Point "); transform_geo_text(&g, buffer+strlen(buffer)); - sprintf(buffer+strlen(buffer), " (0x%x,0x%x)", popup->c.x, popup->c.y); + sprintf(buffer+strlen(buffer), " (0x%lx,0x%lx)", popup->c.x, popup->c.y); descr=popup_item_new_text(&list,buffer, 0); descr->param=popup; -- cgit v1.2.1 From 1413848bc67a5bcbfafbd91b103fd5566808e1b6 Mon Sep 17 00:00:00 2001 From: martin-s Date: Tue, 3 Jan 2006 21:37:48 +0000 Subject: Converting speech.c to new speechd api git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@55 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 1 + 1 file changed, 1 insertion(+) (limited to 'popup.c') diff --git a/popup.c b/popup.c index b55ed86a..6aaaef24 100644 --- a/popup.c +++ b/popup.c @@ -118,6 +118,7 @@ popup_set_position(struct popup_item *item, void *param) struct popup_item *ref=param; struct popup *popup=ref->param; printf("Position %s\n", ref->text); + g_assert(popup->co->vehicle != NULL); vehicle_set_position(popup->co->vehicle, &popup->c); } -- cgit v1.2.1 From c695377efc4881279211c6e19115e09739c503fa Mon Sep 17 00:00:00 2001 From: horwitz Date: Tue, 3 Jan 2006 22:20:09 +0000 Subject: improve memory allocation und fix some warnings git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@57 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 6aaaef24..5c3b8bf9 100644 --- a/popup.c +++ b/popup.c @@ -32,8 +32,7 @@ struct popup_item * popup_item_new_text(struct popup_item **last, char *text, int priority) { struct popup_item *curr; - curr=g_new(struct popup_item,1); - memset(curr, 0, sizeof(*curr)); + curr=g_new0(struct popup_item,1); curr->text=g_strdup(text); curr->priority=priority; curr->destroy=popup_item_destroy_text; -- cgit v1.2.1 From b8bfdaae035a95e7fbcccc7782a7a906195b9bc9 Mon Sep 17 00:00:00 2001 From: horwitz Date: Thu, 5 Jan 2006 01:01:45 +0000 Subject: remove more mallocs and frees git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@61 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 5c3b8bf9..bf6fea08 100644 --- a/popup.c +++ b/popup.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -61,19 +60,20 @@ param_to_menu_new(char *name,struct param_list *plist, int c, int iso) ret=popup_item_new_text(NULL,name,1); last=NULL; for (i = 0 ; i < c ; i++) { - char name_buffer[strlen(plist[i].name)+strlen(plist[i].value)+2]; - char *text=name_buffer; + char *name_buffer = g_strjoin(":",plist[i].name, plist[i].value,NULL); + char *text = name_buffer; - sprintf(name_buffer,"%s:%s", plist[i].name, plist[i].value); if (iso) { text=g_convert(name_buffer,-1,"utf-8","iso8859-1",NULL,NULL,NULL); if (! text) { printf("problem converting '%s'\n", name_buffer); } } - curr=popup_item_new_text(&last, text, i); + curr=popup_item_new_text(&last,text,i); if (iso) - free(text); + g_free(text); + g_free(name_buffer); + } ret->submenu=last; return ret; @@ -194,17 +194,14 @@ popup_display_list_default(struct display_list *d, struct popup_item **popup_lis if (d->type == 4) desc="Point"; seg=(struct segment *)(d->data); if (seg) { - if (d->label && strlen(d->label)) { - item_text=malloc(strlen(desc)+strlen(d->label)+2); - strcpy(item_text, desc); - strcat(item_text," "); - strcat(item_text, d->label); - } else { - item_text=desc; - } + if (d->label && strlen(d->label)) + item_text=g_strjoin(" ",desc,d->label,NULL); + else + item_text=g_strdup(desc); text=g_convert(item_text,-1,"utf-8","iso8859-1",NULL,NULL,NULL); curr_item=popup_item_new_text(popup_list,text,1); g_free(text); + g_free(item_text); curr_item->submenu=param_to_menu_new("File", plist, file_get_param(seg->blk_inf.file, plist, 100), 1); submenu=curr_item->submenu; -- cgit v1.2.1 From d71e49df9261a6968e7ffab33c6306914ac1d1c0 Mon Sep 17 00:00:00 2001 From: martin-s Date: Wed, 4 Jul 2007 22:44:46 +0000 Subject: Merge with modular_map git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@255 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 374 +++++++++++++++++++++++++--------------------------------------- 1 file changed, 144 insertions(+), 230 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index bf6fea08..4d1c812b 100644 --- a/popup.c +++ b/popup.c @@ -1,87 +1,28 @@ -#include +#include #include -#include -#include -#include "coord.h" -#include "file.h" -#include "map_data.h" -#include "block.h" -#include "display.h" -#include "town.h" -#include "street.h" -#include "poly.h" -#include "log.h" +#include +#include +#include +#include #include "popup.h" -#include "plugin.h" -#include "vehicle.h" -#include "route.h" -#include "cursor.h" -#include "statusbar.h" -#include "container.h" +#include "debug.h" +#include "navit.h" +#include "coord.h" +#include "gui.h" +#include "menu.h" +#include "point.h" +#include "transform.h" +#include "projection.h" +#include "map.h" #include "graphics.h" +#include "item.h" +#include "route.h" -static void -popup_item_destroy_text(struct popup_item *item) -{ - g_free(item->text); - g_free(item); -} - -struct popup_item * -popup_item_new_text(struct popup_item **last, char *text, int priority) -{ - struct popup_item *curr; - curr=g_new0(struct popup_item,1); - curr->text=g_strdup(text); - curr->priority=priority; - curr->destroy=popup_item_destroy_text; - if (last) { - curr->next=*last; - *last=curr; - } - return curr; -} - -static struct popup_item * -popup_item_new_func(struct popup_item **last, char *text, int priority, void (*func)(struct popup_item *, void *), void *param) -{ - struct popup_item *curr=popup_item_new_text(last, text, priority); - curr->func=func; - curr->param=param; - return curr; -} - -static struct popup_item * -param_to_menu_new(char *name,struct param_list *plist, int c, int iso) -{ - struct popup_item *last, *curr, *ret; - int i; - - ret=popup_item_new_text(NULL,name,1); - last=NULL; - for (i = 0 ; i < c ; i++) { - char *name_buffer = g_strjoin(":",plist[i].name, plist[i].value,NULL); - char *text = name_buffer; - - if (iso) { - text=g_convert(name_buffer,-1,"utf-8","iso8859-1",NULL,NULL,NULL); - if (! text) { - printf("problem converting '%s'\n", name_buffer); - } - } - curr=popup_item_new_text(&last,text,i); - if (iso) - g_free(text); - g_free(name_buffer); - - } - ret->submenu=last; - return ret; -} - +#if 0 static void popup_set_no_passing(struct popup_item *item, void *param) { +#if 0 struct display_list *l=param; struct segment *seg=(struct segment *)(l->data); struct street_str *str=(struct street_str *)(seg->data[0]); @@ -93,32 +34,36 @@ popup_set_no_passing(struct popup_item *item, void *param) sprintf(log,"Attributes Street 0x%x updated: limit=0x%x(0x%x)", segid, 0x33, str->limit); str->limit=0x33; log_write(log, seg->blk_inf.file, str, sizeof(*str)); +#endif } +#endif + static void -popup_set_destination(struct popup_item *item, void *param) +popup_set_destination(struct menu *menu, void *data1, void *data2) { - struct popup_item *ref=param; - struct popup *popup=ref->param; - struct container *co=popup->co; - printf("Destination %s\n", ref->text); - route_set_position(co->route, cursor_pos_get(co->cursor)); - route_set_destination(co->route, &popup->c); - graphics_redraw(popup->co); - if (co->statusbar && co->statusbar->statusbar_route_update) - co->statusbar->statusbar_route_update(co->statusbar, co->route); + struct navit *nav=data1; + struct coord *c=data2; + struct route *route; + struct coord_geo g; + char buffer[1024]; + char buffer_geo[1024]; + transform_to_geo(transform_get_projection(navit_get_trans(nav)), c, &g); + transform_geo_text(&g, buffer_geo); + sprintf(buffer,"Map Point %s", buffer_geo); + navit_set_destination(nav, c, buffer); } + extern void *vehicle; static void -popup_set_position(struct popup_item *item, void *param) +popup_set_position(struct menu *menu, void *data1, void *data2) { - struct popup_item *ref=param; - struct popup *popup=ref->param; - printf("Position %s\n", ref->text); - g_assert(popup->co->vehicle != NULL); - vehicle_set_position(popup->co->vehicle, &popup->c); + struct navit *nav=data1; + struct coord *c=data2; + dbg(0,"%p %p\n", nav, c); + navit_set_position(nav, c); } #if 0 @@ -138,170 +83,139 @@ popup_break_crossing(struct display_list *l) } #endif -static void -popup_call_func(GtkObject *obj, void *parm) + +#define popup_printf(menu, type, fmt...) popup_printf_cb(menu, type, NULL, NULL, NULL, fmt) + +static void * +popup_printf_cb(void *menu, enum menu_type type, void (*callback)(struct menu *menu, void *data1, void *data2), void *data1, void *data2, const char *fmt, ...) { - struct popup_item *curr=parm; - curr->func(curr, curr->param); + gchar *str; + va_list ap; + void *ret; + + va_start(ap, fmt); + str=g_strdup_vprintf(fmt, ap); + dbg(0,"%s\n", str); + ret=menu_add(menu, str, type, callback, data1, data2); + va_end(ap); + g_free(str); + return ret; } -static GtkWidget * -popup_menu(struct popup_item *list) +static void +popup_show_attr_val(void *menu, struct attr *attr) { - int min_prio,curr_prio; - struct popup_item *curr; - GtkWidget *item,*menu,*submenu; + char *attr_name=attr_to_name(attr->type); - curr_prio=0; - menu=gtk_menu_new(); - do { - min_prio=INT_MAX; - curr=list; - while (curr) { - if (curr->priority == curr_prio) { - item=gtk_menu_item_new_with_label(curr->text); - gtk_menu_append(GTK_MENU(menu), item); - if (curr->submenu) { - submenu=popup_menu(curr->submenu); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); - } else if (curr->func) { - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK (popup_call_func), curr); - } - } - if (curr->priority > curr_prio && curr->priority < min_prio) - min_prio=curr->priority; - curr=curr->next; - } - curr_prio=min_prio; - } while (min_prio != INT_MAX); - return menu; + if (attr->type == attr_limit) + popup_printf(menu, menu_type_menu, "%s: %d", attr_name, attr->u.num); + else + popup_printf(menu, menu_type_menu, "%s: %s", attr_name, attr->u.str); } +#if 0 static void -popup_display_list_default(struct display_list *d, struct popup_item **popup_list) +popup_show_attr(void *menu, struct item *item, enum attr_type attr_type) { - struct segment *seg; - char *desc,*text,*item_text; - struct popup_item *curr_item,*submenu; - struct param_list plist[100]; - - desc=NULL; - if (d->type == 0) desc="Polygon"; - if (d->type == 1) desc="Polyline"; - if (d->type == 2) desc="Street"; - if (d->type == 3) desc="Label"; - if (d->type == 4) desc="Point"; - seg=(struct segment *)(d->data); - if (seg) { - if (d->label && strlen(d->label)) - item_text=g_strjoin(" ",desc,d->label,NULL); - else - item_text=g_strdup(desc); - text=g_convert(item_text,-1,"utf-8","iso8859-1",NULL,NULL,NULL); - curr_item=popup_item_new_text(popup_list,text,1); - g_free(text); - g_free(item_text); - - curr_item->submenu=param_to_menu_new("File", plist, file_get_param(seg->blk_inf.file, plist, 100), 1); - submenu=curr_item->submenu; - submenu->next=param_to_menu_new("Block", plist, block_get_param(&seg->blk_inf, plist, 100), 1); - submenu=submenu->next; - - if (d->type == 0 || d->type == 1) { - submenu->next=param_to_menu_new(desc, plist, poly_get_param(seg, plist, 100), 1); - } - if (d->type == 2) { - submenu->next=param_to_menu_new(desc, plist, street_get_param(seg, plist, 100, 1), 1); - popup_item_new_func(&submenu->next,"Set no passing", 1000, popup_set_no_passing, d); - } - if (d->type == 3) { - submenu->next=param_to_menu_new(desc, plist, town_get_param(seg, plist, 100), 1); - } - if (d->type == 4) { - submenu->next=param_to_menu_new(desc, plist, street_bti_get_param(seg, plist, 100), 1); - } - } + struct attr attr; + memset(&attr, 0, sizeof(attr)); + attr.type=attr_type; + if (item_attr_get(item, attr_type, &attr)) + popup_show_attr_val(menu, &attr); } +#endif static void -popup_display_list(struct container *co, struct popup *popup, struct popup_item **popup_list) +popup_show_attrs(void *menu, struct item *item) { - GtkWidget *menu, *item; - struct display_list *list[100],**p=list; - - menu=gtk_menu_new(); - item=gtk_menu_item_new_with_label("Selection"); - gtk_menu_append (GTK_MENU(menu), item); - display_find(&popup->pnt, co->disp, display_end, 3, list, 100); - while (*p) { - if (! (*p)->info) - popup_display_list_default(*p, popup_list); +#if 0 + popup_show_attr(menu, item, attr_debug); + popup_show_attr(menu, item, attr_address); + popup_show_attr(menu, item, attr_phone); + popup_show_attr(menu, item, attr_phone); + popup_show_attr(menu, item, attr_entry_fee); + popup_show_attr(menu, item, attr_open_hours); +#else + struct attr attr; + for (;;) { + memset(&attr, 0, sizeof(attr)); + if (item_attr_get(item, attr_any, &attr)) + popup_show_attr_val(menu, &attr); else - (*(*p)->info)(*p, popup_list); - p++; - } + break; + } + +#endif } static void -popup_destroy_items(struct popup_item *item) +popup_show_item(void *popup, struct displayitem *di) { - struct popup_item *next; - while (item) { - if (item->active && item->func) - item->func(item, item->param); - if (item->submenu) - popup_destroy_items(item->submenu); - next=item->next; - assert(item->destroy != NULL); - item->destroy(item); - item=next; + struct map_rect *mr; + void *menu, *menu_map, *menu_item; + char *label; + struct item *item; + + label=graphics_displayitem_get_label(di); + item=graphics_displayitem_get_item(di); + + if (label) + menu=popup_printf(popup, menu_type_submenu, "%s '%s'", item_to_name(item->type), label); + else + menu=popup_printf(popup, menu_type_submenu, "%s", item_to_name(item->type)); + menu_item=popup_printf(menu, menu_type_submenu, "Item"); + popup_printf(menu_item, menu_type_menu, "type: 0x%x", item->type); + popup_printf(menu_item, menu_type_menu, "id: 0x%x 0x%x", item->id_hi, item->id_lo); + if (item->map) { + mr=map_rect_new(item->map,NULL); + item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo); + dbg(1,"item=%p\n", item); + if (item) { + popup_show_attrs(menu_item, item); + } + map_rect_destroy(mr); + menu_map=popup_printf(menu, menu_type_submenu, "Map"); + } else { + popup_printf(menu, menu_type_menu, "(No map)"); } } static void -popup_destroy(GtkObject *obj, void *parm) +popup_display(struct navit *nav, void *popup, struct point *p) { - struct popup *popup=parm; - - popup_destroy_items(popup->items); - g_free(popup); + struct displaylist_handle *dlh; + struct displaylist *display; + struct displayitem *di; + + display=navit_get_displaylist(nav); + dlh=graphics_displaylist_open(display); + while ((di=graphics_displaylist_next(dlh))) { + if (graphics_displayitem_within_dist(di, p, 5)) { + popup_show_item(popup, di); + } + } + graphics_displaylist_close(dlh); } +struct coord c; + void -popup(struct container *co, int x, int y, int button) +popup(struct navit *nav, int button, struct point *p) { - GtkWidget *menu; - struct popup *popup=g_new(struct popup,1); - struct popup_item *list=NULL; - struct popup_item *descr; + void *popup,*men; + char buffer[1024]; struct coord_geo g; - char buffer[256]; - - popup->co=co; - popup->pnt.x=x; - popup->pnt.y=y; - transform_reverse(co->trans, &popup->pnt, &popup->c); - popup_display_list(co, popup, &list); - plugin_call_popup(co, popup, &list); - transform_lng_lat(&popup->c, &g); - strcpy(buffer,"Map Point "); - transform_geo_text(&g, buffer+strlen(buffer)); - sprintf(buffer+strlen(buffer), " (0x%lx,0x%lx)", popup->c.x, popup->c.y); - descr=popup_item_new_text(&list,buffer, 0); - descr->param=popup; - - popup_item_new_func(&list,"Set as Position", 1000, popup_set_position, descr); - popup_item_new_func(&list,"Set as Destination", 1001, popup_set_destination, descr); - - popup->items=list; - menu=popup_menu(list); - gtk_widget_show_all(menu); - popup->gui_data=menu; - - gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, button, gtk_get_current_event_time()); - g_signal_connect(G_OBJECT(menu), "selection-done", G_CALLBACK (popup_destroy), popup); + popup=gui_popup_new(navit_get_gui(nav)); + transform_reverse(navit_get_trans(nav), p, &c); + men=popup_printf(popup, menu_type_submenu, "Point 0x%x 0x%x", c.x, c.y); + popup_printf(men, menu_type_menu, "Screen %d %d", p->x, p->y); + transform_to_geo(transform_get_projection(navit_get_trans(nav)), &c, &g); + transform_geo_text(&g, buffer); + popup_printf(men, menu_type_menu, "%s", buffer); + popup_printf(men, menu_type_menu, "%f %f", g.lat, g.lng); + dbg(0,"%p %p\n", nav, &c); + popup_printf_cb(men, menu_type_menu, popup_set_position, nav, &c, "Set as position"); + popup_printf_cb(men, menu_type_menu, popup_set_destination, nav, &c, "Set as destination"); + popup_display(nav, popup, p); } - - -- cgit v1.2.1 From 487206aca8befedf1c8f8a8be9fff20d9f26c65f Mon Sep 17 00:00:00 2001 From: horwitz Date: Thu, 5 Jul 2007 20:44:00 +0000 Subject: Fix some warnings git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@263 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 1 - 1 file changed, 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 4d1c812b..4ce4b0f6 100644 --- a/popup.c +++ b/popup.c @@ -44,7 +44,6 @@ popup_set_destination(struct menu *menu, void *data1, void *data2) { struct navit *nav=data1; struct coord *c=data2; - struct route *route; struct coord_geo g; char buffer[1024]; char buffer_geo[1024]; -- cgit v1.2.1 From 870dad30241777638455c2c1e4b438457294b538 Mon Sep 17 00:00:00 2001 From: martin-s Date: Mon, 9 Jul 2007 22:18:31 +0000 Subject: Support of bookmars, improvement in navigation git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@289 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 4ce4b0f6..9357b8ec 100644 --- a/popup.c +++ b/popup.c @@ -53,6 +53,20 @@ popup_set_destination(struct menu *menu, void *data1, void *data2) navit_set_destination(nav, c, buffer); } +static void +popup_set_bookmark(struct menu *menu, void *data1, void *data2) +{ + struct navit *nav=data1; + struct coord *c=data2; + struct coord_geo g; + char buffer[1024]; + char buffer_geo[1024]; + transform_to_geo(transform_get_projection(navit_get_trans(nav)), c, &g); + transform_geo_text(&g, buffer_geo); + sprintf(buffer,"Map Point %s", buffer_geo); + navit_add_bookmark(nav, c, buffer); +} + extern void *vehicle; @@ -106,6 +120,7 @@ popup_show_attr_val(void *menu, struct attr *attr) { char *attr_name=attr_to_name(attr->type); + printf("attr\n"); if (attr->type == attr_limit) popup_printf(menu, menu_type_menu, "%s: %d", attr_name, attr->u.num); else @@ -216,5 +231,6 @@ popup(struct navit *nav, int button, struct point *p) dbg(0,"%p %p\n", nav, &c); popup_printf_cb(men, menu_type_menu, popup_set_position, nav, &c, "Set as position"); popup_printf_cb(men, menu_type_menu, popup_set_destination, nav, &c, "Set as destination"); + popup_printf_cb(men, menu_type_menu, popup_set_bookmark, nav, &c, "Add as bookmark"); popup_display(nav, popup, p); } -- cgit v1.2.1 From 5f604527929ed18dc85a39c0889ebb68a02c9ad0 Mon Sep 17 00:00:00 2001 From: martin-s Date: Fri, 13 Jul 2007 11:48:12 +0000 Subject: Improved bookmark support git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@333 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 9357b8ec..c549f23c 100644 --- a/popup.c +++ b/popup.c @@ -64,7 +64,8 @@ popup_set_bookmark(struct menu *menu, void *data1, void *data2) transform_to_geo(transform_get_projection(navit_get_trans(nav)), c, &g); transform_geo_text(&g, buffer_geo); sprintf(buffer,"Map Point %s", buffer_geo); - navit_add_bookmark(nav, c, buffer); + if (!gui_add_bookmark(navit_get_gui(nav), c, buffer)) + navit_add_bookmark(nav, c, buffer); } -- cgit v1.2.1 From 46308ae891b489d51b281d28a2794a9961c7fc48 Mon Sep 17 00:00:00 2001 From: martin-s Date: Sat, 11 Aug 2007 21:58:18 +0000 Subject: Fixed some Bugs in poi_geodownload git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@386 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 1 - 1 file changed, 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index c549f23c..cc532b71 100644 --- a/popup.c +++ b/popup.c @@ -121,7 +121,6 @@ popup_show_attr_val(void *menu, struct attr *attr) { char *attr_name=attr_to_name(attr->type); - printf("attr\n"); if (attr->type == attr_limit) popup_printf(menu, menu_type_menu, "%s: %d", attr_name, attr->u.num); else -- cgit v1.2.1 From 146f3568d0f7519475aeb5b029fdc7d2f984f044 Mon Sep 17 00:00:00 2001 From: martin-s Date: Mon, 5 Nov 2007 09:22:05 +0000 Subject: Added support for getting country id from a street git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@516 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index cc532b71..2ae09cc7 100644 --- a/popup.c +++ b/popup.c @@ -121,7 +121,7 @@ popup_show_attr_val(void *menu, struct attr *attr) { char *attr_name=attr_to_name(attr->type); - if (attr->type == attr_limit) + if (attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end) popup_printf(menu, menu_type_menu, "%s: %d", attr_name, attr->u.num); else popup_printf(menu, menu_type_menu, "%s: %s", attr_name, attr->u.str); -- cgit v1.2.1 From 474a7c2e582b20f1fa1f41571d99a6a527e787d4 Mon Sep 17 00:00:00 2001 From: zaxl Date: Mon, 19 Nov 2007 11:41:04 +0000 Subject: make popup coordinate static git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@567 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 2ae09cc7..38572a4b 100644 --- a/popup.c +++ b/popup.c @@ -211,7 +211,7 @@ popup_display(struct navit *nav, void *popup, struct point *p) graphics_displaylist_close(dlh); } -struct coord c; +static struct coord c; void popup(struct navit *nav, int button, struct point *p) -- cgit v1.2.1 From 01e6907fbe9a5395a7040a051281830e690a41bf Mon Sep 17 00:00:00 2001 From: zaxl Date: Mon, 19 Nov 2007 19:58:19 +0000 Subject: Create struct pcoord containing the projection. Use it to propagate destinations/positions to route code. Use it to create the navit's instance. Use it in search structs so when you have the targets coordinates you know what projection they are. - SDL have to be fixed, GTK uses coordinates for lists data, SDL not. Fix memory leak when using route_rect, it allocates map_selection but users didn't free it. search_list_town/search_list_streets allocate the coordinate but do not free it - fixed. Store and read the projections in/from destinations.txt. git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@568 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 38572a4b..4566fb1f 100644 --- a/popup.c +++ b/popup.c @@ -43,14 +43,17 @@ static void popup_set_destination(struct menu *menu, void *data1, void *data2) { struct navit *nav=data1; - struct coord *c=data2; + struct pcoord *pc=data2; + struct coord c; struct coord_geo g; char buffer[1024]; char buffer_geo[1024]; - transform_to_geo(transform_get_projection(navit_get_trans(nav)), c, &g); + c.x = pc->x; + c.y = pc->y; + transform_to_geo(transform_get_projection(navit_get_trans(nav)), &c, &g); transform_geo_text(&g, buffer_geo); sprintf(buffer,"Map Point %s", buffer_geo); - navit_set_destination(nav, c, buffer); + navit_set_destination(nav, pc, buffer); } static void @@ -75,7 +78,7 @@ static void popup_set_position(struct menu *menu, void *data1, void *data2) { struct navit *nav=data1; - struct coord *c=data2; + struct pcoord *c=data2; dbg(0,"%p %p\n", nav, c); navit_set_position(nav, c); } @@ -211,7 +214,7 @@ popup_display(struct navit *nav, void *popup, struct point *p) graphics_displaylist_close(dlh); } -static struct coord c; +static struct pcoord c; void popup(struct navit *nav, int button, struct point *p) @@ -219,16 +222,20 @@ popup(struct navit *nav, int button, struct point *p) void *popup,*men; char buffer[1024]; struct coord_geo g; + struct coord co; popup=gui_popup_new(navit_get_gui(nav)); - transform_reverse(navit_get_trans(nav), p, &c); - men=popup_printf(popup, menu_type_submenu, "Point 0x%x 0x%x", c.x, c.y); + transform_reverse(navit_get_trans(nav), p, &co); + men=popup_printf(popup, menu_type_submenu, "Point 0x%x 0x%x", co.x, co.y); popup_printf(men, menu_type_menu, "Screen %d %d", p->x, p->y); - transform_to_geo(transform_get_projection(navit_get_trans(nav)), &c, &g); + transform_to_geo(transform_get_projection(navit_get_trans(nav)), &co, &g); transform_geo_text(&g, buffer); popup_printf(men, menu_type_menu, "%s", buffer); popup_printf(men, menu_type_menu, "%f %f", g.lat, g.lng); dbg(0,"%p %p\n", nav, &c); + c.pro = transform_get_projection(navit_get_trans(nav)); + c.x = co.x; + c.y = co.y; popup_printf_cb(men, menu_type_menu, popup_set_position, nav, &c, "Set as position"); popup_printf_cb(men, menu_type_menu, popup_set_destination, nav, &c, "Set as destination"); popup_printf_cb(men, menu_type_menu, popup_set_bookmark, nav, &c, "Add as bookmark"); -- cgit v1.2.1 From f63255ecd34afe5d329a4465d37d4c1a5540bddd Mon Sep 17 00:00:00 2001 From: zaxl Date: Sun, 25 Nov 2007 01:32:15 +0000 Subject: Fix bookmarks with projections, add /usr/X11R6/lib/X11/fonts/TTF to font path and check for luximbi.ttf, remove useless coord iterations from track and some shame from the code there git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@587 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 4566fb1f..4ab76d72 100644 --- a/popup.c +++ b/popup.c @@ -60,15 +60,18 @@ static void popup_set_bookmark(struct menu *menu, void *data1, void *data2) { struct navit *nav=data1; - struct coord *c=data2; + struct pcoord *pc=data2; + struct coord c; struct coord_geo g; char buffer[1024]; char buffer_geo[1024]; - transform_to_geo(transform_get_projection(navit_get_trans(nav)), c, &g); - transform_geo_text(&g, buffer_geo); + c.x = pc->x; + c.y = pc->y; + transform_to_geo(pc->pro, &c, &g); + transform_geo_text(&g, buffer_geo); sprintf(buffer,"Map Point %s", buffer_geo); - if (!gui_add_bookmark(navit_get_gui(nav), c, buffer)) - navit_add_bookmark(nav, c, buffer); + if (!gui_add_bookmark(navit_get_gui(nav), pc, buffer)) + navit_add_bookmark(nav, pc, buffer); } -- cgit v1.2.1 From 7e9929c49b7a1d50ece4b0d32f319458ebdc73e2 Mon Sep 17 00:00:00 2001 From: martin-s Date: Mon, 3 Dec 2007 13:17:19 +0000 Subject: Converted menu callbacks to new callback api git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@608 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 4ab76d72..d911679f 100644 --- a/popup.c +++ b/popup.c @@ -16,6 +16,7 @@ #include "map.h" #include "graphics.h" #include "item.h" +#include "callback.h" #include "route.h" #if 0 @@ -40,10 +41,8 @@ popup_set_no_passing(struct popup_item *item, void *param) #endif static void -popup_set_destination(struct menu *menu, void *data1, void *data2) +popup_set_destination(struct navit *nav, struct pcoord *pc) { - struct navit *nav=data1; - struct pcoord *pc=data2; struct coord c; struct coord_geo g; char buffer[1024]; @@ -57,10 +56,8 @@ popup_set_destination(struct menu *menu, void *data1, void *data2) } static void -popup_set_bookmark(struct menu *menu, void *data1, void *data2) +popup_set_bookmark(struct navit *nav, struct pcoord *pc) { - struct navit *nav=data1; - struct pcoord *pc=data2; struct coord c; struct coord_geo g; char buffer[1024]; @@ -78,12 +75,10 @@ popup_set_bookmark(struct menu *menu, void *data1, void *data2) extern void *vehicle; static void -popup_set_position(struct menu *menu, void *data1, void *data2) +popup_set_position(struct navit *nav, struct pcoord *pc) { - struct navit *nav=data1; - struct pcoord *c=data2; - dbg(0,"%p %p\n", nav, c); - navit_set_position(nav, c); + dbg(0,"%p %p\n", nav, pc); + navit_set_position(nav, pc); } #if 0 @@ -104,10 +99,10 @@ popup_break_crossing(struct display_list *l) #endif -#define popup_printf(menu, type, fmt...) popup_printf_cb(menu, type, NULL, NULL, NULL, fmt) +#define popup_printf(menu, type, fmt...) popup_printf_cb(menu, type, NULL, fmt) static void * -popup_printf_cb(void *menu, enum menu_type type, void (*callback)(struct menu *menu, void *data1, void *data2), void *data1, void *data2, const char *fmt, ...) +popup_printf_cb(void *menu, enum menu_type type, struct callback *cb, const char *fmt, ...) { gchar *str; va_list ap; @@ -116,7 +111,7 @@ popup_printf_cb(void *menu, enum menu_type type, void (*callback)(struct menu *m va_start(ap, fmt); str=g_strdup_vprintf(fmt, ap); dbg(0,"%s\n", str); - ret=menu_add(menu, str, type, callback, data1, data2); + ret=menu_add(menu, str, type, cb); va_end(ap); g_free(str); return ret; @@ -239,8 +234,8 @@ popup(struct navit *nav, int button, struct point *p) c.pro = transform_get_projection(navit_get_trans(nav)); c.x = co.x; c.y = co.y; - popup_printf_cb(men, menu_type_menu, popup_set_position, nav, &c, "Set as position"); - popup_printf_cb(men, menu_type_menu, popup_set_destination, nav, &c, "Set as destination"); - popup_printf_cb(men, menu_type_menu, popup_set_bookmark, nav, &c, "Add as bookmark"); + 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_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, &c), "Add as bookmark"); popup_display(nav, popup, p); } -- cgit v1.2.1 From 834a8afa4515062c38949eb993f28b3a4e6ec688 Mon Sep 17 00:00:00 2001 From: martin-s Date: Tue, 18 Dec 2007 12:07:41 +0000 Subject: Improved i18n git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@645 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index d911679f..812ed3e3 100644 --- a/popup.c +++ b/popup.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "popup.h" #include "debug.h" @@ -19,6 +20,7 @@ #include "callback.h" #include "route.h" +#define _(STRING) gettext(STRING) #if 0 static void popup_set_no_passing(struct popup_item *item, void *param) @@ -224,8 +226,8 @@ popup(struct navit *nav, int button, struct point *p) popup=gui_popup_new(navit_get_gui(nav)); transform_reverse(navit_get_trans(nav), p, &co); - men=popup_printf(popup, menu_type_submenu, "Point 0x%x 0x%x", co.x, co.y); - popup_printf(men, menu_type_menu, "Screen %d %d", p->x, p->y); + men=popup_printf(popup, menu_type_submenu, _("Point 0x%x 0x%x"), co.x, co.y); + popup_printf(men, menu_type_menu, _("Screen %d %d"), p->x, p->y); transform_to_geo(transform_get_projection(navit_get_trans(nav)), &co, &g); transform_geo_text(&g, buffer); popup_printf(men, menu_type_menu, "%s", buffer); @@ -234,8 +236,8 @@ popup(struct navit *nav, int button, struct point *p) c.pro = transform_get_projection(navit_get_trans(nav)); c.x = co.x; 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_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, &c), "Add as bookmark"); + 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_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, &c), _("Add as bookmark")); popup_display(nav, popup, p); } -- cgit v1.2.1 From b891672324ba28b6baadad5cc91b76890b947ec3 Mon Sep 17 00:00:00 2001 From: martin-s Date: Wed, 26 Dec 2007 10:39:48 +0000 Subject: Add:Core:Support for position_coord_geo parsing git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@670 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 812ed3e3..69b1b6b6 100644 --- a/popup.c +++ b/popup.c @@ -120,14 +120,18 @@ popup_printf_cb(void *menu, enum menu_type type, struct callback *cb, const char } static void -popup_show_attr_val(void *menu, struct attr *attr) +popup_show_attr_val(struct map *map, void *menu, struct attr *attr) { char *attr_name=attr_to_name(attr->type); + char *str; if (attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end) popup_printf(menu, menu_type_menu, "%s: %d", attr_name, attr->u.num); - else - popup_printf(menu, menu_type_menu, "%s: %s", attr_name, attr->u.str); + else { + str=map_convert_string(map, attr->u.str); + popup_printf(menu, menu_type_menu, "%s: %s", attr_name, str); + map_convert_free(str); + } } #if 0 @@ -143,7 +147,7 @@ popup_show_attr(void *menu, struct item *item, enum attr_type attr_type) #endif static void -popup_show_attrs(void *menu, struct item *item) +popup_show_attrs(struct map *map, void *menu, struct item *item) { #if 0 popup_show_attr(menu, item, attr_debug); @@ -157,7 +161,7 @@ popup_show_attrs(void *menu, struct item *item) for (;;) { memset(&attr, 0, sizeof(attr)); if (item_attr_get(item, attr_any, &attr)) - popup_show_attr_val(menu, &attr); + popup_show_attr_val(map, menu, &attr); else break; } @@ -188,7 +192,7 @@ popup_show_item(void *popup, struct displayitem *di) item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo); dbg(1,"item=%p\n", item); if (item) { - popup_show_attrs(menu_item, item); + popup_show_attrs(item->map, menu_item, item); } map_rect_destroy(mr); menu_map=popup_printf(menu, menu_type_submenu, "Map"); -- cgit v1.2.1 From 60dee80cd5b027ca7f5cb53f97bf34f238f6f950 Mon Sep 17 00:00:00 2001 From: martin-s Date: Sat, 5 Jan 2008 20:04:22 +0000 Subject: Fix:Core:Changed navigation to provide a map git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@720 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 69b1b6b6..026ee35b 100644 --- a/popup.c +++ b/popup.c @@ -125,13 +125,9 @@ popup_show_attr_val(struct map *map, void *menu, struct attr *attr) char *attr_name=attr_to_name(attr->type); char *str; - if (attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end) - popup_printf(menu, menu_type_menu, "%s: %d", attr_name, attr->u.num); - else { - str=map_convert_string(map, attr->u.str); - popup_printf(menu, menu_type_menu, "%s: %s", attr_name, str); - map_convert_free(str); - } + str=attr_to_text(attr, map, 1); + popup_printf(menu, menu_type_menu, "%s: %s", attr_name, str); + g_free(str); } #if 0 -- cgit v1.2.1 From 7d580f16622046d906319d30bd664c7c0df7cab0 Mon Sep 17 00:00:00 2001 From: afaber Date: Mon, 7 Jan 2008 23:15:41 +0000 Subject: win32 patches git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@735 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 026ee35b..be4738e8 100644 --- a/popup.c +++ b/popup.c @@ -240,4 +240,10 @@ popup(struct navit *nav, int button, struct point *p) popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, &c), _("Set as destination")); 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); +#ifdef _WIN32 + // menu needs first to be constructed before doing the menu popup + // therefore this work around for win32 + // needs to be fixed + popup=gui_popup_new(navit_get_gui(nav)); +#endif } -- cgit v1.2.1 From 60b14cf45fb6bca03b1f4c04cf8da31cad94b157 Mon Sep 17 00:00:00 2001 From: martin-s Date: Sun, 13 Jan 2008 11:29:06 +0000 Subject: Fix:Core:Improved popup handling git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@760 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index be4738e8..cba5250c 100644 --- a/popup.c +++ b/popup.c @@ -240,10 +240,5 @@ popup(struct navit *nav, int button, struct point *p) popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, &c), _("Set as destination")); 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); -#ifdef _WIN32 - // menu needs first to be constructed before doing the menu popup - // therefore this work around for win32 - // needs to be fixed - popup=gui_popup_new(navit_get_gui(nav)); -#endif + menu_popup(popup); } -- cgit v1.2.1 From c8f1919902aa8306fc813f5107c5365e3411e76c Mon Sep 17 00:00:00 2001 From: kazer_ Date: Fri, 25 Jan 2008 16:15:44 +0000 Subject: Add:Translations:Made the popup coordinate text more meaningful for translations git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@812 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index cba5250c..3f9f4bb1 100644 --- a/popup.c +++ b/popup.c @@ -227,7 +227,7 @@ popup(struct navit *nav, int button, struct point *p) popup=gui_popup_new(navit_get_gui(nav)); transform_reverse(navit_get_trans(nav), p, &co); men=popup_printf(popup, menu_type_submenu, _("Point 0x%x 0x%x"), co.x, co.y); - popup_printf(men, menu_type_menu, _("Screen %d %d"), p->x, p->y); + popup_printf(men, menu_type_menu, _("Screen coord : %d %d"), p->x, p->y); transform_to_geo(transform_get_projection(navit_get_trans(nav)), &co, &g); transform_geo_text(&g, buffer); popup_printf(men, menu_type_menu, "%s", buffer); -- cgit v1.2.1 From 5df6e66b1c9029b769e6eafcf274256c1bc4777f Mon Sep 17 00:00:00 2001 From: martin-s Date: Thu, 6 Mar 2008 19:24:30 +0000 Subject: Add:Core:New GUI internal git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@942 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 3f9f4bb1..2bbe36cf 100644 --- a/popup.c +++ b/popup.c @@ -225,6 +225,8 @@ popup(struct navit *nav, int button, struct point *p) struct coord co; popup=gui_popup_new(navit_get_gui(nav)); + if (! popup) + return; transform_reverse(navit_get_trans(nav), p, &co); men=popup_printf(popup, menu_type_submenu, _("Point 0x%x 0x%x"), co.x, co.y); popup_printf(men, menu_type_menu, _("Screen coord : %d %d"), p->x, p->y); -- cgit v1.2.1 From 496f8fbe05b59e37a4086abaf5e3543378bf6a43 Mon Sep 17 00:00:00 2001 From: martin-s Date: Sun, 20 Apr 2008 10:40:40 +0000 Subject: Fix:Core:More cleanups git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@1025 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 2bbe36cf..a9fe7129 100644 --- a/popup.c +++ b/popup.c @@ -166,7 +166,7 @@ popup_show_attrs(struct map *map, void *menu, struct item *item) } static void -popup_show_item(void *popup, struct displayitem *di) +popup_show_item(struct navit *nav, void *popup, struct displayitem *di) { struct map_rect *mr; void *menu, *menu_map, *menu_item; @@ -189,6 +189,19 @@ popup_show_item(void *popup, struct displayitem *di) dbg(1,"item=%p\n", item); if (item) { popup_show_attrs(item->map, menu_item, item); + if (item->type < type_line) { + struct coord co; + struct pcoord *c; + if (item_coord_get(item, &co, 1)) { + c=g_new(struct pcoord, 1); + c->pro = transform_get_projection(navit_get_trans(nav)); + c->x = co.x; + c->y = co.y; + popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_position), nav, c), _("Set as position")); + popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, c), _("Set as destination")); + popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, c), _("Add as bookmark")); + } + } } map_rect_destroy(mr); menu_map=popup_printf(menu, menu_type_submenu, "Map"); @@ -208,7 +221,7 @@ popup_display(struct navit *nav, void *popup, struct point *p) dlh=graphics_displaylist_open(display); while ((di=graphics_displaylist_next(dlh))) { if (graphics_displayitem_within_dist(di, p, 5)) { - popup_show_item(popup, di); + popup_show_item(nav, popup, di); } } graphics_displaylist_close(dlh); -- cgit v1.2.1 From cf57c17b71bf495f4048479c56f5db8fb6a47142 Mon Sep 17 00:00:00 2001 From: horwitz Date: Thu, 5 Jun 2008 21:56:14 +0000 Subject: Add license files and headers git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@1100 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'popup.c') diff --git a/popup.c b/popup.c index a9fe7129..444b5dfb 100644 --- a/popup.c +++ b/popup.c @@ -1,3 +1,22 @@ +/** + * Navit, a modular navigation system. + * Copyright (C) 2005-2008 Navit Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + #include #include #include -- cgit v1.2.1 From 988d650c73e74d53485d27a437e2161b20d05ab3 Mon Sep 17 00:00:00 2001 From: zaxl Date: Fri, 31 Oct 2008 20:12:34 +0000 Subject: FIX:build: Make --disable-nls and --with-included-gettext work. Add navit_nls.h which defines gettext wrappers, please, include navit_nls.h and do not include libintl.h directly. Fix Makefiles.ams to pass make distcheck git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@1624 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 444b5dfb..9ba18126 100644 --- a/popup.c +++ b/popup.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include "popup.h" #include "debug.h" @@ -38,8 +37,8 @@ #include "item.h" #include "callback.h" #include "route.h" +#include "navit_nls.h" -#define _(STRING) gettext(STRING) #if 0 static void popup_set_no_passing(struct popup_item *item, void *param) -- cgit v1.2.1 From 52ad2d1d9143a3f5f05002a4f6c25b98ae676a43 Mon Sep 17 00:00:00 2001 From: steven_s Date: Sun, 9 Nov 2008 16:13:30 +0000 Subject: Patch:core:Added geo coordinate formatting function that supports multiple formats | Replacing local geoformatting with calls to this function. git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@1709 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 9ba18126..16376057 100644 --- a/popup.c +++ b/popup.c @@ -70,7 +70,7 @@ popup_set_destination(struct navit *nav, struct pcoord *pc) c.x = pc->x; c.y = pc->y; transform_to_geo(transform_get_projection(navit_get_trans(nav)), &c, &g); - transform_geo_text(&g, buffer_geo); + coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer_geo,sizeof(buffer_geo)); sprintf(buffer,"Map Point %s", buffer_geo); navit_set_destination(nav, pc, buffer); } @@ -85,7 +85,7 @@ popup_set_bookmark(struct navit *nav, struct pcoord *pc) c.x = pc->x; c.y = pc->y; transform_to_geo(pc->pro, &c, &g); - transform_geo_text(&g, buffer_geo); + coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer_geo,sizeof(buffer_geo)); sprintf(buffer,"Map Point %s", buffer_geo); if (!gui_add_bookmark(navit_get_gui(nav), pc, buffer)) navit_add_bookmark(nav, pc, buffer); @@ -262,7 +262,7 @@ popup(struct navit *nav, int button, struct point *p) men=popup_printf(popup, menu_type_submenu, _("Point 0x%x 0x%x"), co.x, co.y); popup_printf(men, menu_type_menu, _("Screen coord : %d %d"), p->x, p->y); transform_to_geo(transform_get_projection(navit_get_trans(nav)), &co, &g); - transform_geo_text(&g, buffer); + coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer)); popup_printf(men, menu_type_menu, "%s", buffer); popup_printf(men, menu_type_menu, "%f %f", g.lat, g.lng); dbg(0,"%p %p\n", nav, &c); -- cgit v1.2.1 From 5f9260d76c786c0e54a69e50c946b5e79d89dbda Mon Sep 17 00:00:00 2001 From: martin-s Date: Fri, 12 Dec 2008 21:25:37 +0000 Subject: Fixed:Core:Improved map querying api git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@1785 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 16376057..0a694de5 100644 --- a/popup.c +++ b/popup.c @@ -32,9 +32,9 @@ #include "point.h" #include "transform.h" #include "projection.h" +#include "item.h" #include "map.h" #include "graphics.h" -#include "item.h" #include "callback.h" #include "route.h" #include "navit_nls.h" -- cgit v1.2.1 From c950029f58e6cb1e73ee1fce43984b5623b64fc5 Mon Sep 17 00:00:00 2001 From: tinloaf Date: Thu, 1 Jan 2009 20:07:14 +0000 Subject: Fix:Core:Adjust debug values for popup menus git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@1875 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 0a694de5..acef54d7 100644 --- a/popup.c +++ b/popup.c @@ -97,7 +97,7 @@ extern void *vehicle; static void popup_set_position(struct navit *nav, struct pcoord *pc) { - dbg(0,"%p %p\n", nav, pc); + dbg(1,"%p %p\n", nav, pc); navit_set_position(nav, pc); } @@ -130,7 +130,7 @@ popup_printf_cb(void *menu, enum menu_type type, struct callback *cb, const char va_start(ap, fmt); str=g_strdup_vprintf(fmt, ap); - dbg(0,"%s\n", str); + dbg(1,"%s\n", str); ret=menu_add(menu, str, type, cb); va_end(ap); g_free(str); @@ -265,7 +265,7 @@ popup(struct navit *nav, int button, struct point *p) coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer)); popup_printf(men, menu_type_menu, "%s", buffer); popup_printf(men, menu_type_menu, "%f %f", g.lat, g.lng); - dbg(0,"%p %p\n", nav, &c); + dbg(1,"%p %p\n", nav, &c); c.pro = transform_get_projection(navit_get_trans(nav)); c.x = co.x; c.y = co.y; -- cgit v1.2.1 From c2c4a675f334f01643350d62226970590c42db59 Mon Sep 17 00:00:00 2001 From: martin-s Date: Wed, 14 Jan 2009 13:14:40 +0000 Subject: Fix:core:Reverted popup debug change because of a massive slowdown git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@1946 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index acef54d7..b277988b 100644 --- a/popup.c +++ b/popup.c @@ -130,7 +130,7 @@ popup_printf_cb(void *menu, enum menu_type type, struct callback *cb, const char va_start(ap, fmt); str=g_strdup_vprintf(fmt, ap); - dbg(1,"%s\n", str); + dbg(0,"%s\n", str); ret=menu_add(menu, str, type, cb); va_end(ap); g_free(str); -- cgit v1.2.1 From 33a58b9afc103e81c550de699ce51ab7fc3ad577 Mon Sep 17 00:00:00 2001 From: martin-s Date: Mon, 26 Jan 2009 11:43:19 +0000 Subject: Add:Core:Made graphics rendering a background task to get better routing performance and avoid lagging git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@1971 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index b277988b..d58de405 100644 --- a/popup.c +++ b/popup.c @@ -238,7 +238,7 @@ popup_display(struct navit *nav, void *popup, struct point *p) display=navit_get_displaylist(nav); dlh=graphics_displaylist_open(display); while ((di=graphics_displaylist_next(dlh))) { - if (graphics_displayitem_within_dist(di, p, 5)) { + if (graphics_displayitem_within_dist(display, di, p, 5)) { popup_show_item(nav, popup, di); } } -- cgit v1.2.1 From 850bc3219497aaf48942ab2026b862b722a31e53 Mon Sep 17 00:00:00 2001 From: martin-s Date: Wed, 11 Mar 2009 09:48:48 +0000 Subject: Fix:Core:Double _ in popups to avoid it being mistaken for hotkey indication git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@2098 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index d58de405..0e6f5960 100644 --- a/popup.c +++ b/popup.c @@ -124,13 +124,33 @@ popup_break_crossing(struct display_list *l) static void * popup_printf_cb(void *menu, enum menu_type type, struct callback *cb, const char *fmt, ...) { - gchar *str; + gchar *str,*us; + int usc=0; va_list ap; void *ret; va_start(ap, fmt); str=g_strdup_vprintf(fmt, ap); dbg(0,"%s\n", str); + us=str; + while (*us) { + if (*us == '_') + usc++; + us++; + } + if (usc) { + gchar *str2=g_malloc(strlen(str)+us+1); + gchar *us2=str2; + us=str; + while (*us) { + if (*us == '_') + *us2++=*us; + *us2++=*us++; + } + *us2='\0'; + g_free(str); + str=str2; + } ret=menu_add(menu, str, type, cb); va_end(ap); g_free(str); -- cgit v1.2.1 From 03582c58ed29c1b25da1c8a388cb3cf4b5014ea6 Mon Sep 17 00:00:00 2001 From: horwitz Date: Mon, 27 Apr 2009 13:43:52 +0000 Subject: Fix:Core:Fix a typo which resulted in a warning git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@2238 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 0e6f5960..67f8ecd2 100644 --- a/popup.c +++ b/popup.c @@ -139,7 +139,7 @@ popup_printf_cb(void *menu, enum menu_type type, struct callback *cb, const char us++; } if (usc) { - gchar *str2=g_malloc(strlen(str)+us+1); + gchar *str2=g_malloc(strlen(str)+usc+1); gchar *us2=str2; us=str; while (*us) { -- cgit v1.2.1 From 3a42d77ab74312dd7c3f2cd08a944719f362b367 Mon Sep 17 00:00:00 2001 From: martin-s Date: Tue, 5 May 2009 18:42:04 +0000 Subject: Add:Core:Made routing optionally asynchronous git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@2254 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 67f8ecd2..1f347c18 100644 --- a/popup.c +++ b/popup.c @@ -72,7 +72,7 @@ popup_set_destination(struct navit *nav, struct pcoord *pc) transform_to_geo(transform_get_projection(navit_get_trans(nav)), &c, &g); coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer_geo,sizeof(buffer_geo)); sprintf(buffer,"Map Point %s", buffer_geo); - navit_set_destination(nav, pc, buffer); + navit_set_destination(nav, pc, buffer, 1); } static void -- cgit v1.2.1 From 8153206c611845f640f959e85bb6f30de5903744 Mon Sep 17 00:00:00 2001 From: martin-s Date: Wed, 3 Jun 2009 09:37:43 +0000 Subject: Add:Core:Experimental support for traffic distortions git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@2302 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 64 insertions(+), 10 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 1f347c18..d5c09f12 100644 --- a/popup.c +++ b/popup.c @@ -60,6 +60,44 @@ popup_set_no_passing(struct popup_item *item, void *param) #endif +static void +popup_traffic_distortion(struct item *item, char *attr) +{ + FILE *map=fopen("distortion.txt","a"); + struct coord c; + struct map_rect *mr; + fprintf(map,"type=traffic_distortion %s\n",attr); + mr=map_rect_new(item->map,NULL); + item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo); + while (item_coord_get(item, &c, 1)) { + fprintf(map,"0x%x 0x%x\n",c.x,c.y); + } + fclose(map); +} + +static void +popup_traffic_distortion_blocked(struct item *item) +{ + dbg(0,"item=%p\n",item); + popup_traffic_distortion(item, "maxspeed=0"); +} + +static void +popup_traffic_distortion_speed(struct item *item, int maxspeed) +{ + char buffer[256]; + sprintf(buffer,"maxspeed=%d",maxspeed); + popup_traffic_distortion(item,buffer); +} + +static void +popup_traffic_distortion_delay(struct item *item, int delay) +{ + char buffer[256]; + sprintf(buffer,"delay=%d",delay*600); + popup_traffic_distortion(item,buffer); +} + static void popup_set_destination(struct navit *nav, struct pcoord *pc) { @@ -207,23 +245,23 @@ static void popup_show_item(struct navit *nav, void *popup, struct displayitem *di) { struct map_rect *mr; - void *menu, *menu_map, *menu_item; + void *menu, *menu_map, *menu_item, *menu_dist; char *label; - struct item *item; + struct item *item,*diitem; label=graphics_displayitem_get_label(di); - item=graphics_displayitem_get_item(di); + diitem=graphics_displayitem_get_item(di); if (label) - menu=popup_printf(popup, menu_type_submenu, "%s '%s'", item_to_name(item->type), label); + menu=popup_printf(popup, menu_type_submenu, "%s '%s'", item_to_name(diitem->type), label); else - menu=popup_printf(popup, menu_type_submenu, "%s", item_to_name(item->type)); + menu=popup_printf(popup, menu_type_submenu, "%s", item_to_name(diitem->type)); menu_item=popup_printf(menu, menu_type_submenu, "Item"); - popup_printf(menu_item, menu_type_menu, "type: 0x%x", item->type); - popup_printf(menu_item, menu_type_menu, "id: 0x%x 0x%x", item->id_hi, item->id_lo); - if (item->map) { - mr=map_rect_new(item->map,NULL); - item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo); + popup_printf(menu_item, menu_type_menu, "type: 0x%x", diitem->type); + popup_printf(menu_item, menu_type_menu, "id: 0x%x 0x%x", diitem->id_hi, diitem->id_lo); + if (diitem->map) { + mr=map_rect_new(diitem->map,NULL); + item=map_rect_get_item_byid(mr, diitem->id_hi, diitem->id_lo); dbg(1,"item=%p\n", item); if (item) { popup_show_attrs(item->map, menu_item, item); @@ -246,6 +284,22 @@ popup_show_item(struct navit *nav, void *popup, struct displayitem *di) } else { popup_printf(menu, menu_type_menu, "(No map)"); } + if (diitem && item_get_default_flags(diitem->type)) { + int speeds[]={5,10,20,30,40,50,60,70,80,90,100}; + int delays[]={1,2,3,5,10,15,20,30,45,60,75,90,120,150,180,240,300}; + int i; + menu_dist=popup_printf(menu, menu_type_submenu, "Traffic distortion"); + popup_printf_cb(menu_dist, menu_type_menu, callback_new_1(callback_cast(popup_traffic_distortion_blocked), diitem), "Blocked"); + menu_item=popup_printf(menu_dist, menu_type_submenu,"Max speed"); + for (i = 0 ; i < sizeof(speeds)/sizeof(int); i++) { + popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_traffic_distortion_speed), diitem, speeds[i]), "%d km/h",speeds[i]); + } + menu_item=popup_printf(menu_dist, menu_type_submenu,"Delay"); + for (i = 0 ; i < sizeof(delays)/sizeof(int); i++) { + popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_traffic_distortion_delay), diitem, delays[i]*600), "%d min",delays[i]); + } + } + } static void -- cgit v1.2.1 From 082cb2828089b4201af34ea26b4c8e69316a9ca3 Mon Sep 17 00:00:00 2001 From: horwitz Date: Thu, 18 Jun 2009 10:21:52 +0000 Subject: Fix:Core:Fix coverity bug #37, Pointer 'diitem' dereferenced before NULL check. git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@2342 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index d5c09f12..2b8611d4 100644 --- a/popup.c +++ b/popup.c @@ -259,7 +259,7 @@ popup_show_item(struct navit *nav, void *popup, struct displayitem *di) menu_item=popup_printf(menu, menu_type_submenu, "Item"); popup_printf(menu_item, menu_type_menu, "type: 0x%x", diitem->type); popup_printf(menu_item, menu_type_menu, "id: 0x%x 0x%x", diitem->id_hi, diitem->id_lo); - if (diitem->map) { + if (diitem && diitem->map) { mr=map_rect_new(diitem->map,NULL); item=map_rect_get_item_byid(mr, diitem->id_hi, diitem->id_lo); dbg(1,"item=%p\n", item); -- cgit v1.2.1 From a0f28bf3c2fb5e31c02f966d350e5f45eed63626 Mon Sep 17 00:00:00 2001 From: horwitz Date: Thu, 18 Jun 2009 14:48:52 +0000 Subject: Fix:Core:Fix coverity bug #39, Pointer 'diitem' dereferenced before NULL check. git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@2346 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- popup.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'popup.c') diff --git a/popup.c b/popup.c index 2b8611d4..704ad7b1 100644 --- a/popup.c +++ b/popup.c @@ -252,6 +252,8 @@ popup_show_item(struct navit *nav, void *popup, struct displayitem *di) label=graphics_displayitem_get_label(di); diitem=graphics_displayitem_get_item(di); + dbg_assert(diitem); + if (label) menu=popup_printf(popup, menu_type_submenu, "%s '%s'", item_to_name(diitem->type), label); else @@ -259,7 +261,7 @@ popup_show_item(struct navit *nav, void *popup, struct displayitem *di) menu_item=popup_printf(menu, menu_type_submenu, "Item"); popup_printf(menu_item, menu_type_menu, "type: 0x%x", diitem->type); popup_printf(menu_item, menu_type_menu, "id: 0x%x 0x%x", diitem->id_hi, diitem->id_lo); - if (diitem && diitem->map) { + if (diitem->map) { mr=map_rect_new(diitem->map,NULL); item=map_rect_get_item_byid(mr, diitem->id_hi, diitem->id_lo); dbg(1,"item=%p\n", item); @@ -284,7 +286,7 @@ popup_show_item(struct navit *nav, void *popup, struct displayitem *di) } else { popup_printf(menu, menu_type_menu, "(No map)"); } - if (diitem && item_get_default_flags(diitem->type)) { + if (item_get_default_flags(diitem->type)) { int speeds[]={5,10,20,30,40,50,60,70,80,90,100}; int delays[]={1,2,3,5,10,15,20,30,45,60,75,90,120,150,180,240,300}; int i; @@ -299,7 +301,6 @@ popup_show_item(struct navit *nav, void *popup, struct displayitem *di) popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_traffic_distortion_delay), diitem, delays[i]*600), "%d min",delays[i]); } } - } static void -- cgit v1.2.1