From 4f3b02e1fc419d5c4d8d8161743536a281e90f16 Mon Sep 17 00:00:00 2001 From: martin-s Date: Thu, 25 Jun 2009 18:42:13 +0000 Subject: Add:gui_internal:Added possibility to log a message to the debug log git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@2374 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- gui/internal/gui_internal.c | 89 ++++++++++- item_def.h | 1 + navit.c | 2 +- navit.h | 28 +--- navit.xml | 1 + xpm/Makefile.am | 1 + xpm/gui_log.svg | 352 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 445 insertions(+), 29 deletions(-) create mode 100644 xpm/gui_log.svg diff --git a/gui/internal/gui_internal.c b/gui/internal/gui_internal.c index d1dabc04..a184c150 100644 --- a/gui/internal/gui_internal.c +++ b/gui/internal/gui_internal.c @@ -360,6 +360,7 @@ static void gui_internal_search_street_in_town(struct gui_priv *this, struct wid static void gui_internal_search_town(struct gui_priv *this, struct widget *wm, void *data); static void gui_internal_search_town_in_country(struct gui_priv *this, struct widget *wm); static void gui_internal_search_country(struct gui_priv *this, struct widget *widget, void *data); +static void gui_internal_check_exit(struct gui_priv *this); static struct widget *gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode); static struct menu_data * gui_internal_menu_data(struct gui_priv *this); @@ -3292,18 +3293,33 @@ static void gui_internal_menu_root(struct gui_priv *this) } static void -gui_internal_cmd_menu(struct gui_priv *this, struct point *p, int ignore) +gui_internal_enter(struct gui_priv *this, int ignore) { struct graphics *gra=this->gra; - struct transformation *trans; - struct coord c; - struct attr attr,attrp; - this->ignore_button=ignore; this->clickp_valid=this->vehicle_valid=0; navit_block(this->nav, 1); graphics_overlay_disable(gra, 1); + this->root.p.x=0; + this->root.p.y=0; + this->root.background=this->background; +} + +static void +gui_internal_leave(struct gui_priv *this) +{ + graphics_draw_mode(this->gra, draw_mode_end); +} + +static void +gui_internal_cmd_menu(struct gui_priv *this, struct point *p, int ignore) +{ + struct transformation *trans; + struct coord c; + struct attr attr,attrp; + + gui_internal_enter(this, ignore); trans=navit_get_trans(this->nav); if (p) { transform_reverse(trans, p, &c); @@ -3322,9 +3338,6 @@ gui_internal_cmd_menu(struct gui_priv *this, struct point *p, int ignore) this->vehicle_valid=1; } // draw menu - this->root.p.x=0; - this->root.p.y=0; - this->root.background=this->background; gui_internal_menu_root(this); } @@ -3334,6 +3347,65 @@ gui_internal_cmd_menu2(struct gui_priv *this) gui_internal_cmd_menu(this, NULL, 1); } + +static void +gui_internal_cmd_log_do(struct gui_priv *this, struct widget *widget) +{ + if (widget->text && strlen(widget->text)) + navit_textfile_debug_log(this->nav, "type=log_entry label=\"%s\"",widget->text); + g_free(widget->text); + widget->text=NULL; + gui_internal_prune_menu(this, NULL); + gui_internal_check_exit(this); +} + +static void +gui_internal_cmd_log_clicked(struct gui_priv *this, struct widget *widget, void *data) +{ + gui_internal_cmd_log_do(this, widget->data); +} + +static void +gui_internal_cmd_log_changed(struct gui_priv *this, struct widget *wm, void *data) +{ + int len; + if (wm->text) { + len=strlen(wm->text); + if (len && (wm->text[len-1] == '\n' || wm->text[len-1] == '\r')) { + wm->text[len-1]='\0'; + gui_internal_cmd_log_do(this, wm); + } + } +} + + +static void +gui_internal_cmd_log(struct gui_priv *this) +{ + struct widget *w,*wb,*wk,*wl,*we,*wnext; + gui_internal_enter(this, 1); + wb=gui_internal_menu(this, "Log Message"); + w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill); + gui_internal_widget_append(wb, w); + we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill); + gui_internal_widget_append(w, we); + gui_internal_widget_append(we, wk=gui_internal_label_new(this, _("Message"))); + wk->state |= STATE_EDIT|STATE_CLEAR; + wk->background=this->background; + wk->flags |= flags_expand|flags_fill; + wk->func = gui_internal_cmd_log_changed; + gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active"))); + wnext->state |= STATE_SENSITIVE; + wnext->func = gui_internal_cmd_log_clicked; + wnext->data=wk; + wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill); + gui_internal_widget_append(w, wl); + if (this->keyboard) + gui_internal_widget_append(w, gui_internal_keyboard(this,2)); + gui_internal_menu_render(this); + gui_internal_leave(this); +} + static void gui_internal_check_exit(struct gui_priv *this) { @@ -3744,6 +3816,7 @@ static struct command_table commands[] = { {"menu",command_cast(gui_internal_cmd_menu2)}, {"fullscreen",command_cast(gui_internal_cmd_fullscreen)}, {"get_data",command_cast(gui_internal_get_data)}, + {"log",command_cast(gui_internal_cmd_log)}, }; diff --git a/item_def.h b/item_def.h index a6970274..b8327314 100644 --- a/item_def.h +++ b/item_def.h @@ -305,6 +305,7 @@ ITEM(route_end) ITEM(selected_point) ITEM(power_tower) ITEM(route_start_reverse) +ITEM(log_entry) /* Line */ ITEM2(0x80000000,line) ITEM2(0x80000001,line_unspecified) diff --git a/navit.c b/navit.c index 307e48ec..0e975e55 100644 --- a/navit.c +++ b/navit.c @@ -1055,7 +1055,7 @@ navit_add_former_destinations_from_file(struct navit *this_) } -static void +void navit_textfile_debug_log(struct navit *this_, const char *fmt, ...) { va_list ap; diff --git a/navit.h b/navit.h index 3208b69c..2068055e 100644 --- a/navit.h +++ b/navit.h @@ -26,7 +26,6 @@ extern "C" { extern struct gui *main_loop_gui; /* prototypes */ enum attr_type; -enum item_type; struct attr; struct attr_iter; struct callback; @@ -37,15 +36,12 @@ struct mapset; struct message; struct navigation; struct navit; -struct navit_vehicle; -struct navit_window_items; struct pcoord; struct point; struct route; -struct speech; struct tracking; struct transformation; -struct vehicle; +struct vehicleprofile; void navit_add_mapset(struct navit *this_, struct mapset *ms); struct mapset *navit_get_mapset(struct navit *this_); struct tracking *navit_get_tracking(struct navit *this_); @@ -53,7 +49,6 @@ void navit_draw(struct navit *this_); void navit_draw_displaylist(struct navit *this_); void navit_handle_resize(struct navit *this_, int w, int h); int navit_get_width(struct navit *this_); -int navit_check_route(struct navit *this_); int navit_get_height(struct navit *this_); int navit_ignore_button(struct navit *this_); void navit_ignore_graphics_events(struct navit *this_, int ignore); @@ -62,18 +57,20 @@ void navit_handle_motion(struct navit *this_, struct point *p); void navit_zoom_in(struct navit *this_, int factor, struct point *p); void navit_zoom_out(struct navit *this_, int factor, struct point *p); struct navit *navit_new(struct attr *parent, struct attr **attrs); +void navit_add_message(struct navit *this_, char *message); +struct message *navit_get_messages(struct navit *this_); struct graphics *navit_get_graphics(struct navit *this_); +struct vehicleprofile *navit_get_vehicleprofile(struct navit *this_); void navit_set_destination(struct navit *this_, struct pcoord *c, const char *description, int async); +int navit_check_route(struct navit *this_); void navit_add_bookmark(struct navit *this_, struct pcoord *c, const char *description); -void navit_say(struct navit *this_, char *text); +void navit_textfile_debug_log(struct navit *this_, const char *fmt, ...); int navit_speech_estimate(struct navit *this_, char *str); -void navit_speak(struct navit *this_); +void navit_say(struct navit *this_, char *text); void navit_announcer_toggle(struct navit *this_); +void navit_speak(struct navit *this_); void navit_window_roadbook_destroy(struct navit *this_); void navit_window_roadbook_new(struct navit *this_); -struct navit_window_items *navit_window_items_new(const char *name, int distance); -void navit_window_items_add_item(struct navit_window_items *nwi, enum item_type type); -void navit_add_window_items(struct navit *this_, struct navit_window_items *nwi); void navit_init(struct navit *this_); void navit_zoom_to_route(struct navit *this_, int orientation); void navit_set_center(struct navit *this_, struct pcoord *center); @@ -87,22 +84,13 @@ void navit_attr_iter_destroy(struct attr_iter *iter); void navit_add_callback(struct navit *this_, struct callback *cb); void navit_remove_callback(struct navit *this_, struct callback *cb); void navit_set_position(struct navit *this_, struct pcoord *c); -void navit_tracking_add(struct navit *this_, struct tracking *tracking); -void navit_set_speech(struct navit *this_, struct speech *speech); struct gui *navit_get_gui(struct navit *this_); struct transformation *navit_get_trans(struct navit *this_); struct route *navit_get_route(struct navit *this_); struct navigation *navit_get_navigation(struct navit *this_); struct displaylist *navit_get_displaylist(struct navit *this_); int navit_block(struct navit *this_, int block); -int navit_command_register(struct navit *this_, char *command, struct callback *cb); -struct callback *navit_command_unregister(struct navit *this_, char *command); -int navit_command_call_attrs(struct navit *this_, char *command, struct attr **in, struct attr ***out); -int navit_command_call(struct navit *this_, char *command); -void navit_add_message(struct navit *this_, char *message); -struct message *navit_get_messages(struct navit *this_); void navit_destroy(struct navit *this_); -struct vehicleprofile * navit_get_vehicleprofile(struct navit *this_); /* end of prototypes */ #ifdef __cplusplus } diff --git a/navit.xml b/navit.xml index b923ab3f..8a955cc1 100644 --- a/navit.xml +++ b/navit.xml @@ -37,6 +37,7 @@ + diff --git a/xpm/Makefile.am b/xpm/Makefile.am index 36f4a284..3fd749f2 100644 --- a/xpm/Makefile.am +++ b/xpm/Makefile.am @@ -107,6 +107,7 @@ svgs += gui_strength_4.svg svgs += gui_strength_5.svg svgs += gui_minus.svg svgs += gui_plus.svg +svgs += gui_log.svg svgs += airport.svg svgs += attraction.svg diff --git a/xpm/gui_log.svg b/xpm/gui_log.svg new file mode 100644 index 00000000..33a1ac9e --- /dev/null +++ b/xpm/gui_log.svg @@ -0,0 +1,352 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Justify fill + October 2006 + + + Andreas Nilsson + + + http://www.gnome.org + + + justify + format + align + left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1