Diff of /trunk/src/cache.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1 by harbaum, Sat Jun 20 11:08:47 2009 UTC revision 187 by harbaum, Mon Nov 16 13:39:00 2009 UTC
# Line 19  Line 19 
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,
26                     cache->long_is_html, TRUE, cache, NULL);             cache->long_is_html?HTML_HTML:HTML_PLAIN_TEXT, TRUE, cache, NULL);
27  }  }
28    
29  #ifndef USE_MAEMO  // maemos touchscreen doesn't support tooltips  #ifndef USE_MAEMO  // maemos touchscreen doesn't support tooltips
# Line 41  static const char *cache_size_tip[] = { Line 42  static const char *cache_size_tip[] = {
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,
# Line 51  void bearing_fill_hbox(GtkWidget *hbox, Line 51  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(refpos.lat && 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)
# Line 92  void overview_coordinate_update(cache_co Line 94  void overview_coordinate_update(cache_co
94                          (GtkCallback)gtk_widget_destroy, NULL);                          (GtkCallback)gtk_widget_destroy, NULL);
95    
96    /* update distance/etc */    /* update distance/etc */
97    bearing_fill_hbox(context->bearing_hbox, context->appdata,    if(!isnan(context->cache->pos.lat) &&
98                      *get_pos(context->appdata), notes_get_pos(context));       !isnan(context->cache->pos.lon))
99        bearing_fill_hbox(context->bearing_hbox, context->appdata,
100                          *get_pos(context->appdata), notes_get_pos(context));
101    
102    gtk_widget_show_all(context->bearing_hbox);    gtk_widget_show_all(context->bearing_hbox);
103  }  }
104    
105  #ifdef ENABLE_BROWSER_INTERFACE  static void gcvote_set(cache_context_t *context, vote_t *vote) {
106  static void on_www_clicked(GtkButton *button, gpointer data) {    if(!vote) return;
107    
108      if(context->quality) {
109        gtk_widget_destroy(context->quality);
110        context->quality = NULL;
111      }
112    
113      if(context->votes) {
114        gtk_widget_destroy(context->votes);
115        context->votes = NULL;
116      }
117    
118      /* update/draw the voting */
119    #ifndef USE_MAEMO
120      GtkTooltips *tips = gtk_tooltips_new();
121    #endif
122    
123      char *votes_str = g_strdup_printf(_("Quality (%d %s):"), vote->votes,
124                                          (vote->votes == 1)?_("vote"):_("votes"));
125      context->votes = GTK_LABEL_SMALL(votes_str);
126      gtk_box_pack_start(GTK_BOX(context->votebox),
127                         context->votes, FALSE, FALSE, 0);
128      g_free(votes_str);
129      context->quality = icon_get_widget(ICON_STARS, (int)(vote->quality*2-2));
130      gtk_box_pack_start(GTK_BOX(context->votebox), context->quality,
131                         FALSE, FALSE, 0);
132    
133    #ifndef USE_MAEMO
134      char *str = g_strdup_printf(_("Quality: %d"), vote->quality);
135      gtk_tooltips_set_tip(tips, context->votebox, str, NULL);
136      g_free(str);
137    #endif
138    
139      gtk_widget_show_all(context->votebox);
140    
141      g_free(vote);
142    }
143    
144    static void gcvote_callback(vote_t *vote, gpointer data) {
145    cache_context_t *context = (cache_context_t*)data;    cache_context_t *context = (cache_context_t*)data;
146    browser_url(context->appdata, context->cache->url);  
147      /* no vote returned: request failed, just cleanup */
148      if(!vote) {
149        printf("gcvote: callback for failed request\n");
150    
151        gcvote_request_free(context->gcvote_request);
152        context->gcvote_request = NULL;
153        return;
154      }
155    
156      printf("gcvote: callback is being called with a %d/%d\n",
157             vote->quality, vote->votes);
158    
159      gcvote_set(context, vote);
160    
161      gcvote_save(context->appdata, context->cache, &context->gcvote_request->mem);
162    
163      gcvote_request_free(context->gcvote_request);
164      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  }  }
 #endif  
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();
# Line 114  static GtkWidget *cache_overview(cache_c Line 180  static GtkWidget *cache_overview(cache_c
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      /* hbox containing the four columns of cache details */
186      GtkWidget *ihbox = gtk_hbox_new(FALSE, 0);
187    
188    table =  gtk_table_new(3,4, FALSE);    /* 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_defaults(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    #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
# Line 130  static GtkWidget *cache_overview(cache_c Line 206  static GtkWidget *cache_overview(cache_c
206    if(cache->container != CACHE_CONT_UNKNOWN) {    if(cache->container != CACHE_CONT_UNKNOWN) {
207      ivbox = gtk_vbox_new(FALSE, 0);      ivbox = gtk_vbox_new(FALSE, 0);
208      sprintf(str, _("Size: %s"), _(cache_size_name[cache->container]));      sprintf(str, _("Size: %s"), _(cache_size_name[cache->container]));
209      gtk_box_pack_start_defaults(GTK_BOX(ivbox), GTK_LABEL_SMALL(str));      gtk_box_pack_start(GTK_BOX(ivbox), GTK_LABEL_SMALL(str),
210      gtk_box_pack_start_defaults(GTK_BOX(ivbox),                         FALSE, FALSE, 0);
211          icon_get_widget(ICON_CACHE_SIZE, cache->container));      gtk_box_pack_start(GTK_BOX(ivbox),
212      gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 0,1,1,2);                         icon_get_widget(ICON_CACHE_SIZE, cache->container),
213                           FALSE, FALSE, 0);
214    
215        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:
227        (!cache->available?STRIKETHROUGH:STRIKETHROUGH_NONE);        (!cache->available?STRIKETHROUGH:STRIKETHROUGH_NONE);
228      GtkWidget *lbl = NULL;      GtkWidget *lbl = link_button_attrib(context->appdata,
229                                            cache->id, context->cache->url,
230  #ifdef ENABLE_BROWSER_INTERFACE                                          SIZE_BIG, strike);
231      if(!cache->url)      pack_vcentered(colbox, lbl);
 #endif  
       lbl = gtk_label_attrib(cache->id, SIZE_BIG, strike);  
 #ifdef ENABLE_BROWSER_INTERFACE  
     else {  
       /* add Go button */  
       lbl = gtk_button_attrib(cache->id, SIZE_BIG, strike);  
       //      gtk_button_set_relief(GTK_BUTTON(button),GTK_RELIEF_NONE);  
       gtk_signal_connect(GTK_OBJECT(lbl), "clicked",  
                          (GtkSignalFunc)on_www_clicked, context);  
     }  
 #endif  
   
     gtk_table_attach(GTK_TABLE(table), lbl, 1,2,0,1, FALSE, FALSE, 0, 0);  
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")));
237      gtk_box_pack_start_defaults(GTK_BOX(ivbox), GTK_LABEL_SMALL(_("by")));  
238      gtk_box_pack_start_defaults(GTK_BOX(ivbox), GTK_LABEL_SMALL(cache->owner));      static const char *owner_type = "profile/";
239      gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 1,2,1,2);      pack_vcentered(colbox,
240                    link_button_by_id(appdata, cache->owner->name,
241                                      owner_type, cache->owner->id));
242    }    }
243    
244      gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox);
245    
246      /* ----------- vbox containing all ratings ---------- */
247      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) {
251      ivbox = gtk_vbox_new(FALSE, 0);      ivbox = gtk_vbox_new(FALSE, 0);
252      gtk_box_pack_start_defaults(GTK_BOX(ivbox),      gtk_box_pack_start(GTK_BOX(ivbox),
253                                  GTK_LABEL_SMALL(_("Difficulty:")));                         GTK_LABEL_SMALL(_("Difficulty:")),
254      gtk_box_pack_start_defaults(GTK_BOX(ivbox),                         FALSE, FALSE, 0);
255         icon_get_widget(ICON_STARS, (int)(cache->difficulty*2-2)));      gtk_box_pack_start(GTK_BOX(ivbox),
256      gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 2,3,0,1);                    icon_get_widget(ICON_STARS, (int)(cache->difficulty*2-2)),
257                           FALSE, FALSE, 0);
258    
259        pack_vcentered(colbox, ivbox);
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);
# Line 187  static GtkWidget *cache_overview(cache_c Line 266  static GtkWidget *cache_overview(cache_c
266    /* ------------ box containing terrain rating ------------ */    /* ------------ box containing terrain rating ------------ */
267    if(cache->terrain != 0) {    if(cache->terrain != 0) {
268      ivbox = gtk_vbox_new(FALSE, 0);      ivbox = gtk_vbox_new(FALSE, 0);
269      gtk_box_pack_start_defaults(GTK_BOX(ivbox), GTK_LABEL_SMALL(_("Terrain:")));      gtk_box_pack_start(GTK_BOX(ivbox), GTK_LABEL_SMALL(_("Terrain:")),
270      gtk_box_pack_start_defaults(GTK_BOX(ivbox),                         FALSE, FALSE, 0);
271        icon_get_widget(ICON_STARS, (int)(cache->terrain*2-2)));      gtk_box_pack_start(GTK_BOX(ivbox),
272      gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 2,3,1,2);                         icon_get_widget(ICON_STARS, (int)(cache->terrain*2-2)),
273                           FALSE, FALSE, 0);
274        pack_vcentered(colbox, ivbox);
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);
278  #endif  #endif
279    }    }
280    
281      /* --------------------- GCVote ------------------------ */
282      if(!appdata->disable_gcvote) {
283        vote_t *vote = gcvote_restore(appdata, cache);
284    
285        context->gcvote_request =
286          gcvote_request(appdata, gcvote_callback, cache->url, context);
287    
288        context->votebox = gtk_vbox_new(FALSE, 0);
289        pack_vcentered(colbox, context->votebox);
290    
291        /* fill with vote if present on disk (will also free vote) */
292        if(vote)
293          gcvote_set(context, vote);
294      }
295    
296      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);
# Line 206  static GtkWidget *cache_overview(cache_c Line 309  static GtkWidget *cache_overview(cache_c
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    context->bearing_hbox = gtk_hbox_new(FALSE, 0);    if(!isnan(cache->pos.lat) && !isnan(cache->pos.lon)) {
321    bearing_fill_hbox(context->bearing_hbox, appdata, *refpos,      context->bearing_hbox = gtk_hbox_new(FALSE, 0);
322                      gpx_cache_pos(cache));      bearing_fill_hbox(context->bearing_hbox, appdata, *refpos,
323    gtk_box_pack_start_defaults(GTK_BOX(ivbox), context->bearing_hbox);                        gpx_cache_pos(cache));
324        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    
336    if(cache->short_description)    if(cache->short_description)
337      gtk_box_pack_start_defaults(GTK_BOX(vbox),      gtk_box_pack_start_defaults(GTK_BOX(vbox),
338          html_view(appdata, cache->short_description,          html_view(appdata, cache->short_description,
339                    cache->short_is_html, TRUE, cache, NULL));            cache->short_is_html?HTML_HTML:HTML_PLAIN_TEXT, TRUE, cache, NULL));
340    
341    return vbox;    return vbox;
342  }  }
343    
344  /* slow but short, we don't need performance here ... */  /* slow but short, we don't need performance here ... */
345  static void rot13(char *t) {  static void rot13(char *t) {
346      int braces = 0;
347    
348    while(*t) {    while(*t) {
349      if(((*t >= 'a') && (*t < 'n')) ||      if(!braces) {
350         ((*t >= 'A') && (*t < 'N'))) *t += 13;        if(*t == '[')
351      else if(((*t >= 'n') && (*t <= 'z')) ||          braces++;
352              ((*t >= 'N') && (*t <= 'Z'))) *t -= 13;        else if(((*t >= 'a') && (*t < 'n')) ||
353                  ((*t >= 'A') && (*t < 'N'))) *t += 13;
354          else if(((*t >= 'n') && (*t <= 'z')) ||
355                  ((*t >= 'N') && (*t <= 'Z'))) *t -= 13;
356        } else {
357          if(braces > 0 && *t == ']')
358            braces--;
359        }
360    
361      t++;      t++;
362    }    }
# Line 264  static void on_decrypt(GtkWidget *widget Line 382  static void on_decrypt(GtkWidget *widget
382  static GtkWidget *cache_hint(appdata_t *appdata, cache_t *cache) {  static GtkWidget *cache_hint(appdata_t *appdata, cache_t *cache) {
383    /* encrypting/decrypting html is nothing we want to do */    /* encrypting/decrypting html is nothing we want to do */
384    if(cache->hint_is_html)    if(cache->hint_is_html)
385      return html_view(appdata, cache->hint, TRUE, TRUE, NULL, NULL);      return html_view(appdata, cache->hint, HTML_HTML, TRUE, NULL, NULL);
386    
387    /* we can now be sure that we are talking about pain text */    /* we can now be sure that we are talking about pain text */
388    GtkWidget *vbox = gtk_vbox_new(FALSE, 0);    GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
389    
390    char *hint = strdup(cache->hint);    char *hint = strdup(cache->hint);
391    rot13(hint);    rot13(hint);
392    GtkWidget *view = html_view(appdata, hint, FALSE, TRUE, NULL, NULL);    GtkWidget *view =
393        html_view(appdata, hint, HTML_PLAIN_TEXT, TRUE, NULL, NULL);
394    gtk_box_pack_start_defaults(GTK_BOX(vbox), view);    gtk_box_pack_start_defaults(GTK_BOX(vbox), view);
395    free(hint);    free(hint);
396    
397    GtkWidget *button = gtk_button_new_with_label(_("Encrypt/Decrypt"));    GtkWidget *button = gtk_button_new_with_label(_("Encrypt/Decrypt"));
398    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
399      hildon_gtk_widget_set_theme_size(button,
400               (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
401    #endif
402    gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
403    gtk_signal_connect(GTK_OBJECT(button), "clicked",    gtk_signal_connect(GTK_OBJECT(button), "clicked",
404             GTK_SIGNAL_FUNC(on_decrypt), gtk_bin_get_child(GTK_BIN(view)));             GTK_SIGNAL_FUNC(on_decrypt), gtk_bin_get_child(GTK_BIN(view)));
# Line 329  static GtkWidget *cache_wpts(appdata_t * Line 451  static GtkWidget *cache_wpts(appdata_t *
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),        gtk_box_pack_start_defaults(GTK_BOX(ihbox),
459            GTK_LABEL_SMALL((char*)pos_get_bearing_str(*refpos, wpt->pos)));            GTK_LABEL_SMALL((char*)pos_get_bearing_str(*refpos, wpt->pos)));
460      snprintf(str, sizeof(str), _("%.1f°"),        snprintf(str, sizeof(str), _("%.1f°"),
461             gpx_pos_get_bearing(*refpos, wpt->pos));                 gpx_pos_get_bearing(*refpos, wpt->pos));
462      gtk_box_pack_start_defaults(GTK_BOX(ihbox), GTK_LABEL_SMALL(str));        gtk_box_pack_start_defaults(GTK_BOX(ihbox), GTK_LABEL_SMALL(str));
     gpx_pos_get_distance_str(str, sizeof(str),  
                              *refpos, wpt->pos, appdata->imperial);  
     gtk_box_pack_start(GTK_BOX(ihbox), GTK_LABEL_SMALL(str),1,0,0);  
   
     gtk_table_attach_defaults(GTK_TABLE(table), ihbox, 3,4,  
                               wpt_row+0, wpt_row+1);  
   
     /* ------------------ description ------------------------- */  
     if(wpt->desc) {  
       GtkTextBuffer *buffer = gtk_text_buffer_new(NULL);  
       gtk_text_buffer_set_text(buffer, wpt->desc, strlen(wpt->desc));  
   
 #ifndef USE_MAEMO  
       GtkWidget *textview = gtk_text_view_new_with_buffer(buffer);  
 #else  
       GtkWidget *textview = hildon_text_view_new();  
       hildon_text_view_set_buffer(HILDON_TEXT_VIEW(textview), buffer);  
 #endif  
463    
464        gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_WORD);        gpx_pos_get_distance_str(str, sizeof(str),
465        gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);                                 *refpos, wpt->pos, appdata->imperial);
466        gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textview), FALSE);        gtk_box_pack_start(GTK_BOX(ihbox), GTK_LABEL_SMALL(str),1,0,0);
467    
468          gtk_table_attach_defaults(GTK_TABLE(table), ihbox, 3,4,
469                                    wpt_row+0, wpt_row+1);
470        }
471    
472        gtk_table_attach_defaults(GTK_TABLE(table), textview, 0,4,      /* ------------------ description ------------------------- */
473        if(wpt->desc)
474          gtk_table_attach_defaults(GTK_TABLE(table),
475                                    simple_text_widget(wpt->desc), 0,4,
476                                  wpt_row+1, wpt_row+2);                                  wpt_row+1, wpt_row+2);
     }  
477    
478      /* ------------------ comment ------------------------- */      /* ------------------ comment ------------------------- */
479      if(wpt->cmt) {      if(wpt->cmt)
480        GtkTextBuffer *buffer = gtk_text_buffer_new(NULL);        gtk_table_attach_defaults(GTK_TABLE(table),
481        gtk_text_buffer_set_text(buffer, wpt->cmt, strlen(wpt->cmt));                                  simple_text_widget(wpt->cmt), 0,4,
 #ifndef USE_MAEMO  
       GtkWidget *textview = gtk_text_view_new_with_buffer(buffer);  
 #else  
       GtkWidget *textview = hildon_text_view_new();  
       hildon_text_view_set_buffer(HILDON_TEXT_VIEW(textview), buffer);  
 #endif  
       gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_WORD);  
       gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);  
       gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textview), FALSE);  
   
       gtk_table_attach_defaults(GTK_TABLE(table), textview, 0,4,  
482                                  wpt_row+2, wpt_row+3);                                  wpt_row+2, wpt_row+3);
     }  
483    
484      /* --------------------- seperator -------------------------*/      /* --------------------- seperator -------------------------*/
485      if(wpt->next)      if(wpt->next) {
486          gtk_table_set_row_spacing(GTK_TABLE(table), wpt_row+2, 8);
487        gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(), 0,4,        gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(), 0,4,
488                                  wpt_row+3, wpt_row+4);                                  wpt_row+3, wpt_row+4);
489          gtk_table_set_row_spacing(GTK_TABLE(table), wpt_row+3, 8);
490        }
491    
492      wpt_row+=4;      wpt_row+=4;
493      wpt = wpt->next;      wpt = wpt->next;
# Line 425  static GtkWidget *cache_tbs(appdata_t *a Line 526  static GtkWidget *cache_tbs(appdata_t *a
526    
527    int tb_row=0;    int tb_row=0;
528    while(tb) {    while(tb) {
529        static const char *tb_type = "track/details.aspx";
530    
531      /* --------------------- icon/ref/name -------------------------*/      /* --------------------- icon/ref/name -------------------------*/
532      gtk_table_attach_defaults(GTK_TABLE(table), icon_get_widget(ICON_TB, 0),      GtkWidget *icon = NULL;
533        if((strcasestr(tb->name, "coin") != 0) ||
534           (strcasestr(tb->name, "muenze") != 0) ||
535           (strcasestr(tb->name, "münze") != 0))
536          icon = icon_get_widget(ICON_TB, 1);   /* coin icon */
537        else
538          icon = icon_get_widget(ICON_TB, 0);   /* tb icon */
539    
540        gtk_table_attach_defaults(GTK_TABLE(table), icon,
541                                0, 1, tb_row+0, tb_row+1);                                0, 1, tb_row+0, tb_row+1);
542      if(tb->ref)  
543        gtk_table_attach_defaults(GTK_TABLE(table), GTK_LABEL_BIG(tb->ref),      if(tb->ref) {
544          GtkWidget *ref = link_button_by_id(appdata, tb->ref, tb_type, tb->id);
545          gtk_table_attach_defaults(GTK_TABLE(table), ref,
546                                  1, 2, tb_row+0, tb_row+1);                                  1, 2, tb_row+0, tb_row+1);
547        }
548    
549      if(tb->name)      if(tb->name)
550        gtk_table_attach_defaults(GTK_TABLE(table), GTK_LABEL_BIG(tb->name),        gtk_table_attach_defaults(GTK_TABLE(table), GTK_LABEL_BIG(tb->name),
551                                  2, 3, tb_row+0, tb_row+1);                                  2, 3, tb_row+0, tb_row+1);
# Line 456  static GtkWidget *cache_tbs(appdata_t *a Line 571  static GtkWidget *cache_tbs(appdata_t *a
571  #endif  #endif
572  }  }
573    
574  static GtkWidget *cache_logs(appdata_t *appdata, log_t *log, int is_html) {  #ifdef ENABLE_BROWSER_INTERFACE
575    static void on_gclink_clicked(GtkButton *button, gpointer data) {
576      cache_context_t *context = (cache_context_t*)data;
577      char *url = g_strdup_printf("http://www.geocaching.com/seek/log.aspx?wp=%s", context->cache->id);
578      browser_url(context->appdata, url);
579      g_free(url);
580    }
581    #endif
582    
583    static GtkWidget *cache_logs(appdata_t *appdata, cache_context_t *context,
584                                 log_t *log, int is_html) {
585  #ifndef  USE_PANNABLE_AREA  #ifndef  USE_PANNABLE_AREA
586    /* put this inside a scrolled view */    /* put this inside a scrolled view */
587    GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);    GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);
# Line 466  static GtkWidget *cache_logs(appdata_t * Line 591  static GtkWidget *cache_logs(appdata_t *
591    GtkWidget *pannable_area = hildon_pannable_area_new();    GtkWidget *pannable_area = hildon_pannable_area_new();
592  #endif  #endif
593    
594    GtkWidget *table = gtk_table_new(4*gpx_number_of_logs(log), 3, FALSE);  #ifdef ENABLE_BROWSER_INTERFACE
595    int cnt = 0;    gboolean gc_link = strncmp(context->cache->id, "GC", 2) == 0;
596    #else
597    #define gc_link (FALSE)
598    #endif
599    
600      GtkWidget *vbox = gtk_vbox_new(FALSE, 6);
601    
602    #ifdef ENABLE_BROWSER_INTERFACE
603      if(gc_link) {
604        GtkWidget *but =
605          gtk_button_new_with_label(_("Post a new log entry for this geocache"));
606    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
607      hildon_gtk_widget_set_theme_size(but,
608               (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
609    #endif
610        gtk_signal_connect(GTK_OBJECT(but), "clicked",
611                           GTK_SIGNAL_FUNC(on_gclink_clicked), context);
612    
613        gtk_box_pack_start(GTK_BOX(vbox), but, FALSE, FALSE, 0);
614      }
615    #endif
616    
617      int logs = gpx_number_of_logs(log);
618      GtkWidget *table = gtk_table_new(2*logs-1, 2,FALSE);
619      int log_cnt = 0;
620    
621      gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8);
622    
623    /* add all logs to the vbox */    /* add all logs to the vbox */
624    while(log) {    while(log) {
625      gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(),      GtkWidget *ivbox = gtk_vbox_new(FALSE, 2);
626                                0, 3, cnt+0, cnt+1);      GtkWidget *ihbox = gtk_hbox_new(FALSE, 2);
627      gtk_table_attach_defaults(GTK_TABLE(table),  
628                                icon_get_widget(ICON_LOG, log->type),      static const char *finder_type = "profile/";
629                                0, 1, cnt+1, cnt+2);      GtkWidget *finder = link_button_by_id(appdata, log->finder->name,
630                                              finder_type, log->finder->id);
631    
632        /* if the finder is a button make sure it's the right size and */
633        /* does not exceed the size limits */
634        if(GTK_WIDGET_TYPE(finder) == GTK_TYPE_BUTTON) {
635    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
636          hildon_gtk_widget_set_theme_size(finder,
637                       (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
638    #endif
639    
640          gtk_label_set_ellipsize(GTK_LABEL(gtk_bin_get_child(GTK_BIN(finder))),
641                                  PANGO_ELLIPSIZE_END);
642        } else
643          gtk_label_set_ellipsize(GTK_LABEL(finder), PANGO_ELLIPSIZE_END);
644    
645        gtk_box_pack_start(GTK_BOX(ivbox), finder, FALSE, FALSE, 0);
646    
647        gtk_box_pack_start_defaults(GTK_BOX(ihbox),
648                  icon_get_widget(ICON_LOG, log->type));
649    
650      char date_str[32];      char date_str[32];
651      if(log->day && log->month && log->year) {      if(log->day && log->month && log->year) {
# Line 485  static GtkWidget *cache_logs(appdata_t * Line 655  static GtkWidget *cache_logs(appdata_t *
655      } else      } else
656        strcpy(date_str, "---");        strcpy(date_str, "---");
657    
658      gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(date_str),      gtk_box_pack_start_defaults(GTK_BOX(ihbox), gtk_label_new(date_str));
                               1, 2, cnt+1, cnt+2);  
659    
660      gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(log->finder),      gtk_box_pack_start(GTK_BOX(ivbox), ihbox, FALSE, FALSE, 0);
661                                2, 3, cnt+1, cnt+2);  
662      gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(),      gtk_table_attach(GTK_TABLE(table), ivbox, 0, 1,
663                                0, 3, cnt+2, cnt+3);                       2*log_cnt, 2*log_cnt+1, 0, GTK_EXPAND | GTK_FILL, 0, 0);
664    
665      if(log->text) {      if(log->text) {
666        gtk_table_attach_defaults(GTK_TABLE(table),        gtk_table_attach_defaults(GTK_TABLE(table),
667                  html_view(appdata, log->text, is_html, FALSE, NULL, NULL),          html_view(appdata, log->text,
668                  0, 3, cnt+3, cnt+4);                    is_html?HTML_HTML:HTML_CUSTOM_MARKUP, FALSE, NULL, NULL),
669                                    1, 2, 2*log_cnt, 2*log_cnt+1);
670        }
671    
672        if(log_cnt < logs-1) {
673          gtk_table_set_row_spacing(GTK_TABLE(table), 2*log_cnt, 8);
674    
675          gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(),
676                                    0, 2, 2*log_cnt+1, 2*log_cnt+2);
677    
678          gtk_table_set_row_spacing(GTK_TABLE(table), 2*log_cnt+1, 8);
679      }      }
680    
681      log = log->next;      log = log->next;
682      cnt+=4;      log_cnt++;
683    }    }
684    
685      gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
686    
687  #ifndef  USE_PANNABLE_AREA  #ifndef  USE_PANNABLE_AREA
688    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
689                                          table);                                          vbox);
690    return scrolled_window;    return scrolled_window;
691  #else  #else
692    hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(pannable_area),    hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(pannable_area),
693                                           table);                                           vbox);
694    return pannable_area;    return pannable_area;
695  #endif  #endif
696  }  }
# Line 543  static void on_notebook_page_change(GtkN Line 724  static void on_notebook_page_change(GtkN
724    
725    /* this is a workaround, around some bug in the gtktextwidget or so ... */    /* this is a workaround, around some bug in the gtktextwidget or so ... */
726    /* i tried to get info on this and everybody agreed that this is a bug */    /* i tried to get info on this and everybody agreed that this is a bug */
727    /* in gtk but noone had a read fix. so i came up with this. */    /* in gtk but noone had a fix ready. so i came up with this. */
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);
731    }    } else if(strcasecmp(name, _("TBs")) == 0) {
732        gtk_widget_queue_resize(w);
733    if(strcasecmp(name, _("Goto")) == 0) {    } else if(strcasecmp(name, _("Goto")) == 0) {
734  #ifdef USE_MAEMO  #ifdef USE_MAEMO
735      context->handler_id = gtk_timeout_add(1000, screensaver_update,      context->handler_id = gtk_timeout_add(1000, screensaver_update,
736                                            context->appdata);                                            context->appdata);
# Line 569  static void on_notebook_destroy(GtkWidge Line 750  static void on_notebook_destroy(GtkWidge
750    
751    printf("destroying notebook\n");    printf("destroying notebook\n");
752    
753      /* cancel a pending gcvote request */
754      if(context->gcvote_request) {
755        gcvote_request_free(context->gcvote_request);
756        context->gcvote_request = NULL;
757      }
758    
759    notes_destroy_event(NULL, context);    notes_destroy_event(NULL, context);
760    goto_destroy_event(NULL, context);    goto_destroy_event(NULL, context);
761    
# Line 580  static void on_notebook_destroy(GtkWidge Line 767  static void on_notebook_destroy(GtkWidge
767    free(user_data);    free(user_data);
768  }  }
769    
770    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
771    #define CUSTOM_NOTEBOOK
772    #endif
773    
774    static GtkWidget *notebook_new(void) {
775    #ifdef CUSTOM_NOTEBOOK
776      GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
777    
778      GtkWidget *notebook =  gtk_notebook_new();
779    
780      /* prevents user from accidentially touching the breadcrumb trail */
781      /* (looks ugly on fremantle as it isn't themed) */
782      //  gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM);
783    
784      /* solution for fremantle: we use a row of ordinary buttons instead */
785      /* of regular tabs */
786    
787      /* hide the regular tabs */
788      gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
789    
790      gtk_box_pack_start_defaults(GTK_BOX(vbox), notebook);
791    
792      /* store a reference to the notebook in the vbox */
793      g_object_set_data(G_OBJECT(vbox), "notebook", (gpointer)notebook);
794    
795      /* create a hbox for the buttons */
796      GtkWidget *hbox = gtk_hbox_new(TRUE, 0);
797      gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
798      g_object_set_data(G_OBJECT(vbox), "hbox", (gpointer)hbox);
799    
800      return vbox;
801    #else
802      return gtk_notebook_new();
803    #endif
804    }
805    
806    #ifdef CUSTOM_NOTEBOOK
807    static void on_notebook_button_clicked(GtkWidget *button, gpointer data) {
808      GtkNotebook *nb =
809        GTK_NOTEBOOK(g_object_get_data(G_OBJECT(data), "notebook"));
810    
811      gint page = (gint)g_object_get_data(G_OBJECT(button), "page");
812      gtk_notebook_set_current_page(nb, page);
813    }
814    #endif
815    
816    static void notebook_append_page(GtkWidget *notebook,
817                                     GtkWidget *page, char *label) {
818    #ifdef CUSTOM_NOTEBOOK
819      GtkNotebook *nb =
820        GTK_NOTEBOOK(g_object_get_data(G_OBJECT(notebook), "notebook"));
821    
822      gint page_num = gtk_notebook_append_page(nb, page, gtk_label_new(label));
823      GtkWidget *button = NULL;
824    
825      /* select button for page 0 by default */
826      if(!page_num) {
827        button = gtk_radio_button_new_with_label(NULL, label);
828        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
829        g_object_set_data(G_OBJECT(notebook), "group_master", (gpointer)button);
830      } else {
831        GtkWidget *master = g_object_get_data(G_OBJECT(notebook), "group_master");
832        button = gtk_radio_button_new_with_label_from_widget(
833                                     GTK_RADIO_BUTTON(master), label);
834      }
835    
836      gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE);
837      g_object_set_data(G_OBJECT(button), "page", (gpointer)page_num);
838    
839      gtk_signal_connect(GTK_OBJECT(button), "clicked",
840               GTK_SIGNAL_FUNC(on_notebook_button_clicked), notebook);
841    
842    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
843      hildon_gtk_widget_set_theme_size(button,
844               (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
845    #endif
846    
847      gtk_box_pack_start_defaults(
848         GTK_BOX(g_object_get_data(G_OBJECT(notebook), "hbox")),
849         button);
850    
851    #else
852      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, gtk_label_new(label));
853    #endif
854    }
855    
856    static GObject *notebook_object(GtkWidget *notebook) {
857    #ifdef CUSTOM_NOTEBOOK
858      return G_OBJECT(g_object_get_data(G_OBJECT(notebook), "notebook"));
859    #else
860      return G_OBJECT(notebook);
861    #endif
862    }
863    
864  GtkWidget *cache_view(appdata_t *appdata, cache_t *cache) {  GtkWidget *cache_view(appdata_t *appdata, cache_t *cache) {
865    GtkWidget *notebook;    GtkWidget *notebook;
866    
# Line 596  GtkWidget *cache_view(appdata_t *appdata Line 877  GtkWidget *cache_view(appdata_t *appdata
877  #define TAB_WPTS   _("Waypoints")  #define TAB_WPTS   _("Waypoints")
878  #endif  #endif
879    
880    notebook =  gtk_notebook_new();    notebook = notebook_new();
 #ifdef USE_MAEMO  
 #if MAEMO_VERSION_MAJOR >= 5  
   /* prevents user from accidentially touching the breadcrumb trail */  
   gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM);  
 #endif  
 #endif  
881    
882    gtk_notebook_append_page(GTK_NOTEBOOK(notebook),    notebook_append_page(notebook,
883         cache_overview(cache_context), gtk_label_new(_("Main")));         cache_overview(cache_context), _("Main"));
884    
885    if(cache->long_description)    if(cache->long_description)
886      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
887             cache_description(appdata, cache), gtk_label_new(TAB_DESC));             cache_description(appdata, cache), TAB_DESC);
888    
889    if(cache->hint)    if(cache->hint)
890      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
891             cache_hint(appdata, cache), gtk_label_new(_("Hint")));             cache_hint(appdata, cache), _("Hint"));
892    
893    if(cache->log)    if(cache->log)
894      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
895             cache_logs(appdata, cache->log, cache->logs_are_html),       cache_logs(appdata, cache_context, cache->log, cache->logs_are_html),
896             gtk_label_new(_("Logs")));             _("Logs"));
897    
898    if(cache->wpt)    if(cache->wpt)
899      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
900               cache_wpts(appdata, cache->wpt), gtk_label_new(TAB_WPTS));               cache_wpts(appdata, cache->wpt), TAB_WPTS);
901    
902    if(cache->tb)    if(cache->tb)
903      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
904               cache_tbs(appdata, cache->tb), gtk_label_new(_("TBs")));               cache_tbs(appdata, cache->tb), _("TBs"));
905    
906    gtk_notebook_append_page(GTK_NOTEBOOK(notebook),    notebook_append_page(notebook,
907             cache_notes(cache_context), gtk_label_new(_("Notes")));             cache_notes(cache_context), _("Notes"));
908    
909    gtk_notebook_append_page(GTK_NOTEBOOK(notebook),    notebook_append_page(notebook,
910             goto_cache(cache_context), gtk_label_new(_("Goto")));             goto_cache(cache_context), _("Goto"));
911    
912    g_signal_connect(G_OBJECT(notebook), "switch-page",    g_signal_connect(notebook_object(notebook), "switch-page",
913             G_CALLBACK(on_notebook_page_change), cache_context);             G_CALLBACK(on_notebook_page_change), cache_context);
914    
915    g_signal_connect(G_OBJECT(notebook), "destroy",    g_signal_connect(notebook_object(notebook), "destroy",
916             G_CALLBACK(on_notebook_destroy), cache_context);             G_CALLBACK(on_notebook_destroy), cache_context);
917    
918    return notebook;    return notebook;
# Line 665  void cache_dialog(appdata_t *appdata, ca Line 940  void cache_dialog(appdata_t *appdata, ca
940    
941  #else  #else
942  #ifdef USE_STACKABLE_WINDOW  #ifdef USE_STACKABLE_WINDOW
943    static void on_cache_destroy (GtkWidget *widget, appdata_t *appdata) {
944      appdata->cur_cache = NULL;
945    
946      /* restore cur_view */
947      appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");
948    }
949    
950  void cache_dialog(appdata_t *appdata, cache_t *cache) {  void cache_dialog(appdata_t *appdata, cache_t *cache) {
951    GtkWidget *window = hildon_stackable_window_new();    GtkWidget *window = hildon_stackable_window_new();
952    
953    gtk_window_set_title(GTK_WINDOW(window), cache->name);    /* store last "cur_view" in window */
954      g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view);
955    
956      appdata->cur_cache = cache;
957      char *title = g_strdup_printf("%s - GPXView", cache->name);
958      gtk_window_set_title(GTK_WINDOW(window), title);
959      g_free(title);
960    
961    /* create cache visualization widget */    /* create cache visualization widget */
962    gtk_container_add(GTK_CONTAINER(window),    appdata->cur_view = cache_view(appdata, cache);
963                      cache_view(appdata, cache));    gtk_container_add(GTK_CONTAINER(window), appdata->cur_view);
964    
965      hildon_window_set_app_menu(HILDON_WINDOW(window),
966                                 menu_create(appdata, MENU_CACHE));
967    
968      g_signal_connect(G_OBJECT(window), "destroy",
969                       G_CALLBACK(on_cache_destroy), appdata);
970    
971    gtk_widget_show_all(window);    gtk_widget_show_all(window);
972  }  }

Legend:
Removed from v.1  
changed lines
  Added in v.187