From: martin-s Date: Sun, 22 Jul 2007 15:37:55 +0000 (+0000) Subject: Added roadbook button X-Git-Tag: navit-0.5.0.5194svn~4779 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=efd720cfec175179b52b2a4f514cbdcae864949b;p=profile%2Fivi%2Fnavit.git Added roadbook button git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@369 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- diff --git a/navit/src/callback.c b/navit/src/callback.c index 49d2cd0..8985b8d 100644 --- a/navit/src/callback.c +++ b/navit/src/callback.c @@ -67,54 +67,61 @@ callback_list_remove_destroy(struct callback_list *l, struct callback *cb) } void -callback_list_call(struct callback_list *l, int pcount, void **p) +callback_call(struct callback *cb, int pcount, void **p) { + int i; void *pf[8]; - struct callback *cb; + if (cb->pcount + pcount <= 8) { + dbg(1,"cb->pcount=%d %p pcount=%d %p\n", cb->pcount, cb->p[0], pcount, p[0]); + for (i = 0 ; i < cb->pcount ; i++) + pf[i]=cb->p[i]; + for (i = 0 ; i < pcount ; i++) + pf[i+cb->pcount]=p[i]; + switch (cb->pcount+pcount) { + case 8: + cb->func(pf[0],pf[1],pf[2],pf[3],pf[4],pf[5],pf[6],pf[7]); + break; + case 7: + cb->func(pf[0],pf[1],pf[2],pf[3],pf[4],pf[5],pf[6]); + break; + case 6: + cb->func(pf[0],pf[1],pf[2],pf[3],pf[4],pf[5]); + break; + case 5: + cb->func(pf[0],pf[1],pf[2],pf[3],pf[4]); + break; + case 4: + cb->func(pf[0],pf[1],pf[2],pf[3]); + break; + case 3: + cb->func(pf[0],pf[1],pf[2]); + break; + case 2: + cb->func(pf[0],pf[1]); + break; + case 1: + cb->func(pf[0]); + break; + case 0: + cb->func(); + break; + } + } else { + g_warning("too many parameters for callback\n"); + } +} + + +void +callback_list_call(struct callback_list *l, int pcount, void **p) +{ GList *cbi; - int i; + struct callback *cb; cbi=l->list; while (cbi) { cb=cbi->data; - if (cb->pcount + pcount <= 8) { - dbg(1,"cb->pcount=%d %p pcount=%d %p\n", cb->pcount, cb->p[0], pcount, p[0]); - for (i = 0 ; i < cb->pcount ; i++) - pf[i]=cb->p[i]; - for (i = 0 ; i < pcount ; i++) - pf[i+cb->pcount]=p[i]; - switch (cb->pcount+pcount) { - case 8: - cb->func(pf[0],pf[1],pf[2],pf[3],pf[4],pf[5],pf[6],pf[7]); - break; - case 7: - cb->func(pf[0],pf[1],pf[2],pf[3],pf[4],pf[5],pf[6]); - break; - case 6: - cb->func(pf[0],pf[1],pf[2],pf[3],pf[4],pf[5]); - break; - case 5: - cb->func(pf[0],pf[1],pf[2],pf[3],pf[4]); - break; - case 4: - cb->func(pf[0],pf[1],pf[2],pf[3]); - break; - case 3: - cb->func(pf[0],pf[1],pf[2]); - break; - case 2: - cb->func(pf[0],pf[1]); - break; - case 1: - cb->func(pf[0]); - break; - case 0: - cb->func(); - break; - } - } else { - g_warning("too many parameters for callback\n"); - } + callback_call(cb, pcount, p); cbi=g_list_next(cbi); } diff --git a/navit/src/callback.h b/navit/src/callback.h index bf38a78..aad5c4b 100644 --- a/navit/src/callback.h +++ b/navit/src/callback.h @@ -10,8 +10,10 @@ void callback_list_add(struct callback_list *l, struct callback *cb); struct callback *callback_list_add_new(struct callback_list *l, void (*func)(void), int pcount, void **p); void callback_list_remove(struct callback_list *l, struct callback *cb); void callback_list_remove_destroy(struct callback_list *l, struct callback *cb); +void callback_call(struct callback *cb, int pcount, void **p); void callback_list_call(struct callback_list *l, int pcount, void **p); void callback_list_destroy(struct callback_list *l); +/* end of prototypes */ static inline struct callback *callback_new_0(void (*func)(void)) { @@ -25,6 +27,17 @@ static inline struct callback *callback_new_1(void (*func)(void), void *p1) return callback_new(func, 1, p); } +static inline void callback_call_0(struct callback *cb) +{ + callback_call(cb, 0, NULL); +} + +static inline void callback_list_call_0(struct callback_list *l) +{ + callback_list_call(l, 0, NULL); +} + + static inline void callback_list_call_1(struct callback_list *l, void *p1) { void *p[1]; @@ -41,7 +54,6 @@ static inline void callback_list_call_2(struct callback_list *l, void *p1, void } #define callback_cast(x) (void (*)(void))(x) -/* end of prototypes */ #ifdef __cplusplus } #endif diff --git a/navit/src/gui/gtk/datawindow.c b/navit/src/gui/gtk/datawindow.c index a505675..ade86df 100644 --- a/navit/src/gui/gtk/datawindow.c +++ b/navit/src/gui/gtk/datawindow.c @@ -88,6 +88,12 @@ gui_gtk_datawindow_mode(struct datawindow_priv *win, int start) } } +static void +gui_gtk_datawindow_delete(GtkWidget *widget, GdkEvent *event, struct datawindow_priv *win) +{ + callback_call_0(win->close); +} + static struct datawindow_methods gui_gtk_datawindow_meth = { gui_gtk_datawindow_destroy, @@ -116,6 +122,7 @@ gui_gtk_datawindow_new(struct gui_priv *gui, char *name, struct callback *click, win->close=close; if (gui) gtk_window_set_transient_for(GTK_WINDOW((GtkWidget *)(win->window)), GTK_WINDOW(gui->win)); + g_signal_connect(G_OBJECT(win->window), "delete-event", G_CALLBACK(gui_gtk_datawindow_delete), win); gtk_widget_show_all(win->window); return win; return NULL; diff --git a/navit/src/gui/gtk/gui_gtk_action.c b/navit/src/gui/gtk/gui_gtk_action.c index 143b374..6ed61d2 100644 --- a/navit/src/gui/gtk/gui_gtk_action.c +++ b/navit/src/gui/gtk/gui_gtk_action.c @@ -46,6 +46,12 @@ refresh_action(GtkWidget *w, struct navit *nav, void *dummy) } static void +roadbook_action(GtkWidget *w, struct navit *nav, void *dummy) +{ + navit_window_roadbook_new(nav); +} + +static void cursor_action(GtkWidget *w, struct navit *nav, void *dummy) { navit_toggle_cursor(nav); @@ -55,6 +61,15 @@ cursor_action(GtkWidget *w, struct navit *nav, void *dummy) } static void +tracking_action(GtkWidget *w, struct navit *nav, void *dummy) +{ + navit_toggle_tracking(nav); +#if 0 + ac->gui->co->flags->track=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)); +#endif +} + +static void orient_north_action(GtkWidget *w, struct navit *nav, void *dummy) { #if 0 @@ -165,6 +180,7 @@ static GtkActionEntry entries[] = { "ZoomOutAction", GTK_STOCK_ZOOM_OUT, _n("ZoomOut"), NULL, NULL, G_CALLBACK(zoom_out_action) }, { "ZoomInAction", GTK_STOCK_ZOOM_IN, _n("ZoomIn"), NULL, NULL, G_CALLBACK(zoom_in_action) }, { "RefreshAction", GTK_STOCK_REFRESH, _n("Refresh"), NULL, NULL, G_CALLBACK(refresh_action) }, + { "RoadbookAction", GTK_STOCK_JUSTIFY_FILL, _n("Roadbook"), NULL, NULL, G_CALLBACK(roadbook_action) }, { "InfoAction", GTK_STOCK_INFO, _n("Info"), NULL, NULL, G_CALLBACK(info_action) }, { "DestinationAction", "flag_icon", _n("Destination"), NULL, NULL, G_CALLBACK(destination_action) }, { "RouteClearAction", NULL, _n("Clear"), NULL, NULL, G_CALLBACK(route_clear_action) }, @@ -177,6 +193,7 @@ static guint n_entries = G_N_ELEMENTS (entries); static GtkToggleActionEntry toggleentries[] = { { "CursorAction", "cursor_icon",_n("Cursor"), NULL, NULL, G_CALLBACK(cursor_action),TRUE }, + { "TrackingAction", NULL ,_n("Tracking"), NULL, NULL, G_CALLBACK(tracking_action),TRUE }, { "OrientationAction", "orientation_icon", _n("Orientation"), NULL, NULL, G_CALLBACK(orient_north_action),FALSE } }; @@ -325,7 +342,9 @@ static char layout[] = \ \ \ + \ \ + \ \ \ \ @@ -354,6 +373,7 @@ static char layout[] = \ \ \ + \ \ \ \ diff --git a/navit/src/navit.c b/navit/src/navit.c index 8dc5963..dc42306 100644 --- a/navit/src/navit.c +++ b/navit/src/navit.c @@ -61,11 +61,11 @@ struct navit { struct navigation *navigation; struct speech *speech; struct tracking *tracking; - struct map_flags *flags; int ready; struct window *win; struct displaylist *displaylist; int cursor_flag; + int tracking_flag; GList *vehicles; struct navit_vehicle *vehicle; struct callback_list *vehicle_cbl; @@ -189,11 +189,11 @@ navit_new(const char *ui, const char *graphics, struct coord *center, enum proje this_->bookmarks_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); this_->cursor_flag=1; + this_->tracking_flag=1; this_->trans=transform_new(); transform_set_projection(this_->trans, pro); transform_setup(this_->trans, center, zoom, 0); - /* this_->flags=g_new0(struct map_flags, 1); */ this_->displaylist=graphics_displaylist_new(); this_->gui=gui_new(this_, ui, 792, 547); if (! this_->gui) { @@ -573,7 +573,7 @@ navit_window_roadbook_update(struct navit *this_) datawindow_mode(this_->roadbook_window, 0); } -static void +void navit_window_roadbook_new(struct navit *this_) { this_->roadbook_callback=callback_new_1(callback_cast(navit_window_roadbook_update), this_); @@ -768,6 +768,12 @@ navit_toggle_cursor(struct navit *this_) this_->cursor_flag=1-this_->cursor_flag; } +void +navit_toggle_tracking(struct navit *this_) +{ + this_->tracking_flag=1-this_->tracking_flag; +} + static void navit_cursor_offscreen(struct navit *this_, struct cursor *cursor) { @@ -792,7 +798,7 @@ navit_cursor_update(struct navit *this_, struct cursor *cursor) if (this_->pid && speed > 2) kill(this_->pid, SIGWINCH); - if (this_->tracking) { + if (this_->tracking && this_->tracking_flag) { struct coord c=*cursor_c; if (tracking_update(this_->tracking, &c, dir)) { cursor_c=&c; diff --git a/navit/src/navit.h b/navit/src/navit.h index e1988a1..7e79aa4 100644 --- a/navit/src/navit.h +++ b/navit/src/navit.h @@ -41,10 +41,12 @@ void navit_add_menu_bookmarks(struct navit *this_, struct menu *men); void navit_add_menu_vehicles(struct navit *this_, struct menu *men); void navit_add_menu_vehicle(struct navit *this_, struct menu *men); void navit_speak(struct navit *this_); +void navit_window_roadbook_new(struct navit *this_); void navit_init(struct navit *this_); void navit_set_center(struct navit *this_, struct coord *center); void navit_set_center_screen(struct navit *this_, struct point *p); void navit_toggle_cursor(struct navit *this_); +void navit_toggle_tracking(struct navit *this_); void navit_set_position(struct navit *this_, struct coord *c); struct navit_vehicle *navit_add_vehicle(struct navit *this_, struct vehicle *v, const char *name, struct color *c, int update, int follow); void navit_add_vehicle_cb(struct navit *this_, struct callback *cb); diff --git a/navit/src/route.c b/navit/src/route.c index ec5ce24..65dd0c3 100644 --- a/navit/src/route.c +++ b/navit/src/route.c @@ -224,7 +224,7 @@ route_set_position(struct route *this, struct coord *pos) if (this->pos) route_info_free(this->pos); this->pos=route_find_nearest_street(this->ms, pos); - dbg(0,"this->pos=%p\n", this->pos); + dbg(1,"this->pos=%p\n", this->pos); if (! this->pos) return; if (this->dst)