19 |
|
|
20 |
#include "gpxview.h" |
#include "gpxview.h" |
21 |
#include <math.h> |
#include <math.h> |
22 |
|
#include <string.h> |
23 |
|
|
24 |
static GtkWidget *cache_description(appdata_t *appdata, cache_t *cache) { |
static GtkWidget *cache_description(appdata_t *appdata, cache_t *cache) { |
25 |
return html_view(appdata, cache->long_description, |
return html_view(appdata, cache->long_description, |
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)) { |
57 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), |
gtk_box_pack_start_defaults(GTK_BOX(hbox), |
58 |
GTK_LABEL_SMALL((char*)pos_get_bearing_str(refpos, pos))); |
GTK_LABEL_SMALL((char*)pos_get_bearing_str(refpos, pos))); |
59 |
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL(" ")); |
60 |
snprintf(str, sizeof(str), _("%.1f°"), |
snprintf(str, sizeof(str), _("%.1f°"), |
61 |
gpx_pos_get_bearing(refpos, pos)); |
gpx_pos_get_bearing(refpos, pos)); |
62 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL(str)); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL(str)); |
63 |
gpx_pos_get_distance_str(str, sizeof(str), |
gpx_pos_get_distance_str(str, sizeof(str), |
64 |
refpos, pos, appdata->imperial); |
refpos, pos, appdata->imperial); |
65 |
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL(" ")); |
66 |
gtk_box_pack_start(GTK_BOX(hbox), |
gtk_box_pack_start(GTK_BOX(hbox), |
67 |
gtk_label_attrib(str, SIZE_SMALL, STRIKETHROUGH_NONE),1,0,0); |
gtk_label_attrib(str, SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0); |
68 |
} else |
} else |
69 |
gtk_box_pack_start(GTK_BOX(hbox), |
gtk_box_pack_start(GTK_BOX(hbox), |
70 |
gtk_label_attrib(_("(no position)"), |
gtk_label_attrib(_("(no position)"), |
71 |
SIZE_SMALL, STRIKETHROUGH_NONE),1,0,0); |
SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0); |
72 |
} else |
} else |
73 |
gtk_box_pack_start(GTK_BOX(hbox), |
gtk_box_pack_start(GTK_BOX(hbox), |
74 |
gtk_label_attrib(_("(invalid position in notes)"), |
gtk_label_attrib(_("(invalid position in notes)"), |
75 |
SIZE_SMALL, STRIKETHROUGH_NONE),1,0,0); |
SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0); |
76 |
} |
} |
77 |
|
|
78 |
/* this function sets everthing related to the coordinate. used to */ |
/* this function sets everything related to the coordinate. used to */ |
79 |
/* cope with the user setting a new "note coordinate" */ |
/* cope with the user setting a new "note coordinate" */ |
80 |
void overview_coordinate_update(cache_context_t *context) { |
void overview_coordinate_update(cache_context_t *context) { |
81 |
if(!context->notes.modified) |
if(!context->notes.modified) |
164 |
context->gcvote_request = NULL; |
context->gcvote_request = NULL; |
165 |
} |
} |
166 |
|
|
167 |
|
static void pack_vcentered(GtkWidget *vbox, GtkWidget *child) { |
168 |
|
GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); |
169 |
|
gtk_container_add(GTK_CONTAINER(align), child); |
170 |
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), align); |
171 |
|
} |
172 |
|
|
173 |
static GtkWidget *cache_overview(cache_context_t *context) { |
static GtkWidget *cache_overview(cache_context_t *context) { |
174 |
GtkWidget *vbox, *ivbox; |
GtkWidget *vbox, *ivbox; |
175 |
GtkWidget *table, *tip; |
GtkWidget *colbox, *tip; |
176 |
char str[64]; |
char str[64]; |
177 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
178 |
GtkTooltips *tips = gtk_tooltips_new(); |
GtkTooltips *tips = gtk_tooltips_new(); |
180 |
appdata_t *appdata = context->appdata; |
appdata_t *appdata = context->appdata; |
181 |
cache_t *cache = context->cache; |
cache_t *cache = context->cache; |
182 |
|
|
183 |
vbox = gtk_vbox_new(FALSE, 0); |
vbox = gtk_vbox_new(FALSE, 4); |
184 |
|
|
185 |
table = gtk_table_new(3,4, FALSE); |
/* hbox containing the four columns of cache details */ |
186 |
|
GtkWidget *ihbox = gtk_hbox_new(FALSE, 0); |
187 |
|
|
188 |
|
/* vbox containing leftmost column (icon and container) */ |
189 |
|
colbox = gtk_vbox_new(FALSE, 0); |
190 |
|
|
191 |
if(cache->type != CACHE_TYPE_UNKNOWN) { |
if(cache->type != CACHE_TYPE_UNKNOWN) { |
192 |
gtk_table_attach(GTK_TABLE(table), |
gtk_box_pack_start_defaults(GTK_BOX(colbox), |
193 |
tip = icon_get_widget(ICON_CACHE_TYPE, cache->type), 0,1,0,1, |
|
194 |
GTK_FILL, 0, GTK_FILL, 0); |
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5) |
195 |
|
tip = icon_get_widget(ICON_CACHE_TYPE_2X, cache->type)); |
196 |
|
#else |
197 |
|
tip = icon_get_widget(ICON_CACHE_TYPE_1_5X, cache->type)); |
198 |
|
#endif |
199 |
|
|
200 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
201 |
gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL); |
gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL); |
202 |
#endif |
#endif |
211 |
gtk_box_pack_start(GTK_BOX(ivbox), |
gtk_box_pack_start(GTK_BOX(ivbox), |
212 |
icon_get_widget(ICON_CACHE_SIZE, cache->container), |
icon_get_widget(ICON_CACHE_SIZE, cache->container), |
213 |
FALSE, FALSE, 0); |
FALSE, FALSE, 0); |
214 |
gtk_table_attach(GTK_TABLE(table), ivbox, 0,1,1,2, |
|
215 |
GTK_EXPAND | GTK_FILL, 0, GTK_FILL, 0); |
pack_vcentered(colbox, ivbox); |
216 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
217 |
gtk_tooltips_set_tip(tips, ivbox, _(cache_size_tip[cache->container]), NULL); |
gtk_tooltips_set_tip(tips, ivbox, _(cache_size_tip[cache->container]), NULL); |
218 |
#endif |
#endif |
219 |
} |
} |
220 |
|
|
221 |
|
gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox); |
222 |
|
colbox = gtk_vbox_new(FALSE, 0); |
223 |
|
|
224 |
/* ----------------------- id ---------------------------- */ |
/* ----------------------- id ---------------------------- */ |
225 |
if(cache->id) { |
if(cache->id) { |
226 |
int strike = cache->archived?STRIKETHROUGH_RED: |
int strike = cache->archived?STRIKETHROUGH_RED: |
228 |
GtkWidget *lbl = link_button_attrib(context->appdata, |
GtkWidget *lbl = link_button_attrib(context->appdata, |
229 |
cache->id, context->cache->url, |
cache->id, context->cache->url, |
230 |
SIZE_BIG, strike); |
SIZE_BIG, strike); |
231 |
gtk_table_attach(GTK_TABLE(table), lbl, 1,2,0,1, FALSE, FALSE, 0, 0); |
pack_vcentered(colbox, lbl); |
232 |
} |
} |
233 |
|
|
234 |
/* --------------- box containing owner info ------------- */ |
/* --------------- box containing owner info ------------- */ |
235 |
if(cache->owner) { |
if(cache->owner) { |
236 |
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"))); |
|
237 |
|
|
238 |
static const char *owner_type = "profile/"; |
static const char *owner_type = "profile/"; |
239 |
gtk_box_pack_start_defaults(GTK_BOX(ivbox), |
pack_vcentered(colbox, |
240 |
link_button_by_id(appdata, cache->owner->name, |
link_button_by_id(appdata, cache->owner->name, |
241 |
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); |
|
242 |
} |
} |
243 |
|
|
244 |
|
gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox); |
245 |
|
|
246 |
/* ----------- vbox containing all ratings ---------- */ |
/* ----------- vbox containing all ratings ---------- */ |
247 |
GtkWidget *ratebox = gtk_vbox_new(FALSE, 0); |
colbox = gtk_vbox_new(FALSE, 0); |
248 |
|
|
249 |
/* ----------- box containing difficulty rating ---------- */ |
/* ----------- box containing difficulty rating ---------- */ |
250 |
if(cache->difficulty != 0) { |
if(cache->difficulty != 0) { |
256 |
icon_get_widget(ICON_STARS, (int)(cache->difficulty*2-2)), |
icon_get_widget(ICON_STARS, (int)(cache->difficulty*2-2)), |
257 |
FALSE, FALSE, 0); |
FALSE, FALSE, 0); |
258 |
|
|
259 |
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); |
|
260 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
261 |
sprintf(str, _("Difficulty: %.1f"), cache->difficulty); |
sprintf(str, _("Difficulty: %.1f"), cache->difficulty); |
262 |
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
271 |
gtk_box_pack_start(GTK_BOX(ivbox), |
gtk_box_pack_start(GTK_BOX(ivbox), |
272 |
icon_get_widget(ICON_STARS, (int)(cache->terrain*2-2)), |
icon_get_widget(ICON_STARS, (int)(cache->terrain*2-2)), |
273 |
FALSE, FALSE, 0); |
FALSE, FALSE, 0); |
274 |
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); |
|
275 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
276 |
sprintf(str, _("Terrain: %.1f"), cache->terrain); |
sprintf(str, _("Terrain: %.1f"), cache->terrain); |
277 |
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
gtk_tooltips_set_tip(tips, ivbox, str, NULL); |
279 |
} |
} |
280 |
|
|
281 |
/* --------------------- GCVote ------------------------ */ |
/* --------------------- GCVote ------------------------ */ |
282 |
|
if(!appdata->disable_gcvote) { |
283 |
vote_t *vote = gcvote_restore(appdata, cache); |
vote_t *vote = gcvote_restore(appdata, cache); |
284 |
|
|
285 |
context->gcvote_request = |
context->gcvote_request = |
286 |
gcvote_request(appdata, gcvote_callback, cache->url, context); |
gcvote_request(appdata, gcvote_callback, cache->url, context); |
287 |
|
|
288 |
context->votebox = gtk_vbox_new(FALSE, 0); |
context->votebox = gtk_vbox_new(FALSE, 0); |
289 |
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); |
|
290 |
|
|
291 |
/* fill with vote if present on disk (will also free vote) */ |
/* fill with vote if present on disk (will also free vote) */ |
292 |
if(vote) |
if(vote) |
293 |
gcvote_set(context, vote); |
gcvote_set(context, vote); |
294 |
|
} |
295 |
|
|
296 |
gtk_table_attach_defaults(GTK_TABLE(table), ratebox, 2,3,0,2); |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox); |
297 |
|
|
298 |
/* ----------------------------------------------------- */ |
/* ----------------------------------------------------- */ |
299 |
|
|
300 |
|
|
301 |
/* ----------------- the two coordinates ----------------- */ |
/* ----------------- the two coordinates ----------------- */ |
302 |
/* ----------------- and the heading/distance ------------ */ |
/* ----------------- and the heading/distance ------------ */ |
303 |
|
colbox = gtk_vbox_new(FALSE, 0); |
304 |
|
|
305 |
pos_t *refpos = get_pos(appdata); |
pos_t *refpos = get_pos(appdata); |
306 |
|
|
307 |
ivbox = gtk_vbox_new(FALSE, 0); |
ivbox = gtk_vbox_new(FALSE, 0); |
309 |
STRIKETHROUGH:STRIKETHROUGH_NONE; |
STRIKETHROUGH:STRIKETHROUGH_NONE; |
310 |
|
|
311 |
/* the original coordinate is being displayed */ |
/* the original coordinate is being displayed */ |
312 |
gtk_box_pack_start_defaults(GTK_BOX(ivbox), |
gtk_box_pack_start(GTK_BOX(ivbox), |
313 |
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); |
314 |
gtk_box_pack_start_defaults(GTK_BOX(ivbox), |
gtk_box_pack_start(GTK_BOX(ivbox), |
315 |
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); |
316 |
|
|
317 |
|
pack_vcentered(colbox, ivbox); |
318 |
|
|
319 |
/* but calculations may be done with respect to the overriden one */ |
/* but calculations may be done with respect to the overriden one */ |
320 |
if(!isnan(cache->pos.lat) && !isnan(cache->pos.lon)) { |
if(!isnan(cache->pos.lat) && !isnan(cache->pos.lon)) { |
321 |
context->bearing_hbox = gtk_hbox_new(FALSE, 0); |
context->bearing_hbox = gtk_hbox_new(FALSE, 0); |
322 |
bearing_fill_hbox(context->bearing_hbox, appdata, *refpos, |
bearing_fill_hbox(context->bearing_hbox, appdata, *refpos, |
323 |
gpx_cache_pos(cache)); |
gpx_cache_pos(cache)); |
324 |
gtk_box_pack_start_defaults(GTK_BOX(ivbox), context->bearing_hbox); |
pack_vcentered(colbox, context->bearing_hbox); |
325 |
} |
} |
326 |
|
|
327 |
gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 3,4,0,2); |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox); |
328 |
|
|
329 |
/* ----------------------------------------------------- */ |
/* ----------------------------------------------------- */ |
330 |
|
|
331 |
gtk_box_pack_start(GTK_BOX(vbox), table, 0,0,0); |
gtk_box_pack_start(GTK_BOX(vbox), ihbox, FALSE, FALSE, 0); |
332 |
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); |
333 |
|
|
334 |
/* ----------------------------------------------------- */ |
/* ----------------------------------------------------- */ |
335 |
|
|
451 |
pos_lon(wpt->pos.lon, SIZE_BIG, STRIKETHROUGH_NONE), |
pos_lon(wpt->pos.lon, SIZE_BIG, STRIKETHROUGH_NONE), |
452 |
2,3, wpt_row, wpt_row+1); |
2,3, wpt_row, wpt_row+1); |
453 |
|
|
454 |
ihbox = gtk_hbox_new(FALSE, 0); |
if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { |
455 |
gtk_box_pack_start(GTK_BOX(ihbox), gtk_image_new_from_pixbuf( |
ihbox = gtk_hbox_new(FALSE, 0); |
456 |
|
gtk_box_pack_start(GTK_BOX(ihbox), gtk_image_new_from_pixbuf( |
457 |
icon_bearing(*refpos, wpt->pos)),1,0,0); |
icon_bearing(*refpos, wpt->pos)),1,0,0); |
458 |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), |
snprintf(str, sizeof(str), _("%.1f°"), |
459 |
GTK_LABEL_SMALL((char*)pos_get_bearing_str(*refpos, wpt->pos))); |
gpx_pos_get_bearing(*refpos, wpt->pos)); |
460 |
snprintf(str, sizeof(str), _("%.1f°"), |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), GTK_LABEL_SMALL(str)); |
461 |
gpx_pos_get_bearing(*refpos, wpt->pos)); |
|
462 |
gtk_box_pack_start_defaults(GTK_BOX(ihbox), GTK_LABEL_SMALL(str)); |
gpx_pos_get_distance_str(str, sizeof(str), |
463 |
gpx_pos_get_distance_str(str, sizeof(str), |
*refpos, wpt->pos, appdata->imperial); |
464 |
*refpos, wpt->pos, appdata->imperial); |
gtk_box_pack_start(GTK_BOX(ihbox), GTK_LABEL_SMALL(str),1,0,0); |
465 |
gtk_box_pack_start(GTK_BOX(ihbox), GTK_LABEL_SMALL(str),1,0,0); |
|
466 |
|
gtk_table_attach_defaults(GTK_TABLE(table), ihbox, 3,4, |
467 |
|
wpt_row+0, wpt_row+1); |
468 |
|
} |
469 |
|
|
|
gtk_table_attach_defaults(GTK_TABLE(table), ihbox, 3,4, |
|
|
wpt_row+0, wpt_row+1); |
|
|
|
|
470 |
/* ------------------ description ------------------------- */ |
/* ------------------ description ------------------------- */ |
471 |
if(wpt->desc) |
if(wpt->desc) |
472 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
527 |
static const char *tb_type = "track/details.aspx"; |
static const char *tb_type = "track/details.aspx"; |
528 |
|
|
529 |
/* --------------------- icon/ref/name -------------------------*/ |
/* --------------------- icon/ref/name -------------------------*/ |
530 |
gtk_table_attach_defaults(GTK_TABLE(table), icon_get_widget(ICON_TB, 0), |
GtkWidget *icon = NULL; |
531 |
0, 1, tb_row+0, tb_row+1); |
if((strcasestr(tb->name, "coin") != 0) || |
532 |
|
(strcasestr(tb->name, "muenze") != 0) || |
533 |
|
(strcasestr(tb->name, "münze") != 0)) |
534 |
|
icon = icon_get_widget(ICON_TB, 1); /* coin icon */ |
535 |
|
else |
536 |
|
icon = icon_get_widget(ICON_TB, 0); /* tb icon */ |
537 |
|
|
538 |
|
gtk_table_attach_defaults(GTK_TABLE(table), icon, |
539 |
|
0, 1, tb_row+0, tb_row+1); |
540 |
|
|
541 |
if(tb->ref) { |
if(tb->ref) { |
542 |
GtkWidget *ref = link_button_by_id(appdata, tb->ref, tb_type, tb->id); |
GtkWidget *ref = link_button_by_id(appdata, tb->ref, tb_type, tb->id); |
608 |
gtk_signal_connect(GTK_OBJECT(but), "clicked", |
gtk_signal_connect(GTK_OBJECT(but), "clicked", |
609 |
GTK_SIGNAL_FUNC(on_gclink_clicked), context); |
GTK_SIGNAL_FUNC(on_gclink_clicked), context); |
610 |
|
|
611 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), but); |
gtk_box_pack_start(GTK_BOX(vbox), but, FALSE, FALSE, 0); |
612 |
} |
} |
613 |
#endif |
#endif |
614 |
|
|
657 |
|
|
658 |
gtk_box_pack_start(GTK_BOX(ivbox), ihbox, FALSE, FALSE, 0); |
gtk_box_pack_start(GTK_BOX(ivbox), ihbox, FALSE, FALSE, 0); |
659 |
|
|
660 |
gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 0, 1, |
gtk_table_attach(GTK_TABLE(table), ivbox, 0, 1, |
661 |
2*log_cnt, 2*log_cnt+1); |
2*log_cnt, 2*log_cnt+1, 0, GTK_EXPAND | GTK_FILL, 0, 0); |
662 |
|
|
663 |
if(log->text) { |
if(log->text) { |
664 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
665 |
html_view(appdata, log->text, |
html_view(appdata, log->text, |
680 |
log_cnt++; |
log_cnt++; |
681 |
} |
} |
682 |
|
|
683 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), table); |
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
684 |
|
|
685 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
686 |
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), |
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), |
801 |
#endif |
#endif |
802 |
} |
} |
803 |
|
|
804 |
|
#ifdef CUSTOM_NOTEBOOK |
805 |
static void on_notebook_button_clicked(GtkWidget *button, gpointer data) { |
static void on_notebook_button_clicked(GtkWidget *button, gpointer data) { |
806 |
GtkNotebook *nb = |
GtkNotebook *nb = |
807 |
GTK_NOTEBOOK(g_object_get_data(G_OBJECT(data), "notebook")); |
GTK_NOTEBOOK(g_object_get_data(G_OBJECT(data), "notebook")); |
808 |
|
|
809 |
/* get previously selected page */ |
gint page = (gint)g_object_get_data(G_OBJECT(button), "page"); |
|
gint page = gtk_notebook_get_current_page(nb); |
|
|
char *id_str = g_strdup_printf("button_%d", page); |
|
|
gtk_toggle_button_set_active( |
|
|
GTK_TOGGLE_BUTTON(g_object_get_data(G_OBJECT(data), id_str)), FALSE); |
|
|
g_free(id_str); |
|
|
|
|
|
page = (gint)g_object_get_data(G_OBJECT(button), "page"); |
|
810 |
gtk_notebook_set_current_page(nb, page); |
gtk_notebook_set_current_page(nb, page); |
811 |
} |
} |
812 |
|
#endif |
813 |
|
|
814 |
static void notebook_append_page(GtkWidget *notebook, |
static void notebook_append_page(GtkWidget *notebook, |
815 |
GtkWidget *page, char *label) { |
GtkWidget *page, char *label) { |
818 |
GTK_NOTEBOOK(g_object_get_data(G_OBJECT(notebook), "notebook")); |
GTK_NOTEBOOK(g_object_get_data(G_OBJECT(notebook), "notebook")); |
819 |
|
|
820 |
gint page_num = gtk_notebook_append_page(nb, page, gtk_label_new(label)); |
gint page_num = gtk_notebook_append_page(nb, page, gtk_label_new(label)); |
821 |
|
GtkWidget *button = NULL; |
|
GtkWidget *button = gtk_toggle_button_new_with_label(label); |
|
|
g_object_set_data(G_OBJECT(button), "page", (gpointer)page_num); |
|
822 |
|
|
823 |
/* select button for page 0 by default */ |
/* select button for page 0 by default */ |
824 |
if(!page_num) |
if(!page_num) { |
825 |
|
button = gtk_radio_button_new_with_label(NULL, label); |
826 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); |
827 |
|
g_object_set_data(G_OBJECT(notebook), "group_master", (gpointer)button); |
828 |
|
} else { |
829 |
|
GtkWidget *master = g_object_get_data(G_OBJECT(notebook), "group_master"); |
830 |
|
button = gtk_radio_button_new_with_label_from_widget( |
831 |
|
GTK_RADIO_BUTTON(master), label); |
832 |
|
} |
833 |
|
|
834 |
|
gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE); |
835 |
|
g_object_set_data(G_OBJECT(button), "page", (gpointer)page_num); |
836 |
|
|
837 |
gtk_signal_connect(GTK_OBJECT(button), "clicked", |
gtk_signal_connect(GTK_OBJECT(button), "clicked", |
838 |
GTK_SIGNAL_FUNC(on_notebook_button_clicked), notebook); |
GTK_SIGNAL_FUNC(on_notebook_button_clicked), notebook); |
839 |
|
|
|
g_object_set_data(G_OBJECT(button), "page", (gpointer)page_num); |
|
|
|
|
840 |
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5) |
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5) |
841 |
hildon_gtk_widget_set_theme_size(button, |
hildon_gtk_widget_set_theme_size(button, |
842 |
(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH)); |
(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH)); |
843 |
#endif |
#endif |
844 |
|
|
|
char *id_str = g_strdup_printf("button_%d", page_num); |
|
|
g_object_set_data(G_OBJECT(notebook), id_str, (gpointer)button); |
|
|
g_free(id_str); |
|
|
|
|
845 |
gtk_box_pack_start_defaults( |
gtk_box_pack_start_defaults( |
846 |
GTK_BOX(g_object_get_data(G_OBJECT(notebook), "hbox")), |
GTK_BOX(g_object_get_data(G_OBJECT(notebook), "hbox")), |
847 |
button); |
button); |