100 |
gtk_widget_show_all(context->bearing_hbox); |
gtk_widget_show_all(context->bearing_hbox); |
101 |
} |
} |
102 |
|
|
103 |
|
static void gcvote_callback(vote_t *vote, gpointer data) { |
104 |
|
cache_context_t *context = (cache_context_t*)data; |
105 |
|
|
106 |
|
/* no vote returned: request failed, just cleanup */ |
107 |
|
if(!vote) { |
108 |
|
printf("gcvote callback for failed request\n"); |
109 |
|
|
110 |
|
gcvote_request_free(context->gcvote_request); |
111 |
|
context->gcvote_request = NULL; |
112 |
|
return FALSE; |
113 |
|
} |
114 |
|
|
115 |
|
printf("gcvote callback is being called with a %d/%d\n", |
116 |
|
vote->quality, vote->votes); |
117 |
|
|
118 |
|
/* update/draw the voting */ |
119 |
|
if(!context->quality) { |
120 |
|
#ifndef USE_MAEMO |
121 |
|
GtkTooltips *tips = gtk_tooltips_new(); |
122 |
|
#endif |
123 |
|
|
124 |
|
GtkWidget *ivbox = gtk_vbox_new(FALSE, 0); |
125 |
|
|
126 |
|
char *votes_str = g_strdup_printf(_("Quality (%d %s):"), vote->votes, |
127 |
|
(vote->votes == 1)?_("vote"):_("votes")); |
128 |
|
context->votes = GTK_LABEL_SMALL(votes_str); |
129 |
|
gtk_box_pack_start(GTK_BOX(ivbox), context->votes, FALSE, FALSE, 0); |
130 |
|
g_free(votes_str); |
131 |
|
context->quality = icon_get_widget(ICON_STARS, (int)(vote->quality*2-2)); |
132 |
|
gtk_box_pack_start(GTK_BOX(ivbox), context->quality, |
133 |
|
FALSE, FALSE, 0); |
134 |
|
|
135 |
|
GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); |
136 |
|
gtk_container_add(GTK_CONTAINER(align), ivbox); |
137 |
|
gtk_box_pack_start_defaults(GTK_BOX(context->ratebox), align); |
138 |
|
#ifndef USE_MAEMO |
139 |
|
char *str = g_strdup_printf(_("Quality: %d"), vote->quality); |
140 |
|
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
141 |
|
g_free(str); |
142 |
|
#endif |
143 |
|
|
144 |
|
gtk_widget_show_all(context->ratebox); |
145 |
|
|
146 |
|
gcvote_request_free(context->gcvote_request); |
147 |
|
context->gcvote_request = NULL; |
148 |
|
} |
149 |
|
} |
150 |
|
|
151 |
static GtkWidget *cache_overview(cache_context_t *context) { |
static GtkWidget *cache_overview(cache_context_t *context) { |
152 |
GtkWidget *vbox, *ivbox; |
GtkWidget *vbox, *ivbox; |
153 |
GtkWidget *table, *tip; |
GtkWidget *table, *tip; |
209 |
gtk_table_attach(GTK_TABLE(table), ivbox, 1,2,1,2, FALSE,FALSE,0,0); |
gtk_table_attach(GTK_TABLE(table), ivbox, 1,2,1,2, FALSE,FALSE,0,0); |
210 |
} |
} |
211 |
|
|
212 |
|
/* ----------- vbox containing all ratings ---------- */ |
213 |
|
GtkWidget *ratebox = context->ratebox = gtk_vbox_new(FALSE, 0); |
214 |
|
|
215 |
/* ----------- box containing difficulty rating ---------- */ |
/* ----------- box containing difficulty rating ---------- */ |
216 |
if(cache->difficulty != 0) { |
if(cache->difficulty != 0) { |
217 |
ivbox = gtk_vbox_new(FALSE, 0); |
ivbox = gtk_vbox_new(FALSE, 0); |
221 |
gtk_box_pack_start(GTK_BOX(ivbox), |
gtk_box_pack_start(GTK_BOX(ivbox), |
222 |
icon_get_widget(ICON_STARS, (int)(cache->difficulty*2-2)), |
icon_get_widget(ICON_STARS, (int)(cache->difficulty*2-2)), |
223 |
FALSE, FALSE, 0); |
FALSE, FALSE, 0); |
224 |
gtk_table_attach(GTK_TABLE(table), ivbox, 2,3,0,1, |
|
225 |
GTK_EXPAND | GTK_FILL, 0, GTK_FILL, 0); |
GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); |
226 |
|
gtk_container_add(GTK_CONTAINER(align), ivbox); |
227 |
|
gtk_box_pack_start_defaults(GTK_BOX(ratebox), align); |
228 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
229 |
sprintf(str, _("Difficulty: %.1f"), cache->difficulty); |
sprintf(str, _("Difficulty: %.1f"), cache->difficulty); |
230 |
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
239 |
gtk_box_pack_start(GTK_BOX(ivbox), |
gtk_box_pack_start(GTK_BOX(ivbox), |
240 |
icon_get_widget(ICON_STARS, (int)(cache->terrain*2-2)), |
icon_get_widget(ICON_STARS, (int)(cache->terrain*2-2)), |
241 |
FALSE, FALSE, 0); |
FALSE, FALSE, 0); |
242 |
gtk_table_attach(GTK_TABLE(table), ivbox, 2,3,1,2, |
GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); |
243 |
GTK_EXPAND | GTK_FILL, 0, GTK_FILL, 0); |
gtk_container_add(GTK_CONTAINER(align), ivbox); |
244 |
|
gtk_box_pack_start_defaults(GTK_BOX(ratebox), align); |
245 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
246 |
sprintf(str, _("Terrain: %.1f"), cache->terrain); |
sprintf(str, _("Terrain: %.1f"), cache->terrain); |
247 |
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
248 |
#endif |
#endif |
249 |
} |
} |
250 |
|
|
251 |
|
/* --------------------- GCVote ------------------------ */ |
252 |
|
/* gcvote if present and possible */ |
253 |
|
|
254 |
|
context->gcvote_request = |
255 |
|
gcvote_request(appdata, gcvote_callback, cache->url, context); |
256 |
|
|
257 |
|
#if 0 |
258 |
|
vote_t *vote = gcvote_get(appdata, cache->url); |
259 |
|
if(vote) { |
260 |
|
ivbox = gtk_vbox_new(FALSE, 0); |
261 |
|
|
262 |
|
char *votes_str = g_strdup_printf(_("Quality (%d %s):"), vote->votes, |
263 |
|
(vote->votes == 1)?_("vote"):_("votes")); |
264 |
|
gtk_box_pack_start(GTK_BOX(ivbox), GTK_LABEL_SMALL(votes_str), |
265 |
|
FALSE, FALSE, 0); |
266 |
|
g_free(votes_str); |
267 |
|
gtk_box_pack_start(GTK_BOX(ivbox), |
268 |
|
icon_get_widget(ICON_STARS, (int)(vote->quality*2-2)), FALSE, FALSE, 0); |
269 |
|
|
270 |
|
GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); |
271 |
|
gtk_container_add(GTK_CONTAINER(align), ivbox); |
272 |
|
gtk_box_pack_start_defaults(GTK_BOX(ratebox), align); |
273 |
|
#ifndef USE_MAEMO |
274 |
|
sprintf(str, _("Quality: %d"), vote->quality); |
275 |
|
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
276 |
|
#endif |
277 |
|
|
278 |
|
gcvote_free(vote); |
279 |
|
} |
280 |
|
#endif |
281 |
|
|
282 |
|
gtk_table_attach_defaults(GTK_TABLE(table), ratebox, 2,3,0,2); |
283 |
|
|
284 |
|
/* ----------------------------------------------------- */ |
285 |
|
|
286 |
|
|
287 |
/* ----------------- the two coordinates ----------------- */ |
/* ----------------- the two coordinates ----------------- */ |
288 |
/* ----------------- and the heading/distance ------------ */ |
/* ----------------- and the heading/distance ------------ */ |
289 |
pos_t *refpos = get_pos(appdata); |
pos_t *refpos = get_pos(appdata); |
313 |
gtk_box_pack_start(GTK_BOX(vbox), table, 0,0,0); |
gtk_box_pack_start(GTK_BOX(vbox), table, 0,0,0); |
314 |
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); |
315 |
|
|
316 |
|
/* ----------------------------------------------------- */ |
317 |
|
|
318 |
if(cache->short_description) |
if(cache->short_description) |
319 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), |
gtk_box_pack_start_defaults(GTK_BOX(vbox), |
320 |
html_view(appdata, cache->short_description, |
html_view(appdata, cache->short_description, |