51 |
|
|
52 |
if(!isnan(pos.lat) && !isnan(pos.lon)) { |
if(!isnan(pos.lat) && !isnan(pos.lon)) { |
53 |
gtk_box_pack_start(GTK_BOX(hbox), gtk_image_new_from_pixbuf( |
gtk_box_pack_start(GTK_BOX(hbox), gtk_image_new_from_pixbuf( |
54 |
icon_bearing(refpos, pos)),TRUE,FALSE,0); |
icon_bearing(refpos, pos)),TRUE,FALSE,0); |
55 |
|
|
56 |
if(!isnan(refpos.lat) && !isnan(refpos.lon)) { |
if(!isnan(refpos.lat) && !isnan(refpos.lon)) { |
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), |
|
|
GTK_LABEL_SMALL((char*)pos_get_bearing_str(refpos, pos))); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL(" ")); |
|
57 |
snprintf(str, sizeof(str), _("%.1f°"), |
snprintf(str, sizeof(str), _("%.1f°"), |
58 |
gpx_pos_get_bearing(refpos, pos)); |
gpx_pos_get_bearing(refpos, pos)); |
59 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL(str)); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL(str)); |
61 |
refpos, pos, appdata->imperial); |
refpos, pos, appdata->imperial); |
62 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL(" ")); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL(" ")); |
63 |
gtk_box_pack_start(GTK_BOX(hbox), |
gtk_box_pack_start(GTK_BOX(hbox), |
64 |
gtk_label_attrib(str, SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0); |
gtk_label_attrib(str, SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0); |
65 |
} else |
} else |
66 |
gtk_box_pack_start(GTK_BOX(hbox), |
gtk_box_pack_start(GTK_BOX(hbox), |
67 |
gtk_label_attrib(_("(no position)"), |
gtk_label_attrib(_("(no position)"), |
68 |
SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0); |
SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0); |
69 |
} else |
} else |
70 |
gtk_box_pack_start(GTK_BOX(hbox), |
gtk_box_pack_start(GTK_BOX(hbox), |
71 |
gtk_label_attrib(_("(invalid position in notes)"), |
gtk_label_attrib(_("(invalid position in notes)"), |
72 |
SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0); |
SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0); |
73 |
} |
} |
74 |
|
|
75 |
/* this function sets everything related to the coordinate. used to */ |
/* this function sets everything related to the coordinate. used to */ |
80 |
|
|
81 |
/* update position labels */ |
/* update position labels */ |
82 |
int strike = notes_get_override(context)?STRIKETHROUGH:STRIKETHROUGH_NONE; |
int strike = notes_get_override(context)?STRIKETHROUGH:STRIKETHROUGH_NONE; |
83 |
char str[32]; |
lat_label_attrib_set(context->pos_lat_label, |
84 |
pos_lat_str(str, sizeof(str), context->cache->pos.lat); |
context->cache->pos.lat, SIZE_BIG, strike); |
85 |
gtk_label_attrib_set(context->pos_lat_label, str, SIZE_BIG, strike); |
lon_label_attrib_set(context->pos_lon_label, |
86 |
pos_lon_str(str, sizeof(str), context->cache->pos.lon); |
context->cache->pos.lon, SIZE_BIG, strike); |
|
gtk_label_attrib_set(context->pos_lon_label, str, SIZE_BIG, strike); |
|
87 |
|
|
88 |
/* remove enire hbox and build a new one */ |
/* remove enire hbox and build a new one */ |
89 |
gtk_container_foreach(GTK_CONTAINER(context->bearing_hbox), |
gtk_container_foreach(GTK_CONTAINER(context->bearing_hbox), |
763 |
gtk_timeout_remove(context->handler_id); |
gtk_timeout_remove(context->handler_id); |
764 |
#endif |
#endif |
765 |
|
|
766 |
free(user_data); |
#ifdef USE_STACKABLE_WINDOW |
767 |
|
if(context->notes_have_been_changed) { |
768 |
|
printf("notes changed -> cachelist redraw\n"); |
769 |
|
|
770 |
|
/* now the cachelist is visible again. so redraw it since it may */ |
771 |
|
/* have changed */ |
772 |
|
cachelist_redraw(context->appdata); |
773 |
|
} |
774 |
|
#endif |
775 |
|
|
776 |
|
printf("freeing cache context\n"); |
777 |
|
context->appdata->cache_context = NULL; |
778 |
|
g_free(context); |
779 |
} |
} |
780 |
|
|
781 |
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5) |
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5) |
875 |
GtkWidget *cache_view(appdata_t *appdata, cache_t *cache) { |
GtkWidget *cache_view(appdata_t *appdata, cache_t *cache) { |
876 |
GtkWidget *notebook; |
GtkWidget *notebook; |
877 |
|
|
878 |
cache_context_t *cache_context = malloc(sizeof(cache_context_t)); |
cache_context_t *cache_context = g_new0(cache_context_t, 1); |
879 |
memset(cache_context, 0, sizeof(cache_context_t)); |
appdata->cache_context = cache_context; |
880 |
cache_context->appdata = appdata; |
cache_context->appdata = appdata; |
881 |
cache_context->cache = cache; |
cache_context->cache = cache; |
882 |
|
|
914 |
notebook_append_page(notebook, |
notebook_append_page(notebook, |
915 |
cache_tbs(appdata, cache->tb), _("TBs")); |
cache_tbs(appdata, cache->tb), _("TBs")); |
916 |
|
|
917 |
notebook_append_page(notebook, |
/* the demo caches don't have coordinates, so avoid */ |
918 |
cache_notes(cache_context), _("Notes")); |
/* having to deal with them */ |
919 |
|
if(!isnan(cache->pos.lat) && !isnan(cache->pos.lon)) { |
920 |
|
notebook_append_page(notebook, |
921 |
|
cache_notes(cache_context), _("Notes")); |
922 |
|
|
923 |
notebook_append_page(notebook, |
notebook_append_page(notebook, |
924 |
goto_cache(cache_context), _("Goto")); |
goto_cache(cache_context), _("Goto")); |
925 |
|
} |
926 |
|
|
927 |
g_signal_connect(notebook_object(notebook), "switch-page", |
g_signal_connect(notebook_object(notebook), "switch-page", |
928 |
G_CALLBACK(on_notebook_page_change), cache_context); |
G_CALLBACK(on_notebook_page_change), cache_context); |
958 |
static void on_cache_destroy (GtkWidget *widget, appdata_t *appdata) { |
static void on_cache_destroy (GtkWidget *widget, appdata_t *appdata) { |
959 |
appdata->cur_cache = NULL; |
appdata->cur_cache = NULL; |
960 |
|
|
961 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
962 |
|
appdata->window = HILDON_WINDOW(hildon_window_stack_peek(stack)); |
963 |
|
|
964 |
/* restore cur_view */ |
/* restore cur_view */ |
965 |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
966 |
} |
} |
967 |
|
|
968 |
void cache_dialog(appdata_t *appdata, cache_t *cache) { |
void cache_dialog(appdata_t *appdata, cache_t *cache) { |
969 |
GtkWidget *window = hildon_stackable_window_new(); |
GtkWidget *window = hildon_stackable_window_new(); |
970 |
|
appdata->window = HILDON_WINDOW(window); |
971 |
|
|
972 |
/* store last "cur_view" in window */ |
/* store last "cur_view" in window */ |
973 |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
974 |
|
|
975 |
appdata->cur_cache = cache; |
appdata->cur_cache = cache; |
976 |
char *title = g_strdup_printf("%s - GPXView", cache->name); |
gtk_window_set_title(GTK_WINDOW(window), cache->name); |
|
gtk_window_set_title(GTK_WINDOW(window), title); |
|
|
g_free(title); |
|
977 |
|
|
978 |
/* create cache visualization widget */ |
/* create cache visualization widget */ |
979 |
appdata->cur_view = cache_view(appdata, cache); |
appdata->cur_view = cache_view(appdata, cache); |