dbus_message_iter_get_basic(&iter, &description);
dbg(0, " destination -> %s\n", description);
- navit_set_destination(navit, &pc, description);
+ navit_set_destination(navit, &pc, description, 1);
return empty_reply(connection, message);
}
{
PyObject *pcoord;
const char *description;
- if (!PyArg_ParseTuple(args, "O!s", &pcoord_Type, &pcoord, &description))
+ int async;
+ if (!PyArg_ParseTuple(args, "O!si", &pcoord_Type, &pcoord, &description, &async))
return NULL;
- navit_set_destination(self->navit, pcoord_py_get(pcoord), description);
+ navit_set_destination(self->navit, pcoord_py_get(pcoord), description, async);
Py_RETURN_NONE;
}
gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
if (c) {
desc=description(search, &iter);
- navit_set_destination(search->nav, c, desc);
+ navit_set_destination(search->nav, c, desc, 1);
g_free(desc);
}
}
static void
route_clear_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
{
- navit_set_destination(gui->nav, NULL, NULL);
+ navit_set_destination(gui->nav, NULL, NULL, 0);
}
static void
if(data->attr.type == attr_destination) {
char * label;
g_object_get(G_OBJECT(action), "label", &label,NULL);
- navit_set_destination(data->gui->nav, data->attr.u.pcoord, label);
+ navit_set_destination(data->gui->nav, data->attr.u.pcoord, label, 1);
g_free(label);
}
}
{
struct widget *w=wm->data;
dbg(0,"c=%d:0x%x,0x%x\n", w->c.pro, w->c.x, w->c.y);
- navit_set_destination(this->nav, &w->c, w->name);
+ navit_set_destination(this->nav, &w->c, w->name, 1);
if (this->flags & 512) {
struct attr follow;
follow.type=attr_follow;
static void
gui_internal_cmd_abort_navigation(struct gui_priv *this, struct widget *wm, void *data)
{
- navit_set_destination(this->nav, NULL, NULL);
+ navit_set_destination(this->nav, NULL, NULL, 0);
}
* @returns nothing
*/
void
-navit_set_destination(struct navit *this_, struct pcoord *c, const char *description)
+navit_set_destination(struct navit *this_, struct pcoord *c, const char *description, int async)
{
if (c) {
this_->destination=*c;
g_free(destination_file);
callback_list_call_attr_0(this_->attr_cbl, attr_destination);
if (this_->route) {
- route_set_destination(this_->route, c);
+ route_set_destination(this_->route, c, async);
if (this_->ready == 3)
navit_draw(this_);
pc.x=c.x;
pc.y=c.y;
if (valid) {
- route_set_destination(this_->route, &pc);
+ route_set_destination(this_->route, &pc, 1);
this_->destination=pc;
this_->destination_valid=1;
}
/* Finally, if we reached our destination, stop navigation. */
if (this_->route && route_destination_reached(this_->route)) {
- navit_set_destination(this_, NULL, NULL);
+ navit_set_destination(this_, NULL, NULL, 0);
}
profile(0,"return 5\n");
}
void navit_zoom_out(struct navit *this_, int factor, struct point *p);
struct navit *navit_new(struct attr *parent, struct attr **attrs);
struct graphics *navit_get_graphics(struct navit *this_);
-void navit_set_destination(struct navit *this_, struct pcoord *c, const char *description);
+void navit_set_destination(struct navit *this_, struct pcoord *c, const char *description, int async);
void navit_add_bookmark(struct navit *this_, struct pcoord *c, const char *description);
void navit_say(struct navit *this_, char *text);
int navit_speech_estimate(struct navit *this_, char *str);
transform_to_geo(transform_get_projection(navit_get_trans(nav)), &c, &g);
coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer_geo,sizeof(buffer_geo));
sprintf(buffer,"Map Point %s", buffer_geo);
- navit_set_destination(nav, pc, buffer);
+ navit_set_destination(nav, pc, buffer, 1);
}
static void
static struct route_info * route_find_nearest_street(struct vehicleprofile *vehicleprofile, struct mapset *ms, struct pcoord *c);
static struct route_graph_point *route_graph_get_point(struct route_graph *this, struct coord *c);
-static void route_graph_update(struct route *this, struct callback *cb);
+static void route_graph_update(struct route *this, struct callback *cb, int async);
static void route_graph_build_done(struct route_graph *rg, int cancel);
static struct route_path *route_path_new(struct route_graph *this, struct route_path *oldpath, struct route_info *pos, struct route_info *dst, struct vehicleprofile *profile);
static void route_process_street_graph(struct route_graph *this, struct item *item);
static void route_graph_destroy(struct route_graph *this);
-static void route_path_update(struct route *this, int cancel);
+static void route_path_update(struct route *this, int cancel, int async);
/**
* @brief Returns the projection used for this route
* @param this The route to update
*/
static void
-route_path_update(struct route *this, int cancel)
+route_path_update(struct route *this, int cancel, int async)
{
dbg(1,"enter %d\n", cancel);
if (! this->pos || ! this->dst) {
if (! this->route_graph_flood_done_cb)
this->route_graph_flood_done_cb=callback_new_2(callback_cast(route_path_update_done), this, 1);
dbg(1,"route_graph_update\n");
- route_graph_update(this, this->route_graph_flood_done_cb);
+ route_graph_update(this, this->route_graph_flood_done_cb, async);
}
}
if (! this->pos)
return;
route_info_distances(this->pos, pos->pro);
- route_path_update(this, 0);
+ route_path_update(this, 0, 1);
}
/**
dbg(3,"street 0=(0x%x,0x%x) %d=(0x%x,0x%x)\n", ret->street->c[0].x, ret->street->c[0].y, ret->street->count-1, ret->street->c[ret->street->count-1].x, ret->street->c[ret->street->count-1].y);
this->pos=ret;
if (this->dst)
- route_path_update(this, 0);
+ route_path_update(this, 0, 1);
dbg(2,"ret\n");
}
* @param dst Coordinates to set as destination
*/
void
-route_set_destination(struct route *this, struct pcoord *dst)
+route_set_destination(struct route *this, struct pcoord *dst, int async)
{
profile(0,NULL);
if (this->dst)
/* The graph has to be destroyed and set to NULL, otherwise route_path_update() doesn't work */
route_graph_destroy(this->graph);
this->graph=NULL;
- route_path_update(this, 1);
+ route_path_update(this, 1, async);
profile(0,"end");
}
* @return The new route graph.
*/
static struct route_graph *
-route_graph_build(struct mapset *ms, struct coord *c1, struct coord *c2, struct callback *done_cb)
+route_graph_build(struct mapset *ms, struct coord *c1, struct coord *c2, struct callback *done_cb, int async)
{
struct route_graph *ret=g_new0(struct route_graph, 1);
ret->done_cb=done_cb;
ret->busy=1;
if (route_graph_build_next_map(ret)) {
- ret->idle_cb=callback_new_1(callback_cast(route_graph_build_idle), ret);
- ret->idle_ev=event_add_idle(50, ret->idle_cb);
+ if (async) {
+ ret->idle_cb=callback_new_1(callback_cast(route_graph_build_idle), ret);
+ ret->idle_ev=event_add_idle(50, ret->idle_cb);
+ } else {
+ while (ret->busy)
+ route_graph_build_idle(ret);
+ }
} else
route_graph_build_done(ret, 0);
* @param this The route to update the graph for
*/
static void
-route_graph_update(struct route *this, struct callback *cb)
+route_graph_update(struct route *this, struct callback *cb, int async)
{
struct attr route_status;
this->route_graph_done_cb=callback_new_2(callback_cast(route_graph_update_done), this, cb);
route_status.u.num=route_status_building_graph;
route_set_attr(this, &route_status);
- this->graph=route_graph_build(this->ms, &this->pos->c, &this->dst->c, this->route_graph_done_cb);
+ this->graph=route_graph_build(this->ms, &this->pos->c, &this->dst->c, this->route_graph_done_cb, async);
}
/**
void route_set_position(struct route *this, struct pcoord *pos);
void route_set_position_from_tracking(struct route *this, struct tracking *tracking);
struct map_selection *route_rect(int order, struct coord *c1, struct coord *c2, int rel, int abs);
-void route_set_destination(struct route *this, struct pcoord *dst);
+void route_set_destination(struct route *this, struct pcoord *dst, int async);
struct route_path_handle *route_path_open(struct route *this);
struct route_path_segment *route_path_get_segment(struct route_path_handle *h);
struct coord *route_path_segment_get_start(struct route_path_segment *s);