Diff of /trunk/src/cache.c

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

revision 13 by harbaum, Sat Jun 27 11:09:19 2009 UTC revision 293 by harbaum, Tue Aug 17 19:00:06 2010 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)) {
       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  #ifdef ENABLE_BROWSER_INTERFACE  static void gcvote_set(cache_context_t *context, vote_t *vote) {
102  static void on_www_clicked(GtkButton *button, gpointer data) {    if(!vote) return;
103    
104      if(context->quality) {
105        gtk_widget_destroy(context->quality);
106        context->quality = NULL;
107      }
108    
109      if(context->votes) {
110        gtk_widget_destroy(context->votes);
111        context->votes = NULL;
112      }
113    
114      /* update/draw the voting */
115    #ifndef USE_MAEMO
116      GtkTooltips *tips = gtk_tooltips_new();
117    #endif
118    
119      char *votes_str = g_strdup_printf(_("Quality (%d %s):"), vote->votes,
120                                        (vote->votes == 1)?_("vote"):_("votes"));
121      context->votes = GTK_LABEL_SMALL(votes_str);
122      gtk_box_pack_start(GTK_BOX(context->votebox),
123                         context->votes, FALSE, FALSE, 0);
124      g_free(votes_str);
125      context->quality = icon_get_widget(ICON_STARS, (int)(vote->quality*2-2));
126      gtk_box_pack_start(GTK_BOX(context->votebox), context->quality,
127                         FALSE, FALSE, 0);
128    
129    #ifndef USE_MAEMO
130      char *str = g_strdup_printf(_("Quality: %d"), vote->quality);
131      gtk_tooltips_set_tip(tips, context->votebox, str, NULL);
132      g_free(str);
133    #endif
134    
135      gtk_widget_show_all(context->votebox);
136    
137      g_free(vote);
138    }
139    
140    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    browser_url(context->appdata, context->cache->url);  
143      /* no vote returned: request failed, just cleanup */
144      if(!vote) {
145        printf("gcvote: callback for failed request\n");
146    
147        gcvote_request_free(context->gcvote_request);
148        context->gcvote_request = NULL;
149        return;
150      }
151    
152      printf("gcvote: callback is being called with a %d/%d\n",
153             vote->quality, vote->votes);
154    
155      gcvote_set(context, vote);
156    
157      gcvote_save(context->appdata, context->cache, &context->gcvote_request->mem);
158    
159      gcvote_request_free(context->gcvote_request);
160      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  #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_defaults(GTK_TABLE(table),      gtk_box_pack_start_defaults(GTK_BOX(colbox),
197        tip = icon_get_widget(ICON_CACHE_TYPE, cache->type), 0,1,0,1);          tip = icon_get_widget(ICON_SIZE, cache->type));
198    
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);
207      sprintf(str, _("Size: %s"), _(cache_size_name[cache->container]));      sprintf(str, _("Size: %s"), _(cache_size_name[cache->container]));
208      gtk_box_pack_start_defaults(GTK_BOX(ivbox), GTK_LABEL_SMALL(str));      gtk_box_pack_start(GTK_BOX(ivbox), GTK_LABEL_SMALL(str),
209      gtk_box_pack_start_defaults(GTK_BOX(ivbox),                         FALSE, FALSE, 0);
210          icon_get_widget(ICON_CACHE_SIZE, cache->container));      gtk_box_pack_start(GTK_BOX(ivbox),
211      gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 0,1,1,2);                         icon_get_widget(ICON_CACHE_SIZE, cache->container),
212                           FALSE, FALSE, 0);
213    
214        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:
226        (!cache->available?STRIKETHROUGH:STRIKETHROUGH_NONE);        (!cache->available?STRIKETHROUGH:STRIKETHROUGH_NONE);
227      GtkWidget *lbl = NULL;      GtkWidget *lbl = link_button_attrib(context->appdata,
228                                            cache->id, context->cache->url,
229  #ifdef ENABLE_BROWSER_INTERFACE                                          SIZE_BIG, strike);
230      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);  
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")));
236      gtk_box_pack_start_defaults(GTK_BOX(ivbox), GTK_LABEL_SMALL(_("by")));  
237      gtk_box_pack_start_defaults(GTK_BOX(ivbox), GTK_LABEL_SMALL(cache->owner));      static const char *owner_type = "profile/";
238      gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 1,2,1,2);      pack_vcentered(colbox,
239                    link_button_by_id(appdata, cache->owner->name,
240                                      owner_type, cache->owner->id));
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 ---------- */
250      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) {
254      ivbox = gtk_vbox_new(FALSE, 0);      ivbox = gtk_vbox_new(FALSE, 0);
255      gtk_box_pack_start_defaults(GTK_BOX(ivbox),      gtk_box_pack_start(GTK_BOX(ivbox),
256                                  GTK_LABEL_SMALL(_("Difficulty:")));                         GTK_LABEL_SMALL(_("Difficulty:")),
257      gtk_box_pack_start_defaults(GTK_BOX(ivbox),                         FALSE, FALSE, 0);
258         icon_get_widget(ICON_STARS, (int)(cache->difficulty*2-2)));      gtk_box_pack_start(GTK_BOX(ivbox),
259      gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 2,3,0,1);                    icon_get_widget(ICON_STARS, (int)(cache->difficulty*2-2)),
260                           FALSE, FALSE, 0);
261    
262        pack_vcentered(colbox, ivbox);
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);
# Line 190  static GtkWidget *cache_overview(cache_c Line 269  static GtkWidget *cache_overview(cache_c
269    /* ------------ box containing terrain rating ------------ */    /* ------------ box containing terrain rating ------------ */
270    if(cache->terrain != 0) {    if(cache->terrain != 0) {
271      ivbox = gtk_vbox_new(FALSE, 0);      ivbox = gtk_vbox_new(FALSE, 0);
272      gtk_box_pack_start_defaults(GTK_BOX(ivbox), GTK_LABEL_SMALL(_("Terrain:")));      gtk_box_pack_start(GTK_BOX(ivbox), GTK_LABEL_SMALL(_("Terrain:")),
273      gtk_box_pack_start_defaults(GTK_BOX(ivbox),                         FALSE, FALSE, 0);
274        icon_get_widget(ICON_STARS, (int)(cache->terrain*2-2)));      gtk_box_pack_start(GTK_BOX(ivbox),
275      gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 2,3,1,2);                         icon_get_widget(ICON_STARS, (int)(cache->terrain*2-2)),
276                           FALSE, FALSE, 0);
277        pack_vcentered(colbox, ivbox);
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);
281  #endif  #endif
282    }    }
283    
284      /* --------------------- GCVote ------------------------ */
285      if(!appdata->disable_gcvote) {
286        vote_t *vote = gcvote_restore(appdata, cache);
287    
288        context->gcvote_request =
289          gcvote_request(appdata, gcvote_callback, cache->url, context);
290    
291        context->votebox = gtk_vbox_new(FALSE, 0);
292        pack_vcentered(colbox, context->votebox);
293    
294        /* fill with vote if present on disk (will also free vote) */
295        if(vote)
296          gcvote_set(context, vote);
297      }
298    
299      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);
# Line 209  static GtkWidget *cache_overview(cache_c Line 312  static GtkWidget *cache_overview(cache_c
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    
365    if(cache->short_description)    if(cache->short_description)
366      gtk_box_pack_start_defaults(GTK_BOX(vbox),      gtk_box_pack_start_defaults(GTK_BOX(vbox),
367          html_view(appdata, cache->short_description,          html_view(appdata, cache->short_description,
368                    cache->short_is_html, TRUE, cache, NULL));            cache->short_is_html?HTML_HTML:HTML_PLAIN_TEXT, TRUE, cache, NULL));
369    
370    return vbox;    return vbox;
371  }  }
372    
373  /* slow but short, we don't need performance here ... */  /* slow but short, we don't need performance here ... */
374  static void rot13(char *t) {  static void rot13(char *t) {
375      int braces = 0;
376    
377    while(*t) {    while(*t) {
378      if(((*t >= 'a') && (*t < 'n')) ||      if(!braces) {
379         ((*t >= 'A') && (*t < 'N'))) *t += 13;        if(*t == '[')
380      else if(((*t >= 'n') && (*t <= 'z')) ||          braces++;
381              ((*t >= 'N') && (*t <= 'Z'))) *t -= 13;        else if(((*t >= 'a') && (*t < 'n')) ||
382                  ((*t >= 'A') && (*t < 'N'))) *t += 13;
383          else if(((*t >= 'n') && (*t <= 'z')) ||
384                  ((*t >= 'N') && (*t <= 'Z'))) *t -= 13;
385        } else {
386          if(braces > 0 && *t == ']')
387            braces--;
388        }
389    
390      t++;      t++;
391    }    }
# Line 269  static void on_decrypt(GtkWidget *widget Line 411  static void on_decrypt(GtkWidget *widget
411  static GtkWidget *cache_hint(appdata_t *appdata, cache_t *cache) {  static GtkWidget *cache_hint(appdata_t *appdata, cache_t *cache) {
412    /* encrypting/decrypting html is nothing we want to do */    /* encrypting/decrypting html is nothing we want to do */
413    if(cache->hint_is_html)    if(cache->hint_is_html)
414      return html_view(appdata, cache->hint, TRUE, TRUE, NULL, NULL);      return html_view(appdata, cache->hint, HTML_HTML, TRUE, NULL, NULL);
415    
416    /* we can now be sure that we are talking about pain text */    /* we can now be sure that we are talking about pain text */
417    GtkWidget *vbox = gtk_vbox_new(FALSE, 0);    GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
418    
419    char *hint = strdup(cache->hint);    char *hint = strdup(cache->hint);
420    rot13(hint);    rot13(hint);
421    GtkWidget *view = html_view(appdata, hint, FALSE, TRUE, NULL, NULL);    GtkWidget *view =
422        html_view(appdata, hint, HTML_PLAIN_TEXT, TRUE, NULL, NULL);
423    gtk_box_pack_start_defaults(GTK_BOX(vbox), view);    gtk_box_pack_start_defaults(GTK_BOX(vbox), view);
424    free(hint);    free(hint);
425    
426    GtkWidget *button = gtk_button_new_with_label(_("Encrypt/Decrypt"));    GtkWidget *button = gtk_button_new_with_label(_("Encrypt/Decrypt"));
427    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
428      hildon_gtk_widget_set_theme_size(button,
429               (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
430    #endif
431    gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
432    gtk_signal_connect(GTK_OBJECT(button), "clicked",    gtk_signal_connect(GTK_OBJECT(button), "clicked",
433             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 334  static GtkWidget *cache_wpts(appdata_t * Line 480  static GtkWidget *cache_wpts(appdata_t *
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));
            gpx_pos_get_bearing(*refpos, wpt->pos));  
     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_HILDON_TEXT_VIEW  
       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  
490    
491        gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_WORD);        gpx_pos_get_distance_str(str, sizeof(str),
492        gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);                                 *refpos, wpt->pos, appdata->imperial);
493        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);
494    
495          gtk_table_attach_defaults(GTK_TABLE(table), ihbox, 3,4,
496                                    wpt_row+0, wpt_row+1);
497        }
498    
499        gtk_table_attach_defaults(GTK_TABLE(table), textview, 0,4,      /* ------------------ description ------------------------- */
500        if(wpt->desc)
501          gtk_table_attach_defaults(GTK_TABLE(table),
502                                    simple_text_widget(wpt->desc), 0,4,
503                                  wpt_row+1, wpt_row+2);                                  wpt_row+1, wpt_row+2);
     }  
504    
505      /* ------------------ comment ------------------------- */      /* ------------------ comment ------------------------- */
506      if(wpt->cmt) {      if(wpt->cmt)
507        GtkTextBuffer *buffer = gtk_text_buffer_new(NULL);        gtk_table_attach_defaults(GTK_TABLE(table),
508        gtk_text_buffer_set_text(buffer, wpt->cmt, strlen(wpt->cmt));                                  simple_text_widget(wpt->cmt), 0,4,
 #ifndef USE_HILDON_TEXT_VIEW  
       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,  
509                                  wpt_row+2, wpt_row+3);                                  wpt_row+2, wpt_row+3);
     }  
510    
511      /* --------------------- seperator -------------------------*/      /* --------------------- seperator -------------------------*/
512      if(wpt->next)      if(wpt->next) {
513          gtk_table_set_row_spacing(GTK_TABLE(table), wpt_row+2, 8);
514        gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(), 0,4,        gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(), 0,4,
515                                  wpt_row+3, wpt_row+4);                                  wpt_row+3, wpt_row+4);
516          gtk_table_set_row_spacing(GTK_TABLE(table), wpt_row+3, 8);
517        }
518    
519      wpt_row+=4;      wpt_row+=4;
520      wpt = wpt->next;      wpt = wpt->next;
# Line 430  static GtkWidget *cache_tbs(appdata_t *a Line 553  static GtkWidget *cache_tbs(appdata_t *a
553    
554    int tb_row=0;    int tb_row=0;
555    while(tb) {    while(tb) {
556        static const char *tb_type = "track/details.aspx";
557    
558      /* --------------------- icon/ref/name -------------------------*/      /* --------------------- icon/ref/name -------------------------*/
559      gtk_table_attach_defaults(GTK_TABLE(table), icon_get_widget(ICON_TB, 0),      GtkWidget *icon = NULL;
560        if((strcasestr(tb->name, "coin") != 0) ||
561           (strcasestr(tb->name, "muenze") != 0) ||
562           (strcasestr(tb->name, "münze") != 0))
563          icon = icon_get_widget(ICON_TB, 1);   /* coin icon */
564        else
565          icon = icon_get_widget(ICON_TB, 0);   /* tb icon */
566    
567        gtk_table_attach_defaults(GTK_TABLE(table), icon,
568                                0, 1, tb_row+0, tb_row+1);                                0, 1, tb_row+0, tb_row+1);
569      if(tb->ref)  
570        gtk_table_attach_defaults(GTK_TABLE(table), GTK_LABEL_BIG(tb->ref),      if(tb->ref) {
571          GtkWidget *ref = link_button_by_id(appdata, tb->ref, tb_type, tb->id);
572          gtk_table_attach_defaults(GTK_TABLE(table), ref,
573                                  1, 2, tb_row+0, tb_row+1);                                  1, 2, tb_row+0, tb_row+1);
574        }
575    
576      if(tb->name)      if(tb->name)
577        gtk_table_attach_defaults(GTK_TABLE(table), GTK_LABEL_BIG(tb->name),        gtk_table_attach_defaults(GTK_TABLE(table), GTK_LABEL_BIG(tb->name),
578                                  2, 3, tb_row+0, tb_row+1);                                  2, 3, tb_row+0, tb_row+1);
# Line 461  static GtkWidget *cache_tbs(appdata_t *a Line 598  static GtkWidget *cache_tbs(appdata_t *a
598  #endif  #endif
599  }  }
600    
601  static GtkWidget *cache_logs(appdata_t *appdata, log_t *log, int is_html) {  #ifdef ENABLE_BROWSER_INTERFACE
602    static void on_gclink_clicked(GtkButton *button, gpointer data) {
603      cache_context_t *context = (cache_context_t*)data;
604      char *url = g_strdup_printf("http://www.geocaching.com/seek/log.aspx?wp=%s", context->cache->id);
605      browser_url(context->appdata, url);
606      g_free(url);
607    }
608    #endif
609    
610    static GtkWidget *cache_logs(appdata_t *appdata, cache_context_t *context,
611                                 log_t *log, int is_html) {
612  #ifndef  USE_PANNABLE_AREA  #ifndef  USE_PANNABLE_AREA
613    /* put this inside a scrolled view */    /* put this inside a scrolled view */
614    GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);    GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);
# Line 471  static GtkWidget *cache_logs(appdata_t * Line 618  static GtkWidget *cache_logs(appdata_t *
618    GtkWidget *pannable_area = hildon_pannable_area_new();    GtkWidget *pannable_area = hildon_pannable_area_new();
619  #endif  #endif
620    
621    GtkWidget *table = gtk_table_new(4*gpx_number_of_logs(log), 3, FALSE);  #ifdef ENABLE_BROWSER_INTERFACE
622    int cnt = 0;    gboolean gc_link = strncmp(context->cache->id, "GC", 2) == 0;
623    #else
624    #define gc_link (FALSE)
625    #endif
626    
627      GtkWidget *vbox = gtk_vbox_new(FALSE, 6);
628    
629    #ifdef ENABLE_BROWSER_INTERFACE
630      if(gc_link) {
631        GtkWidget *but =
632          gtk_button_new_with_label(_("Post a new log entry for this geocache"));
633    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
634      hildon_gtk_widget_set_theme_size(but,
635               (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
636    #endif
637        gtk_signal_connect(GTK_OBJECT(but), "clicked",
638                           GTK_SIGNAL_FUNC(on_gclink_clicked), context);
639    
640        gtk_box_pack_start(GTK_BOX(vbox), but, FALSE, FALSE, 0);
641      }
642    #endif
643    
644      int logs = gpx_number_of_logs(log);
645      GtkWidget *table = gtk_table_new(2*logs-1, 2,FALSE);
646      int log_cnt = 0;
647    
648      gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8);
649    
650    /* add all logs to the vbox */    /* add all logs to the vbox */
651    while(log) {    while(log) {
652      gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(),      GtkWidget *ivbox = gtk_vbox_new(FALSE, 2);
653                                0, 3, cnt+0, cnt+1);      GtkWidget *ihbox = gtk_hbox_new(FALSE, 2);
654      gtk_table_attach_defaults(GTK_TABLE(table),  
655                                icon_get_widget(ICON_LOG, log->type),      static const char *finder_type = "profile/";
656                                0, 1, cnt+1, cnt+2);      GtkWidget *finder = link_button_by_id(appdata, log->finder->name,
657                                              finder_type, log->finder->id);
658    
659        /* if the finder is a button make sure it's the right size and */
660        /* does not exceed the size limits */
661        if(GTK_WIDGET_TYPE(finder) == GTK_TYPE_BUTTON) {
662    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
663          hildon_gtk_widget_set_theme_size(finder,
664                       (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
665    #endif
666    
667        gtk_label_set_ellipsize(GTK_LABEL(gtk_bin_get_child(GTK_BIN(finder))),
668                                  PANGO_ELLIPSIZE_END);
669        } else
670          gtk_label_set_ellipsize(GTK_LABEL(finder), PANGO_ELLIPSIZE_END);
671    
672        gtk_box_pack_start(GTK_BOX(ivbox), finder, FALSE, FALSE, 0);
673    
674        gtk_box_pack_start_defaults(GTK_BOX(ihbox),
675                  icon_get_widget(ICON_LOG, log->type));
676    
677      char date_str[32];      char date_str[32];
678      if(log->day && log->month && log->year) {      if(log->day && log->month && log->year) {
# Line 490  static GtkWidget *cache_logs(appdata_t * Line 682  static GtkWidget *cache_logs(appdata_t *
682      } else      } else
683        strcpy(date_str, "---");        strcpy(date_str, "---");
684    
685      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);  
686    
687      gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(log->finder),      gtk_box_pack_start(GTK_BOX(ivbox), ihbox, FALSE, FALSE, 0);
688                                2, 3, cnt+1, cnt+2);  
689      gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(),      gtk_table_attach(GTK_TABLE(table), ivbox, 0, 1,
690                                0, 3, cnt+2, cnt+3);                       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, is_html, FALSE, NULL, NULL),          html_view(appdata, log->text,
695                  0, 3, cnt+3, cnt+4);                    is_html?HTML_HTML:HTML_CUSTOM_MARKUP, FALSE, NULL, NULL),
696                                    1, 2, 2*log_cnt, 2*log_cnt+1);
697        }
698    
699        if(log_cnt < logs-1) {
700          gtk_table_set_row_spacing(GTK_TABLE(table), 2*log_cnt, 8);
701    
702          gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(),
703                                    0, 2, 2*log_cnt+1, 2*log_cnt+2);
704    
705          gtk_table_set_row_spacing(GTK_TABLE(table), 2*log_cnt+1, 8);
706      }      }
707    
708      log = log->next;      log = log->next;
709      cnt+=4;      log_cnt++;
710    }    }
711    
712      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),
716                                          table);                                          vbox);
717    return scrolled_window;    return scrolled_window;
718  #else  #else
719    hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(pannable_area),    hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(pannable_area),
720                                           table);                                           vbox);
721    return pannable_area;    return pannable_area;
722  #endif  #endif
723  }  }
# Line 548  static void on_notebook_page_change(GtkN Line 751  static void on_notebook_page_change(GtkN
751    
752    /* this is a workaround, around some bug in the gtktextwidget or so ... */    /* this is a workaround, around some bug in the gtktextwidget or so ... */
753    /* 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 */
754    /* 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. */
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);
758    }    } else if(strcasecmp(name, _("Goto")) == 0) {
   
   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    
# Line 574  static void on_notebook_destroy(GtkWidge Line 776  static void on_notebook_destroy(GtkWidge
776    
777    printf("destroying notebook\n");    printf("destroying notebook\n");
778    
779      /* cancel a pending gcvote request */
780      if(context->gcvote_request) {
781        gcvote_request_free(context->gcvote_request);
782        context->gcvote_request = NULL;
783      }
784    
785    notes_destroy_event(NULL, context);    notes_destroy_event(NULL, context);
786    goto_destroy_event(NULL, context);    goto_destroy_event(NULL, context);
787    
# Line 582  static void on_notebook_destroy(GtkWidge Line 790  static void on_notebook_destroy(GtkWidge
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");
796    
797        /* now the cachelist is visible again. so redraw it since it may */
798        /* have changed */
799        cachelist_redraw(context->appdata);
800      }
801    #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) {
809      return G_OBJECT(notebook_get_gtk_notebook(notebook));
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    
# Line 601  GtkWidget *cache_view(appdata_t *appdata Line 825  GtkWidget *cache_view(appdata_t *appdata
825  #define TAB_WPTS   _("Waypoints")  #define TAB_WPTS   _("Waypoints")
826  #endif  #endif
827    
828    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  
829    
830    gtk_notebook_append_page(GTK_NOTEBOOK(notebook),    notebook_append_page(notebook,
831         cache_overview(cache_context), gtk_label_new(_("Main")));         cache_overview(cache_context), _("Main"));
832    
833    if(cache->long_description)    if(cache->long_description)
834      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
835             cache_description(appdata, cache), gtk_label_new(TAB_DESC));             cache_description(appdata, cache), TAB_DESC);
836    
837    if(cache->hint)    if(cache->hint)
838      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
839             cache_hint(appdata, cache), gtk_label_new(_("Hint")));             cache_hint(appdata, cache), _("Hint"));
840    
841    if(cache->log)    // always display log page to allow user to post a new log
842      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),    if(cache->log
843             cache_logs(appdata, cache->log, cache->logs_are_html),  #ifdef ENABLE_BROWSER_INTERFACE
844             gtk_label_new(_("Logs")));       || (strncmp(cache->id, "GC", 2) == 0)
845    #endif
846         )
847        notebook_append_page(notebook,
848         cache_logs(appdata, cache_context, cache->log, cache->logs_are_html),
849               _("Logs"));
850    
851    if(cache->wpt)    if(cache->wpt)
852      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
853               cache_wpts(appdata, cache->wpt), gtk_label_new(TAB_WPTS));               cache_wpts(appdata, cache->wpt), TAB_WPTS);
854    
855    if(cache->tb)    if(cache->tb)
856      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
857               cache_tbs(appdata, cache->tb), gtk_label_new(_("TBs")));               cache_tbs(appdata, cache->tb), _("TBs"));
858    
859    gtk_notebook_append_page(GTK_NOTEBOOK(notebook),    /* the demo caches don't have coordinates, so avoid */
860             cache_notes(cache_context), gtk_label_new(_("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    gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
866             goto_cache(cache_context), gtk_label_new(_("Goto")));                           goto_cache(cache_context), _("Goto"));
867      }
868    
869    g_signal_connect(G_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);
871    
872    g_signal_connect(G_OBJECT(notebook), "destroy",    g_signal_connect(notebook_object(notebook), "destroy",
873             G_CALLBACK(on_notebook_destroy), cache_context);             G_CALLBACK(on_notebook_destroy), cache_context);
874    
875    return notebook;    return notebook;
# Line 673  void cache_dialog(appdata_t *appdata, ca Line 900  void cache_dialog(appdata_t *appdata, ca
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("GPXView - %s", 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);

Legend:
Removed from v.13  
changed lines
  Added in v.293