}
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);
}
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))
{
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];
}
#define callback_cast(x) (void (*)(void))(x)
-/* end of prototypes */
#ifdef __cplusplus
}
#endif
}
}
+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,
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;
}
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);
}
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
{ "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) },
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 }
};
<menuitem name=\"Zoom in\" action=\"ZoomInAction\" />\
<menuitem name=\"Zoom out\" action=\"ZoomOutAction\" />\
<menuitem name=\"Cursor\" action=\"CursorAction\"/>\
+ <menuitem name=\"Tracking\" action=\"TrackingAction\"/>\
<menuitem name=\"Orientation\" action=\"OrientationAction\"/>\
+ <menuitem name=\"Roadbook\" action=\"RoadbookAction\"/>\
<menuitem name=\"Quit\" action=\"QuitAction\" />\
<placeholder name=\"RouteMenuAdditions\" />\
</menu>\
<toolitem name=\"Orientation\" action=\"OrientationAction\"/>\
<toolitem name=\"Destination\" action=\"DestinationAction\"/>\
<toolitem name=\"Info\" action=\"InfoAction\"/>\
+ <toolitem name=\"Roadbook\" action=\"RoadbookAction\"/>\
<toolitem name=\"Quit\" action=\"QuitAction\"/>\
<separator/>\
</placeholder>\
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;
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) {
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_);
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)
{
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;
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);
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)