#include "gps-panels.h"
#include "gps-conn.h"
#include "search.h"
+#include "dialogs.h"
+#include "filter-gui.h"
#include "help.h"
+#include "map-repo.h"
+#include "config-gconf.h"
-gboolean
-menu_cb_route_download(GtkAction * action)
+static gboolean
+path_tree_view_update_store(GtkWidget *tree_view, Path *path)
{
GtkListStore *store;
-route_download(NULL);
-store=route_generate_store(&_route);
-if (store!=NULL) {
- gtk_tree_view_set_model(route_tree_view, store);
- g_object_unref(G_OBJECT(store));
-}
+g_assert(tree_view);
+g_assert(path);
+
+store=path_generate_store(path);
+if (!store)
+ return FALSE;
+
+gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), store);
+g_object_unref(G_OBJECT(store));
return TRUE;
}
+/***********************
+ Route menu callbacks
+ ***********************/
gboolean
-menu_cb_route_open(GtkAction * action)
+menu_cb_route_download(GtkAction * action)
{
-GtkListStore *store;
+route_download(_route, NULL);
+route_menu_set_sensitive(path_tree_view_update_store(route_tree_view, _route));
+return TRUE;
+}
-route_open_file();
-store=route_generate_store(&_route);
-if (store!=NULL) {
- gtk_tree_view_set_model(route_tree_view, store);
- g_object_unref(G_OBJECT(store));
+gboolean
+menu_cb_route_open(GtkAction *action)
+{
+route_open_file(_route);
+route_menu_set_sensitive(path_tree_view_update_store(route_tree_view, _route));
+return TRUE;
}
+
+gboolean
+menu_cb_route_save(GtkAction * action)
+{
+route_save(_route);
return TRUE;
}
gboolean
menu_cb_route_distnext(GtkAction * action)
{
-route_show_distance_to_next();
+route_show_distance_to_next(_route);
return TRUE;
}
gboolean
menu_cb_route_distlast(GtkAction * action)
{
-route_show_distance_to_last();
+route_show_distance_to_last(_route);
return TRUE;
}
gboolean
menu_cb_route_reset(GtkAction * action)
{
-route_find_nearest_point();
+route_find_nearest_point(_route);
map_render_data();
MACRO_QUEUE_DRAW_AREA();
return TRUE;
gboolean
menu_cb_route_clear(GtkAction * action)
{
-route_clear();
-gtk_tree_view_set_model(route_tree_view, NULL);
+if (route_clear(_route)) {
+ gtk_tree_view_set_model(route_tree_view, NULL);
+ route_menu_set_sensitive(FALSE);
+}
return TRUE;
}
+/***********************
+ Track menu callbacks
+ ***********************/
gboolean
menu_cb_track_open(GtkAction * action)
{
-track_open();
+track_open(_track);
+path_tree_view_update_store(track_tree_view, _track);
return TRUE;
}
gboolean
menu_cb_track_save(GtkAction * action)
{
-track_save();
+track_save(_track);
+path_tree_view_update_store(track_tree_view, _track);
return TRUE;
}
gboolean
menu_cb_track_insert_break(GtkAction * action)
{
-track_insert_break();
+path_insert_break(_track);
+path_tree_view_update_store(track_tree_view, _track);
return TRUE;
}
gboolean
menu_cb_track_insert_mark(GtkAction * action)
{
-track_insert_mark();
+if (track_insert_mark(_track)) {
+ map_render_paths();
+ MACRO_QUEUE_DRAW_AREA();
+ path_tree_view_update_store(track_tree_view, _track);
+}
return TRUE;
}
gboolean
menu_cb_track_distlast(GtkAction * action)
{
-track_show_distance_from_last();
+track_show_distance_from_last(_track);
return TRUE;
}
gboolean
menu_cb_track_distfirst(GtkAction * action)
{
-track_show_distance_from_first();
-return TRUE;
-}
-
-gboolean
-menu_cb_route_save(GtkAction * action)
-{
-route_save();
+track_show_distance_from_first(_track);
return TRUE;
}
gboolean
menu_cb_track_clear(GtkAction * action)
{
-track_clear();
+track_clear(_track);
+path_tree_view_update_store(track_tree_view, _track);
return TRUE;
}
gboolean
menu_cb_track_filter(GtkAction * action)
{
-filter_dialog();
+filter_dialog(_window);
return TRUE;
}
+/***********************
+ Other menu callbacks
+ ***********************/
gboolean
menu_cb_show_tracks(GtkAction *action)
{
if (map_goto_position(&_home)==FALSE) {
MACRO_BANNER_SHOW_INFO(_window, _("Home not set."));
} else {
- map_set_zoom(3);
+ if (map_get_zoom()>3)
+ map_set_zoom(3);
MACRO_BANNER_SHOW_INFO(_window, _("At home location"));
}
return TRUE;
gboolean
menu_cb_goto_nextway(GtkAction * action)
{
-if (_next_way && _next_way->point->unity) {
+g_return_val_if_fail(_route, TRUE);
+
+if (_route->next_way && _route->next_way->point->unity) {
if (_center_mode > 0)
set_action_activate("autocenter_none", TRUE);
- map_center_unit(_next_way->point->unitx, _next_way->point->unity);
+ map_center_unit(_route->next_way->point->unitx, _route->next_way->point->unity);
} else {
MACRO_BANNER_SHOW_INFO(_window, _("There is no next waypoint."));
}
return TRUE;
}
+gboolean
+menu_cb_view_toolbar(GtkAction *action)
+{
+if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))
+ gtk_widget_show(_toolbar);
+else
+ gtk_widget_hide(_toolbar);
+
+return TRUE;
+}
+
gboolean
menu_cb_enable_gps(GtkAction * action)
{
gps_conn_set_state(_gps, RCVR_DOWN);
gps_connect_now(_gps);
} else {
- popup_error(_window, _("Cannot enable GPS until a GPS Receiver has been configured in the GPS Settings dialog."));
+ MACRO_BANNER_SHOW_INFO(_window, _("Cannot enable GPS until a GPS Receiver has been configured in the GPS Settings dialog."));
set_action_activate("gps_enabled", FALSE);
}
} else {
if (_gps->io.conn > RCVR_OFF)
gps_conn_set_state(_gps, RCVR_OFF);
gps_disconnect(_gps);
- track_add(NULL);
+ track_add(_track, NULL);
_speed_excess=FALSE;
}
if (_enable_gps==FALSE)
menu_cb_auto_download(GtkAction * action)
{
if ((_auto_download = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)) )) {
- if (_curr_repo->url == REPOTYPE_NONE)
+ if (_curr_repo->url == REPOTYPE_NONE) {
popup_error(_window, _("NOTE: You must set a Map URI in the current repository in order to download maps."));
+ /* set_action_activate("", FALSE); */
+ }
map_force_redraw();
+} else {
+ map_download_stop();
}
return TRUE;
gboolean
menu_cb_settings(GtkAction * action)
{
-settings_dialog();
-MACRO_RECALC_FOCUS_BASE();
-MACRO_RECALC_FOCUS_SIZE();
-map_force_redraw();
+if (settings_dialog()) {
+ MACRO_RECALC_FOCUS_BASE(_center_ratio);
+ MACRO_RECALC_FOCUS_SIZE(_center_ratio);
+ map_force_redraw();
+}
return TRUE;
}
gps_connect_now(_gps);
}
}
-MACRO_RECALC_FOCUS_BASE();
-MACRO_RECALC_FOCUS_SIZE();
-map_force_redraw();
+
return TRUE;
}
return TRUE;
}
+gboolean
+menu_cb_settings_keys(GtkAction * action)
+{
+settings_dialog_hardkeys();
+return TRUE;
+}
+
+gboolean
+menu_cb_import_osm(GtkAction * action)
+{
+osm_import_dialog(_window);
+return TRUE;
+}
+
gboolean
menu_cb_help(GtkAction * action)
{
return TRUE;
}
-gboolean
-window_cb_key_press(GtkWidget * widget, GdkEventKey * event)
+static CustomKey
+custom_key_get_type(gint keyval)
{
-CustomKey custom_key;
-
-switch (event->keyval) {
+switch (keyval) {
case HILDON_HARDKEY_UP:
- custom_key = CUSTOM_KEY_UP;
+ return CUSTOM_KEY_UP;
break;
case HILDON_HARDKEY_DOWN:
- custom_key = CUSTOM_KEY_DOWN;
+ return CUSTOM_KEY_DOWN;
break;
case HILDON_HARDKEY_LEFT:
- custom_key = CUSTOM_KEY_LEFT;
+ return CUSTOM_KEY_LEFT;
break;
case HILDON_HARDKEY_RIGHT:
- custom_key = CUSTOM_KEY_RIGHT;
+ return CUSTOM_KEY_RIGHT;
break;
case HILDON_HARDKEY_SELECT:
- custom_key = CUSTOM_KEY_SELECT;
+ return CUSTOM_KEY_SELECT;
break;
case HILDON_HARDKEY_INCREASE:
- custom_key = CUSTOM_KEY_INCREASE;
+ return CUSTOM_KEY_INCREASE;
break;
case HILDON_HARDKEY_DECREASE:
- custom_key = CUSTOM_KEY_DECREASE;
+ return CUSTOM_KEY_DECREASE;
break;
case HILDON_HARDKEY_FULLSCREEN:
- custom_key = CUSTOM_KEY_FULLSCREEN;
+ return CUSTOM_KEY_FULLSCREEN;
break;
case HILDON_HARDKEY_ESC:
- custom_key = CUSTOM_KEY_ESC;
+ return CUSTOM_KEY_ESC;
break;
default:
- return FALSE;
+ return CUSTOM_KEY_ENUM_COUNT;
}
- switch (_action[custom_key]) {
+}
+
+gboolean
+window_cb_key_press(GtkWidget * widget, GdkEventKey * event)
+{
+CustomKey custom_key;
+
+custom_key=custom_key_get_type(event->keyval);
+if (custom_key==CUSTOM_KEY_ENUM_COUNT)
+ return FALSE;
+
+switch (_action[custom_key]) {
case CUSTOM_ACTION_PAN_NORTH:
map_pan(0, -PAN_UNITS);
break;
break;
case CUSTOM_ACTION_TOGGLE_AUTOCENTER:
switch (_center_mode) {
- case CENTER_LATLON:
- case CENTER_WAS_LEAD:
- set_action_activate("autocenter_lead", TRUE);
- break;
- case CENTER_LEAD:
- case CENTER_WAS_LATLON:
- set_action_activate("autocenter_latlon", TRUE);
- break;
- default:
- set_action_activate("autocenter_latlon", TRUE);
- break;
+ case CENTER_LATLON:
+ case CENTER_WAS_LEAD:
+ set_action_activate("autocenter_lead", TRUE);
+ break;
+ case CENTER_LEAD:
+ case CENTER_WAS_LATLON:
+ set_action_activate("autocenter_latlon", TRUE);
+ break;
+ default:
+ set_action_activate("autocenter_latlon", TRUE);
+ break;
}
break;
case CUSTOM_ACTION_ZOOM_IN:
}
break;
case CUSTOM_ACTION_ROUTE_DISTNEXT:
- route_show_distance_to_next();
+ route_show_distance_to_next(_route);
break;
case CUSTOM_ACTION_ROUTE_DISTLAST:
- route_show_distance_to_last();
+ route_show_distance_to_last(_route);
break;
case CUSTOM_ACTION_TRACK_BREAK:
- track_insert_break();
+ path_insert_break(_track);
break;
case CUSTOM_ACTION_TRACK_DISTLAST:
- track_show_distance_from_last();
+ track_show_distance_from_last(_track);
break;
case CUSTOM_ACTION_TRACK_DISTFIRST:
- track_show_distance_from_first();
+ track_show_distance_from_first(_track);
break;
case CUSTOM_ACTION_TOGGLE_GPS:
set_action_activate("gps_enable", !_enable_gps);
g_ascii_formatd(strlon, 32, "%.06f", lon);
g_snprintf(buffer, sizeof(buffer), "%s, %s", strlat, strlon);
-route_download(buffer);
+route_download(_route, buffer);
}
void
void
cmenu_add_route(guint unitx, guint unity)
{
-MACRO_PATH_INCREMENT_TAIL(_route);
-_route.tail->unitx = x2unit(_cmenu_position_x);
-_route.tail->unity = y2unit(_cmenu_position_y);
-route_find_nearest_point();
+MACRO_PATH_INCREMENT_TAIL(*_route);
+_route->tail->unitx = x2unit(_cmenu_position_x);
+_route->tail->unity = y2unit(_cmenu_position_y);
+route_find_nearest_point(_route);
map_force_redraw();
}
GTK_STOCK_CANCEL,
GTK_RESPONSE_REJECT, NULL);
- gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
- table = gtk_table_new(2, 2, FALSE), TRUE, TRUE, 0);
-
- gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Lat, Lon")),
- 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
- gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-
- unit2latlon(unitx, unity, lat, lon);
- lat_format(_degformat, lat, tmp1);
- lon_format(_degformat, lon, tmp2);
- p_latlon = g_strdup_printf("%s, %s", tmp1, tmp2);
- gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(p_latlon),
- 1, 2, 0, 1, GTK_FILL, 0, 2, 4);
- gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
- g_free(p_latlon);
-
- gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Description")),
- 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
- gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-
- txt_scroll = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scroll),
- GTK_SHADOW_IN);
- gtk_table_attach(GTK_TABLE(table),
- txt_scroll,
- 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
-
- txt_desc = gtk_text_view_new();
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt_desc), GTK_WRAP_WORD);
-
- gtk_container_add(GTK_CONTAINER(txt_scroll), txt_desc);
- gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 400, 60);
-
- gtk_widget_show_all(dialog);
-
- while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
- GtkTextBuffer *tbuf;
- GtkTextIter ti1, ti2;
- gchar *desc;
-
- tbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_desc));
- gtk_text_buffer_get_iter_at_offset(tbuf, &ti1, 0);
- gtk_text_buffer_get_end_iter(tbuf, &ti2);
- desc = gtk_text_buffer_get_text(tbuf, &ti1, &ti2, TRUE);
-
- if (*desc) {
- /* There's a description. Add a waypoint. */
- MACRO_PATH_INCREMENT_TAIL(_route);
- _route.tail->unitx = unitx;
- _route.tail->unity = unity;
- _route.tail->time = 0;
- _route.tail->altitude = NAN;
-
- MACRO_PATH_INCREMENT_WTAIL(_route);
- _route.wtail->point = _route.tail;
- _route.wtail->desc
- = gtk_text_buffer_get_text(tbuf, &ti1, &ti2, TRUE);
- } else {
- GtkWidget *confirm;
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table = gtk_table_new(2, 2, FALSE), TRUE, TRUE, 0);
- g_free(desc);
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Lat, Lon")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
+gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
- confirm = hildon_note_new_confirmation(GTK_WINDOW(dialog),
- _("Creating a \"waypoint\" with no description actually "
- "adds a break point. Is that what you want?"));
+unit2latlon(unitx, unity, lat, lon);
+lat_format(_degformat, lat, tmp1);
+lon_format(_degformat, lon, tmp2);
+p_latlon = g_strdup_printf("%s, %s", tmp1, tmp2);
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(p_latlon), 1, 2, 0, 1, GTK_FILL, 0, 2, 4);
+gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
+g_free(p_latlon);
- if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
- /* There's no description. Add a break by adding a (0, 0)
- * point (if necessary), and then the ordinary route point. */
- if (_route.tail->unity) {
- MACRO_PATH_INCREMENT_TAIL(_route);
- *_route.tail = _point_null;
- }
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Description")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
+gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
- MACRO_PATH_INCREMENT_TAIL(_route);
- _route.tail->unitx = unitx;
- _route.tail->unity = unity;
- _route.tail->time = 0;
- _route.tail->altitude = NAN;
+txt_scroll = gtk_scrolled_window_new(NULL, NULL);
+gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scroll), GTK_SHADOW_IN);
+gtk_table_attach(GTK_TABLE(table), txt_scroll, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
- gtk_widget_destroy(confirm);
- } else {
- gtk_widget_destroy(confirm);
- continue;
+gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+txt_desc = gtk_text_view_new();
+gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt_desc), GTK_WRAP_WORD);
+
+gtk_container_add(GTK_CONTAINER(txt_scroll), txt_desc);
+gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 400, 60);
+
+gtk_widget_show_all(dialog);
+
+while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
+ GtkTextBuffer *tbuf;
+ GtkTextIter ti1, ti2;
+ gchar *desc;
+
+ tbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_desc));
+ gtk_text_buffer_get_iter_at_offset(tbuf, &ti1, 0);
+ gtk_text_buffer_get_end_iter(tbuf, &ti2);
+ desc = gtk_text_buffer_get_text(tbuf, &ti1, &ti2, TRUE);
+
+ if (*desc) {
+ /* There's a description. Add a waypoint. */
+ MACRO_PATH_INCREMENT_TAIL(*_route);
+ _route->tail->unitx = unitx;
+ _route->tail->unity = unity;
+ _route->tail->time = 0;
+ _route->tail->altitude = NAN;
+
+ MACRO_PATH_INCREMENT_WTAIL(*_route);
+ _route->wtail->point = _route->tail;
+ _route->wtail->desc = gtk_text_buffer_get_text(tbuf, &ti1, &ti2, TRUE);
+ } else {
+ GtkWidget *confirm;
+
+ g_free(desc);
+
+ confirm = hildon_note_new_confirmation(GTK_WINDOW(dialog),
+ _("Creating a \"waypoint\" with no description actually "
+ "adds a break point. Is that what you want?"));
+
+ if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
+ /* There's no description. Add a break by adding a (0, 0)
+ * point (if necessary), and then the ordinary route point. */
+ if (_route->tail->unity) {
+ MACRO_PATH_INCREMENT_TAIL(*_route);
+ *_route->tail = _point_null;
}
- }
- route_find_nearest_point();
- map_render_paths();
- MACRO_QUEUE_DRAW_AREA();
- break;
+ MACRO_PATH_INCREMENT_TAIL(*_route);
+ _route->tail->unitx = unitx;
+ _route->tail->unity = unity;
+ _route->tail->time = 0;
+ _route->tail->altitude = NAN;
+
+ gtk_widget_destroy(confirm);
+ } else {
+ gtk_widget_destroy(confirm);
+ continue;
+ }
}
+
+ route_find_nearest_point(_route);
+ map_render_paths();
+ MACRO_QUEUE_DRAW_AREA();
+ break;
+}
gtk_widget_destroy(dialog);
}
unit2latlon(unitx, unity, _home.lat, _home.lon);
_home.valid=TRUE;
-config_save_home();
+if (!config_save_position(&_home, GCONF_KEY_POSITION_HOME))
+ popup_error(_window, _("Failed to save home position."));
+
map_render_data();
return TRUE;
}
unity = y2unit(_cmenu_position_y);
unit2latlon(unitx, unity, _dest.lat, _dest.lon);
_dest.valid=TRUE;
-#if 0
-map_update_location_from_center();
-#endif
+if (!config_save_position(&_dest, GCONF_KEY_POSITION_DEST))
+ popup_error(_window, _("Failed to save destination."));
+
return TRUE;
}
unit2latlon(_gps->data.unitx, _gps->data.unity, _gps->data.lat, _gps->data.lon);
/* Move mark to new location. */
-map_refresh_mark();
_gps->data.time=time(NULL);
-track_add(&_gps->data);
+track_add(_track, &_gps->data);
+map_refresh_mark();
return TRUE;
}
{
WayPoint *way;
-if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
+if ((way = route_find_nearest_waypoint(_route, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
cmenu_show_latlon(way->point->unitx, way->point->unity);
return TRUE;
{
WayPoint *way;
-if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y)))) {
+if ((way = route_find_nearest_waypoint(_route, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y)))) {
MACRO_BANNER_SHOW_INFO(_window, way->desc);
}
{
WayPoint *way;
-if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
+if ((way = route_find_nearest_waypoint(_route, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
cmenu_clip_latlon(way->point->unitx, way->point->unity);
return TRUE;
}
{
WayPoint *way;
-if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
+if ((way = route_find_nearest_waypoint(_route, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), way->desc, -1);
return TRUE;
{
WayPoint *way;
-if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
+if ((way = route_find_nearest_waypoint(_route, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
cmenu_route_to(way->point->unitx, way->point->unity);
return TRUE;
{
WayPoint *way;
-if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
- route_show_distance_to(way->point);
+if ((way = route_find_nearest_waypoint(_route, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
+ route_show_distance_to(_route, way->point);
return TRUE;
}
{
WayPoint *way;
-if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y)))) {
+if ((way = route_find_nearest_waypoint(_route, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y)))) {
gchar buffer[BUFFER_SIZE];
GtkWidget *confirm;
guint num_del;
/* Delete surrounding route data, too. */
- if (way == _route.whead)
- pdel_min = _route.head;
+ if (way == _route->whead)
+ pdel_min = _route->head;
else
pdel_min = way[-1].point;
- if (way == _route.wtail)
- pdel_max = _route.tail;
+ if (way == _route->wtail)
+ pdel_max = _route->tail;
else
pdel_max = way[1].point;
&& pdel_end < pdel_max; pdel_end++) {
}
- /* If pdel_end is set to _route.tail, and if _route.tail is a
- * non-zero point, then delete _route.tail. */
- if (pdel_end == _route.tail && pdel_end->unity)
- pdel_end++; /* delete _route.tail too */
+ /* If pdel_end is set to _route->tail, and if _route->tail is a
+ * non-zero point, then delete _route->tail. */
+ if (pdel_end == _route->tail && pdel_end->unity)
+ pdel_end++; /* delete _route->tail too */
/* else, if *both* endpoints are zero points, delete one. */
else if (!pdel_start->unity && !pdel_end->unity)
pdel_start--;
/* Delete BETWEEN pdel_start and pdel_end, exclusive. */
num_del = pdel_end - pdel_start - 1;
- memmove(pdel_start + 1, pdel_end,(_route.tail - pdel_end + 1) * sizeof(Point));
- _route.tail -= num_del;
+ memmove(pdel_start + 1, pdel_end,(_route->tail - pdel_end + 1) * sizeof(Point));
+ _route->tail -= num_del;
/* Remove waypoint and move/adjust subsequent waypoints. */
g_free(way->desc);
- while (way++ != _route.wtail) {
+ while (way++ != _route->wtail) {
way[-1] = *way;
way[-1].point -= num_del;
}
- _route.wtail--;
+ _route->wtail--;
- route_find_nearest_point();
+ route_find_nearest_point(_route);
map_force_redraw();
}
gtk_widget_destroy(confirm);
{
WayPoint *way;
-if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y)))) {
+if ((way = route_find_nearest_waypoint(_route, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y)))) {
poi_info *p;
p=poi_new();
unit2latlon(way->point->unitx, way->point->unity, p->lat, p->lon);
poi_edit_dialog(ACTION_ADD_POI, p);
+ /* XXX: free it ? */
}
return TRUE;
}
poi_edit_dialog(ACTION_EDIT_POI, p);
return TRUE;
}
+
+/***/
+
+gboolean
+headphone_button_cb(gpointer data)
+{
+gint hb_action=0;
+switch (hb_action) {
+case 1:
+#if 0
+ /* XXX: Add code to add generic POI */
+ hildon_banner_show_information(_window, NULL, _("POI Added"));
+#endif
+break;
+case 0:
+default:
+ path_insert_mark_text(_track, g_strdup("Mark"));
+ hildon_banner_show_information(_window, NULL, _("Mark added"));
+break;
+}
+return FALSE;
+}