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 */ |
77 |
void overview_coordinate_update(cache_context_t *context) { |
void overview_coordinate_update(cache_context_t *context) { |
78 |
if(!context->notes.modified) |
if(!context->notes.modified) |
79 |
return; |
return; |
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); |
87 |
gtk_label_attrib_set(context->pos_lon_label, str, SIZE_BIG, strike); |
|
|
|
|
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), |
90 |
(GtkCallback)gtk_widget_destroy, NULL); |
(GtkCallback)gtk_widget_destroy, NULL); |
91 |
|
|
92 |
/* update distance/etc */ |
/* update distance/etc */ |
93 |
if(!isnan(context->cache->pos.lat) && |
if(!isnan(context->cache->pos.lat) && |
94 |
!isnan(context->cache->pos.lon)) |
!isnan(context->cache->pos.lon)) |
95 |
bearing_fill_hbox(context->bearing_hbox, context->appdata, |
bearing_fill_hbox(context->bearing_hbox, context->appdata, |
96 |
*get_pos(context->appdata), notes_get_pos(context)); |
*get_pos(context->appdata), notes_get_pos(context)); |
97 |
|
|
98 |
gtk_widget_show_all(context->bearing_hbox); |
gtk_widget_show_all(context->bearing_hbox); |
99 |
} |
} |
100 |
|
|
101 |
static void gcvote_set(cache_context_t *context, vote_t *vote) { |
static void gcvote_set(cache_context_t *context, vote_t *vote) { |
102 |
if(!vote) return; |
if(!vote) return; |
103 |
|
|
104 |
if(context->quality) { |
if(context->quality) { |
105 |
gtk_widget_destroy(context->quality); |
gtk_widget_destroy(context->quality); |
106 |
context->quality = NULL; |
context->quality = NULL; |
107 |
} |
} |
108 |
|
|
109 |
if(context->votes) { |
if(context->votes) { |
110 |
gtk_widget_destroy(context->votes); |
gtk_widget_destroy(context->votes); |
111 |
context->votes = NULL; |
context->votes = NULL; |
112 |
} |
} |
113 |
|
|
114 |
/* update/draw the voting */ |
/* update/draw the voting */ |
115 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
116 |
GtkTooltips *tips = gtk_tooltips_new(); |
GtkTooltips *tips = gtk_tooltips_new(); |
117 |
#endif |
#endif |
118 |
|
|
119 |
char *votes_str = g_strdup_printf(_("Quality (%d %s):"), vote->votes, |
char *votes_str = g_strdup_printf(_("Quality (%d %s):"), vote->votes, |
120 |
(vote->votes == 1)?_("vote"):_("votes")); |
(vote->votes == 1)?_("vote"):_("votes")); |
121 |
context->votes = GTK_LABEL_SMALL(votes_str); |
context->votes = GTK_LABEL_SMALL(votes_str); |
122 |
gtk_box_pack_start(GTK_BOX(context->votebox), |
gtk_box_pack_start(GTK_BOX(context->votebox), |
123 |
context->votes, FALSE, FALSE, 0); |
context->votes, FALSE, FALSE, 0); |
125 |
context->quality = icon_get_widget(ICON_STARS, (int)(vote->quality*2-2)); |
context->quality = icon_get_widget(ICON_STARS, (int)(vote->quality*2-2)); |
126 |
gtk_box_pack_start(GTK_BOX(context->votebox), context->quality, |
gtk_box_pack_start(GTK_BOX(context->votebox), context->quality, |
127 |
FALSE, FALSE, 0); |
FALSE, FALSE, 0); |
128 |
|
|
129 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
130 |
char *str = g_strdup_printf(_("Quality: %d"), vote->quality); |
char *str = g_strdup_printf(_("Quality: %d"), vote->quality); |
131 |
gtk_tooltips_set_tip(tips, context->votebox, str, NULL); |
gtk_tooltips_set_tip(tips, context->votebox, str, NULL); |
139 |
|
|
140 |
static void gcvote_callback(vote_t *vote, gpointer data) { |
static void gcvote_callback(vote_t *vote, gpointer data) { |
141 |
cache_context_t *context = (cache_context_t*)data; |
cache_context_t *context = (cache_context_t*)data; |
142 |
|
|
143 |
/* no vote returned: request failed, just cleanup */ |
/* no vote returned: request failed, just cleanup */ |
144 |
if(!vote) { |
if(!vote) { |
145 |
printf("gcvote: callback for failed request\n"); |
printf("gcvote: callback for failed request\n"); |
146 |
|
|
147 |
gcvote_request_free(context->gcvote_request); |
gcvote_request_free(context->gcvote_request); |
148 |
context->gcvote_request = NULL; |
context->gcvote_request = NULL; |
149 |
return; |
return; |
153 |
vote->quality, vote->votes); |
vote->quality, vote->votes); |
154 |
|
|
155 |
gcvote_set(context, vote); |
gcvote_set(context, vote); |
156 |
|
|
157 |
gcvote_save(context->appdata, context->cache, &context->gcvote_request->mem); |
gcvote_save(context->appdata, context->cache, &context->gcvote_request->mem); |
158 |
|
|
159 |
gcvote_request_free(context->gcvote_request); |
gcvote_request_free(context->gcvote_request); |
160 |
context->gcvote_request = NULL; |
context->gcvote_request = NULL; |
161 |
} |
} |
166 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), align); |
gtk_box_pack_start_defaults(GTK_BOX(vbox), align); |
167 |
} |
} |
168 |
|
|
169 |
|
#ifdef FREMANTLE |
170 |
|
#define ICON_SIZE ICON_CACHE_TYPE_2X |
171 |
|
#else |
172 |
|
#define ICON_SIZE ICON_CACHE_TYPE_1_5X |
173 |
|
#endif |
174 |
|
|
175 |
static GtkWidget *cache_overview(cache_context_t *context) { |
static GtkWidget *cache_overview(cache_context_t *context) { |
176 |
GtkWidget *vbox, *ivbox; |
GtkWidget *vbox, *ivbox; |
177 |
GtkWidget *colbox, *tip; |
GtkWidget *colbox, *tip; |
181 |
#endif |
#endif |
182 |
appdata_t *appdata = context->appdata; |
appdata_t *appdata = context->appdata; |
183 |
cache_t *cache = context->cache; |
cache_t *cache = context->cache; |
184 |
|
|
185 |
vbox = gtk_vbox_new(FALSE, 4); |
vbox = gtk_vbox_new(FALSE, 4); |
186 |
|
|
187 |
/* hbox containing the four columns of cache details */ |
/* hbox containing the four columns of cache details */ |
188 |
GtkWidget *ihbox = gtk_hbox_new(FALSE, 0); |
GtkWidget *ihbox = gtk_hbox_new(FALSE, 0); |
189 |
|
|
190 |
/* vbox containing leftmost column (icon and container) */ |
/* vbox containing leftmost column (icon and container) */ |
191 |
colbox = gtk_vbox_new(FALSE, 0); |
colbox = gtk_vbox_new(FALSE, 0); |
192 |
|
|
193 |
if(cache->type != CACHE_TYPE_UNKNOWN) { |
if(cache->type != CACHE_TYPE_UNKNOWN) { |
194 |
gtk_box_pack_start_defaults(GTK_BOX(colbox), |
gtk_box_pack_start_defaults(GTK_BOX(colbox), |
195 |
|
tip = icon_get_widget(ICON_SIZE, cache->type)); |
196 |
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5) |
|
|
tip = icon_get_widget(ICON_CACHE_TYPE_2X, cache->type)); |
|
|
#else |
|
|
tip = icon_get_widget(ICON_CACHE_TYPE_1_5X, cache->type)); |
|
|
#endif |
|
|
|
|
197 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
198 |
gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL); |
gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL); |
199 |
#endif |
#endif |
200 |
} |
} |
201 |
|
|
202 |
/* ------------ box containing container info ------------ */ |
/* ------------ box containing container info ------------ */ |
203 |
if(cache->container != CACHE_CONT_UNKNOWN) { |
if(cache->container != CACHE_CONT_UNKNOWN) { |
204 |
ivbox = gtk_vbox_new(FALSE, 0); |
ivbox = gtk_vbox_new(FALSE, 0); |
208 |
gtk_box_pack_start(GTK_BOX(ivbox), |
gtk_box_pack_start(GTK_BOX(ivbox), |
209 |
icon_get_widget(ICON_CACHE_SIZE, cache->container), |
icon_get_widget(ICON_CACHE_SIZE, cache->container), |
210 |
FALSE, FALSE, 0); |
FALSE, FALSE, 0); |
211 |
|
|
212 |
pack_vcentered(colbox, ivbox); |
pack_vcentered(colbox, ivbox); |
213 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
214 |
gtk_tooltips_set_tip(tips, ivbox, _(cache_size_tip[cache->container]), NULL); |
gtk_tooltips_set_tip(tips, ivbox, _(cache_size_tip[cache->container]), NULL); |
215 |
#endif |
#endif |
216 |
} |
} |
217 |
|
|
218 |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox); |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox); |
219 |
colbox = gtk_vbox_new(FALSE, 0); |
colbox = gtk_vbox_new(FALSE, 0); |
220 |
|
|
221 |
/* ----------------------- id ---------------------------- */ |
/* ----------------------- id ---------------------------- */ |
222 |
if(cache->id) { |
if(cache->id) { |
223 |
int strike = cache->archived?STRIKETHROUGH_RED: |
int strike = cache->archived?STRIKETHROUGH_RED: |
596 |
|
|
597 |
#ifdef ENABLE_BROWSER_INTERFACE |
#ifdef ENABLE_BROWSER_INTERFACE |
598 |
if(gc_link) { |
if(gc_link) { |
599 |
GtkWidget *but = |
GtkWidget *but = |
600 |
gtk_button_new_with_label(_("Post a new log entry for this geocache")); |
gtk_button_new_with_label(_("Post a new log entry for this geocache")); |
601 |
|
#if 0 |
602 |
|
gtk_button_set_image(GTK_BUTTON(but), |
603 |
|
gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON)); |
604 |
|
gtk_button_set_image_position(GTK_BUTTON(but), GTK_POS_LEFT); |
605 |
|
#endif |
606 |
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5) |
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5) |
607 |
hildon_gtk_widget_set_theme_size(but, |
hildon_gtk_widget_set_theme_size(but, |
608 |
(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH)); |
(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH)); |
637 |
(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH)); |
(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH)); |
638 |
#endif |
#endif |
639 |
|
|
640 |
gtk_label_set_ellipsize(GTK_LABEL(gtk_bin_get_child(GTK_BIN(finder))), |
gtk_label_set_ellipsize(GTK_LABEL(gtk_bin_get_child(GTK_BIN(finder))), |
641 |
PANGO_ELLIPSIZE_END); |
PANGO_ELLIPSIZE_END); |
642 |
} else |
} else |
643 |
gtk_label_set_ellipsize(GTK_LABEL(finder), PANGO_ELLIPSIZE_END); |
gtk_label_set_ellipsize(GTK_LABEL(finder), PANGO_ELLIPSIZE_END); |
728 |
/* seems to work ... */ |
/* seems to work ... */ |
729 |
if(strcasecmp(name, _("Logs")) == 0) { |
if(strcasecmp(name, _("Logs")) == 0) { |
730 |
gtk_widget_queue_resize(w); |
gtk_widget_queue_resize(w); |
|
} else if(strcasecmp(name, _("TBs")) == 0) { |
|
|
gtk_widget_queue_resize(w); |
|
731 |
} else if(strcasecmp(name, _("Goto")) == 0) { |
} else if(strcasecmp(name, _("Goto")) == 0) { |
732 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
733 |
context->handler_id = gtk_timeout_add(1000, screensaver_update, |
context->handler_id = gtk_timeout_add(1000, screensaver_update, |
734 |
context->appdata); |
context->appdata); |
735 |
#endif |
#endif |
736 |
|
|
737 |
goto_coordinate_update(context); |
goto_coordinate_update(context); |
738 |
} |
} |
739 |
|
|
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 |
|
|
954 |
static void on_cache_destroy (GtkWidget *widget, appdata_t *appdata) { |
static void on_cache_destroy (GtkWidget *widget, appdata_t *appdata) { |
955 |
appdata->cur_cache = NULL; |
appdata->cur_cache = NULL; |
956 |
|
|
957 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
958 |
|
appdata->window = HILDON_WINDOW(hildon_window_stack_peek(stack)); |
959 |
|
|
960 |
/* restore cur_view */ |
/* restore cur_view */ |
961 |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
962 |
} |
} |
963 |
|
|
964 |
void cache_dialog(appdata_t *appdata, cache_t *cache) { |
void cache_dialog(appdata_t *appdata, cache_t *cache) { |
965 |
GtkWidget *window = hildon_stackable_window_new(); |
GtkWidget *window = hildon_stackable_window_new(); |
966 |
|
appdata->window = HILDON_WINDOW(window); |
967 |
|
|
968 |
/* store last "cur_view" in window */ |
/* store last "cur_view" in window */ |
969 |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
970 |
|
|
971 |
appdata->cur_cache = cache; |
appdata->cur_cache = cache; |
972 |
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); |
|
973 |
|
|
974 |
/* create cache visualization widget */ |
/* create cache visualization widget */ |
975 |
appdata->cur_view = cache_view(appdata, cache); |
appdata->cur_view = cache_view(appdata, cache); |