if (abs((gint) _pos.unitx - _track.tail->unitx) > _draw_width
|| abs((gint) _pos.unity - _track.tail->unity) > _draw_width) {
+
/* If time != 0, update the nearest-waypoint data. */
- if (time && _route.head != _route.tail
- && (newly_fixed ? (route_find_nearest_point(), TRUE)
- : route_update_nears(TRUE))) {
+ if (time && _route.head != _route.tail &&
+ (newly_fixed ? (route_find_nearest_point(), TRUE) : route_update_nears(TRUE))) {
/* Nearest waypoint has changed - re-render paths. */
map_render_paths();
MACRO_QUEUE_DRAW_AREA();
}
+
if (_show_tracks & TRACKS_MASK) {
+ gint tx1, ty1, tx2, ty2;
+
/* Instead of calling map_render_paths(), we'll draw the new line
* ourselves and call gtk_widget_queue_draw_area(). */
- gint tx1, ty1, tx2, ty2;
map_render_segment(_gc[COLORABLE_TRACK],
_gc[COLORABLE_TRACK_BREAK],
_track.tail->unitx,
_track.tail->unity, _pos.unitx,
_pos.unity);
+
if (time && _track.tail->unity) {
tx1 = unit2x(_track.tail->unitx);
ty1 = unit2y(_track.tail->unity);
tx2 = unit2x(_pos.unitx);
ty2 = unit2y(_pos.unity);
gtk_widget_queue_draw_area(_map_widget,
- MIN(tx1,
- tx2) -
- _draw_width, MIN(ty1,
- ty2)
- - _draw_width,
- abs(tx1 - tx2) +
- (2 * _draw_width),
- abs(ty1 - ty2) +
- (2 * _draw_width));
+ MIN(tx1, tx2) - _draw_width,
+ MIN(ty1, ty2) - _draw_width,
+ abs(tx1 - tx2) + (2 * _draw_width),
+ abs(ty1 - ty2) + (2 * _draw_width));
}
}
+
MACRO_PATH_INCREMENT_TAIL(_track);
if (time)
else
*_track.tail = _point_null;
- if (_autoroute_data.enabled && !_autoroute_data.in_progress
- && _near_point_dist_squared > 400) {
- MACRO_BANNER_SHOW_INFO(_window,
- _
- ("Recalculating directions..."));
+ 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);
KEEP_DISPLAY_ON();
}
- announce_thres_unsquared = (20 + (guint) _gps.speed)
- * _announce_notice_ratio * 3;
+ announce_thres_unsquared = (20 + (guint) _gps.speed) * _announce_notice_ratio * 3;
+
/* Check if we should announce upcoming waypoints. */
if (show_directions && time && _next_way_dist_squared
< (announce_thres_unsquared * announce_thres_unsquared)) {
- if (_enable_voice
- && strcmp(_next_way->desc, _last_spoken_phrase)) {
+ if (_enable_voice && strcmp(_next_way->desc, _last_spoken_phrase)) {
g_free(_last_spoken_phrase);
_last_spoken_phrase = g_strdup(_next_way->desc);
sound_speak(_last_spoken_phrase);
x1 = unit2bufx(_track.tail->unitx);
y1 = unit2bufy(_track.tail->unity);
/* Make sure this circle will be visible. */
- if ((x1 < BUF_WIDTH_PIXELS)
- && ((unsigned)y1 < BUF_HEIGHT_PIXELS))
+ if ((x1 < BUF_WIDTH_PIXELS) && ((unsigned)y1 < BUF_HEIGHT_PIXELS))
gdk_draw_arc(_map_pixmap, _gc[COLORABLE_TRACK_BREAK], FALSE, /* FALSE: not filled. */
x1 - _draw_width, y1 - _draw_width, 2 * _draw_width, 2 * _draw_width, 0, /* start at 0 degrees. */
360 * 64);
return r;
}
-gboolean track_insert_mark(void)
+/**
+ * Add a text description at current point
+ *
+ */
+void track_insert_mark_text(gchar *text)
{
- gfloat lat, lon;
- gchar tmp1[16], tmp2[16], *p_latlon;
- GtkWidget *dialog;
- GtkWidget *table;
- GtkWidget *label;
- GtkWidget *txt_scroll;
- GtkWidget *txt_desc;
- printf("%s()\n", __PRETTY_FUNCTION__);
+MACRO_PATH_INCREMENT_WTAIL(_track);
+_track.wtail->point = _track.tail;
+_track.wtail->desc = text;
+}
- 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_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(_pos.unitx, _pos.unity, lat, lon);
- lat_format(lat, tmp1);
- lon_format(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),
+/**
+ * Ask for a text description for the current point
+ *
+ */
+
+gboolean track_insert_mark(void)
+{
+gfloat lat, lon;
+gchar tmp1[16], tmp2[16], *p_latlon;
+GtkWidget *dialog;
+GtkWidget *table;
+GtkWidget *label;
+GtkWidget *txt_scroll;
+GtkWidget *txt_desc;
+
+printf("%s()\n", __PRETTY_FUNCTION__);
+
+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_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(_pos.unitx, _pos.unity, lat, lon);
+lat_format(lat, tmp1);
+lon_format(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) {
- MACRO_PATH_INCREMENT_WTAIL(_track);
- _track.wtail->point = _track.tail;
- _track.wtail->desc = gtk_text_buffer_get_text(tbuf, &ti1, &ti2, TRUE);
- } else {
- popup_error(dialog, _("Please provide a description for the mark."));
- g_free(desc);
- continue;
- }
+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);
- map_render_paths();
- MACRO_QUEUE_DRAW_AREA();
- break;
+gtk_container_add(GTK_CONTAINER(txt_scroll), txt_desc);
+gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 450, 80);
+
+gtk_widget_show_all(dialog);
+
+while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
+ GtkTextBuffer *tbuf;
+ GtkTextIter ti1, ti2;
+
+ 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);
+
+ if (gtk_text_buffer_get_char_count(tbuf)>0) {
+ track_insert_mark_text(gtk_text_buffer_get_text(tbuf, &ti1, &ti2, TRUE));
+ } else {
+ popup_error(dialog, _("Please provide a description for the mark."));
+ continue;
}
- gtk_widget_destroy(dialog);
+
+ map_render_paths();
+ MACRO_QUEUE_DRAW_AREA();
+ break;
+}
+gtk_widget_destroy(dialog);
}