Changed api for gui and graphics
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 28 Aug 2007 17:31:21 +0000 (17:31 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 28 Aug 2007 17:31:21 +0000 (17:31 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@393 ffa7fe5e-494d-0410-b361-a75ebd5db220

33 files changed:
navit/src/attr.c
navit/src/attr.h
navit/src/attr_def.h
navit/src/binding/python/binding_python.c
navit/src/data/garmin_img/garmin_img.c
navit/src/data/mg/map.c
navit/src/data/mg/mg.h
navit/src/data/textfile/textfile.c
navit/src/graphics.c
navit/src/graphics.h
navit/src/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
navit/src/graphics/null/graphics_null.c
navit/src/graphics/opengl/graphics_opengl.c
navit/src/gui.c
navit/src/gui.h
navit/src/gui/gtk/gui_gtk_window.c
navit/src/gui/sdl/gui_sdl_window.cpp
navit/src/item.c
navit/src/item.h
navit/src/map.c
navit/src/map.h
navit/src/mapset.c
navit/src/maptype.c
navit/src/navigation.c
navit/src/navit.c
navit/src/navit.h
navit/src/navit.xml
navit/src/plugin_def.h
navit/src/route.c
navit/src/search.c
navit/src/track.c
navit/src/xmlconfig.c
navit/src/xpm/Makefile.am

index 7a5faab..ceb74dc 100644 (file)
@@ -20,7 +20,7 @@ static struct attr_name attr_names[]={
 };
 
 enum attr_type
-attr_from_name(char *name)
+attr_from_name(const char *name)
 {
        int i;
 
@@ -44,7 +44,7 @@ attr_to_name(enum attr_type attr)
 }
 
 struct attr *
-attr_new_from_text(char *name, char *value)
+attr_new_from_text(const char *name, const char *value)
 {
        enum attr_type attr;
        struct attr *ret;
@@ -57,6 +57,9 @@ attr_new_from_text(char *name, char *value)
        case attr_item_type:
                ret->u.item_type=item_from_name(value);
                break;
+       case attr_data:
+               ret->u.str=value;
+               break;
        default:
                dbg(1,"default\n");
                g_free(ret);
index 823872d..c4cc401 100644 (file)
@@ -21,10 +21,13 @@ struct attr {
        } u;
 };
 
-enum attr_type attr_from_name(char *name);
-char * attr_to_name(enum attr_type attr);
-struct attr * attr_new_from_text(char *name, char *value);
-struct attr * attr_search(struct attr **attrs, struct attr *last, enum attr_type attr);
+/* prototypes */
+enum attr_type;
+struct attr;
+enum attr_type attr_from_name(const char *name);
+char *attr_to_name(enum attr_type attr);
+struct attr *attr_new_from_text(const char *name, const char *value);
+struct attr *attr_search(struct attr **attrs, struct attr *last, enum attr_type attr);
 void attr_free(struct attr *attr);
-
+/* end of prototypes */
 #endif
index 0f25976..ae8a069 100644 (file)
@@ -12,9 +12,12 @@ ATTR2(type_item_end,0x0001ffff)
 ATTR2(type_int_begin,0x00020000)
 ATTR(id)
 ATTR(limit)
+ATTR(w)
+ATTR(h)
 ATTR2(type_int_end,0x0002ffff)
 ATTR2(type_string_begin,0x00030000)
 ATTR(label)
+ATTR(data)
 ATTR(country_all)
 ATTR(country_iso3)
 ATTR(country_iso2)
index 81c07e5..f1931e5 100644 (file)
@@ -2,6 +2,7 @@
 #include <Python.h>
 #include <fcntl.h>
 #include "coord.h"
+#include "projection.h"
 #include "map.h"
 #include "mapset.h"
 #include "plugin.h"
@@ -173,7 +174,7 @@ map_new_py(PyObject *self, PyObject *args)
        if (!PyArg_ParseTuple(args, "ss:navit.map", &type, &filename))
                return NULL;
        ret=PyObject_NEW(mapObject, &map_Type);
-       ret->m=map_new(type,filename,NULL);
+       ret->m=map_new(type,NULL);
        return (PyObject *)ret;
 }
 
index 86b03ca..0ba74f8 100644 (file)
@@ -5,13 +5,13 @@
 #include <math.h>
 #include "plugin.h"
 #include "data.h"
+#include "projection.h"
 #include "map.h"
 #include "maptype.h"
 #include "item.h"
 #include "attr.h"
 #include "coord.h"
 #include "transform.h"
-#include "projection.h"
 #include <stdio.h>
 #include "attr.h"
 #include "coord.h"
@@ -1458,6 +1458,8 @@ map_rect_get_item_byid_garmin_img(struct map_rect_priv *mr, int id_hi, int id_lo
 }
 
 static struct map_methods map_methods_garmin_img = {
+       projection_garmin,
+       "iso8859-1",
        map_destroy_garmin_img,
        map_charset_garmin_img,
        map_projection_garmin_img,
@@ -1468,13 +1470,17 @@ static struct map_methods map_methods_garmin_img = {
 };
 
 static struct map_priv *
-map_new_garmin_img(struct map_methods *meth, char *filename)
+map_new_garmin_img(struct map_methods *meth, struct attr **attrs)
 {
        struct map_priv *m;
+       struct attr *data=attr_search(attrs, NULL, attr_data);
+       if (! data)
+               return NULL;
+
        *meth=map_methods_garmin_img;
        m=g_new(struct map_priv, 1);
        m->id=++map_id;
-       m->filename=g_strdup(filename);
+       m->filename=g_strdup(data->u.str);
        return m;
 }
 
index 6122b98..c951d9f 100644 (file)
@@ -3,11 +3,10 @@
 #include "debug.h"
 #include "plugin.h"
 #include "maptype.h"
-#include "projection.h"
 #include "mg.h"
 
 
-struct map_priv * map_new_mg(struct map_methods *meth, char *dirname, struct attr **attrs, char **charset, enum projection *pro);
+struct map_priv * map_new_mg(struct map_methods *meth, struct attr **attrs);
 
 static int map_id;
 
@@ -248,6 +247,8 @@ map_search_get_item_mg(struct map_search_priv *ms)
 }
 
 static struct map_methods map_methods_mg = {
+       projection_mg,
+       "iso8859-1",
        map_destroy_mg,
        map_rect_new_mg,
        map_rect_destroy_mg,
@@ -259,30 +260,31 @@ static struct map_methods map_methods_mg = {
 };
 
 struct map_priv *
-map_new_mg(struct map_methods *meth, char *dirname, struct attr **attrs, char **charset, enum projection *pro)
+map_new_mg(struct map_methods *meth, struct attr **attrs)
 {
        struct map_priv *m;
-       int i,maybe_missing,len=strlen(dirname);
-       char filename[len+16];
+       int i,maybe_missing;
+       struct attr *data;
+       char *filename;
        
        *meth=map_methods_mg;
-       *charset="iso8859-1";
-       *pro=projection_mg;
+       data=attr_search(attrs, NULL, attr_data);
+       if (! data)
+               return NULL;
 
        m=g_new(struct map_priv, 1);
        m->id=++map_id;
-       m->dirname=g_strdup(dirname);
-       strcpy(filename, dirname);
-       filename[len]='/';
+       m->dirname=g_strdup(data->u.str);
        for (i = 0 ; i < file_end ; i++) {
                if (file[i]) {
-                       strcpy(filename+len+1, file[i]);
+                       filename=g_strdup_printf("%s/%s", data->u.str, file[i]);
                        m->file[i]=file_create_caseinsensitive(filename);
                        if (! m->file[i]) {
                                maybe_missing=(i == file_border_ply || i == file_height_ply || i == file_sea_ply);
                                if (! maybe_missing)
                                        g_warning("Failed to load %s", filename);
                        }
+                       g_free(filename);
                }
        }
 
index 78f72c0..62433af 100644 (file)
@@ -3,6 +3,7 @@
 #include "attr.h"
 #include "coord.h"
 #include "data.h"
+#include "projection.h"
 #include "map.h"
 #include "file.h"
 
index 17e62f8..cfa8930 100644 (file)
@@ -5,13 +5,13 @@
 #include <math.h>
 #include "debug.h"
 #include "plugin.h"
+#include "projection.h"
 #include "map.h"
 #include "maptype.h"
 #include "item.h"
 #include "attr.h"
 #include "coord.h"
 #include "transform.h"
-#include "projection.h"
 
 #include "textfile.h"
 
@@ -283,6 +283,8 @@ map_rect_get_item_byid_textfile(struct map_rect_priv *mr, int id_hi, int id_lo)
 }
 
 static struct map_methods map_methods_textfile = {
+       projection_mg,
+       "iso8859-1",
        map_destroy_textfile,
        map_rect_new_textfile,
        map_rect_destroy_textfile,
@@ -291,17 +293,18 @@ static struct map_methods map_methods_textfile = {
 };
 
 static struct map_priv *
-map_new_textfile(struct map_methods *meth, char *filename, struct attr **attrs, char **charset, enum projection *pro)
+map_new_textfile(struct map_methods *meth, struct attr **attrs)
 {
        struct map_priv *m;
-       dbg(1,"map_new_textfile %s\n",filename);        
+       struct attr *data=attr_search(attrs, NULL, attr_data);
+       if (! data)
+               return NULL;
+       dbg(1,"map_new_textfile %s\n", data->u.str);    
        *meth=map_methods_textfile;
-       *charset="iso8859-1";
-       *pro=projection_mg;
 
        m=g_new(struct map_priv, 1);
        m->id=++map_id;
-       m->filename=g_strdup(filename);
+       m->filename=g_strdup(data->u.str);
        return m;
 }
 
index 7a2f205..5c7c000 100644 (file)
@@ -6,10 +6,10 @@
 #include "draw_info.h"
 #include "point.h"
 #include "graphics.h"
+#include "projection.h"
 #include "map.h"
 #include "coord.h"
 #include "transform.h"
-#include "projection.h"
 #include "plugin.h"
 #include "profile.h"
 #include "mapset.h"
@@ -31,16 +31,16 @@ struct displaylist {
 };
 
 struct graphics *
-graphics_new(const char *type)
+graphics_new(const char *type, struct attr **attrs)
 {
        struct graphics *this_;
-       struct graphics_priv * (*new)(struct graphics_methods *meth);
+       struct graphics_priv * (*new)(struct graphics_methods *meth, struct attr **attrs);
 
        new=plugin_get_graphics_type(type);
        if (! new)
                return NULL;    
        this_=g_new0(struct graphics, 1);
-       this_->priv=(*new)(&this_->meth);
+       this_->priv=(*new)(&this_->meth, attrs);
        return this_;
 }
 
index 6218b34..fbf2c4f 100644 (file)
@@ -82,6 +82,7 @@ struct graphics_image {
 
 /* prototypes */
 enum draw_mode_num;
+struct attr;
 struct color;
 struct displayitem;
 struct displaylist;
@@ -94,7 +95,7 @@ struct item;
 struct point;
 struct route;
 struct transformation;
-struct graphics *graphics_new(const char *type);
+struct graphics *graphics_new(const char *type, struct attr **attrs);
 void graphics_init(struct graphics *this_);
 void *graphics_get_data(struct graphics *this_, char *type);
 void graphics_register_resize_callback(struct graphics *this_, void (*callback)(void *data, int w, int h), void *data);
@@ -112,12 +113,12 @@ void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct
 void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r);
 void display_add(struct displaylist *displaylist, struct item *item, int count, struct point *pnt, char *label);
 int graphics_ready(struct graphics *this_);
+void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, GList *layouts, struct route *route);
 void graphics_draw(struct graphics *gra, struct displaylist *displaylist, GList *mapsets, struct transformation *trans, GList *layouts, struct route *route);
 struct displaylist_handle *graphics_displaylist_open(struct displaylist *displaylist);
 struct displayitem *graphics_displaylist_next(struct displaylist_handle *dlh);
 void graphics_displaylist_close(struct displaylist_handle *dlh);
 struct displaylist *graphics_displaylist_new(void);
-void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, GList *layouts, struct route *route);
 struct item *graphics_displayitem_get_item(struct displayitem *di);
 char *graphics_displayitem_get_label(struct displayitem *di);
 int graphics_displayitem_within_dist(struct displayitem *di, struct point *p, int dist);
index cd38b2a..554f120 100644 (file)
@@ -758,7 +758,7 @@ graphics_gtk_drawing_area_new_helper(struct graphics_methods *meth)
 }
 
 static struct graphics_priv *
-graphics_gtk_drawing_area_new(struct graphics_methods *meth)
+graphics_gtk_drawing_area_new(struct graphics_methods *meth, struct attr **attrs)
 {
        GtkWidget *draw;
 
index 35ebd58..748a5bc 100644 (file)
@@ -194,7 +194,7 @@ overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct poin
 
 
 static struct graphics_priv *
-graphics_null_new(struct graphics_methods *meth)
+graphics_null_new(struct graphics_methods *meth, struct attr **attrs)
 {
        *meth=graphics_methods;
        return &graphics_priv;
index 8e42435..4a5b5fa 100644 (file)
@@ -891,7 +891,7 @@ static struct graphics_methods graphics_methods = {
 };
 
 static struct graphics_priv *
-graphics_opengl_new(struct graphics_methods *meth)
+graphics_opengl_new(struct graphics_methods *meth, struct attr **attrs)
 {
        struct graphics_priv *this=g_new0(struct graphics_priv,1);
        *meth=graphics_methods;
index 63a68d6..bddc916 100644 (file)
@@ -7,17 +7,17 @@
 #include "plugin.h"
 
 struct gui *
-gui_new(struct navit *nav, const char *type, int w, int h)
+gui_new(struct navit *nav, const char *type, struct attr **attrs)
 {
        struct gui *this_;
-       struct gui_priv *(*guitype_new)(struct navit *nav, struct gui_methods *meth, int w, int h);
+       struct gui_priv *(*guitype_new)(struct navit *nav, struct gui_methods *meth, struct attr **attrs);
 
         guitype_new=plugin_get_gui_type(type);
         if (! guitype_new)
                 return NULL;
 
        this_=g_new0(struct gui, 1);
-       this_->priv=guitype_new(nav, &this_->meth, w, h);
+       this_->priv=guitype_new(nav, &this_->meth, attrs);
        return this_;
 }
 
index f5238b7..c477d4d 100644 (file)
@@ -25,6 +25,7 @@ struct gui {
 };
 
 /* prototypes */
+struct attr;
 struct callback;
 struct coord;
 struct datawindow;
@@ -33,7 +34,7 @@ struct gui;
 struct menu;
 struct navit;
 struct statusbar;
-struct gui *gui_new(struct navit *nav, const char *type, int w, int h);
+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);
index 9d2f9ec..89c4b9d 100644 (file)
@@ -149,12 +149,13 @@ gui_gtk_delete(GtkWidget *widget, GdkEvent *event, struct navit *nav)
 }
 
 static struct gui_priv *
-gui_gtk_new(struct navit *nav, struct gui_methods *meth, int w, int h
+gui_gtk_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs
 {
        struct gui_priv *this;
+       int w=792, h=547;
 
        *meth=gui_gtk_methods;
-
+       
        this=g_new0(struct gui_priv, 1);
        this->nav=nav;
        this->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
index e999ec6..c6b9a37 100644 (file)
@@ -680,7 +680,7 @@ static void init_sdlgui(void)
 }
 
 static struct gui_priv *
-gui_sdl_new(struct navit *nav, struct gui_methods *meth, int w, int h
+gui_sdl_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs
 {
        dbg(1,"Begin SDL init\n");
        struct gui_priv *this_;
index 81ec9b2..aa18904 100644 (file)
@@ -53,7 +53,7 @@ struct item * item_new(char *type, int zoom)
 }
 
 enum item_type
-item_from_name(char *name)
+item_from_name(const char *name)
 {
        int i;
 
index d497f15..fe24dd8 100644 (file)
@@ -43,7 +43,7 @@ int item_coord_get(struct item *it, struct coord *c, int count);
 void item_attr_rewind(struct item *it);
 int item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr);
 struct item *item_new(char *type, int zoom);
-enum item_type item_from_name(char *name);
+enum item_type item_from_name(const char *name);
 char *item_to_name(enum item_type item);
 struct item_hash *item_hash_new(void);
 void item_hash_insert(struct item_hash *h, struct item *item, void *val);
index 36bf329..facf6da 100644 (file)
@@ -2,10 +2,10 @@
 #include <string.h>
 #include "debug.h"
 #include "coord.h"
+#include "projection.h"
 #include "map.h"
 #include "maptype.h"
 #include "transform.h"
-#include "projection.h"
 #include "item.h"
 #include "plugin.h"
 #include "country.h"
 struct map {
        struct map_methods meth;
        struct map_priv *priv;
-       char *filename;
        char *type;
-       char *charset;
+       char *filename;
        int active;
-       enum projection projection;
 };
 
 struct map_rect {
@@ -26,10 +24,12 @@ struct map_rect {
 };
 
 struct map *
-map_new(const char *type, const char *filename, struct attr **attrs)
+map_new(const char *type, struct attr **attrs)
 {
        struct map *m;
-       struct map_priv *(*maptype_new)(struct map_methods *meth, const char *name, struct attr *attrs, char **charset, enum projection *pro);
+       struct map_priv *(*maptype_new)(struct map_methods *meth, struct attr **attrs);
+       struct attr *data=attr_search(attrs, NULL, attr_data);
+
 
        maptype_new=plugin_get_map_type(type);
        if (! maptype_new)
@@ -37,9 +37,10 @@ map_new(const char *type, const char *filename, struct attr **attrs)
 
        m=g_new0(struct map, 1);
        m->active=1;
-       m->filename=g_strdup(filename);
        m->type=g_strdup(type);
-       m->priv=maptype_new(&m->meth, filename, attrs, &m->charset, &m->projection);
+       if (data) 
+               m->filename=g_strdup(data->u.str);
+       m->priv=maptype_new(&m->meth, attrs);
        return m;
 }
 
@@ -70,13 +71,13 @@ map_set_active(struct map *this, int active)
 int
 map_requires_conversion(struct map *this)
 {
-       return (this->charset != NULL); 
+       return (this->meth.charset != NULL);    
 }
 
 char *
 map_convert_string(struct map *this, char *str)
 {
-       return g_convert(str, -1,"utf-8",this->charset,NULL,NULL,NULL);
+       return g_convert(str, -1,"utf-8",this->meth.charset,NULL,NULL,NULL);
 }
 
 void
@@ -88,7 +89,7 @@ map_convert_free(char *str)
 enum projection
 map_projection(struct map *this)
 {
-       return this->projection;
+       return this->meth.pro;
 }
 
 void
index 9127494..84e5b02 100644 (file)
@@ -10,6 +10,8 @@ struct map_selection {
 };
 
 struct map_methods {
+       enum projection pro;
+       char *charset;
        void                    (*map_destroy)(struct map_priv *priv);
        struct map_rect_priv *  (*map_rect_new)(struct map_priv *map, struct map_selection *sel);
        void                    (*map_rect_destroy)(struct map_rect_priv *mr);
@@ -28,13 +30,14 @@ struct map;
 struct map_rect;
 struct map_search;
 struct map_selection;
-struct map *map_new(const char *type, const char *filename, struct attr **attrs);
-char * map_convert_string(struct map *this, char *str);
-void map_convert_free(char *str);
+struct map *map_new(const char *type, struct attr **attrs);
 char *map_get_filename(struct map *this);
 char *map_get_type(struct map *this);
 int map_get_active(struct map *this);
 void map_set_active(struct map *this, int active);
+int map_requires_conversion(struct map *this);
+char *map_convert_string(struct map *this, char *str);
+void map_convert_free(char *str);
 enum projection map_projection(struct map *this);
 void map_destroy(struct map *m);
 struct map_rect *map_rect_new(struct map *m, struct map_selection *sel);
@@ -44,4 +47,4 @@ void map_rect_destroy(struct map_rect *mr);
 struct map_search *map_search_new(struct map *m, struct item *item, struct attr *search_attr, int partial);
 struct item *map_search_get_item(struct map_search *this);
 void map_search_destroy(struct map_search *this);
-int map_requires_conversion(struct map *this);
+/* end of prototypes */
index 39cb0d5..e118bb9 100644 (file)
@@ -3,6 +3,7 @@
 #include "debug.h"
 #include "item.h"
 #include "mapset.h"
+#include "projection.h"
 #include "map.h"
 
 struct mapset {
index 8103961..0c0a26b 100644 (file)
@@ -1,4 +1,5 @@
 #include <glib.h>
+#include "projection.h"
 #include "map.h"
 #include "maptype.h"
 
index e23ce3f..5348165 100644 (file)
@@ -12,6 +12,7 @@
 #include "route.h"
 #include "transform.h"
 #include "mapset.h"
+#include "projection.h"
 #include "map.h"
 #include "navit.h"
 #include "callback.h"
index 7227b82..6aa995a 100644 (file)
 #include "callback.h"
 #include "gui.h"
 #include "item.h"
+#include "projection.h"
 #include "map.h"
 #include "mapset.h"
 #include "main.h"
 #include "coord.h"
 #include "point.h"
 #include "transform.h"
-#include "projection.h"
 #include "param.h"
 #include "menu.h"
 #include "graphics.h"
@@ -29,6 +29,7 @@
 #include "speech.h"
 #include "track.h"
 #include "vehicle.h"
+#include "color.h"
 
 #define _(STRING)    gettext(STRING)
 
@@ -38,6 +39,7 @@ struct navit_vehicle {
        int update_curr;
        int follow;
        int follow_curr;
+       struct color c;
        struct menu *menu;
        struct cursor *cursor;
        struct vehicle *vehicle;
@@ -83,6 +85,7 @@ struct navit {
 
 struct gui *main_loop_gui;
 
+static void navit_cursor_update(struct navit *this_, struct cursor *cursor);
 
 void
 navit_add_mapset(struct navit *this_, struct mapset *ms)
@@ -175,7 +178,7 @@ navit_zoom_out(struct navit *this_, int factor)
 }
 
 struct navit *
-navit_new(const char *ui, const char *graphics, struct coord *center, enum projection pro, int zoom)
+navit_new(struct coord *center, enum projection pro, int zoom)
 {
        struct navit *this_=g_new0(struct navit, 1);
        FILE *f;
@@ -198,39 +201,32 @@ navit_new(const char *ui, const char *graphics, struct coord *center, enum proje
 
        transform_setup(this_->trans, center, zoom, 0);
        this_->displaylist=graphics_displaylist_new();
-       this_->gui=gui_new(this_, ui, 792, 547);
-       if (! this_->gui) {
-               g_warning("failed to create gui '%s'", ui);
-               navit_destroy(this_);
-               return NULL;
-       }
+       return this_;
+}
+
+void
+navit_set_gui(struct navit *this_, struct gui *gui)
+{
+       this_->gui=gui;
        if (gui_has_main_loop(this_->gui)) {
                if (! main_loop_gui) {
                        main_loop_gui=this_->gui;
                } else {
                        g_warning("gui with main loop already active, ignoring this instance");
-                       navit_destroy(this_);
-                       return NULL;
+                       return;
                }
        }
        this_->menubar=gui_menubar_new(this_->gui);
        this_->toolbar=gui_toolbar_new(this_->gui);
        this_->statusbar=gui_statusbar_new(this_->gui);
-       this_->gra=graphics_new(graphics);
-       if (! this_->gra) {
-               g_warning("failed to create graphics '%s'", graphics);
-               navit_destroy(this_);
-               return NULL;
-       }
+}
+
+void
+navit_set_graphics(struct navit *this_, struct graphics *gra)
+{
+       this_->gra=gra;
        graphics_register_resize_callback(this_->gra, navit_resize, this_);
        graphics_register_button_callback(this_->gra, navit_button, this_);
-       if (gui_set_graphics(this_->gui, this_->gra)) {
-               g_warning("failed to connect graphics '%s' to gui '%s'\n", graphics, ui);
-               navit_destroy(this_);
-               return NULL;
-       }
-       graphics_init(this_->gra);
-       return this_;
 }
 
 static void
@@ -721,7 +717,7 @@ navit_window_items_open(struct menu *men, struct navit *this_, struct navit_wind
 }
 
 struct navit_window_items *
-navit_window_items_new(char *name, int distance)
+navit_window_items_new(const char *name, int distance)
 {
        struct navit_window_items *nwi=g_new0(struct navit_window_items, 1);
        nwi->name=g_strdup(name);
@@ -762,7 +758,23 @@ navit_init(struct navit *this_)
 {
        struct menu *men;
        struct mapset *ms;
+       GList *l;
+       struct navit_vehicle *nv;
 
+       if (!this_->gui || !this_->gra || gui_set_graphics(this_->gui, this_->gra)) {
+               g_warning("failed to connect graphics to gui\n");
+               navit_destroy(this_);
+               return;
+       }
+       graphics_init(this_->gra);
+       l=this_->vehicles;
+       while (l) {
+               nv=l->data;
+               nv->cursor=cursor_new(this_->gra, nv->vehicle, &nv->c, this_->trans);
+               nv->update_cb=callback_new_1(callback_cast(navit_cursor_update), this_);
+               cursor_add_callback(nv->cursor, nv->update_cb);
+               l=g_list_next(l);
+       }
        if (this_->mapsets) {
                ms=this_->mapsets->data;
                if (this_->route)
@@ -879,7 +891,7 @@ navit_cursor_update(struct navit *this_, struct cursor *cursor)
        cursor_c=cursor_pos_get(cursor);
        dir=cursor_get_dir(cursor);
        speed=cursor_get_speed(cursor);
-       pro=vehicle_projection(this_->vehicle);
+       pro=vehicle_projection(this_->vehicle->vehicle);
 
        if (!transform(this_->trans, pro, cursor_c, &pnt) || !transform_within_border(this_->trans, &pnt, border)) {
                if (!this_->cursor_flag)
@@ -942,9 +954,7 @@ navit_add_vehicle(struct navit *this_, struct vehicle *v, const char *name, stru
        nv->name=g_strdup(name);
        nv->update_curr=nv->update=update;
        nv->follow_curr=nv->follow=follow;
-       nv->cursor=cursor_new(this_->gra, v, c, this_->trans);
-       nv->update_cb=callback_new_1(callback_cast(navit_cursor_update), this_);
-       cursor_add_callback(nv->cursor, nv->update_cb);
+       nv->c=*c;
 
        this_->vehicles=g_list_append(this_->vehicles, nv);
        return nv;
index 9a3094e..fc22cdf 100644 (file)
@@ -3,12 +3,13 @@ extern "C" {
 #endif
 extern struct gui *main_loop_gui;
 /* prototypes */
-enum projection;
 enum item_type;
+enum projection;
 struct callback;
 struct color;
 struct coord;
 struct displaylist;
+struct graphics;
 struct gui;
 struct layout;
 struct mapset;
@@ -16,6 +17,7 @@ struct menu;
 struct navigation;
 struct navit;
 struct navit_vehicle;
+struct navit_window_items;
 struct point;
 struct route;
 struct speech;
@@ -29,7 +31,9 @@ void navit_draw(struct navit *this_);
 void navit_draw_displaylist(struct navit *this_);
 void navit_zoom_in(struct navit *this_, int factor);
 void navit_zoom_out(struct navit *this_, int factor);
-struct navit *navit_new(const char *ui, const char *graphics, struct coord *center, enum projection pro, int zoom);
+struct navit *navit_new(struct coord *center, enum projection pro, int zoom);
+void navit_set_gui(struct navit *this_, struct gui *gui);
+void navit_set_graphics(struct navit *this_, struct graphics *gra);
 void navit_set_destination(struct navit *this_, struct coord *c, char *description);
 void navit_add_bookmark(struct navit *this_, struct coord *c, char *description);
 void navit_add_menu_layouts(struct navit *this_, struct menu *men);
@@ -42,9 +46,9 @@ 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_window_roadbook_destroy(struct navit *this_);
-struct navit_window_items * navit_window_items_new(char *name, int distance);
+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);
index 85e9b43..d31275b 100644 (file)
@@ -5,9 +5,12 @@
        <plugin path="graphics/null/.libs/libgraphics_null.so" active="no" />
 </plugins>
 <debug name="navit:do_draw" level="0" />
-<navit gui="gtk" graphics="gtk_drawing_area" center="5031.51 N 735.83 E" zoom="8192" >
-<!-- For SDL, use rather the following line
-<navit gui="sdl" graphics="opengl" center="5031.51 N 305.83 E" zoom="128" >
+<navit center="5031.51 N 735.83 E" zoom="8192" >
+       <gui type="gtk" />
+       <graphics type="gtk_drawing_area" />
+<!-- For SDL, use rather the following lines
+       <gui type="sdl" />
+       <graphics type="opengl" />
 -->
        
        <vehicle name="Meins" enabled="yes" source="gpsd://localhost" color="#0000ff"/>
index 701598d..c3e9393 100644 (file)
@@ -3,9 +3,9 @@ struct attr;
 PLUGIN_FUNC1(draw, struct container *, co)
 PLUGIN_FUNC3(popup, struct container *, map, struct popup *, p, struct popup_item **, list)
 struct navit;
-PLUGIN_TYPE(graphics, (struct graphics_methods *meth)) 
-PLUGIN_TYPE(gui, (struct navit *nav, struct gui_methods *meth, int w, int h)) 
-PLUGIN_TYPE(map, (struct map_methods *meth, char *data, struct attr **attr, char **charset, enum projection *pro)) 
+PLUGIN_TYPE(graphics, (struct graphics_methods *meth, struct attr **attr)) 
+PLUGIN_TYPE(gui, (struct navit *nav, struct gui_methods *meth, struct attr **attr)) 
+PLUGIN_TYPE(map, (struct map_methods *meth, struct attr **attr)) 
 PLUGIN_TYPE(osd, (struct osd_methods *meth)) 
 PLUGIN_TYPE(speech, (char *data, struct speech_methods *meth)) 
 PLUGIN_TYPE(vehicle, (struct vehicle_methods *meth)) 
index 65dd0c3..345d2a7 100644 (file)
@@ -11,6 +11,7 @@
 #include "debug.h"
 #include "profile.h"
 #include "coord.h"
+#include "projection.h"
 #include "map.h"
 #include "mapset.h"
 #include "item.h"
@@ -958,7 +959,6 @@ route_info_free(struct route_info *inf)
 
 
 #include "point.h"
-#include "projection.h"
 
 struct street_data *
 route_info_street(struct route_info *rinf)
index 3d7e3e0..91f2cb3 100644 (file)
@@ -1,5 +1,6 @@
 #include <glib.h>
 #include "debug.h"
+#include "projection.h"
 #include "map.h"
 #include "mapset.h"
 #include "coord.h"
index 23ec5d3..38f83c7 100644 (file)
@@ -5,6 +5,7 @@
 #include "coord.h"
 #include "item.h"
 #include "route.h"
+#include "projection.h"
 #include "map.h"
 #include "mapset.h"
 
index 0c645f6..a36d3bd 100644 (file)
@@ -5,15 +5,18 @@
 #include "coord.h"
 #include "layout.h"
 #include "mapset.h"
+#include "projection.h"
 #include "map.h"
 #include "navigation.h"
 #include "navit.h"
 #include "plugin.h"
-#include "projection.h"
 #include "route.h"
 #include "speech.h"
 #include "track.h"
 #include "vehicle.h"
+#include "point.h"
+#include "graphics.h"
+#include "gui.h"
 #include "xmlconfig.h"
 
 
@@ -28,7 +31,7 @@ struct xmlstate {
 } *xmlstate_root;
 
 
-static struct attr ** convert_to_attr(struct xmlstate *state)
+static struct attr ** convert_to_attrs(struct xmlstate *state)
 {
        const gchar **attribute_name=state->attribute_names;
        const gchar **attribute_value=state->attribute_values;
@@ -39,7 +42,7 @@ static struct attr ** convert_to_attr(struct xmlstate *state)
                count++;
                attribute_name++;
        }
-       ret=g_new(struct attr, count+1);
+       ret=g_new(struct attr *, count+1);
        attribute_name=state->attribute_names;
        count=0;
        while (*attribute_name) {
@@ -186,7 +189,7 @@ xmlconfig_debug(struct xmlstate *state)
 static int
 xmlconfig_navit(struct xmlstate *state)
 {
-       const char *value,*gui,*graphics;
+       const char *value;
        int zoom=0;
        struct coord c;
        enum projection pro=projection_mg;
@@ -201,15 +204,39 @@ xmlconfig_navit(struct xmlstate *state)
                c.x=1300000;
                c.y=7000000;
        }
-       gui=find_attribute(state, "gui", 0);
-       if (! gui)
-               gui="gtk";
-       graphics=find_attribute(state, "graphics", 0);
-       if (! graphics)
-               graphics="gtk_drawing_area";
-       state->element_object = navit_new(gui, graphics, &c, pro, zoom);
+       state->element_object = navit_new(&c, pro, zoom);
+       if (! state->element_object)
+               return 0;
+       return 1;
+}
+
+static int
+xmlconfig_graphics(struct xmlstate *state)
+{
+       struct attr **attrs;
+       const char *type=find_attribute(state, "type", 1);
+       if (! type)
+               return 0;
+       attrs=convert_to_attrs(state);
+       state->element_object = graphics_new(type, attrs);
+       if (! state->element_object)
+               return 0;
+       navit_set_graphics(state->parent->element_object, state->element_object);
+       return 1;
+}
+
+static int
+xmlconfig_gui(struct xmlstate *state)
+{
+       struct attr **attrs;
+       const char *type=find_attribute(state, "type", 1);
+       if (! type)
+               return 0;
+       attrs=convert_to_attrs(state);
+       state->element_object = gui_new(state->parent->element_object, type, attrs);
        if (! state->element_object)
                return 0;
+       navit_set_gui(state->parent->element_object, state->element_object);
        return 1;
 }
 
@@ -369,13 +396,12 @@ xmlconfig_mapset(struct xmlstate *state)
 static int
 xmlconfig_map(struct xmlstate *state)
 {
-       struct attr **attr;
+       struct attr **attrs;
        const char *type=find_attribute(state, "type", 1);
-       const char *data=find_attribute(state, "data", 1);
-       if (! type || ! data)
+       if (! type)
                return 0;
-       attr=convert_to_attr(state);
-       state->element_object = map_new(type, data, attr);
+       attrs=convert_to_attrs(state);
+       state->element_object = map_new(type, attrs);
        if (! state->element_object)
                return 0;
        if (!find_boolean(state, "active", 1, 0))
@@ -551,6 +577,8 @@ struct element_func {
 } elements[] = {
        { "debug", NULL, xmlconfig_debug},
        { "navit", NULL, xmlconfig_navit},
+       { "graphics", "navit", xmlconfig_graphics},
+       { "gui", "navit", xmlconfig_gui},
        { "layout", "navit", xmlconfig_layout},
        { "layer", "layout", xmlconfig_layer},
        { "item", "layer", xmlconfig_item},
index 1c4507c..4117c9d 100644 (file)
@@ -1,3 +1,5 @@
 include $(top_srcdir)/Makefile.inc
-xpm_DATA = camping.xpm car_dealer.xpm flag_bk_tr.xpm flag_bk_wh.xpm flag_bl_wh.xpm fuel.xpm hospital.xpm hotel.xpm parking.xpm restaurant.xpm unknown.xpm
+xpm_DATA = camping.xpm car_dealer.xpm flag_bk_tr.xpm flag_bk_wh.xpm flag_bl_wh.xpm fuel.xpm hospital.xpm hotel.xpm parking.xpm restaurant.xpm unknown.xpm burgerking.ico
 EXTRA_DIST = $(xpm_DATA)
+burgerking.ico:
+       wget http://www.burgerking.de/favicon.ico -O burgerking.ico