Fix:Core:More cleanups
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 20 Apr 2008 10:40:40 +0000 (10:40 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 20 Apr 2008 10:40:40 +0000 (10:40 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1025 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/src/attr_def.h
navit/src/navigation.c
navit/src/navigation.h
navit/src/navit.c
navit/src/popup.c
navit/src/route.c
navit/src/route.h
navit/src/xmlconfig.c

index 8480aae..9ea3f51 100644 (file)
@@ -38,6 +38,11 @@ ATTR(position_qual)
 ATTR(zoom)
 ATTR(retry_interval)
 ATTR(projection)
+ATTR(offroad)
+ATTR(vocabulary_name)
+ATTR(vocabulary_name_systematic)
+ATTR(vocabulary_distances)
+ATTR(announce_name_systematic_first)
 ATTR2(0x00028000,type_boolean_begin)
 /* boolean */
 ATTR(overwrite)
index cb8741d..faf95b0 100644 (file)
@@ -35,7 +35,6 @@ struct suffix {
 };
 
 struct navigation {
-       struct mapset *ms;
        struct map *map;
        struct item_hash *hash;
        struct navigation_itm *first;
@@ -60,11 +59,10 @@ struct navigation_command {
 };
 
 struct navigation *
-navigation_new(struct mapset *ms)
+navigation_new(struct attr **attrs)
 {
        int i,j;
        struct navigation *ret=g_new0(struct navigation, 1);
-       ret->ms=ms;
        ret->hash=item_hash_new();
        ret->callback=callback_list_new();
        ret->callback_speech=callback_list_new();
@@ -81,12 +79,6 @@ navigation_new(struct mapset *ms)
        return ret;     
 }
 
-void
-navigation_set_mapset(struct navigation *this_, struct mapset *ms)
-{
-       this_->ms=ms;
-}
-
 int
 navigation_set_announce(struct navigation *this_, enum item_type type, int *level)
 {
index 7f9bf8e..fb873eb 100644 (file)
@@ -7,13 +7,12 @@ extern "C" {
 /* prototypes */
 enum attr_type;
 enum item_type;
+struct attr;
 struct callback;
 struct map;
-struct mapset;
 struct navigation;
 struct route;
-struct navigation *navigation_new(struct mapset *ms);
-void navigation_set_mapset(struct navigation *this_, struct mapset *ms);
+struct navigation *navigation_new(struct attr **attrs);
 int navigation_set_announce(struct navigation *this_, enum item_type type, int *level);
 void navigation_update(struct navigation *this_, struct route *route);
 void navigation_flush(struct navigation *this_);
index b833187..b08fa19 100644 (file)
@@ -1066,7 +1066,6 @@ navit_init(struct navit *this_)
                                mapset_add(ms, map);
                                map_set_active(map, 0);
                        }
-                       navigation_set_mapset(this_->navigation, ms);
                }
                navit_add_bookmarks_from_file(this_);
                navit_add_former_destinations_from_file(this_);
@@ -1324,6 +1323,13 @@ navit_add_attr(struct navit *this_, struct attr *attr, struct attr **attrs)
                return navit_set_gui(this_, attr->u.gui);
        case attr_graphics:
                return navit_set_graphics(this_, attr->u.graphics);
+       case attr_route:
+               this_->route=attr->u.route;
+               route_set_projection(this_->route, transform_get_projection(this_->trans));
+               break;
+       case attr_navigation:
+               this_->navigation=attr->u.navigation;
+               break;
        default:
                return 0;
        }
@@ -1530,19 +1536,6 @@ navit_tracking_add(struct navit *this_, struct tracking *tracking)
 }
 
 void
-navit_route_add(struct navit *this_, struct route *route)
-{
-       this_->route=route;
-       route_set_projection(route, transform_get_projection(this_->trans));
-}
-
-void
-navit_navigation_add(struct navit *this_, struct navigation *navigation)
-{
-       this_->navigation=navigation;
-}
-
-void
 navit_set_speech(struct navit *this_, struct speech *speech)
 {
        this_->speech=speech;
index 2bbe36c..a9fe712 100644 (file)
@@ -166,7 +166,7 @@ popup_show_attrs(struct map *map, void *menu, struct item *item)
 }
 
 static void
-popup_show_item(void *popup, struct displayitem *di)
+popup_show_item(struct navit *nav, void *popup, struct displayitem *di)
 {
        struct map_rect *mr;
        void *menu, *menu_map, *menu_item;
@@ -189,6 +189,19 @@ popup_show_item(void *popup, struct displayitem *di)
                dbg(1,"item=%p\n", item);
                if (item) {
                        popup_show_attrs(item->map, menu_item, item);
+                       if (item->type < type_line) {
+                               struct coord co;
+                               struct pcoord *c;
+                               if (item_coord_get(item, &co, 1)) {
+                                       c=g_new(struct pcoord, 1);
+                                       c->pro = transform_get_projection(navit_get_trans(nav));
+                                       c->x = co.x;
+                                       c->y = co.y;
+                                       popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_position), nav, c), _("Set as position"));
+                                       popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, c), _("Set as destination"));
+                                       popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, c), _("Add as bookmark"));
+                               }
+                       }
                }
                map_rect_destroy(mr);
                menu_map=popup_printf(menu, menu_type_submenu, "Map");
@@ -208,7 +221,7 @@ popup_display(struct navit *nav, void *popup, struct point *p)
        dlh=graphics_displaylist_open(display);
        while ((di=graphics_displaylist_next(dlh))) {
                if (graphics_displayitem_within_dist(di, p, 5)) {
-                       popup_show_item(popup, di);
+                       popup_show_item(nav, popup, di);
                }
        }
        graphics_displaylist_close(dlh);
index 3c10789..f8082b9 100644 (file)
@@ -150,14 +150,13 @@ route_path_destroy(struct route_path *this)
 }
 
 struct route *
-route_new(struct mapset *ms)
+route_new(struct attr **attrs)
 {
        struct route *this=g_new0(struct route, 1);
        if (!this) {
                printf("%s:Out of memory\n", __FUNCTION__);
                return NULL;
        }
-       this->ms=ms;
        return this;
 }
 
index 9473bea..9fb4268 100644 (file)
@@ -37,7 +37,7 @@ struct route_path_segment;
 struct street_data;
 struct tracking;
 struct transformation;
-struct route *route_new(struct mapset *ms);
+struct route *route_new(struct attr **attrs);
 void route_set_mapset(struct route *this, struct mapset *ms);
 struct mapset *route_get_mapset(struct route *this);
 struct route_info *route_get_pos(struct route *this);
index f342205..cbd7289 100644 (file)
@@ -243,7 +243,7 @@ xmlconfig_graphics(struct xmlstate *state)
        attrs=convert_to_attrs(state);
        state->element_object = graphics_new(type, attrs);
        if (! state->element_object) {
-               dbg(0,"Failed to create graphics '%s'\n", type);
+               dbg(0,"Failed to create graphics object '%s'\n", type);
                return 0;
        }
        graphics_attr.type=attr_graphics;
@@ -262,7 +262,7 @@ xmlconfig_gui(struct xmlstate *state)
        attrs=convert_to_attrs(state);
        state->element_object = gui_new(state->parent->element_object, type, attrs);
        if (! state->element_object) {
-               dbg(0,"Failed to create gui '%s'\n", type);
+               dbg(0,"Failed to create gui object '%s'\n", type);
                return 0;
        }
        gui_attr.type=attr_gui;
@@ -356,9 +356,18 @@ xmlconfig_tracking(struct xmlstate *state)
 static int
 xmlconfig_route(struct xmlstate *state)
 {
-       state->element_object = route_new(NULL);
-       navit_route_add(state->parent->element_object, state->element_object);
-       return 1;
+       struct attr **attrs;
+       struct attr route_attr;
+
+       attrs=convert_to_attrs(state);
+       state->element_object = route_new(attrs);
+       if (! state->element_object) {
+               dbg(0,"Failed to create route object\n");
+               return 0;
+       }
+       route_attr.type=attr_route;
+       route_attr.u.route=state->element_object;
+       return navit_add_attr(state->parent->element_object, &route_attr, NULL);
 }
 
 static int
@@ -393,9 +402,18 @@ xmlconfig_speed(struct xmlstate *state)
 static int
 xmlconfig_navigation(struct xmlstate *state)
 {
-       state->element_object = navigation_new(NULL);
-       navit_navigation_add(state->parent->element_object, state->element_object);
-       return 1;
+       struct attr **attrs;
+       struct attr navigation_attr;
+
+       attrs=convert_to_attrs(state);
+       state->element_object = navigation_new(attrs);
+       if (! state->element_object) {
+               dbg(0,"Failed to create navigation object\n");
+               return 0;
+       }
+       navigation_attr.type=attr_navigation;
+       navigation_attr.u.navigation=state->element_object;
+       return navit_add_attr(state->parent->element_object, &navigation_attr, NULL);
 }
 
 static int