summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-04-20 10:40:40 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-04-20 10:40:40 +0000
commit496f8fbe05b59e37a4086abaf5e3543378bf6a43 (patch)
treec6c0f24e4196123774c20e3503e8f7af4d1e7679
parent008136425764337f8526c50e8dcd3889fa9f22e7 (diff)
downloadnavit-svn-496f8fbe05b59e37a4086abaf5e3543378bf6a43.tar.gz
Fix:Core:More cleanups
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@1025 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r--attr_def.h5
-rw-r--r--navigation.c10
-rw-r--r--navigation.h5
-rw-r--r--navit.c21
-rw-r--r--popup.c17
-rw-r--r--route.c3
-rw-r--r--route.h2
-rw-r--r--xmlconfig.c34
8 files changed, 58 insertions, 39 deletions
diff --git a/attr_def.h b/attr_def.h
index 8480aae2..9ea3f512 100644
--- a/attr_def.h
+++ b/attr_def.h
@@ -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)
diff --git a/navigation.c b/navigation.c
index cb8741d5..faf95b0d 100644
--- a/navigation.c
+++ b/navigation.c
@@ -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)
{
diff --git a/navigation.h b/navigation.h
index 7f9bf8e5..fb873ebf 100644
--- a/navigation.h
+++ b/navigation.h
@@ -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_);
diff --git a/navit.c b/navit.c
index b8331878..b08fa19d 100644
--- a/navit.c
+++ b/navit.c
@@ -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;
diff --git a/popup.c b/popup.c
index 2bbe36cf..a9fe7129 100644
--- a/popup.c
+++ b/popup.c
@@ -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);
diff --git a/route.c b/route.c
index 3c107899..f8082b98 100644
--- a/route.c
+++ b/route.c
@@ -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;
}
diff --git a/route.h b/route.h
index 9473bea7..9fb4268e 100644
--- a/route.h
+++ b/route.h
@@ -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);
diff --git a/xmlconfig.c b/xmlconfig.c
index f3422057..cbd7289f 100644
--- a/xmlconfig.c
+++ b/xmlconfig.c
@@ -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