42 |
#endif |
#endif |
43 |
|
|
44 |
static const char *cache_size_name[] = { |
static const char *cache_size_name[] = { |
45 |
"Regular", "Small", "Micro", "Other", |
"Regular", "Small", "Micro", "Other", "Not chosen", "Large", "Virtual" |
|
"Not chosen", "Large", "Virtual" |
|
46 |
}; |
}; |
47 |
|
|
48 |
void bearing_fill_hbox(GtkWidget *hbox, |
void bearing_fill_hbox(GtkWidget *hbox, |
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)),1,0,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))); |
|
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)); |
60 |
gpx_pos_get_distance_str(str, sizeof(str), |
gpx_pos_get_distance_str(str, sizeof(str), |
61 |
refpos, pos, appdata->imperial); |
refpos, pos, appdata->imperial); |
62 |
|
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),1,0,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),1,0,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),1,0,0); |
SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0); |
73 |
} |
} |
74 |
|
|
75 |
/* this function sets everthing related to the coordinate. used to */ |
/* this function sets everything related to the coordinate. used to */ |
76 |
/* cope with the user setting a new "note coordinate" */ |
/* cope with the user setting a new "note coordinate" */ |
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 |
} |
} |
162 |
|
|
163 |
|
static void pack_vcentered(GtkWidget *vbox, GtkWidget *child) { |
164 |
|
GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); |
165 |
|
gtk_container_add(GTK_CONTAINER(align), child); |
166 |
|
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 *table, *tip; |
GtkWidget *colbox, *tip; |
178 |
char str[64]; |
char str[64]; |
179 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
180 |
GtkTooltips *tips = gtk_tooltips_new(); |
GtkTooltips *tips = gtk_tooltips_new(); |
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); |
186 |
|
|
187 |
|
/* hbox containing the four columns of cache details */ |
188 |
|
GtkWidget *pbox = portrait_box_new(FALSE, 0); |
189 |
|
|
190 |
vbox = gtk_vbox_new(FALSE, 0); |
GtkWidget *ihbox = gtk_hbox_new(FALSE, 0); |
191 |
|
|
192 |
table = gtk_table_new(3,4, FALSE); |
/* vbox containing leftmost column (icon and container) */ |
193 |
|
colbox = gtk_vbox_new(FALSE, 0); |
194 |
|
|
195 |
if(cache->type != CACHE_TYPE_UNKNOWN) { |
if(cache->type != CACHE_TYPE_UNKNOWN) { |
196 |
gtk_table_attach(GTK_TABLE(table), |
gtk_box_pack_start_defaults(GTK_BOX(colbox), |
197 |
|
tip = icon_get_widget(ICON_SIZE, cache->type)); |
198 |
#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 |
|
|
0,1,0,1, GTK_FILL, 0, GTK_FILL, 0); |
|
|
|
|
199 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
200 |
gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL); |
gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL); |
201 |
#endif |
#endif |
202 |
} |
} |
203 |
|
|
204 |
/* ------------ box containing container info ------------ */ |
/* ------------ box containing container info ------------ */ |
205 |
if(cache->container != CACHE_CONT_UNKNOWN) { |
if(cache->container != CACHE_CONT_UNKNOWN) { |
206 |
ivbox = gtk_vbox_new(FALSE, 0); |
ivbox = gtk_vbox_new(FALSE, 0); |
210 |
gtk_box_pack_start(GTK_BOX(ivbox), |
gtk_box_pack_start(GTK_BOX(ivbox), |
211 |
icon_get_widget(ICON_CACHE_SIZE, cache->container), |
icon_get_widget(ICON_CACHE_SIZE, cache->container), |
212 |
FALSE, FALSE, 0); |
FALSE, FALSE, 0); |
213 |
gtk_table_attach(GTK_TABLE(table), ivbox, 0,1,1,2, |
|
214 |
GTK_EXPAND | GTK_FILL, 0, GTK_FILL, 0); |
pack_vcentered(colbox, ivbox); |
215 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
216 |
gtk_tooltips_set_tip(tips, ivbox, _(cache_size_tip[cache->container]), NULL); |
gtk_tooltips_set_tip(tips, ivbox, _(cache_size_tip[cache->container]), NULL); |
217 |
#endif |
#endif |
218 |
} |
} |
219 |
|
|
220 |
|
gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox); |
221 |
|
colbox = gtk_vbox_new(FALSE, 0); |
222 |
|
|
223 |
/* ----------------------- id ---------------------------- */ |
/* ----------------------- id ---------------------------- */ |
224 |
if(cache->id) { |
if(cache->id) { |
225 |
int strike = cache->archived?STRIKETHROUGH_RED: |
int strike = cache->archived?STRIKETHROUGH_RED: |
227 |
GtkWidget *lbl = link_button_attrib(context->appdata, |
GtkWidget *lbl = link_button_attrib(context->appdata, |
228 |
cache->id, context->cache->url, |
cache->id, context->cache->url, |
229 |
SIZE_BIG, strike); |
SIZE_BIG, strike); |
230 |
gtk_table_attach(GTK_TABLE(table), lbl, 1,2,0,1, FALSE, FALSE, 0, 0); |
pack_vcentered(colbox, lbl); |
231 |
} |
} |
232 |
|
|
233 |
/* --------------- box containing owner info ------------- */ |
/* --------------- box containing owner info ------------- */ |
234 |
if(cache->owner) { |
if(cache->owner) { |
235 |
ivbox = gtk_vbox_new(FALSE, 0); |
gtk_box_pack_start_defaults(GTK_BOX(colbox), GTK_LABEL_SMALL(_("by"))); |
|
gtk_box_pack_start_defaults(GTK_BOX(ivbox), GTK_LABEL_SMALL(_("by"))); |
|
236 |
|
|
237 |
static const char *owner_type = "profile/"; |
static const char *owner_type = "profile/"; |
238 |
gtk_box_pack_start_defaults(GTK_BOX(ivbox), |
pack_vcentered(colbox, |
239 |
link_button_by_id(appdata, cache->owner->name, |
link_button_by_id(appdata, cache->owner->name, |
240 |
owner_type, cache->owner->id)); |
owner_type, cache->owner->id)); |
|
gtk_table_attach(GTK_TABLE(table), ivbox, 1,2,1,2, FALSE,FALSE,0,0); |
|
241 |
} |
} |
242 |
|
|
243 |
|
gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox); |
244 |
|
|
245 |
|
/* pack left two columns into portrait box */ |
246 |
|
gtk_box_pack_start_defaults(GTK_BOX(pbox), ihbox); |
247 |
|
ihbox = gtk_hbox_new(FALSE, 0); |
248 |
|
|
249 |
/* ----------- vbox containing all ratings ---------- */ |
/* ----------- vbox containing all ratings ---------- */ |
250 |
GtkWidget *ratebox = gtk_vbox_new(FALSE, 0); |
colbox = gtk_vbox_new(FALSE, 0); |
251 |
|
|
252 |
/* ----------- box containing difficulty rating ---------- */ |
/* ----------- box containing difficulty rating ---------- */ |
253 |
if(cache->difficulty != 0) { |
if(cache->difficulty != 0) { |
259 |
icon_get_widget(ICON_STARS, (int)(cache->difficulty*2-2)), |
icon_get_widget(ICON_STARS, (int)(cache->difficulty*2-2)), |
260 |
FALSE, FALSE, 0); |
FALSE, FALSE, 0); |
261 |
|
|
262 |
GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); |
pack_vcentered(colbox, ivbox); |
|
gtk_container_add(GTK_CONTAINER(align), ivbox); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(ratebox), align); |
|
263 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
264 |
sprintf(str, _("Difficulty: %.1f"), cache->difficulty); |
sprintf(str, _("Difficulty: %.1f"), cache->difficulty); |
265 |
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
274 |
gtk_box_pack_start(GTK_BOX(ivbox), |
gtk_box_pack_start(GTK_BOX(ivbox), |
275 |
icon_get_widget(ICON_STARS, (int)(cache->terrain*2-2)), |
icon_get_widget(ICON_STARS, (int)(cache->terrain*2-2)), |
276 |
FALSE, FALSE, 0); |
FALSE, FALSE, 0); |
277 |
GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); |
pack_vcentered(colbox, ivbox); |
|
gtk_container_add(GTK_CONTAINER(align), ivbox); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(ratebox), align); |
|
278 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
279 |
sprintf(str, _("Terrain: %.1f"), cache->terrain); |
sprintf(str, _("Terrain: %.1f"), cache->terrain); |
280 |
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
289 |
gcvote_request(appdata, gcvote_callback, cache->url, context); |
gcvote_request(appdata, gcvote_callback, cache->url, context); |
290 |
|
|
291 |
context->votebox = gtk_vbox_new(FALSE, 0); |
context->votebox = gtk_vbox_new(FALSE, 0); |
292 |
GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); |
pack_vcentered(colbox, context->votebox); |
|
gtk_container_add(GTK_CONTAINER(align), context->votebox); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(ratebox), align); |
|
293 |
|
|
294 |
/* fill with vote if present on disk (will also free vote) */ |
/* fill with vote if present on disk (will also free vote) */ |
295 |
if(vote) |
if(vote) |
296 |
gcvote_set(context, vote); |
gcvote_set(context, vote); |
297 |
} |
} |
298 |
|
|
299 |
gtk_table_attach_defaults(GTK_TABLE(table), ratebox, 2,3,0,2); |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox); |
300 |
|
|
301 |
/* ----------------------------------------------------- */ |
/* ----------------------------------------------------- */ |
302 |
|
|
303 |
|
|
304 |
/* ----------------- the two coordinates ----------------- */ |
/* ----------------- the two coordinates ----------------- */ |
305 |
/* ----------------- and the heading/distance ------------ */ |
/* ----------------- and the heading/distance ------------ */ |
306 |
|
colbox = gtk_vbox_new(FALSE, 0); |
307 |
|
|
308 |
pos_t *refpos = get_pos(appdata); |
pos_t *refpos = get_pos(appdata); |
309 |
|
|
310 |
ivbox = gtk_vbox_new(FALSE, 0); |
ivbox = gtk_vbox_new(FALSE, 0); |
312 |
STRIKETHROUGH:STRIKETHROUGH_NONE; |
STRIKETHROUGH:STRIKETHROUGH_NONE; |
313 |
|
|
314 |
/* the original coordinate is being displayed */ |
/* the original coordinate is being displayed */ |
315 |
gtk_box_pack_start_defaults(GTK_BOX(ivbox), |
gtk_box_pack_start(GTK_BOX(ivbox), |
316 |
context->pos_lat_label = pos_lat(cache->pos.lat, SIZE_BIG, strike)); |
context->pos_lat_label = pos_lat(cache->pos.lat, SIZE_BIG, strike), FALSE, FALSE, 0); |
317 |
gtk_box_pack_start_defaults(GTK_BOX(ivbox), |
gtk_box_pack_start(GTK_BOX(ivbox), |
318 |
context->pos_lon_label = pos_lon(cache->pos.lon, SIZE_BIG, strike)); |
context->pos_lon_label = pos_lon(cache->pos.lon, SIZE_BIG, strike), FALSE, FALSE, 0); |
319 |
|
|
320 |
|
pack_vcentered(colbox, ivbox); |
321 |
|
|
322 |
/* but calculations may be done with respect to the overriden one */ |
/* but calculations may be done with respect to the overriden one */ |
323 |
if(!isnan(cache->pos.lat) && !isnan(cache->pos.lon)) { |
if(!isnan(cache->pos.lat) && !isnan(cache->pos.lon)) { |
324 |
context->bearing_hbox = gtk_hbox_new(FALSE, 0); |
context->bearing_hbox = gtk_hbox_new(FALSE, 0); |
325 |
bearing_fill_hbox(context->bearing_hbox, appdata, *refpos, |
bearing_fill_hbox(context->bearing_hbox, appdata, *refpos, |
326 |
gpx_cache_pos(cache)); |
gpx_cache_pos(cache)); |
327 |
gtk_box_pack_start_defaults(GTK_BOX(ivbox), context->bearing_hbox); |
pack_vcentered(colbox, context->bearing_hbox); |
328 |
} |
} |
329 |
|
|
330 |
gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 3,4,0,2); |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox); |
331 |
|
gtk_box_pack_start_defaults(GTK_BOX(pbox), ihbox); |
332 |
|
|
333 |
/* ----------------------------------------------------- */ |
/* ----------------------------------------------------- */ |
334 |
|
|
335 |
gtk_box_pack_start(GTK_BOX(vbox), table, 0,0,0); |
gtk_box_pack_start(GTK_BOX(vbox), pbox, FALSE, FALSE, 0); |
336 |
gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(),FALSE,FALSE,0); |
gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0); |
337 |
|
|
338 |
|
/* ----------------------------------------------------- */ |
339 |
|
|
340 |
|
if(cache->attribute) { |
341 |
|
ihbox = gtk_hbox_new(FALSE, 0); |
342 |
|
|
343 |
|
attribute_t *att = cache->attribute; |
344 |
|
while(att) { |
345 |
|
if(att->inc) |
346 |
|
tip = icon_get_widget(ICON_ATT, att->id+1); |
347 |
|
else |
348 |
|
tip = icon_get_widget_ovl(ICON_ATT, att->id+1, 0); |
349 |
|
|
350 |
|
gtk_box_pack_start(GTK_BOX(ihbox), tip, 1,0,0); |
351 |
|
|
352 |
|
#ifndef USE_MAEMO |
353 |
|
gtk_tooltips_set_tip(tips, tip, _(att->name), NULL); |
354 |
|
#endif |
355 |
|
|
356 |
|
att = att->next; |
357 |
|
} |
358 |
|
|
359 |
|
gtk_box_pack_start(GTK_BOX(vbox), ihbox, FALSE, FALSE, 0); |
360 |
|
gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0); |
361 |
|
} |
362 |
|
|
363 |
/* ----------------------------------------------------- */ |
/* ----------------------------------------------------- */ |
364 |
|
|
480 |
pos_lon(wpt->pos.lon, SIZE_BIG, STRIKETHROUGH_NONE), |
pos_lon(wpt->pos.lon, SIZE_BIG, STRIKETHROUGH_NONE), |
481 |
2,3, wpt_row, wpt_row+1); |
2,3, wpt_row, wpt_row+1); |
482 |
|
|
483 |
ihbox = gtk_hbox_new(FALSE, 0); |
if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { |
484 |
gtk_box_pack_start(GTK_BOX(ihbox), gtk_image_new_from_pixbuf( |
ihbox = gtk_hbox_new(FALSE, 0); |
485 |
|
gtk_box_pack_start(GTK_BOX(ihbox), gtk_image_new_from_pixbuf( |
486 |
icon_bearing(*refpos, wpt->pos)),1,0,0); |
icon_bearing(*refpos, wpt->pos)),1,0,0); |
487 |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), |
snprintf(str, sizeof(str), _("%.1f°"), |
488 |
GTK_LABEL_SMALL((char*)pos_get_bearing_str(*refpos, wpt->pos))); |
gpx_pos_get_bearing(*refpos, wpt->pos)); |
489 |
snprintf(str, sizeof(str), _("%.1f°"), |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), GTK_LABEL_SMALL(str)); |
490 |
gpx_pos_get_bearing(*refpos, wpt->pos)); |
|
491 |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), GTK_LABEL_SMALL(str)); |
gpx_pos_get_distance_str(str, sizeof(str), |
492 |
gpx_pos_get_distance_str(str, sizeof(str), |
*refpos, wpt->pos, appdata->imperial); |
493 |
*refpos, wpt->pos, appdata->imperial); |
gtk_box_pack_start(GTK_BOX(ihbox), GTK_LABEL_SMALL(str),1,0,0); |
494 |
gtk_box_pack_start(GTK_BOX(ihbox), GTK_LABEL_SMALL(str),1,0,0); |
|
495 |
|
gtk_table_attach_defaults(GTK_TABLE(table), ihbox, 3,4, |
496 |
|
wpt_row+0, wpt_row+1); |
497 |
|
} |
498 |
|
|
|
gtk_table_attach_defaults(GTK_TABLE(table), ihbox, 3,4, |
|
|
wpt_row+0, wpt_row+1); |
|
|
|
|
499 |
/* ------------------ description ------------------------- */ |
/* ------------------ description ------------------------- */ |
500 |
if(wpt->desc) |
if(wpt->desc) |
501 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
628 |
|
|
629 |
#ifdef ENABLE_BROWSER_INTERFACE |
#ifdef ENABLE_BROWSER_INTERFACE |
630 |
if(gc_link) { |
if(gc_link) { |
631 |
GtkWidget *but = |
GtkWidget *but = |
632 |
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")); |
633 |
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5) |
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5) |
634 |
hildon_gtk_widget_set_theme_size(but, |
hildon_gtk_widget_set_theme_size(but, |
637 |
gtk_signal_connect(GTK_OBJECT(but), "clicked", |
gtk_signal_connect(GTK_OBJECT(but), "clicked", |
638 |
GTK_SIGNAL_FUNC(on_gclink_clicked), context); |
GTK_SIGNAL_FUNC(on_gclink_clicked), context); |
639 |
|
|
640 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), but); |
gtk_box_pack_start(GTK_BOX(vbox), but, FALSE, FALSE, 0); |
641 |
} |
} |
642 |
#endif |
#endif |
643 |
|
|
664 |
(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH)); |
(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH)); |
665 |
#endif |
#endif |
666 |
|
|
667 |
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))), |
668 |
PANGO_ELLIPSIZE_END); |
PANGO_ELLIPSIZE_END); |
669 |
} else |
} else |
670 |
gtk_label_set_ellipsize(GTK_LABEL(finder), PANGO_ELLIPSIZE_END); |
gtk_label_set_ellipsize(GTK_LABEL(finder), PANGO_ELLIPSIZE_END); |
686 |
|
|
687 |
gtk_box_pack_start(GTK_BOX(ivbox), ihbox, FALSE, FALSE, 0); |
gtk_box_pack_start(GTK_BOX(ivbox), ihbox, FALSE, FALSE, 0); |
688 |
|
|
689 |
gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 0, 1, |
gtk_table_attach(GTK_TABLE(table), ivbox, 0, 1, |
690 |
2*log_cnt, 2*log_cnt+1); |
2*log_cnt, 2*log_cnt+1, 0, GTK_EXPAND | GTK_FILL, 0, 0); |
691 |
|
|
692 |
if(log->text) { |
if(log->text) { |
693 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
694 |
html_view(appdata, log->text, |
html_view(appdata, log->text, |
709 |
log_cnt++; |
log_cnt++; |
710 |
} |
} |
711 |
|
|
712 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), table); |
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
713 |
|
|
714 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
715 |
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), |
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), |
755 |
/* seems to work ... */ |
/* seems to work ... */ |
756 |
if(strcasecmp(name, _("Logs")) == 0) { |
if(strcasecmp(name, _("Logs")) == 0) { |
757 |
gtk_widget_queue_resize(w); |
gtk_widget_queue_resize(w); |
|
} else if(strcasecmp(name, _("TBs")) == 0) { |
|
|
gtk_widget_queue_resize(w); |
|
758 |
} else if(strcasecmp(name, _("Goto")) == 0) { |
} else if(strcasecmp(name, _("Goto")) == 0) { |
759 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
760 |
context->handler_id = gtk_timeout_add(1000, screensaver_update, |
context->handler_id = gtk_timeout_add(1000, screensaver_update, |
761 |
context->appdata); |
context->appdata); |
762 |
#endif |
#endif |
763 |
|
|
764 |
goto_coordinate_update(context); |
goto_coordinate_update(context); |
765 |
} |
} |
766 |
|
|
790 |
gtk_timeout_remove(context->handler_id); |
gtk_timeout_remove(context->handler_id); |
791 |
#endif |
#endif |
792 |
|
|
793 |
free(user_data); |
#ifdef USE_STACKABLE_WINDOW |
794 |
} |
if(context->notes_have_been_changed) { |
795 |
|
printf("notes changed -> cachelist redraw\n"); |
|
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5) |
|
|
#define CUSTOM_NOTEBOOK |
|
|
#endif |
|
|
|
|
|
static GtkWidget *notebook_new(void) { |
|
|
#ifdef CUSTOM_NOTEBOOK |
|
|
GtkWidget *vbox = gtk_vbox_new(FALSE, 0); |
|
|
|
|
|
GtkWidget *notebook = gtk_notebook_new(); |
|
|
|
|
|
/* prevents user from accidentially touching the breadcrumb trail */ |
|
|
/* (looks ugly on fremantle as it isn't themed) */ |
|
|
// gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM); |
|
|
|
|
|
/* solution for fremantle: we use a row of ordinary buttons instead */ |
|
|
/* of regular tabs */ |
|
|
|
|
|
/* hide the regular tabs */ |
|
|
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE); |
|
|
|
|
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), notebook); |
|
|
|
|
|
/* store a reference to the notebook in the vbox */ |
|
|
g_object_set_data(G_OBJECT(vbox), "notebook", (gpointer)notebook); |
|
|
|
|
|
/* create a hbox for the buttons */ |
|
|
GtkWidget *hbox = gtk_hbox_new(TRUE, 0); |
|
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
|
|
g_object_set_data(G_OBJECT(vbox), "hbox", (gpointer)hbox); |
|
|
|
|
|
return vbox; |
|
|
#else |
|
|
return gtk_notebook_new(); |
|
|
#endif |
|
|
} |
|
|
|
|
|
#ifdef CUSTOM_NOTEBOOK |
|
|
static void on_notebook_button_clicked(GtkWidget *button, gpointer data) { |
|
|
GtkNotebook *nb = |
|
|
GTK_NOTEBOOK(g_object_get_data(G_OBJECT(data), "notebook")); |
|
|
|
|
|
gint page = (gint)g_object_get_data(G_OBJECT(button), "page"); |
|
|
gtk_notebook_set_current_page(nb, page); |
|
|
} |
|
|
#endif |
|
|
|
|
|
static void notebook_append_page(GtkWidget *notebook, |
|
|
GtkWidget *page, char *label) { |
|
|
#ifdef CUSTOM_NOTEBOOK |
|
|
GtkNotebook *nb = |
|
|
GTK_NOTEBOOK(g_object_get_data(G_OBJECT(notebook), "notebook")); |
|
|
|
|
|
gint page_num = gtk_notebook_append_page(nb, page, gtk_label_new(label)); |
|
|
GtkWidget *button = NULL; |
|
796 |
|
|
797 |
/* select button for page 0 by default */ |
/* now the cachelist is visible again. so redraw it since it may */ |
798 |
if(!page_num) { |
/* have changed */ |
799 |
button = gtk_radio_button_new_with_label(NULL, label); |
cachelist_redraw(context->appdata); |
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); |
|
|
g_object_set_data(G_OBJECT(notebook), "group_master", (gpointer)button); |
|
|
} else { |
|
|
GtkWidget *master = g_object_get_data(G_OBJECT(notebook), "group_master"); |
|
|
button = gtk_radio_button_new_with_label_from_widget( |
|
|
GTK_RADIO_BUTTON(master), label); |
|
800 |
} |
} |
|
|
|
|
gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE); |
|
|
g_object_set_data(G_OBJECT(button), "page", (gpointer)page_num); |
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "clicked", |
|
|
GTK_SIGNAL_FUNC(on_notebook_button_clicked), notebook); |
|
|
|
|
|
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5) |
|
|
hildon_gtk_widget_set_theme_size(button, |
|
|
(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH)); |
|
|
#endif |
|
|
|
|
|
gtk_box_pack_start_defaults( |
|
|
GTK_BOX(g_object_get_data(G_OBJECT(notebook), "hbox")), |
|
|
button); |
|
|
|
|
|
#else |
|
|
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, gtk_label_new(label)); |
|
801 |
#endif |
#endif |
802 |
|
|
803 |
|
printf("freeing cache context\n"); |
804 |
|
context->appdata->cache_context = NULL; |
805 |
|
g_free(context); |
806 |
} |
} |
807 |
|
|
808 |
static GObject *notebook_object(GtkWidget *notebook) { |
static GObject *notebook_object(GtkWidget *notebook) { |
809 |
#ifdef CUSTOM_NOTEBOOK |
return G_OBJECT(notebook_get_gtk_notebook(notebook)); |
|
return G_OBJECT(g_object_get_data(G_OBJECT(notebook), "notebook")); |
|
|
#else |
|
|
return G_OBJECT(notebook); |
|
|
#endif |
|
810 |
} |
} |
811 |
|
|
812 |
GtkWidget *cache_view(appdata_t *appdata, cache_t *cache) { |
GtkWidget *cache_view(appdata_t *appdata, cache_t *cache) { |
813 |
GtkWidget *notebook; |
GtkWidget *notebook; |
814 |
|
|
815 |
cache_context_t *cache_context = malloc(sizeof(cache_context_t)); |
cache_context_t *cache_context = g_new0(cache_context_t, 1); |
816 |
memset(cache_context, 0, sizeof(cache_context_t)); |
appdata->cache_context = cache_context; |
817 |
cache_context->appdata = appdata; |
cache_context->appdata = appdata; |
818 |
cache_context->cache = cache; |
cache_context->cache = cache; |
819 |
|
|
838 |
notebook_append_page(notebook, |
notebook_append_page(notebook, |
839 |
cache_hint(appdata, cache), _("Hint")); |
cache_hint(appdata, cache), _("Hint")); |
840 |
|
|
841 |
if(cache->log) |
// always display log page to allow user to post a new log |
842 |
|
if(cache->log |
843 |
|
#ifdef ENABLE_BROWSER_INTERFACE |
844 |
|
|| (strncmp(cache->id, "GC", 2) == 0) |
845 |
|
#endif |
846 |
|
) |
847 |
notebook_append_page(notebook, |
notebook_append_page(notebook, |
848 |
cache_logs(appdata, cache_context, cache->log, cache->logs_are_html), |
cache_logs(appdata, cache_context, cache->log, cache->logs_are_html), |
849 |
_("Logs")); |
_("Logs")); |
856 |
notebook_append_page(notebook, |
notebook_append_page(notebook, |
857 |
cache_tbs(appdata, cache->tb), _("TBs")); |
cache_tbs(appdata, cache->tb), _("TBs")); |
858 |
|
|
859 |
notebook_append_page(notebook, |
/* the demo caches don't have coordinates, so avoid */ |
860 |
cache_notes(cache_context), _("Notes")); |
/* having to deal with them */ |
861 |
|
if(!isnan(cache->pos.lat) && !isnan(cache->pos.lon)) { |
862 |
|
notebook_append_page(notebook, |
863 |
|
cache_notes(cache_context), _("Notes")); |
864 |
|
|
865 |
notebook_append_page(notebook, |
notebook_append_page(notebook, |
866 |
goto_cache(cache_context), _("Goto")); |
goto_cache(cache_context), _("Goto")); |
867 |
|
} |
868 |
|
|
869 |
g_signal_connect(notebook_object(notebook), "switch-page", |
g_signal_connect(notebook_object(notebook), "switch-page", |
870 |
G_CALLBACK(on_notebook_page_change), cache_context); |
G_CALLBACK(on_notebook_page_change), cache_context); |
900 |
static void on_cache_destroy (GtkWidget *widget, appdata_t *appdata) { |
static void on_cache_destroy (GtkWidget *widget, appdata_t *appdata) { |
901 |
appdata->cur_cache = NULL; |
appdata->cur_cache = NULL; |
902 |
|
|
903 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
904 |
|
appdata->window = HILDON_WINDOW(hildon_window_stack_peek(stack)); |
905 |
|
|
906 |
/* restore cur_view */ |
/* restore cur_view */ |
907 |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
908 |
} |
} |
909 |
|
|
910 |
void cache_dialog(appdata_t *appdata, cache_t *cache) { |
void cache_dialog(appdata_t *appdata, cache_t *cache) { |
911 |
GtkWidget *window = hildon_stackable_window_new(); |
GtkWidget *window = hildon_stackable_window_new(); |
912 |
|
appdata->window = HILDON_WINDOW(window); |
913 |
|
|
914 |
/* store last "cur_view" in window */ |
/* store last "cur_view" in window */ |
915 |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
916 |
|
|
917 |
appdata->cur_cache = cache; |
appdata->cur_cache = cache; |
918 |
char *title = g_strdup_printf("%s - GPXView", cache->name); |
gtk_window_set_title(GTK_WINDOW(window), cache->name); |
919 |
gtk_window_set_title(GTK_WINDOW(window), title); |
|
920 |
g_free(title); |
/* make sure window can control gps */ |
921 |
|
g_signal_connect(G_OBJECT(window), "focus-in-event", |
922 |
|
G_CALLBACK(on_main_focus_change), appdata); |
923 |
|
|
924 |
|
g_signal_connect(G_OBJECT(window), "focus-out-event", |
925 |
|
G_CALLBACK(on_main_focus_change), appdata); |
926 |
|
|
927 |
/* create cache visualization widget */ |
/* create cache visualization widget */ |
928 |
appdata->cur_view = cache_view(appdata, cache); |
appdata->cur_view = cache_view(appdata, cache); |