navit_SOURCES = attr.c callback.c compass.c coord.c country.c cursor.c data_window.c debug.c \
file.c graphics.c gui.c item.c layout.c log.c main.c map.c \
mapset.c maptype.c menu.c navit.c navigation.c osd.c param.c phrase.c plugin.c popup.c \
- profile.c route.c search.c speech.c transform.c track.c \
+ profile.c projection.c route.c search.c speech.c transform.c track.c \
util.c vehicle.c xmlconfig.c attr.h attr_def.h callback.h color.h compass.h coord.h country.h \
cursor.h data.h data_window.h data_window_int.h debug.h destination.h draw_info.h endianess.h \
file.h graphics.h gtkext.h gui.h item.h item_def.h log.h layer.h layout.h main.h map-share.h map.h\
map_data.h mapset.h maptype.h menu.h navigation.h navit.h osd.h \
- param.h phrase.h plugin.h point.h plugin_def.h projection.h popup.h route.h profile.h search.h speech.h statusbar.h \
+ param.h phrase.h plugin.h point.h plugin_def.h projection.h popup.h route.h profile.h search.h speech.h \
transform.h track.h util.h vehicle.h xmlconfig.h
osm2navit_SOURCES = osm2navit.c item.c debug.c zipfile.h
#ifndef ATTR_H
#define ATTR_H
+#include "projection.h"
+
enum item_type;
enum attr_type {
int num;
struct item *item;
enum item_type item_type;
+ enum projection projection;
double * numd;
struct color *color;
struct coord_geo *coord_geo;
struct navit *navit;
struct callback *callback;
+ struct vehicle *vehicle;
+ struct layout *layout;
+ struct map *map;
struct log *log;
struct route *route;
struct navigation *navigation;
ATTR(position_qual)
ATTR(zoom)
ATTR(retry_interval)
+ATTR(projection)
ATTR2(0x00028000,type_boolean_begin)
/* boolean */
ATTR(overwrite)
ATTR(callback)
ATTR(route)
ATTR(navigation)
+ATTR(vehicle)
+ATTR(map)
ATTR2(0x0008ffff,type_object_end)
ATTR2(0x00090000,type_coord_begin)
ATTR2(0x0009ffff,type_coord_end)
#include "projection.h"
#include "point.h"
#include "graphics.h"
-#include "statusbar.h"
-#include "menu.h"
#include "vehicle.h"
#include "navit.h"
#include "callback.h"
#include <glib.h>
#include "debug.h"
#include "gui.h"
-#include "statusbar.h"
#include "menu.h"
#include "data_window.h"
#include "plugin.h"
return this_;
}
-struct statusbar *
-gui_statusbar_new(struct gui *gui)
-{
- struct statusbar *this_;
- if (! gui->meth.statusbar_new)
- return NULL;
- this_=g_new0(struct statusbar, 1);
- this_->priv=gui->meth.statusbar_new(gui->priv, &this_->meth);
- if (! this_->priv) {
- g_free(this_);
- return NULL;
- }
- return this_;
-}
-
struct menu *
gui_menubar_new(struct gui *gui)
{
return this_;
}
-
-struct menu *
-gui_toolbar_new(struct gui *gui)
-{
- struct menu *this_;
- if (! gui->meth.toolbar_new)
- return NULL;
- this_=g_new0(struct menu, 1);
- this_->priv=gui->meth.toolbar_new(gui->priv, &this_->meth);
- if (! this_->priv) {
- g_free(this_);
- return NULL;
- }
- return this_;
-}
-
struct menu *
gui_popup_new(struct gui *gui)
{
struct navit;
struct gui_priv;
struct menu_methods;
-struct statusbar_methods;
struct datawindow_methods;
struct callback;
struct graphics;
struct gui_methods {
struct menu_priv *(*menubar_new)(struct gui_priv *priv, struct menu_methods *meth);
- struct menu_priv *(*toolbar_new)(struct gui_priv *priv, struct menu_methods *meth);
- struct statusbar_priv *(*statusbar_new)(struct gui_priv *priv, struct statusbar_methods *meth);
struct menu_priv *(*popup_new)(struct gui_priv *priv, struct menu_methods *meth);
int (*set_graphics)(struct gui_priv *priv, struct graphics *gra);
int (*run_main_loop)(struct gui_priv *priv);
struct gui;
struct menu;
struct navit;
-struct statusbar;
struct gui *gui_new(struct navit *nav, const char *type, struct attr **attrs);
-struct statusbar *gui_statusbar_new(struct gui *gui);
struct menu *gui_menubar_new(struct gui *gui);
-struct menu *gui_toolbar_new(struct gui *gui);
struct menu *gui_popup_new(struct gui *gui);
struct datawindow *gui_datawindow_new(struct gui *gui, char *name, struct callback *click, struct callback *close);
int gui_add_bookmark(struct gui *gui, struct pcoord *c, char *description);
#include "coord.h"
-struct statusbar_methods;
struct menu_methods;
struct datawindow_methods;
struct navit;
struct callback;
+struct statusbar_priv;
struct gui_priv {
struct navit *nav;
GtkActionGroup *base_group;
GtkActionGroup *debug_group;
GtkActionGroup *dyn_group;
- GtkUIManager *menu_manager;
- void *statusbar;
+ GtkUIManager *ui_manager;
+ GSList *layout_group;
+ GSList *projection_group;
+ GSList *vehicle_group;
+ GtkUIManager *menu_manager; // old
+ struct statusbar_priv *statusbar;
+ int menubar_enable;
+ int toolbar_enable;
+ int statusbar_enable;
int dyn_counter;
};
+void gui_gtk_ui_init(struct gui_priv *this);
struct menu_priv *gui_gtk_menubar_new(struct gui_priv *gui, struct menu_methods *meth);
-struct menu_priv *gui_gtk_toolbar_new(struct gui_priv *gui, struct menu_methods *meth);
-struct statusbar_priv *gui_gtk_statusbar_new(struct gui_priv *gui, struct statusbar_methods *meth);
+struct statusbar_priv *gui_gtk_statusbar_new(struct gui_priv *gui);
struct menu_priv *gui_gtk_popup_new(struct gui_priv *gui, struct menu_methods *meth);
struct datawindow_priv *gui_gtk_datawindow_new(struct gui_priv *gui, char *name, struct callback *click, struct callback *close, struct datawindow_methods *meth);
destination_address(gui->nav);
}
-
static void
quit_action (GtkWidget *w, struct gui_priv *gui, void *dummy)
{
navit_destroy(gui->nav);
}
-static void
-visible_blocks_action(GtkWidget *w, struct container *co)
-{
-#if 0
- co->data_window[data_window_type_block]=data_window("Visible Blocks",co->win,NULL);
- graphics_redraw(co);
-#endif
-}
-
-static void
-visible_towns_action(GtkWidget *w, struct container *co)
-{
-#if 0
- co->data_window[data_window_type_town]=data_window("Visible Towns",co->win,NULL);
- graphics_redraw(co);
-#endif
-}
-
-static void
-visible_polys_action(GtkWidget *w, struct container *co)
-{
-#if 0
- co->data_window[data_window_type_street]=data_window("Visible Polys",co->win,NULL);
- graphics_redraw(co);
-#endif
-}
-
-static void
-visible_streets_action(GtkWidget *w, struct container *co)
-{
-#if 0
- co->data_window[data_window_type_street]=data_window("Visible Streets",co->win,NULL);
- graphics_redraw(co);
-#endif
-}
-
-static void
-visible_points_action(GtkWidget *w, struct container *co)
-{
-#if 0
- co->data_window[data_window_type_point]=data_window("Visible Points",co->win,NULL);
- graphics_redraw(co);
-#endif
-}
-
static GtkActionEntry entries[] =
{
- { "DisplayMenuAction", NULL, gettext_noop("Display") },
+ { "DisplayMenuAction", NULL, _n("Display") },
{ "RouteMenuAction", NULL, _n("Route") },
- { "Map", NULL, _n("Map") },
+ { "FormerDestinationMenuAction", NULL, _n("Former Destinations") },
+ { "BookmarkMenuAction", NULL, _n("Bookmarks") },
+ { "MapMenuAction", NULL, _n("Map") },
{ "LayoutMenuAction", NULL, _n("Layout") },
+ { "ProjectionMenuAction", NULL, _n("Projection") },
+ { "VehicleMenuAction", NULL, _n("Vehicle") },
{ "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) },
static GtkActionEntry debug_entries[] =
{
{ "DataMenuAction", NULL, _n("Data") },
- { "VisibleBlocksAction", NULL, _n("VisibleBlocks"), NULL, NULL, G_CALLBACK(visible_blocks_action) },
- { "VisibleTownsAction", NULL, _n("VisibleTowns"), NULL, NULL, G_CALLBACK(visible_towns_action) },
- { "VisiblePolysAction", NULL, _n("VisiblePolys"), NULL, NULL, G_CALLBACK(visible_polys_action) },
- { "VisibleStreetsAction", NULL, _n("VisibleStreets"), NULL, NULL, G_CALLBACK(visible_streets_action) },
- { "VisiblePointsAction", NULL, _n("VisiblePoints"), NULL, NULL, G_CALLBACK(visible_points_action) },
};
static guint n_debug_entries = G_N_ELEMENTS (debug_entries);
<placeholder name=\"RouteMenuAdditions\" />\
</menu>\
<menu name=\"Data\" action=\"DataMenuAction\">\
- <menuitem name=\"Visible Blocks\" action=\"VisibleBlocksAction\" />\
- <menuitem name=\"Visible Towns\" action=\"VisibleTownsAction\" />\
- <menuitem name=\"Visible Polys\" action=\"VisiblePolysAction\" />\
- <menuitem name=\"Visible Streets\" action=\"VisibleStreetsAction\" />\
- <menuitem name=\"Visible Points\" action=\"VisiblePointsAction\" />\
<placeholder name=\"DataMenuAdditions\" />\
</menu>\
<menu name=\"Route\" action=\"RouteMenuAction\">\
<menuitem name=\"Refresh\" action=\"RefreshAction\" />\
<menuitem name=\"Destination\" action=\"DestinationAction\" />\
<menuitem name=\"Clear\" action=\"RouteClearAction\" />\
+ <menu name=\"FormerDestinations\" action=\"FormerDestinationMenuAction\">\
+ <placeholder name=\"FormerDestinationMenuAdditions\" />\
+ </menu>\
+ <menu name=\"Bookmarks\" action=\"BookmarkMenuAction\">\
+ <placeholder name=\"BookmarkMenuAdditions\" />\
+ </menu>\
<placeholder name=\"RouteMenuAdditions\" />\
</menu>\
+ <menu name=\"Map\" action=\"MapMenuAction\">\
+ <menu name=\"Layout\" action=\"LayoutMenuAction\">\
+ <placeholder name=\"LayoutMenuAdditions\" />\
+ </menu>\
+ <menu name=\"Projection\" action=\"ProjectionMenuAction\">\
+ <placeholder name=\"ProjectionMenuAdditions\" />\
+ </menu>\
+ <menu name=\"Vehicle\" action=\"VehicleMenuAction\">\
+ <placeholder name=\"VehicleMenuAdditions\" />\
+ </menu>\
+ <placeholder name=\"MapMenuAdditions\" />\
+ </menu>\
</menubar>\
<toolbar name=\"ToolBar\" action=\"BaseToolbar\" action=\"BaseToolbarAction\">\
<placeholder name=\"ToolItems\">\
if (cb)
ret->handler_id=g_signal_connect(ret->action, "activate", G_CALLBACK(activate), ret);
gtk_action_group_add_action(menu->gui->dyn_group, ret->action);
- ret->merge_id=gtk_ui_manager_new_merge_id(menu->gui->menu_manager);
- gtk_ui_manager_add_ui( menu->gui->menu_manager, ret->merge_id, menu->path, dynname, dynname, type == menu_type_submenu ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, FALSE);
+ ret->merge_id=gtk_ui_manager_new_merge_id(menu->gui->ui_manager);
+ gtk_ui_manager_add_ui( menu->gui->ui_manager, ret->merge_id, menu->path, dynname, dynname, type == menu_type_submenu ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, FALSE);
}
ret->gui=menu->gui;
ret->path=g_strdup_printf("%s/%s", menu->path, dynname);
}
}
if (item->action) {
- gtk_ui_manager_remove_ui(item->gui->menu_manager, item->merge_id);
+ gtk_ui_manager_remove_ui(item->gui->ui_manager, item->merge_id);
gtk_action_group_remove_action(item->gui->dyn_group, item->action);
#if 0
if (item->callback)
}
static struct menu_methods menu_methods = {
+#if 1
add_menu,
set_toggle,
get_toggle,
+#else
+ NULL,
+ NULL,
+ NULL
+#endif
};
popup_activate(struct menu_priv *menu)
{
#ifdef _WIN32
- menu->widget=gtk_ui_manager_get_widget(menu->gui->menu_manager, menu->path );
+ menu->widget=gtk_ui_manager_get_widget(menu->gui->ui_manager, menu->path );
#endif
gtk_menu_popup(GTK_MENU(menu->widget), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
menu->handler_id=g_signal_connect(menu->widget, "selection-done", G_CALLBACK(popup_deactivate), menu);
}
+void
+gui_gtk_ui_init(struct gui_priv *this)
+{
+ GError *error = NULL;
+ struct attr attr;
+ GtkToggleAction *toggle_action;
+
+ this->base_group = gtk_action_group_new ("BaseActions");
+ this->debug_group = gtk_action_group_new ("DebugActions");
+ this->dyn_group = gtk_action_group_new ("DynamicActions");
+ register_my_stock_icons();
+ this->ui_manager = gtk_ui_manager_new ();
+ gtk_action_group_set_translation_domain(this->base_group,"navit");
+ gtk_action_group_set_translation_domain(this->debug_group,"navit");
+ gtk_action_group_set_translation_domain(this->dyn_group,"navit");
+ gtk_action_group_add_actions (this->base_group, entries, n_entries, this);
+ gtk_action_group_add_toggle_actions (this->base_group, toggleentries, n_toggleentries, this);
+ gtk_ui_manager_insert_action_group (this->ui_manager, this->base_group, 0);
+ gtk_action_group_add_actions (this->debug_group, debug_entries, n_debug_entries, this);
+ gtk_ui_manager_insert_action_group (this->ui_manager, this->debug_group, 0);
+ gtk_ui_manager_add_ui_from_string (this->ui_manager, layout, strlen(layout), &error);
+ gtk_ui_manager_insert_action_group (this->ui_manager, this->dyn_group, 0);
+ if (error) {
+ g_message ("building menus failed: %s", error->message);
+ g_error_free (error);
+ }
+ if (navit_get_attr(this->nav, attr_cursor, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "CursorAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ }
+ if (navit_get_attr(this->nav, attr_orientation, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "OrientationAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ }
+ if (navit_get_attr(this->nav, attr_tracking, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "TrackingAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ }
+}
+
static struct menu_priv *
gui_gtk_ui_new (struct gui_priv *this, struct menu_methods *meth, char *path, int popup, GtkWidget **widget_ret)
{
struct menu_priv *ret;
- GError *error;
GtkWidget *widget;
- struct attr attr;
- GtkToggleAction *toggle_action;
*meth=menu_methods;
ret=g_new0(struct menu_priv, 1);
ret->path=g_strdup(path);
ret->gui=this;
- if (! this->menu_manager) {
- this->base_group = gtk_action_group_new ("BaseActions");
- this->debug_group = gtk_action_group_new ("DebugActions");
- this->dyn_group = gtk_action_group_new ("DynamicActions");
- register_my_stock_icons();
- this->menu_manager = gtk_ui_manager_new ();
- gtk_action_group_set_translation_domain(this->base_group,"navit");
- gtk_action_group_set_translation_domain(this->debug_group,"navit");
- gtk_action_group_set_translation_domain(this->dyn_group,"navit");
- gtk_action_group_add_actions (this->base_group, entries, n_entries, this);
- gtk_action_group_add_toggle_actions (this->base_group, toggleentries, n_toggleentries, this);
- gtk_ui_manager_insert_action_group (this->menu_manager, this->base_group, 0);
- gtk_action_group_add_actions (this->debug_group, debug_entries, n_debug_entries, this);
- gtk_ui_manager_insert_action_group (this->menu_manager, this->debug_group, 0);
- gtk_ui_manager_add_ui_from_string (this->menu_manager, layout, strlen(layout), &error);
- gtk_ui_manager_insert_action_group (this->menu_manager, this->dyn_group, 0);
- error=NULL;
- if (error) {
- g_message ("building menus failed: %s", error->message);
- g_error_free (error);
- }
- if (navit_get_attr(this->nav, attr_cursor, &attr)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "CursorAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num);
- } else {
- dbg(0, "Unable to locate CursorAction\n");
- }
- if (navit_get_attr(this->nav, attr_orientation, &attr)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "OrientationAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num);
- } else {
- dbg(0, "Unable to locate OrientationAction\n");
- }
- if (navit_get_attr(this->nav, attr_tracking, &attr)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "TrackingAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num);
- } else {
- dbg(0, "Unable to locate TrackingAction\n");
- }
- }
- widget=gtk_ui_manager_get_widget(this->menu_manager, path);
+
+ widget=gtk_ui_manager_get_widget(this->ui_manager, path);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
if (widget_ret)
*widget_ret=widget;
return ret;
}
-struct menu_priv *
-gui_gtk_toolbar_new(struct gui_priv *this, struct menu_methods *meth)
-{
- return gui_gtk_ui_new(this, meth, "/ui/ToolBar", 0, NULL);
-}
-
+#if 0
struct menu_priv *
gui_gtk_menubar_new(struct gui_priv *this, struct menu_methods *meth)
{
return gui_gtk_ui_new(this, meth, "/ui/MenuBar", 0, &this->menubar);
}
+#endif
struct menu_priv *
gui_gtk_popup_new(struct gui_priv *this, struct menu_methods *meth)
#include "navigation.h"
#include "gui_gtk.h"
-#include "statusbar.h"
-
#define _(STRING) gettext(STRING)
strcpy(this->route_text, buffer);
gtk_label_set_text(GTK_LABEL(this->route), this->route_text);
}
- if (!vehicle_position_attr_get(v, attr_position_coord_geo, &attr))
+ if (!vehicle_get_attr(v, attr_position_coord_geo, &attr))
return;
lng=attr.u.coord_geo->lng;
lat=attr.u.coord_geo->lat;
lat=-lat;
lat_c='S';
}
- if (vehicle_position_attr_get(v, attr_position_direction, &attr))
+ if (vehicle_get_attr(v, attr_position_direction, &attr))
direction=*(attr.u.numd);
direction=fmod(direction,360);
if (direction < 0)
direction+=360;
dir_idx=(direction+22.5)/45;
dir=dirs[dir_idx];
- if (vehicle_position_attr_get(v, attr_position_height, &attr))
+ if (vehicle_get_attr(v, attr_position_height, &attr))
height=*(attr.u.numd);
- if (vehicle_position_attr_get(v, attr_position_speed, &attr))
+ if (vehicle_get_attr(v, attr_position_speed, &attr))
speed=*(attr.u.numd);
- if (vehicle_position_attr_get(v, attr_position_sats_used, &attr))
+ if (vehicle_get_attr(v, attr_position_sats_used, &attr))
sats=attr.u.num;
- if (vehicle_position_attr_get(v, attr_position_qual, &attr))
+ if (vehicle_get_attr(v, attr_position_qual, &attr))
qual=attr.u.num;
sprintf(this->gps_text,"GPS %2d/%1d %02.0f%07.4f%c %03.0f%07.4f%c %4.0fm %3.0f°%-2s %3.0fkm/h", sats, qual, floor(lat), fmod(lat*60,60), lat_c, floor(lng), fmod(lng*60,60), lng_c, height, direction, dir, speed);
gtk_label_set_text(GTK_LABEL(this->gps), this->gps_text);
}
-static struct statusbar_methods methods = {
- statusbar_destroy,
-};
-
struct statusbar_priv *
-gui_gtk_statusbar_new(struct gui_priv *gui, struct statusbar_methods *meth)
+gui_gtk_statusbar_new(struct gui_priv *gui)
{
struct statusbar_priv *this=g_new0(struct statusbar_priv, 1);
this->gui=gui;
- *meth=methods;
-
this->hbox=gtk_hbox_new(FALSE, 1);
this->gps=gtk_label_new( "GPS 00/0 0000.0000N 00000.0000E 0000m 000°NO 000km/h" );
gtk_label_set_justify(GTK_LABEL(this->gps), GTK_JUSTIFY_LEFT);
#include "gui_gtk.h"
#include "transform.h"
#include "config.h"
+#include "callback.h"
+#include "layout.h"
+#include "vehicle.h"
+#include "map.h"
#ifdef USE_HILDON
#include "hildon-widgets/hildon-defines.h"
}
struct gui_methods gui_gtk_methods = {
+#if 0
gui_gtk_menubar_new,
- gui_gtk_toolbar_new,
- gui_gtk_statusbar_new,
+#else
+ NULL,
+#endif
gui_gtk_popup_new,
gui_gtk_set_graphics,
NULL,
static gboolean
gui_gtk_delete(GtkWidget *widget, GdkEvent *event, struct navit *nav)
{
+ /* FIXME remove attr_navit callback */
navit_destroy(nav);
return TRUE;
}
+static void
+gui_gtk_toggle_init(struct gui_priv *this)
+{
+ struct attr attr;
+ GtkToggleAction *toggle_action;
+
+ if (navit_get_attr(this->nav, attr_cursor, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "CursorAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ } else {
+ dbg(0, "Unable to locate CursorAction\n");
+ }
+ if (navit_get_attr(this->nav, attr_orientation, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "OrientationAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ } else {
+ dbg(0, "Unable to locate OrientationAction\n");
+ }
+ if (navit_get_attr(this->nav, attr_tracking, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "TrackingAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ } else {
+ dbg(0, "Unable to locate TrackingAction\n");
+ }
+}
+
+struct action_cb_data {
+ struct gui_priv *gui;
+ struct attr attr;
+};
+
+static void
+gui_gtk_action_activate(GtkToggleAction *action, struct action_cb_data *data)
+{
+}
+static void
+gui_gtk_add_menu(struct gui_priv *this, char *name, char *label, char *path, struct action_cb_data *data)
+{
+ GtkAction *action;
+ guint merge_id;
+
+ action=gtk_action_new(name, label, NULL, NULL);
+ g_signal_connect(action, "activate", G_CALLBACK(gui_gtk_action_activate), data);
+ gtk_action_group_add_action(this->dyn_group, action);
+ merge_id=gtk_ui_manager_new_merge_id(this->ui_manager);
+ gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
+}
+
+static void
+gui_gtk_action_toggled(GtkToggleAction *action, struct action_cb_data *data)
+{
+ map_set_active(data->attr.u.map, gtk_toggle_action_get_active(action));
+ navit_draw(data->gui->nav);
+}
+
+static void
+gui_gtk_add_toggle_menu(struct gui_priv *this, char *name, char *label, char *path, struct action_cb_data *data, gboolean active)
+{
+ GtkToggleAction *toggle_action;
+ guint merge_id;
+
+ toggle_action=gtk_toggle_action_new(name, label, NULL, NULL);
+ gtk_toggle_action_set_active(toggle_action, active);
+ g_signal_connect(GTK_ACTION(toggle_action), "toggled", G_CALLBACK(gui_gtk_action_toggled), data);
+ gtk_action_group_add_action(this->dyn_group, GTK_ACTION(toggle_action));
+ merge_id=gtk_ui_manager_new_merge_id(this->ui_manager);
+ gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
+}
+
+static void
+gui_gtk_action_changed(GtkRadioAction *action, GtkRadioAction *current, struct action_cb_data *data)
+{
+ if (action == current) {
+ navit_set_attr(data->gui->nav, &data->attr);
+ }
+}
+
+static void
+gui_gtk_add_radio_menu(struct gui_priv *this, char *name, char *label, char *path, struct action_cb_data *data, GSList **g)
+{
+ GtkRadioAction *radio_action;
+ guint merge_id;
+
+ radio_action=gtk_radio_action_new(name, label, NULL, NULL, 0);
+ gtk_radio_action_set_group(radio_action, *g);
+ *g=gtk_radio_action_get_group(radio_action);
+ g_signal_connect(GTK_ACTION(radio_action), "changed", G_CALLBACK(gui_gtk_action_changed), data);
+ gtk_action_group_add_action(this->dyn_group, GTK_ACTION(radio_action));
+ merge_id=gtk_ui_manager_new_merge_id(this->ui_manager);
+ gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
+}
+
+static void
+gui_gtk_layouts_init(struct gui_priv *this)
+{
+ struct attr_iter *iter;
+ struct attr attr;
+ struct action_cb_data *data;
+ int count=0;
+ char *name;
+
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_layout, &attr, iter)) {
+ name=g_strdup_printf("Layout %d", count++);
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_layout;
+ data->attr.u.layout=attr.u.layout;
+ gui_gtk_add_radio_menu(this, name, attr.u.layout->name, "/ui/MenuBar/Map/Layout/LayoutMenuAdditions", data, &this->layout_group);
+ g_free(name);
+ }
+ navit_attr_iter_destroy(iter);
+}
+
+static void
+gui_gtk_projections_init(struct gui_priv *this)
+{
+ struct action_cb_data *data;
+
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_projection;
+ data->attr.u.projection=projection_mg;
+ gui_gtk_add_radio_menu(this, "Projection mg", "Map & Guide", "/ui/MenuBar/Map/Projection/ProjectionMenuAdditions", data, &this->projection_group);
+
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_projection;
+ data->attr.u.projection=projection_garmin;
+ gui_gtk_add_radio_menu(this, "Projection garmin", "Garmin", "/ui/MenuBar/Map/Projection/ProjectionMenuAdditions", data, &this->projection_group);
+}
+
+static void
+gui_gtk_vehicles_init(struct gui_priv *this)
+{
+ struct attr_iter *iter;
+ struct attr attr,vattr;
+ struct action_cb_data *data;
+ int count=0;
+ char *name;
+
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
+ vehicle_get_attr(attr.u.vehicle, attr_name, &vattr);
+ name=g_strdup_printf("Vehicle %d", count++);
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_vehicle;
+ data->attr.u.vehicle=attr.u.vehicle;
+ gui_gtk_add_radio_menu(this, name, vattr.u.str, "/ui/MenuBar/Map/Vehicle/VehicleMenuAdditions", data, &this->vehicle_group);
+ g_free(name);
+ }
+ navit_attr_iter_destroy(iter);
+}
+
+static void
+gui_gtk_maps_init(struct gui_priv *this)
+{
+ struct attr_iter *iter;
+ struct attr attr;
+ struct action_cb_data *data;
+ int count=0;
+ char *name, *label;
+
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_map, &attr, iter)) {
+ name=g_strdup_printf("Map %d", count++);
+ label=g_strdup_printf("%s:%s", map_get_type(attr.u.map), map_get_filename(attr.u.map));
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_map;
+ data->attr.u.map=attr.u.map;
+ gui_gtk_add_toggle_menu(this, name, label, "/ui/MenuBar/Map/MapMenuAdditions", data, map_get_active(attr.u.map));
+ g_free(name);
+ g_free(label);
+ }
+ navit_attr_iter_destroy(iter);
+
+}
+
+static void
+gui_gtk_destinations_init(struct gui_priv *this)
+{
+ struct action_cb_data *data;
+
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_destination;
+ data->attr.u.pcoord=g_new(struct pcoord, 1);
+ data->attr.u.pcoord->pro=projection_mg;
+ data->attr.u.pcoord->x=0x13a3e2;
+ data->attr.u.pcoord->y=0x5d6d6a;
+ gui_gtk_add_menu(this, "Destination 1", "Muenchen","/ui/MenuBar/Route/FormerDestinations/FormerDestinationMenuAdditions",data);
+}
+
+static void
+gui_gtk_bookmarks_init(struct gui_priv *this)
+{
+ struct action_cb_data *data;
+
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_destination;
+ data->attr.u.pcoord=g_new(struct pcoord, 1);
+ data->attr.u.pcoord->pro=projection_mg;
+ data->attr.u.pcoord->x=0x13a3e2;
+ data->attr.u.pcoord->y=0x5d6d6a;
+ gui_gtk_add_menu(this, "Bookmark 1", "Muenchen","/ui/MenuBar/Route/Bookmarks/BookmarkMenuAdditions",data);
+}
+
+static void
+gui_gtk_init(struct gui_priv *this, struct navit *nav)
+{
+ GtkWidget *widget;
+
+ gui_gtk_ui_init(this);
+
+ gui_gtk_toggle_init(this);
+ if (this->menubar_enable) {
+ widget=gtk_ui_manager_get_widget(this->ui_manager, "/ui/MenuBar");
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+ }
+ if (this->toolbar_enable) {
+ widget=gtk_ui_manager_get_widget(this->ui_manager, "/ui/ToolBar");
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+ }
+ if (this->statusbar_enable) {
+ this->statusbar=gui_gtk_statusbar_new(this);
+ }
+ gui_gtk_layouts_init(this);
+ gui_gtk_projections_init(this);
+ gui_gtk_vehicles_init(this);
+ gui_gtk_maps_init(this);
+ gui_gtk_destinations_init(this);
+ gui_gtk_bookmarks_init(this);
+}
+
static struct gui_priv *
gui_gtk_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs)
{
int w=792, h=547;
char *cp = getenv("NAVIT_XID");
unsigned xid = 0;
- struct attr *menubar, *toolbar, *statusbar;
+ struct attr *attr;
if (cp) {
xid = strtol(cp, NULL, 0);
}
- menubar = attr_search(attrs, NULL, attr_menubar);
- if (menubar && menubar->u.num == 0) {
- gui_gtk_methods.menubar_new = NULL;
+ this=g_new0(struct gui_priv, 1);
+ this->nav=nav;
+
+ attr = attr_search(attrs, NULL, attr_menubar);
+ if (attr) {
+ this->menubar_enable=attr->u.num;
+ } else {
+ this->menubar_enable=1;
}
- toolbar = attr_search(attrs, NULL, attr_toolbar);
- if (toolbar && toolbar->u.num == 0) {
- gui_gtk_methods.toolbar_new = NULL;
+ attr=attr_search(attrs, NULL, attr_toolbar);
+ if (attr) {
+ this->toolbar_enable=attr->u.num;
+ } else {
+ this->toolbar_enable=1;
}
- statusbar = attr_search(attrs, NULL, attr_statusbar);
- if (statusbar && statusbar->u.num == 0) {
- gui_gtk_methods.statusbar_new = NULL;
+ attr=attr_search(attrs, NULL, attr_statusbar);
+ if (attr) {
+ this->statusbar_enable=attr->u.num;
+ } else {
+ this->statusbar_enable=1;
}
+
*meth=gui_gtk_methods;
- this=g_new0(struct gui_priv, 1);
- this->nav=nav;
if (!xid)
this->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
else
gtk_container_add(GTK_CONTAINER(this->win), this->vbox);
gtk_widget_show_all(this->win);
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(gui_gtk_init), attr_navit, this));
return this;
}
#define YRES 600
-struct statusbar_methods;
struct menu_methods;
struct navit;
bool FormerDestGo(const char * name);
struct gui_priv {
-/*
- GtkWidget *win;
- GtkWidget *vbox;
- GtkActionGroup *base_group;
- GtkActionGroup *debug_group;
- GtkActionGroup *dyn_group;
- GtkUIManager *menu_manager;
- void *statusbar;*/
struct navit *nav;
int dyn_counter;
};
}
}
-static struct menu_priv *
-gui_sdl_toolbar_new(struct gui_priv *this_, struct menu_methods *meth)
-{
- return NULL; //gui_gtk_ui_new(this_, meth, "/ui/ToolBar", nav, 0);
-}
-
-static struct statusbar_priv *
-gui_sdl_statusbar_new(struct gui_priv *gui, struct statusbar_methods *meth)
-{
- return NULL; //gui_gtk_ui_new(this_, meth, "/ui/ToolBar", nav, 0);
-}
static struct menu_priv *
gui_sdl_menubar_new(struct gui_priv *this_, struct menu_methods *meth)
struct gui_methods gui_sdl_methods = {
gui_sdl_menubar_new,
- gui_sdl_toolbar_new,
- gui_sdl_statusbar_new,
gui_sdl_popup_new,
gui_sdl_set_graphics,
gui_run_main_loop,
struct attr attr;
int sats=0, sats_used=0;
- if (vehicle_position_attr_get(v, attr_position_speed, &attr))
+ if (vehicle_get_attr(v, attr_position_speed, &attr))
sprintf (buffer, "%02.02f km/h", *attr.u.numd);
else
strcpy (buffer, "N/A");
CEGUI::WindowManager::getSingleton().getWindow("OSD/SpeedoMeter")->setText(buffer);
- if (vehicle_position_attr_get(v, attr_position_height, &attr))
+ if (vehicle_get_attr(v, attr_position_height, &attr))
sprintf (buffer, "%.f m", *attr.u.numd);
else
strcpy (buffer, "N/A");
CEGUI::WindowManager::getSingleton().getWindow("OSD/Altimeter")->setText(buffer);
- if (vehicle_position_attr_get(v, attr_position_sats, &attr))
+ if (vehicle_get_attr(v, attr_position_sats, &attr))
sats=attr.u.num;
- if (vehicle_position_attr_get(v, attr_position_sats_used, &attr))
+ if (vehicle_get_attr(v, attr_position_sats_used, &attr))
sats_used=attr.u.num;
// printf(" sats : %i, used %i: \n",sats,sats_used);
// Sat image hardcoded for now. may break the TaharezSkin
#include "color.h"
#include "layout.h"
#include "log.h"
+#include "attr.h"
#define _(STRING) gettext(STRING)
/**
*/
struct navit_vehicle {
+#if 0
char *name;
+#endif
int update;
int update_curr;
int follow;
struct transformation *trans;
struct compass *compass;
struct menu *menu;
- struct menu *toolbar;
- struct statusbar *statusbar;
struct menu *menubar;
struct route *route;
struct navigation *navigation;
struct gui *main_loop_gui;
+struct attr_iter {
+ union {
+ GList *list;
+ struct mapset_handle *mapset_handle;
+ } u;
+};
+
static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv);
static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt);
}
}
this_->menubar=gui_menubar_new(this_->gui);
- this_->toolbar=gui_toolbar_new(this_->gui);
- this_->statusbar=gui_statusbar_new(this_->gui);
}
void
}
static void
-navit_map_toggle(struct menu *menu, struct navit *this_, struct map *map)
-{
- if ((menu_get_toggle(menu) != 0) != (map_get_active(map) != 0)) {
- map_set_active(map, (menu_get_toggle(menu) != 0));
- navit_draw(this_);
- }
-}
-
-static void
navit_projection_set(struct navit *this_, enum projection pro)
{
struct coord_geo g;
}
}
-static const char *
-navit_proj2str(enum projection pro)
-{
- switch (pro) {
- case projection_mg:
- return "mg";
- case projection_garmin:
- return "garmin";
- default:
- return "";
- }
-}
static void
navit_append_coord(struct navit *this_, char *file, struct pcoord *c, char *type, char *description, struct menu *rmen, GHashTable *h, void (*cb_func)(void))
{
if (f) {
offset=ftell(f);
if (c) {
- prostr = navit_proj2str(c->pro);
+ prostr = projection_to_name(c->pro);
fprintf(f,"%s%s0x%x 0x%x type=%s label=\"%s\"\n",
prostr, *prostr ? ":" : "", c->x, c->y, type, description);
} else
struct navit *global_navit;
-void
-navit_add_menu_layouts(struct navit *this_, struct menu *men)
-{
- GList *layouts;
- struct layout *l;
- struct callback *cb;
-
- layouts = this_->layouts;
- while (layouts) {
- l=layouts->data;
- cb=callback_new_2(callback_cast(navit_set_attr), this_, attr_new_from_text("layout",l->name));
- menu_add(men, l->name, menu_type_menu, cb);
- layouts=g_list_next(layouts);
- }
-}
-
-void
-navit_add_menu_layout(struct navit *this_, struct menu *men)
-{
- navit_add_menu_layouts(this_, menu_add(men, _("Layout"), menu_type_submenu, NULL));
-}
-
-void
-navit_add_menu_projections(struct navit *this_, struct menu *men)
-{
- struct callback *cb;
- cb=callback_new_2(callback_cast(navit_projection_set), this_, (void *)projection_mg);
- menu_add(men, "M&G", menu_type_menu, cb);
- cb=callback_new_2(callback_cast(navit_projection_set), this_, (void *)projection_garmin);
- menu_add(men, "Garmin", menu_type_menu, cb);
-}
-
-void
-navit_add_menu_projection(struct navit *this_, struct menu *men)
-{
- navit_add_menu_projections(this_, menu_add(men, _("Projection"), menu_type_submenu, NULL));
-}
-
-void
-navit_add_menu_maps(struct navit *this_, struct mapset *ms, struct menu *men)
-{
- struct mapset_handle *handle;
- struct map *map;
- struct menu *mmen;
- struct callback *cb;
-
- handle=mapset_open(ms);
- while ((map=mapset_next(handle,0))) {
- char *s=g_strdup_printf("%s:%s", map_get_type(map), map_get_filename(map));
- cb=callback_new_3(callback_cast(navit_map_toggle), NULL, this_, map);
- mmen=menu_add(men, s, menu_type_toggle, cb);
- callback_set_arg(cb, 0, mmen);
- menu_set_toggle(mmen, map_get_active(map));
- g_free(s);
- }
- mapset_close(handle);
-}
-
static void
navit_add_menu_destinations_from_file(struct navit *this_, char *file, struct menu *rmen, GHashTable *h, struct route *route, void (*cb_func)(void))
{
}
}
-void
+static void
navit_add_menu_former_destinations(struct navit *this_, struct menu *men, struct route *route)
{
if (men)
navit_add_menu_destinations_from_file(this_, "destination.txt", this_->destinations, NULL, route, callback_cast(navit_set_destination_from_destination));
}
-void
+static void
navit_add_menu_bookmarks(struct navit *this_, struct menu *men)
{
if (men)
}
static void
-navit_vehicle_toggle(struct navit *this_, struct navit_vehicle *nv)
-{
- if (menu_get_toggle(nv->menu)) {
- if (this_->vehicle && this_->vehicle != nv)
- menu_set_toggle(this_->vehicle->menu, 0);
- this_->vehicle=nv;
- } else {
- if (this_->vehicle == nv)
- this_->vehicle=NULL;
- }
-}
-
-void
-navit_add_menu_vehicles(struct navit *this_, struct menu *men)
-{
- struct navit_vehicle *nv;
- struct callback *cb;
- GList *l;
- l=this_->vehicles;
- while (l) {
- nv=l->data;
- cb=callback_new_2(callback_cast(navit_vehicle_toggle), this_, nv);
- nv->menu=menu_add(men, nv->name, menu_type_toggle, cb);
- menu_set_toggle(nv->menu, this_->vehicle == nv);
- l=g_list_next(l);
- }
-}
-
-void
-navit_add_menu_vehicle(struct navit *this_, struct menu *men)
-{
- men=menu_add(men, _("Vehicle"), menu_type_submenu, NULL);
- navit_add_menu_vehicles(this_, men);
-}
-
-static void
navit_textfile_debug_log(struct navit *this_, const char *fmt, ...)
{
va_list ap;
this_->windows_items=g_list_append(this_->windows_items, nwi);
}
-void
+static void
navit_add_menu_windows_items(struct navit *this_, struct menu *men)
{
struct navit_window_items *nwi;
}
navigation_set_mapset(this_->navigation, ms);
}
- if (this_->menubar) {
- men=menu_add(this_->menubar, _("Map"), menu_type_submenu, NULL);
- if (men) {
- navit_add_menu_layout(this_, men);
- navit_add_menu_projection(this_, men);
- navit_add_menu_vehicle(this_, men);
- navit_add_menu_maps(this_, ms, men);
- }
- men=menu_add(this_->menubar, _("Route"), menu_type_submenu, NULL);
- if (men) {
- navit_add_menu_former_destinations(this_, men, this_->route);
- navit_add_menu_bookmarks(this_, men);
- }
- } else
- navit_add_menu_former_destinations(this_, NULL, this_->route);
+ navit_add_menu_former_destinations(this_, NULL, this_->route);
}
if (this_->navigation && this_->speech) {
this_->nav_speech_cb=callback_new_1(callback_cast(navit_speak), this_);
int
navit_set_attr(struct navit *this_, struct attr *attr)
{
- GList *layouts;
- struct layout *l;
int dir=0, orient_old=0, attr_updated=0;
switch (attr->type) {
attr_updated=1;
}
break;
- case attr_tracking:
- if (this_->tracking_flag != !!attr->u.num) {
- this_->tracking_flag=!!attr->u.num;
+ case attr_layout:
+ if(this_->layout_current!=attr->u.layout) {
+ this_->layout_current=attr->u.layout;
+ navit_draw(this_);
attr_updated=1;
}
break;
attr_updated=1;
}
break;
- case attr_layout:
- layouts = this_->layouts;
- while (layouts) {
- l=layouts->data;
- if(!strcmp(attr->u.str,l->name) && this_->layout_current!=l) {
- this_->layout_current=l;
- navit_draw(this_);
- attr_updated=1;
+ case attr_projection:
+ if(this_->trans && transform_get_projection(this_->trans) != attr->u.projection) {
+ navit_projection_set(this_, attr->u.projection);
+ attr_updated=1;
+ }
+ break;
+ case attr_tracking:
+ if (this_->tracking_flag != !!attr->u.num) {
+ this_->tracking_flag=!!attr->u.num;
+ attr_updated=1;
+ }
+ break;
+ case attr_vehicle:
+ if (this_->vehicle && this_->vehicle->vehicle != attr->u.vehicle) {
+ GList *l;
+ l=this_->vehicles;
+ while(l) {
+ if (((struct navit_vehicle *)l->data)->vehicle == attr->u.vehicle) {
+ this_->vehicle=(struct navit_vehicle *)l;
+ attr_updated=1;
+ }
+ l=g_list_next(l);
}
- layouts=g_list_next(layouts);
}
break;
default:
}
int
-navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr)
+navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
{
switch (type) {
case attr_cursor:
attr->u.num=this_->cursor_flag;
break;
- case attr_tracking:
- attr->u.num=this_->tracking_flag;
+ case attr_destination:
+ if (! this_->destination_valid)
+ return 0;
+ attr->u.pcoord=&this_->destination;
+ break;
+ case attr_layout:
+ if (iter) {
+ if (iter->u.list) {
+ iter->u.list=g_list_next(iter->u.list);
+ } else {
+ iter->u.list=this_->layouts;
+ }
+ if (!iter->u.list)
+ return 0;
+ attr->u.layout=(struct layout *)iter->u.list->data;
+ } else {
+ attr->u.layout=this_->layout_current;
+ }
+ break;
+ case attr_map:
+ if (iter && this_->mapsets) {
+ if (!iter->u.mapset_handle) {
+ iter->u.mapset_handle=mapset_open((struct mapset *)this_->mapsets->data);
+ }
+ attr->u.map=mapset_next(iter->u.mapset_handle, 0);
+ if(!attr->u.map) {
+ mapset_close(iter->u.mapset_handle);
+ return 0;
+ }
+ } else {
+ return 0;
+ }
break;
case attr_orientation:
attr->u.num=this_->orient_north_flag;
break;
- case attr_layout:
- attr->u.str=g_strdup(this_->layout_current->name);
- break;
- case attr_destination:
- if (! this_->destination_valid)
+ case attr_projection:
+ if(this_->trans) {
+ attr->u.num=transform_get_projection(this_->trans);
+ } else {
return 0;
- attr->u.pcoord=&this_->destination;
+ }
+ break;
+ case attr_tracking:
+ attr->u.num=this_->tracking_flag;
+ break;
+ case attr_vehicle:
+ if(iter) {
+ if(iter->u.list) {
+ iter->u.list=g_list_next(iter->u.list);
+ } else {
+ iter->u.list=this_->vehicles;
+ }
+ if(!iter->u.list)
+ return 0;
+ attr->u.vehicle=((struct navit_vehicle*)iter->u.list->data)->vehicle;
+ } else {
+ if(this_->vehicle) {
+ attr->u.vehicle=this_->vehicle->vehicle;
+ } else {
+ return 0;
+ }
+ }
break;
default:
return 0;
return 1;
}
+struct attr_iter *
+navit_attr_iter_new()
+{
+ return g_new0(struct attr_iter, 1);
+}
+
+void
+navit_attr_iter_destroy(struct attr_iter *iter)
+{
+ g_free(iter);
+}
+
void
navit_add_callback(struct navit *this_, struct callback *cb)
{
if (! this_->ready)
return;
- if (! vehicle_position_attr_get(nv->vehicle, attr_position_direction, &attr_dir) ||
- ! vehicle_position_attr_get(nv->vehicle, attr_position_speed, &attr_speed) ||
- ! vehicle_position_attr_get(nv->vehicle, attr_position_coord_geo, &attr_pos))
+ if (! vehicle_get_attr(nv->vehicle, attr_position_direction, &attr_dir) ||
+ ! vehicle_get_attr(nv->vehicle, attr_position_speed, &attr_speed) ||
+ ! vehicle_get_attr(nv->vehicle, attr_position_coord_geo, &attr_pos))
return;
nv->dir=*attr_dir.u.numd;
nv->speed=*attr_speed.u.numd;
navit_add_vehicle(struct navit *this_, struct vehicle *v, struct attr **attrs)
{
struct navit_vehicle *nv=g_new0(struct navit_vehicle, 1);
- struct attr *name,*update,*follow,*color,*active, *color2, *animate;
+ struct attr *update,*follow,*color,*active, *color2, *animate;
nv->vehicle=v;
nv->update=1;
nv->follow=0;
nv->animate_cursor=0;
- nv->name="Noname";
- if ((name=attr_search(attrs, NULL, attr_name)))
- nv->name=g_strdup(name->u.str);
if ((update=attr_search(attrs, NULL, attr_update)))
nv->update=nv->update=update->u.num;
if ((follow=attr_search(attrs, NULL, attr_follow)))
enum item_type;
enum attr_type;
struct attr;
+struct attr_iter;
+struct attr_iter;
struct callback;
struct coord;
struct displaylist;
struct graphics *navit_get_graphics(struct navit *this_);
void navit_set_destination(struct navit *this_, struct pcoord *c, char *description);
void navit_add_bookmark(struct navit *this_, struct pcoord *c, char *description);
-void navit_add_menu_layouts(struct navit *this_, struct menu *men);
-void navit_add_menu_layout(struct navit *this_, struct menu *men);
-void navit_add_menu_projections(struct navit *this_, struct menu *men);
-void navit_add_menu_projection(struct navit *this_, struct menu *men);
-void navit_add_menu_maps(struct navit *this_, struct mapset *ms, struct menu *men);
-void navit_add_menu_former_destinations(struct navit *this_, struct menu *men, struct route *route);
-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_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_add_menu_windows_items(struct navit *this_, struct menu *men);
void navit_init(struct navit *this_);
void navit_set_center(struct navit *this_, struct pcoord *center);
void navit_set_center_screen(struct navit *this_, struct point *p);
int navit_set_attr(struct navit *this_, struct attr *attr);
-int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr);
+int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
int navit_add_attr(struct navit *this_, struct attr *attr, struct attr **attrs);
+struct attr_iter *navit_attr_iter_new(void);
+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);
<vehicle name="Meins" enabled="yes" source="gpsd://localhost" color="#0000ff" follow="1" refresh="1"/>
-->
- <vehicle name="Deins" enabled="no" source="gpsd://somehost" color="#0000aa"/>
+ <vehicle name="Demo" enabled="yes" source="demo://" color="#0000aa"/>
<tracking>
</tracking>
<route>
p.x=30;
p.y=30;
graphics_draw_circle(this->gr, this->white, &p, 50);
- if (v && vehicle_position_attr_get(v, attr_position_direction, &attr_dir)) {
+ if (v && vehicle_get_attr(v, attr_position_direction, &attr_dir)) {
vdir=*attr_dir.u.numd;
handle(this->gr, this->white, &p, 20, -vdir);
}
- if (navit_get_attr(nav, attr_destination, &destination_attr) && v && vehicle_position_attr_get(v, attr_position_coord_geo, &position_attr)) {
+ if (navit_get_attr(nav, attr_destination, &destination_attr, NULL) && v && vehicle_get_attr(v, attr_position_coord_geo, &position_attr)) {
pro=destination_attr.u.pcoord->pro;
transform_from_geo(pro, position_attr.u.coord_geo, &c1);
c2.x=destination_attr.u.pcoord->x;
projection_none, projection_mg, projection_garmin
};
+enum projection projection_from_name(const char *name);
+char * projection_to_name(enum projection proj);
+
#endif
#include "vehicle.h"
struct vehicle {
+ char *name;
struct vehicle_priv *priv;
struct vehicle_methods meth;
struct callback_list *cbl;
cbl,
struct attr ** attrs);
char *type, *colon;
+ struct attr *name;
dbg(1, "enter\n");
source = attr_search(attrs, NULL, attr_source);
}
dbg(1, "leave\n");
+ if ((name=attr_search(attrs, NULL, attr_name))) {
+ this_->name=g_strdup(name->u.str);
+ } else {
+ this_->name=g_strdup("Noname");
+ }
return this_;
}
int
-vehicle_position_attr_get(struct vehicle *this_, enum attr_type type,
- struct attr *attr)
+vehicle_get_attr(struct vehicle *this_, enum attr_type type, struct attr *attr)
{
- if (this_->meth.position_attr_get)
- return this_->meth.position_attr_get(this_->priv, type,
- attr);
- return 0;
+ switch (type) {
+ case attr_name:
+ attr->u.str=this_->name;
+ break;
+ default:
+ if (this_->meth.position_attr_get) {
+ return this_->meth.position_attr_get(this_->priv, type, attr);
+ } else {
+ return 0;
+ }
+ }
+ attr->type=type;
+ return 1;
}
int
vehicle_destroy(struct vehicle *this_)
{
callback_list_destroy(this_->cbl);
+ if(this_->name) g_free(this_->name);
g_free(this_);
}
/* prototypes */
struct vehicle *vehicle_new(struct attr **attrs);
-int vehicle_position_attr_get(struct vehicle *this_, enum attr_type type, struct attr *attr);
+int vehicle_get_attr(struct vehicle *this_, enum attr_type type, struct attr *attr);
int vehicle_set_attr(struct vehicle *this_, struct attr *attr, struct attr **attrs);
int vehicle_add_attr(struct vehicle *this_, struct attr *attr, struct attr **attrs);
int vehicle_remove_attr(struct vehicle *this_, struct attr *attr);