gboolean
menu_cb_track_insert_mark(GtkAction * action)
{
-track_insert_mark();
-path_tree_view_update_store(track_tree_view, &_track);
+if (track_insert_mark()) {
+ map_render_paths();
+ MACRO_QUEUE_DRAW_AREA();
+ path_tree_view_update_store(track_tree_view, &_track);
+}
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);
+map_refresh_mark();
return TRUE;
}
((guint64)((((gint64)(b).unitx)-(a).unitx)*(((gint64)(b).unitx)-(a).unitx))\
+ (guint64)((((gint64)(b).unity)-(a).unity)*(((gint64)(b).unity)-(a).unity)))
-void route_find_nearest_point(void);
-void cancel_autoroute(gboolean temporary);
-void route_show_distance_to_last(void);
-void route_set_destination_from_last(void);
+static gboolean show_directions=TRUE;
typedef struct _OriginToggleInfo OriginToggleInfo;
struct _OriginToggleInfo {
GtkWidget *txt_to;
};
+void route_find_nearest_point(void);
+void route_cancel_autoroute(gboolean temporary);
+void route_show_distance_to_last(void);
+void route_set_destination_from_last(void);
+
void
route_init(void)
{
confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), _("Really clear the route?"));
if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
- cancel_autoroute(FALSE);
+ route_cancel_autoroute(FALSE);
route_deinit();
route_init();
route_find_nearest_point();
gtk_widget_destroy(confirm);
}
+/**
+ * Check if we should announce upcoming waypoints.
+ */
+void
+route_check_waypoint_announce(GpsData *gps)
+{
+guint announce_thres_unsquared;
+
+if (!gps)
+ return;
+
+announce_thres_unsquared=(20+(guint)gps->speed)*_announce_notice_ratio*3;
+
+if (_next_way_dist_squared < (announce_thres_unsquared * announce_thres_unsquared))
+ announce_waypoint(_next_way->desc);
+}
+
+/**
+ * Check if we should re-calculate route
+ */
+void
+route_autoroute_check(void)
+{
+if (_autoroute_data.enabled && !_autoroute_data.in_progress && _near_point_dist_squared > 400) {
+ MACRO_BANNER_SHOW_INFO(_window, _("Recalculating directions..."));
+ _autoroute_data.in_progress = TRUE;
+ show_directions = FALSE;
+ g_idle_add((GSourceFunc)auto_route_dl_idle, NULL);
+}
+}
+
gboolean
route_open_file(void)
{
if (file_open_get_contents(&_route_dir_uri, &buffer, &size)) {
/* If auto is enabled, append the route, otherwise replace it. */
if (parse_gpx(&_route, buffer, size, _autoroute_data.enabled ? 0 : 1)) {
- cancel_autoroute(FALSE);
+ route_cancel_autoroute(FALSE);
MACRO_BANNER_SHOW_INFO(_window, _("Route Opened"));
/* Find the nearest route point, if we're connected. */
* Cancel the current auto-route.
*/
void
-cancel_autoroute(gboolean temporary)
+route_cancel_autoroute(gboolean temporary)
{
if (_autoroute_data.enabled) {
if (!temporary) {
route_find_nearest_point();
/* Cancel any autoroute that might be occurring. */
- cancel_autoroute(FALSE);
+ route_cancel_autoroute(FALSE);
map_force_redraw();
gboolean route_open_file(void);
gboolean route_save(void);
+gboolean route_download(gchar * to);
void route_clear(void);
+
+void route_check_waypoint_announce(GpsData *gps);
+void route_autoroute_check(void);
+
gboolean auto_route_dl_idle();
-gboolean route_download(gchar * to);
+
WayPoint *find_nearest_waypoint(guint unitx, guint unity);
+
gboolean route_update_nears(gboolean quick);
+
+gboolean route_show_distance_to(Point * point);
void route_show_distance_to_last();
void route_show_distance_to_next();
-gboolean route_show_distance_to(Point * point);
#endif
};
static struct sql_select_stmt sql;
+/* Add sensitivity */
+static gint sensitivity=3;
+
void
track_init(void)
{
}
/**
- * Add a point to the _track list. This function is slightly overloaded,
- * since it is what houses the check for "have we moved
- * significantly": it also initiates the re-calculation of the _near_point
- * data, as well as calling osso_display_state_on() when we have the focus.
+ * Add a point to the _track list.
*
- * If a non-zero time is given, then the current position (as taken from the
- * _gps variable) is appended to _track with the given time. If time is zero,
- * then _point_null is appended to _track with time zero (this produces a "break"
- * in the track).
+ * If a non-null gps is given, then the current position is appended
+ * to _track with the given time. If gps is null, then _point_null is
+ * appended to _track with time zero (this produces a "break" in the track).
*/
-void
+gboolean
track_add(GpsData *gps)
{
-gboolean show_directions = TRUE;
-gint announce_thres_unsquared;
-
if (!gps) {
MACRO_PATH_INCREMENT_TAIL(_track);
*_track.tail=_point_null;
- return;
+ return FALSE;
}
-if (abs((gint)gps->unitx-_track.tail->unitx) > _draw_width || abs((gint)gps->unity-_track.tail->unity) > _draw_width) {
+if (abs((gint)gps->unitx-_track.tail->unitx) > sensitivity || abs((gint)gps->unity-_track.tail->unity) > sensitivity) {
/* If gps is available, update the nearest-waypoint data. */
if (gps && _route.head != _route.tail && (gps->newly_fixed ? (route_find_nearest_point(), TRUE) : route_update_nears(TRUE))) {
/* Instead of calling map_render_paths(), we'll draw the new line
* ourselves and call gtk_widget_queue_draw_area(). */
- map_render_segment(_gc[COLORABLE_TRACK], _gc[COLORABLE_TRACK_BREAK],
- _track.tail->unitx, _track.tail->unity, gps->unitx, gps->unity);
+ map_render_segment(_gc[COLORABLE_TRACK], _gc[COLORABLE_TRACK_BREAK],
+ _track.tail->unitx, _track.tail->unity, gps->unitx, gps->unity);
if (_track.tail->unity && _track.tail->unitx) {
tx1 = unit2x(_track.tail->unitx);
_track.points++;
}
-if (_autoroute_data.enabled && !_autoroute_data.in_progress && _near_point_dist_squared > 400) {
- MACRO_BANNER_SHOW_INFO(_window, _("Recalculating directions..."));
- _autoroute_data.in_progress = TRUE;
- show_directions = FALSE;
- g_idle_add((GSourceFunc)auto_route_dl_idle, NULL);
-}
-
-announce_thres_unsquared=(20+(guint)gps->speed)*_announce_notice_ratio*3;
-
-/* Check if we should announce upcoming waypoints. */
-if (gps && show_directions && _next_way_dist_squared < (announce_thres_unsquared * announce_thres_unsquared)) {
- if (_enable_voice && strcmp(_next_way->desc, _last_spoken_phrase)) {
- g_free(_last_spoken_phrase);
- _last_spoken_phrase=g_strdup(_next_way->desc);
- speak_text(_last_spoken_phrase);
- }
- MACRO_BANNER_SHOW_INFO(_window, _next_way->desc);
-}
-
/* Keep the display on if we are moving. */
KEEP_DISPLAY_ON();
+return TRUE;
}
gboolean
GtkWidget *label;
GtkWidget *txt_scroll;
GtkWidget *txt_desc;
+gboolean ret;
dialog = gtk_dialog_new_with_buttons(_("Insert Mark"),
- GTK_WINDOW(_window),
- GTK_DIALOG_MODAL, GTK_STOCK_OK,
- GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_REJECT, NULL);
+ GTK_WINDOW(_window), GTK_DIALOG_MODAL,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ 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_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), 450, 80);
+gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 450, 100);
gtk_widget_show_all(dialog);
+ret=FALSE;
while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
GtkTextBuffer *tbuf;
GtkTextIter ti1, ti2;
continue;
}
- map_render_paths();
- MACRO_QUEUE_DRAW_AREA();
+ ret=TRUE;
break;
}
gtk_widget_destroy(dialog);
-return TRUE;
+return ret;
}
void track_init(void);
void track_deinit(void);
-void track_add(GpsData *gps);
+gboolean track_add(GpsData *gps);
gboolean track_insert_break(void);
gboolean track_insert_mark(void);
gboolean track_save(void);
static GtkUIManager *ui;
struct ui_notebook_struct {
- GtkWidget *notebook;
- gint map;
- gint gps;
- gint heading;
+ GtkWidget *notebook;
+ gint map;
+ gint gps;
+ gint heading;
gint route;
gint track;
gint qpoi;
" </menu>"
" </menu>"
" <menu action='search'>"
-" <menuitem action='poi_search'/>"
" <menuitem action='search_address'/>"
" </menu>"
" <menu action='track'>"
" </menu>"
" <menu action='poi'>"
" <menuitem action='poi_categories'/>"
+" <menuitem action='poi_search'/>"
#if 0
" <separator/>"
" <menuitem action='poi_import'/>"
{"poi_settings", GTK_STOCK_PREFERENCES, N_("_Settings..."), NULL, NULL, NULL },
{"poi_add", GTK_STOCK_ADD, N_("_Add"), "<control>A", NULL, G_CALLBACK(cb_poi_add) },
{"poi_quick_add", GTK_STOCK_ABOUT, N_("_Quick Add"), "<control>E", NULL, G_CALLBACK(cb_poi_add) },
+ {"poi_search", GTK_STOCK_FIND, N_("_Search..."), NULL, NULL, G_CALLBACK(cb_poi_search) },
{"poi_import", GTK_STOCK_OPEN, N_("_Import..."), NULL, NULL, NULL },
{"poi_export", GTK_STOCK_SAVE, N_("_Export..."), NULL, NULL, NULL },
{"search", NULL, N_("_Search"), NULL, NULL, NULL },
- {"poi_search", GTK_STOCK_FIND, N_("_Search..."), "<control>P", NULL, G_CALLBACK(cb_poi_search) },
{"search_address", GTK_STOCK_FIND, N_("Address..."), "<control>F", NULL, G_CALLBACK(menu_cb_search_address) },
{"map", NULL, N_("_Map"), NULL, NULL, NULL },
{
g_assert(gps);
if (filter_check(&filter, &gps->data, &map_loc)==TRUE) {
- track_add(&_gps->data);
+ if (track_add(&_gps->data)) {
+ route_check_waypoint_announce(&_gps->data);
+ route_autoroute_check();
+ }
map_refresh_mark();
}
return FALSE;