38 |
#define SAT_WIDTH 330 |
#define SAT_WIDTH 330 |
39 |
#define SAT_HEIGHT 60 |
#define SAT_HEIGHT 60 |
40 |
|
|
41 |
/* http://www.gtk.org/tutorial1.2/gtk_tut-30.html */ |
#ifdef ESPEAK |
42 |
/* http://developer.gimp.org/api/2.0/gdk/gdk-Drawing-Primitives.html */ |
#include <espeak/speak_lib.h> |
43 |
|
|
44 |
|
#define ESPEAK_TIMEOUT (15000) // every 15 seconds |
45 |
|
|
46 |
|
char *espeak_make_string(float dist, gboolean imperial) { |
47 |
|
char *retval = NULL; |
48 |
|
|
49 |
|
if(!imperial) { |
50 |
|
/* distance is in kilometers */ |
51 |
|
if(dist < 2.0/1000.0) |
52 |
|
retval = g_strdup(_("1 meter")); |
53 |
|
else if(dist < 1.0) |
54 |
|
retval = g_strdup_printf(_("%u meters"), (int)(dist*1000)); |
55 |
|
else if(dist < 2.0) |
56 |
|
retval = g_strdup(_("1 kilometer")); |
57 |
|
else |
58 |
|
retval = g_strdup_printf(_("%u kilometers"), (int)dist); |
59 |
|
} else { |
60 |
|
|
61 |
|
/* 1 mil = 1760 yd = 5280 ft ... */ |
62 |
|
if(dist < (2.0/5280.0)) |
63 |
|
retval = g_strdup(_("1 foot")); |
64 |
|
else if(dist < (1.0/1760.0)) |
65 |
|
retval = g_strdup_printf(_("%u feet"), (int)(dist*5280)); |
66 |
|
else if(dist < (2.0/1760.0)) |
67 |
|
retval = g_strdup(_("1 yard")); |
68 |
|
else if(dist < 1.0) |
69 |
|
retval = g_strdup_printf(_("%u yard"), (int)(dist*1760)); |
70 |
|
else if(dist < 2.0) |
71 |
|
retval = g_strdup(_("1 mile")); |
72 |
|
else |
73 |
|
retval = g_strdup_printf(_("%u miles"), (int)dist); |
74 |
|
} |
75 |
|
return retval; |
76 |
|
} |
77 |
|
|
78 |
|
static gboolean espeak_do(gpointer data) { |
79 |
|
cache_context_t *context = (cache_context_t*)data; |
80 |
|
|
81 |
|
pos_t *pos = gps_get_pos(context->appdata); |
82 |
|
if(pos && !isnan(pos->lat) && !isnan(pos->lon) && |
83 |
|
!isnan(context->gotoc.pos.lat) && !isnan(context->gotoc.pos.lon)) { |
84 |
|
|
85 |
|
/* build distance */ |
86 |
|
float dist = |
87 |
|
gpx_pos_get_distance(*pos, context->gotoc.pos, |
88 |
|
context->appdata->imperial); |
89 |
|
|
90 |
|
char *talk = espeak_make_string(dist, context->appdata->imperial); |
91 |
|
|
92 |
|
unsigned int unique_identifier=0; |
93 |
|
espeak_Synth(talk, strlen(talk)+1, 0, 0, 0, espeakCHARS_AUTO, |
94 |
|
&unique_identifier, NULL); |
95 |
|
|
96 |
|
g_free(talk); |
97 |
|
} |
98 |
|
|
99 |
|
return TRUE; // speak again |
100 |
|
} |
101 |
|
|
102 |
|
static void espeak_enable(cache_context_t *context, gboolean enable) { |
103 |
|
if(enable) { |
104 |
|
g_assert(!context->gotoc.espeak_handler); |
105 |
|
|
106 |
|
context->gotoc.espeak_handler = |
107 |
|
gtk_timeout_add(ESPEAK_TIMEOUT, espeak_do, context); |
108 |
|
|
109 |
|
espeak_do(context); |
110 |
|
|
111 |
|
} else { |
112 |
|
if(context->gotoc.espeak_handler) { |
113 |
|
gtk_timeout_remove(context->gotoc.espeak_handler); |
114 |
|
context->gotoc.espeak_handler = 0; |
115 |
|
} |
116 |
|
} |
117 |
|
} |
118 |
|
#endif |
119 |
|
|
120 |
static float rad2deg(float rad) { |
static float rad2deg(float rad) { |
121 |
return fmodf(360.0 + (180.0/M_PI) * rad, 360.0); |
return fmodf(360.0 + (180.0/M_PI) * rad, 360.0); |
163 |
/* draw the locked/unlocked icon */ |
/* draw the locked/unlocked icon */ |
164 |
gdk_draw_pixbuf(context->gotoc.compass_pixmap, |
gdk_draw_pixbuf(context->gotoc.compass_pixmap, |
165 |
widget->style->fg_gc[GTK_STATE_NORMAL], |
widget->style->fg_gc[GTK_STATE_NORMAL], |
166 |
icon_get(ICON_MISC, context->appdata->compass_locked?2:3), |
icon_get(ICON_MISC, context->appdata->compass_locked?0:1), |
167 |
0, 0, (width-diameter)/2 + diameter/32, |
0, 0, (width-diameter)/2 + diameter/32, |
168 |
(height+diameter)/2 - 16 - diameter/32 , 16, 16, |
(height+diameter)/2 - 16 - diameter/32 , 16, 16, |
169 |
GDK_RGB_DITHER_NONE,0,0); |
GDK_RGB_DITHER_NONE,0,0); |
270 |
GdkPoint arrow[4]; |
GdkPoint arrow[4]; |
271 |
|
|
272 |
pos_t *pos = gps_get_pos(context->appdata); |
pos_t *pos = gps_get_pos(context->appdata); |
273 |
if(pos) { |
if(pos && !isnan(pos->lat) && !isnan(pos->lon)) { |
274 |
context->appdata->gps = *pos; /* save position */ |
context->appdata->gps.saved = *pos; /* save position */ |
275 |
|
|
276 |
float arot = |
float arot = |
277 |
gpx_pos_get_bearing(*pos, context->gotoc.pos) * |
gpx_pos_get_bearing(*pos, context->gotoc.pos) * |
353 |
0, 0, width, height); |
0, 0, width, height); |
354 |
|
|
355 |
gps_sat_t *sat = gps_get_sats(context->appdata); |
gps_sat_t *sat = gps_get_sats(context->appdata); |
356 |
if(sat && sat->num) { |
gint sat_num = gps_get_satnum(context->appdata); |
357 |
|
|
358 |
|
if(sat && sat_num) { |
359 |
/* setup required colors */ |
/* setup required colors */ |
360 |
GdkGC *used_gc = gdk_gc_new(context->gotoc.sat_pixmap); |
GdkGC *used_gc = gdk_gc_new(context->gotoc.sat_pixmap); |
361 |
gdk_gc_copy(used_gc, widget->style->black_gc); |
gdk_gc_copy(used_gc, widget->style->black_gc); |
365 |
|
|
366 |
#define SAT_SPACING 3 |
#define SAT_SPACING 3 |
367 |
int i, x; |
int i, x; |
368 |
int swid = (width-SAT_SPACING*(sat->num-1))/sat->num; |
int swid = (width-SAT_SPACING*(sat_num-1))/sat_num; |
|
|
|
|
#if 0 |
|
|
int max_ss = 1; |
|
|
for(i=0;i<sat->num;i++) |
|
|
if(sat->ss[i] > max_ss) max_ss = sat->ss[i]; |
|
369 |
|
|
|
printf("max_ss = %d dB\n", max_ss); |
|
|
#else |
|
370 |
/* as of xgps, a ss of 40 and more is "plenty" */ |
/* as of xgps, a ss of 40 and more is "plenty" */ |
371 |
int max_ss = 40; |
int max_ss = 40; |
372 |
for(i=0;i<sat->num;i++) |
for(i=0;i<sat_num;i++) |
373 |
if(sat->ss[i] > max_ss) sat->ss[i] = max_ss; |
if(sat[i].ss > max_ss) sat[i].ss = max_ss; |
|
#endif |
|
374 |
|
|
375 |
if(swid > 40) { |
if(swid > 40) { |
376 |
swid = 40; |
swid = 40; |
377 |
x = (width-sat->num*swid)/2; |
x = (width-sat_num*swid)/2; |
378 |
} else |
} else |
379 |
x = 0; |
x = 0; |
380 |
|
|
381 |
for(i=0;i<sat->num;i++) { |
for(i=0;i<sat_num;i++) { |
382 |
char str[32]; |
char str[32]; |
383 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
384 |
snprintf(str, sizeof(str), "<span size=\"small\">%d</span>", sat->PRN[i]); |
snprintf(str, sizeof(str), "<span size=\"small\">%d</span>", sat[i].prn); |
385 |
PangoLayout *layout = gtk_widget_create_pango_layout(widget, NULL); |
PangoLayout *layout = gtk_widget_create_pango_layout(widget, NULL); |
386 |
pango_layout_set_markup(layout, str, strlen(str)); |
pango_layout_set_markup(layout, str, strlen(str)); |
387 |
#else |
#else |
388 |
snprintf(str, sizeof(str), "%d", sat->PRN[i]); |
snprintf(str, sizeof(str), "%d", sat[i].prn); |
389 |
PangoLayout *layout = gtk_widget_create_pango_layout(widget, str); |
PangoLayout *layout = gtk_widget_create_pango_layout(widget, str); |
390 |
#endif |
#endif |
391 |
|
|
392 |
int tw, th; |
int tw, th; |
393 |
pango_layout_get_pixel_size(layout, &tw, &th); |
pango_layout_get_pixel_size(layout, &tw, &th); |
394 |
gdk_draw_layout(context->gotoc.sat_pixmap, widget->style->black_gc, |
gdk_draw_layout(context->gotoc.sat_pixmap, |
395 |
|
widget->style->text_gc[GTK_STATE_NORMAL], |
396 |
x + swid/2 - tw/2, height - th, layout); |
x + swid/2 - tw/2, height - th, layout); |
397 |
|
|
398 |
g_object_unref(layout); |
g_object_unref(layout); |
399 |
|
|
400 |
int h = (height-th) * sat->ss[i] / max_ss; |
int h = (height-th) * sat[i].ss / max_ss; |
401 |
|
|
402 |
gdk_draw_rectangle(context->gotoc.sat_pixmap, |
gdk_draw_rectangle(context->gotoc.sat_pixmap, |
403 |
sat->used[i]?used_gc:widget->style->black_gc, |
sat[i].used?used_gc:widget->style->fg_gc[GTK_STATE_NORMAL], |
404 |
TRUE, |
TRUE, x, height-h-th, swid, h); |
|
x, height-h-th, swid, h); |
|
405 |
|
|
406 |
x += SAT_SPACING+swid; |
x += SAT_SPACING+swid; |
407 |
} |
} |
408 |
|
|
|
/* free sat infos */ |
|
|
free(sat->PRN); |
|
|
free(sat->ss); |
|
|
free(sat->used); |
|
409 |
} else { |
} else { |
410 |
PangoLayout *layout = gtk_widget_create_pango_layout(widget, _("No SAT info")); |
PangoLayout *layout = |
411 |
|
gtk_widget_create_pango_layout(widget, _("No SAT info")); |
412 |
int tw, th; |
int tw, th; |
413 |
pango_layout_get_pixel_size(layout, &tw, &th); |
pango_layout_get_pixel_size(layout, &tw, &th); |
414 |
gdk_draw_layout(context->gotoc.sat_pixmap, widget->style->black_gc, |
gdk_draw_layout(context->gotoc.sat_pixmap, |
415 |
|
widget->style->text_gc[GTK_STATE_NORMAL], |
416 |
(width - tw)/2, (height - th)/2, layout); |
(width - tw)/2, (height - th)/2, layout); |
417 |
|
|
418 |
g_object_unref(layout); |
g_object_unref(layout); |
419 |
} |
} |
|
|
|
|
/* free the sat structure */ |
|
|
if(sat) |
|
|
free(sat); |
|
420 |
} |
} |
421 |
|
|
422 |
/* Create a new backing pixmap of the appropriate size */ |
/* Create a new backing pixmap of the appropriate size */ |
456 |
|
|
457 |
printf("destroying goto view\n"); |
printf("destroying goto view\n"); |
458 |
|
|
459 |
|
#ifdef ESPEAK |
460 |
|
espeak_enable(context, FALSE); |
461 |
|
#endif |
462 |
|
|
463 |
/* stop timer */ |
/* stop timer */ |
464 |
if(context->gotoc.handler_id) |
if(context->gotoc.handler_id) |
465 |
gtk_timeout_remove(context->gotoc.handler_id); |
gtk_timeout_remove(context->gotoc.handler_id); |
493 |
} |
} |
494 |
|
|
495 |
pos_t *pos = gps_get_pos(context->appdata); |
pos_t *pos = gps_get_pos(context->appdata); |
496 |
if(pos) { |
if(pos && !isnan(pos->lat) && !isnan(pos->lon) && |
497 |
|
!isnan(context->gotoc.pos.lat) && !isnan(context->gotoc.pos.lon)) { |
498 |
char str[16]; |
char str[16]; |
499 |
gpx_pos_get_distance_str(str, sizeof(str), |
gpx_pos_get_distance_str(str, sizeof(str), |
500 |
*pos, context->gotoc.pos, |
*pos, context->gotoc.pos, |
509 |
gtk_label_set_text(GTK_LABEL(context->gotoc.bearing_label), "-----"); |
gtk_label_set_text(GTK_LABEL(context->gotoc.bearing_label), "-----"); |
510 |
} |
} |
511 |
|
|
512 |
float epe = gps_get_epe(context->appdata); |
float eph = gps_get_eph(context->appdata); |
513 |
if(isnan(epe)) |
if(isnan(eph)) |
514 |
gtk_label_set_text(GTK_LABEL(context->gotoc.epe_label), "-----"); |
gtk_label_set_text(GTK_LABEL(context->gotoc.eph_label), "-----"); |
515 |
else { |
else { |
516 |
char str[16]; |
char str[16]; |
517 |
if(context->appdata->imperial) { |
/* distance needs to be given in km */ |
518 |
epe *= 3.2808; |
if(context->appdata->imperial) |
519 |
snprintf(str, sizeof(str), "%.1f ft", epe); |
eph /= (6371.0/3959.0); // km to miles |
|
} else |
|
|
snprintf(str, sizeof(str), "%.1f m", epe); |
|
520 |
|
|
521 |
gtk_label_set_text(GTK_LABEL(context->gotoc.epe_label), str); |
distance_str(str, sizeof(str), eph/1000.0, context->appdata->imperial); |
522 |
|
gtk_label_set_text(GTK_LABEL(context->gotoc.eph_label), str); |
523 |
} |
} |
524 |
|
|
525 |
return TRUE; // fire again |
return TRUE; // fire again |
526 |
} |
} |
527 |
|
|
|
static gint waypoint_changed_event(GtkWidget *widget, gpointer data ) { |
|
|
cache_context_t *context = (cache_context_t*)data; |
|
|
int wpt_idx = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); |
|
|
|
|
|
/* get position of selected waypoint */ |
|
|
if(wpt_idx == 0) |
|
|
context->gotoc.pos = context->appdata->geomath; |
|
|
else if(wpt_idx == 1) |
|
|
// context->gotoc.pos = gpx_cache_pos(context->cache); |
|
|
context->gotoc.pos = notes_get_pos(context); |
|
|
else { |
|
|
wpt_t *wpt = context->cache->wpt; |
|
|
while(wpt_idx > 2) { |
|
|
g_assert(wpt != NULL); |
|
|
wpt = wpt->next; |
|
|
wpt_idx--; |
|
|
} |
|
|
context->gotoc.pos = wpt->pos; |
|
|
} |
|
|
|
|
|
char str[32]; |
|
|
pos_lat_str(str, sizeof(str), context->gotoc.pos.lat); |
|
|
gtk_label_set_text(GTK_LABEL(context->gotoc.lat_lbl), str); |
|
|
pos_lon_str(str, sizeof(str), context->gotoc.pos.lon); |
|
|
gtk_label_set_text(GTK_LABEL(context->gotoc.lon_lbl), str); |
|
|
|
|
|
goto_update(context); |
|
|
|
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
static void manual_pos_update(cache_context_t *context) { |
|
|
context->gotoc.pos.lat = context->appdata->manual_goto.lat; |
|
|
context->gotoc.pos.lon = context->appdata->manual_goto.lon; |
|
|
|
|
|
char str[32]; |
|
|
pos_lat_str(str, sizeof(str), context->gotoc.pos.lat); |
|
|
gtk_label_set_text(GTK_LABEL(context->gotoc.lat_lbl), str); |
|
|
pos_lon_str(str, sizeof(str), context->gotoc.pos.lon); |
|
|
gtk_label_set_text(GTK_LABEL(context->gotoc.lon_lbl), str); |
|
|
|
|
|
goto_update(context); |
|
|
} |
|
|
|
|
|
static void on_posedit_clicked(GtkWidget *button, gpointer data) { |
|
|
cache_context_t *context = (cache_context_t*)data; |
|
|
|
|
|
GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Edit Position"), |
|
|
GTK_WINDOW(context->appdata->window), GTK_DIALOG_MODAL, |
|
|
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); |
|
|
|
|
|
GtkWidget *lat, *lon, *label; |
|
|
GtkWidget *table = gtk_table_new(2, 2, FALSE); |
|
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(table), |
|
|
label = gtk_label_new(_("Latitude:")), 0, 1, 0, 1); |
|
|
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
|
|
gtk_table_attach_defaults(GTK_TABLE(table), |
|
|
lat = lat_entry_new(context->appdata->manual_goto.lat), |
|
|
1, 2, 0, 1); |
|
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(table), |
|
|
label = gtk_label_new(_("Longitude:")), 0, 1, 1, 2); |
|
|
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
|
|
gtk_table_attach_defaults(GTK_TABLE(table), |
|
|
lon = lon_entry_new(context->appdata->manual_goto.lon), |
|
|
1, 2, 1, 2); |
|
|
|
|
|
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
|
|
|
|
|
gtk_widget_show_all(dialog); |
|
|
|
|
|
if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { |
|
|
if(isnan(lat_get(lat)) || isnan(lon_get(lon))) |
|
|
errorf(_("Ignoring invalid position")); |
|
|
else { |
|
|
context->appdata->manual_goto.lat = lat_get(lat); |
|
|
context->appdata->manual_goto.lon = lon_get(lon); |
|
|
|
|
|
manual_pos_update(context); |
|
|
} |
|
|
} |
|
|
gtk_widget_destroy(dialog); |
|
|
} |
|
|
|
|
|
static gint radio_changed_event(GtkWidget *widget, gpointer data ) { |
|
|
cache_context_t *context = (cache_context_t*)data; |
|
|
|
|
|
if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { |
|
|
manual_pos_update(context); |
|
|
gtk_widget_set_sensitive(context->gotoc.edit_but, TRUE); |
|
|
} else { |
|
|
waypoint_changed_event(context->gotoc.cbox, data); |
|
|
gtk_widget_set_sensitive(context->gotoc.edit_but, FALSE); |
|
|
} |
|
|
|
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
#ifdef USE_MAEMO |
|
|
static void on_mm_button_clicked(GtkButton *button, gpointer data) { |
|
|
cache_context_t *context = (cache_context_t*)data; |
|
|
|
|
|
dbus_mm_set_position(context->appdata, &context->gotoc.pos); |
|
|
} |
|
|
#endif |
|
|
|
|
528 |
static gboolean compass_clicked_event(GtkWidget *widget, GdkEventButton *event, |
static gboolean compass_clicked_event(GtkWidget *widget, GdkEventButton *event, |
529 |
gpointer user_data) { |
gpointer user_data) { |
530 |
cache_context_t *context = (cache_context_t*)user_data; |
cache_context_t *context = (cache_context_t*)user_data; |
544 |
return FALSE; |
return FALSE; |
545 |
} |
} |
546 |
|
|
547 |
|
static void pos_modified(GtkWidget *widget, gpointer data ) { |
548 |
|
cache_context_t *context = (cache_context_t*)data; |
549 |
|
|
550 |
|
/* extract position from entries */ |
551 |
|
context->gotoc.pos.lat = lat_entry_get(context->gotoc.lat_entry); |
552 |
|
context->gotoc.pos.lon = lon_entry_get(context->gotoc.lon_entry); |
553 |
|
|
554 |
|
goto_update(context); |
555 |
|
} |
556 |
|
|
557 |
|
#ifdef ESPEAK |
558 |
|
static void espeak_clicked(GtkWidget *widget, gpointer data) { |
559 |
|
cache_context_t *context = (cache_context_t*)data; |
560 |
|
|
561 |
|
GtkWidget *icon = gtk_button_get_image(GTK_BUTTON(widget)); |
562 |
|
gtk_widget_destroy(icon); |
563 |
|
context->appdata->espeak.enabled = !context->appdata->espeak.enabled; |
564 |
|
gtk_button_set_image(GTK_BUTTON(widget), icon_get_widget(ICON_MISC, |
565 |
|
context->appdata->espeak.enabled?6:7)); |
566 |
|
|
567 |
|
espeak_enable(context, context->appdata->espeak.enabled); |
568 |
|
} |
569 |
|
#endif |
570 |
|
|
571 |
|
/* create "goto" tab */ |
572 |
GtkWidget *goto_cache(cache_context_t *context) { |
GtkWidget *goto_cache(cache_context_t *context) { |
573 |
int i; |
int i; |
574 |
|
|
578 |
|
|
579 |
context->gotoc.pos = gpx_cache_pos(context->cache); |
context->gotoc.pos = gpx_cache_pos(context->cache); |
580 |
|
|
581 |
GtkWidget *hbox = gtk_hbox_new(FALSE, 0); |
GtkWidget *hbox = gtk_hbox_new(FALSE, 32); |
582 |
|
|
583 |
context->gotoc.compass_area = gtk_drawing_area_new(); |
context->gotoc.compass_area = gtk_drawing_area_new(); |
584 |
gtk_drawing_area_size(GTK_DRAWING_AREA(context->gotoc.compass_area), |
gtk_drawing_area_size(GTK_DRAWING_AREA(context->gotoc.compass_area), |
597 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context->gotoc.compass_area); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context->gotoc.compass_area); |
598 |
|
|
599 |
GtkWidget *vbox = gtk_vbox_new(FALSE, 0); |
GtkWidget *vbox = gtk_vbox_new(FALSE, 0); |
600 |
GtkWidget *table = gtk_table_new(8, 2, FALSE); |
GtkWidget *table = gtk_table_new(5, 3, FALSE); |
601 |
|
|
602 |
/* ---------- combo box containing waypoint names ------- */ |
/* ---------- destination coordinates ------- */ |
|
GtkWidget *radio = gtk_radio_button_new_with_label(NULL, _("Waypoint:")); |
|
|
gtk_table_attach_defaults(GTK_TABLE(table), radio, 0,1,0,1); |
|
|
|
|
|
context->gotoc.cbox = gtk_combo_box_new_text(); |
|
|
gtk_combo_box_append_text(GTK_COMBO_BOX(context->gotoc.cbox), _("Geomath")); |
|
|
gtk_combo_box_append_text(GTK_COMBO_BOX(context->gotoc.cbox), |
|
|
context->cache->id); |
|
|
|
|
|
wpt_t *wpt = context->cache->wpt; |
|
|
while(wpt) { |
|
|
gtk_combo_box_append_text(GTK_COMBO_BOX(context->gotoc.cbox), wpt->id); |
|
|
wpt = wpt->next; |
|
|
} |
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(context->gotoc.cbox), 1); |
|
|
gtk_signal_connect(GTK_OBJECT(context->gotoc.cbox), "changed", |
|
|
(GtkSignalFunc)waypoint_changed_event, context); |
|
|
gtk_table_attach_defaults(GTK_TABLE(table), context->gotoc.cbox, 1,2,0,1); |
|
|
|
|
|
/* -------------- manual entry field ------------------------- */ |
|
|
gtk_table_attach_defaults(GTK_TABLE(table), |
|
|
gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(radio), |
|
|
_("Manual:")), 0,1,1,2); |
|
|
gtk_signal_connect(GTK_OBJECT(radio), "clicked", |
|
|
(GtkSignalFunc)radio_changed_event, context); |
|
|
|
|
|
context->gotoc.edit_but = gtk_button_new_with_label(_("Edit")); |
|
|
gtk_table_attach_defaults(GTK_TABLE(table), context->gotoc.edit_but, 1,2,1,2); |
|
|
gtk_signal_connect(GTK_OBJECT(context->gotoc.edit_but), "clicked", |
|
|
(GtkSignalFunc)on_posedit_clicked, context); |
|
|
gtk_widget_set_sensitive(context->gotoc.edit_but, FALSE); |
|
|
|
|
|
#if 0 |
|
|
context->gotoc.man_lat = gtk_entry_new(); |
|
|
gtk_table_attach_defaults(GTK_TABLE(table), context->gotoc.man_lat, 1,2,1,2); |
|
|
pos_lat_str(str, sizeof(str), context->appdata->manual_goto.lat); |
|
|
gtk_entry_set_text(GTK_ENTRY(context->gotoc.man_lat), str); |
|
|
textbox_disable(context->gotoc.man_lat); |
|
|
context->gotoc.man_lon = gtk_entry_new(); |
|
|
gtk_table_attach_defaults(GTK_TABLE(table), context->gotoc.man_lon, 1,2,2,3); |
|
|
pos_lon_str(str, sizeof(str), context->appdata->manual_goto.lon); |
|
|
gtk_entry_set_text(GTK_ENTRY(context->gotoc.man_lon), str); |
|
|
textbox_disable(context->gotoc.man_lon); |
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(context->gotoc.man_lat), "changed", |
|
|
(GtkSignalFunc)entry_changed_event, context); |
|
|
gtk_signal_connect(GTK_OBJECT(context->gotoc.man_lon), "changed", |
|
|
(GtkSignalFunc)entry_changed_event, context); |
|
|
#endif |
|
603 |
|
|
|
gtk_table_set_row_spacing(GTK_TABLE(table), 2, 16); |
|
|
|
|
|
/* -------------- waypoint coordinates ------------------------- */ |
|
604 |
/* SIZE_SMALL doesn't work here as setting the label returns to normal */ |
/* SIZE_SMALL doesn't work here as setting the label returns to normal */ |
605 |
context->gotoc.lat_lbl = pos_lat(context->gotoc.pos.lat, SIZE_NORMAL, |
gtk_table_attach_defaults(GTK_TABLE(table), left_label_new(_("Latitude:")), 0,1,0,1); |
606 |
STRIKETHROUGH_NONE); |
context->gotoc.lat_entry = lat_entry_new(context->gotoc.pos.lat); |
607 |
gtk_table_attach_defaults(GTK_TABLE(table), context->gotoc.lat_lbl,0,1,3,4); |
gtk_table_attach_defaults(GTK_TABLE(table), context->gotoc.lat_entry, 1,2,0,1); |
608 |
context->gotoc.lon_lbl = pos_lon(context->gotoc.pos.lon, SIZE_NORMAL, |
gtk_table_attach_defaults(GTK_TABLE(table), left_label_new(_("Longitude:")), 0,1,1,2); |
609 |
STRIKETHROUGH_NONE); |
context->gotoc.lon_entry = lon_entry_new(context->gotoc.pos.lon); |
610 |
gtk_table_attach_defaults(GTK_TABLE(table), context->gotoc.lon_lbl,1,2,3,4); |
gtk_table_attach_defaults(GTK_TABLE(table), context->gotoc.lon_entry, 1,2,1,2); |
611 |
|
|
612 |
|
g_signal_connect(G_OBJECT(context->gotoc.lat_entry), "changed", |
613 |
|
G_CALLBACK(pos_modified), context); |
614 |
|
g_signal_connect(G_OBJECT(context->gotoc.lon_entry), "changed", |
615 |
|
G_CALLBACK(pos_modified), context); |
616 |
|
|
617 |
|
gtk_table_attach_defaults(GTK_TABLE(table), preset_coordinate_picker(context->appdata, |
618 |
|
context->gotoc.lat_entry, context->gotoc.lon_entry), 2,3,0,1); |
619 |
|
|
620 |
|
gtk_table_attach_defaults(GTK_TABLE(table), goto_coordinate(context->appdata, |
621 |
|
context->gotoc.lat_entry, context->gotoc.lon_entry), 2,3,1,2); |
622 |
|
|
623 |
|
gtk_table_set_row_spacing(GTK_TABLE(table), 1, 16); |
624 |
|
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 16); |
625 |
|
|
626 |
/* -------------- distance label ------------------------- */ |
/* -------------- distance label ------------------------- */ |
627 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), left_label_new(_("Distance:")), 0,1,2,3); |
|
gtk_label_new(_("Distance:")), 0,1,4,5); |
|
628 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
629 |
(context->gotoc.distance_label = gtk_label_new("-----")), 1,2,4,5); |
(context->gotoc.distance_label = gtk_label_new("-----")), 1,2,2,3); |
630 |
|
|
631 |
/* -------------- bearing label ------------------------- */ |
/* -------------- bearing label ------------------------- */ |
632 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), left_label_new(_("Bearing:")), 0,1,3,4); |
|
gtk_label_new(_("Bearing:")), 0,1,5,6); |
|
633 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
634 |
(context->gotoc.bearing_label = gtk_label_new("-----")), 1,2,5,6); |
(context->gotoc.bearing_label = gtk_label_new("-----")), 1,2,3,4); |
635 |
|
|
636 |
/* -------------- error label ------------------------- */ |
/* -------------- error label ------------------------- */ |
637 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), left_label_new(_("Est. error:")), 0,1,4,5); |
|
gtk_label_new(_("Est. error:")), 0,1,6,7); |
|
638 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
639 |
(context->gotoc.epe_label = gtk_label_new("-----")), 1,2,6,7); |
(context->gotoc.eph_label = gtk_label_new("-----")), 1,2,4,5); |
640 |
|
|
641 |
gtk_table_set_row_spacing(GTK_TABLE(table), 6, 16); |
gtk_table_set_row_spacing(GTK_TABLE(table), 4, 16); |
642 |
|
|
643 |
/* -------------- sat view box ------------------------- */ |
/* -------------- sat view box ------------------------- */ |
644 |
GtkWidget *ihbox = gtk_hbox_new(FALSE,0); |
GtkWidget *ihbox = gtk_hbox_new(FALSE,0); |
656 |
|
|
657 |
gtk_box_pack_start(GTK_BOX(ihbox), context->gotoc.sat_area, 1,0,0); |
gtk_box_pack_start(GTK_BOX(ihbox), context->gotoc.sat_area, 1,0,0); |
658 |
|
|
659 |
#ifdef USE_MAEMO |
#ifdef ESPEAK |
660 |
GtkWidget *mm_button = gtk_button_new(); |
GtkWidget *ivbox = gtk_vbox_new(FALSE, 0); |
661 |
gtk_button_set_image(GTK_BUTTON(mm_button), icon_get_widget(ICON_MISC, 0)); |
GtkWidget *button = button_new(); |
662 |
gtk_signal_connect(GTK_OBJECT(mm_button), "clicked", |
gtk_button_set_image(GTK_BUTTON(button), icon_get_widget(ICON_MISC, |
663 |
(GtkSignalFunc)on_mm_button_clicked, context); |
context->appdata->espeak.enabled?6:7)); |
664 |
gtk_box_pack_start(GTK_BOX(ihbox), mm_button, 1,0,0); |
gtk_signal_connect (GTK_OBJECT(button), "clicked", |
665 |
|
GTK_SIGNAL_FUNC(espeak_clicked), context); |
666 |
|
if(context->appdata->espeak.sample_rate < 0) |
667 |
|
gtk_widget_set_sensitive(button, FALSE); |
668 |
|
else |
669 |
|
if(context->appdata->espeak.enabled) |
670 |
|
espeak_enable(context, TRUE); |
671 |
|
|
672 |
|
gtk_box_pack_start(GTK_BOX(ivbox), button, 1,0,0); |
673 |
|
gtk_box_pack_start(GTK_BOX(ihbox), ivbox, 1,0,0); |
674 |
#endif |
#endif |
675 |
gtk_table_attach_defaults(GTK_TABLE(table), ihbox, 0,2,7,8); |
|
676 |
|
gtk_table_attach_defaults(GTK_TABLE(table), ihbox, 0,3,5,6); |
677 |
|
|
678 |
/* ------------------------------------------------------- */ |
/* ------------------------------------------------------- */ |
679 |
|
|
680 |
gtk_box_pack_start(GTK_BOX(vbox), table, 1,0,0); |
gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, FALSE, 0); |
681 |
gtk_box_pack_start(GTK_BOX(hbox), vbox, 1,0,0); |
gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); |
682 |
|
|
683 |
context->gotoc.handler_id = gtk_timeout_add(UPDATE_MS, |
context->gotoc.handler_id = |
684 |
goto_update, context); |
gtk_timeout_add(UPDATE_MS, goto_update, context); |
685 |
|
|
686 |
return hbox; |
return hbox; |
687 |
} |
} |
688 |
|
|
689 |
void goto_coordinate_update(cache_context_t *context) { |
void goto_coordinate_update(cache_context_t *context) { |
690 |
|
static pos_t pos = { 0.0, 0.0 }; |
691 |
|
|
692 |
if(!context->notes.modified) |
if(!context->notes.modified) |
693 |
return; |
return; |
694 |
|
|
695 |
waypoint_changed_event(context->gotoc.cbox, context); |
pos_t npos = notes_get_pos(context); |
696 |
|
if(pos_differ(&npos, &pos)) { |
697 |
|
pos = npos; |
698 |
|
|
699 |
|
lat_entry_set(context->gotoc.lat_entry, npos.lat); |
700 |
|
lon_entry_set(context->gotoc.lon_entry, npos.lon); |
701 |
|
} |
702 |
} |
} |