Diff of /trunk/src/cache.c

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

revision 157 by harbaum, Tue Nov 3 20:20:39 2009 UTC revision 229 by harbaum, Fri Dec 4 19:58:26 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,
# 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(!isnan(refpos.lat) && !isnan(refpos.lon)) {      if(!isnan(refpos.lat) && !isnan(refpos.lon)) {
       gtk_box_pack_start_defaults(GTK_BOX(hbox),  
                    GTK_LABEL_SMALL((char*)pos_get_bearing_str(refpos, pos)));  
57        snprintf(str, sizeof(str), _("%.1f°"),        snprintf(str, sizeof(str), _("%.1f°"),
58                 gpx_pos_get_bearing(refpos, pos));                 gpx_pos_get_bearing(refpos, pos));
59        gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL(str));        gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL(str));
60        gpx_pos_get_distance_str(str, sizeof(str),        gpx_pos_get_distance_str(str, sizeof(str),
61                               refpos, pos, appdata->imperial);                               refpos, pos, appdata->imperial);
62          gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL("  "));
63        gtk_box_pack_start(GTK_BOX(hbox),        gtk_box_pack_start(GTK_BOX(hbox),
64               gtk_label_attrib(str, SIZE_SMALL, STRIKETHROUGH_NONE),1,0,0);            gtk_label_attrib(str, SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0);
65      } else      } else
66        gtk_box_pack_start(GTK_BOX(hbox),        gtk_box_pack_start(GTK_BOX(hbox),
67                           gtk_label_attrib(_("(no position)"),                   gtk_label_attrib(_("(no position)"),
68                           SIZE_SMALL, STRIKETHROUGH_NONE),1,0,0);                   SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0);
69    } else    } else
70      gtk_box_pack_start(GTK_BOX(hbox),      gtk_box_pack_start(GTK_BOX(hbox),
71             gtk_label_attrib(_("(invalid position in notes)"),                         gtk_label_attrib(_("(invalid position in notes)"),
72                              SIZE_SMALL, STRIKETHROUGH_NONE),1,0,0);                  SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0);
73  }  }
74    
75  /* this function sets everthing related to the coordinate. used to */  /* this function sets everything related to the coordinate. used to */
76  /* cope with the user setting a new "note coordinate" */  /* cope with the user setting a new "note coordinate" */
77  void overview_coordinate_update(cache_context_t *context) {  void overview_coordinate_update(cache_context_t *context) {
78    if(!context->notes.modified)    if(!context->notes.modified)
79      return;      return;
80    
81    /* update position labels */    /* update position labels */
82    int strike = notes_get_override(context)?STRIKETHROUGH:STRIKETHROUGH_NONE;    int strike = notes_get_override(context)?STRIKETHROUGH:STRIKETHROUGH_NONE;
83    char str[32];    lat_label_attrib_set(context->pos_lat_label,
84    pos_lat_str(str, sizeof(str), context->cache->pos.lat);                         context->cache->pos.lat, SIZE_BIG, strike);
85    gtk_label_attrib_set(context->pos_lat_label, str, SIZE_BIG, strike);    lon_label_attrib_set(context->pos_lon_label,
86    pos_lon_str(str, sizeof(str), context->cache->pos.lon);                         context->cache->pos.lon, SIZE_BIG, strike);
87    gtk_label_attrib_set(context->pos_lon_label, str, SIZE_BIG, strike);  
   
88    /* remove enire hbox and build a new one */    /* remove enire hbox and build a new one */
89    gtk_container_foreach(GTK_CONTAINER(context->bearing_hbox),    gtk_container_foreach(GTK_CONTAINER(context->bearing_hbox),
90                          (GtkCallback)gtk_widget_destroy, NULL);                          (GtkCallback)gtk_widget_destroy, NULL);
91    
92    /* update distance/etc */    /* update distance/etc */
93    if(!isnan(context->cache->pos.lat) &&    if(!isnan(context->cache->pos.lat) &&
94       !isnan(context->cache->pos.lon))       !isnan(context->cache->pos.lon))
95      bearing_fill_hbox(context->bearing_hbox, context->appdata,      bearing_fill_hbox(context->bearing_hbox, context->appdata,
96                        *get_pos(context->appdata), notes_get_pos(context));                        *get_pos(context->appdata), notes_get_pos(context));
97    
98    gtk_widget_show_all(context->bearing_hbox);    gtk_widget_show_all(context->bearing_hbox);
99  }  }
100    
101    static void gcvote_set(cache_context_t *context, vote_t *vote) {
102      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;
142    
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
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, 0);    vbox = gtk_vbox_new(FALSE, 4);
186    
187    table =  gtk_table_new(3,4, FALSE);    /* hbox containing the four columns of cache details */
188      GtkWidget *ihbox = gtk_hbox_new(FALSE, 0);
189    
190      /* vbox containing leftmost column (icon and container) */
191      colbox = gtk_vbox_new(FALSE, 0);
192    
193    if(cache->type != CACHE_TYPE_UNKNOWN) {    if(cache->type != CACHE_TYPE_UNKNOWN) {
194      gtk_table_attach(GTK_TABLE(table),      gtk_box_pack_start_defaults(GTK_BOX(colbox),
195               tip = icon_get_widget(ICON_CACHE_TYPE, cache->type), 0,1,0,1,          tip = icon_get_widget(ICON_SIZE, cache->type));
196               GTK_FILL, 0, GTK_FILL, 0);  
197  #ifndef USE_MAEMO  #ifndef USE_MAEMO
198      gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL);      gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL);
199  #endif  #endif
200    }    }
201    
202    /* ------------ box containing container info ------------ */    /* ------------ box containing container info ------------ */
203    if(cache->container != CACHE_CONT_UNKNOWN) {    if(cache->container != CACHE_CONT_UNKNOWN) {
204      ivbox = gtk_vbox_new(FALSE, 0);      ivbox = gtk_vbox_new(FALSE, 0);
# Line 132  static GtkWidget *cache_overview(cache_c Line 208  static GtkWidget *cache_overview(cache_c
208      gtk_box_pack_start(GTK_BOX(ivbox),      gtk_box_pack_start(GTK_BOX(ivbox),
209                         icon_get_widget(ICON_CACHE_SIZE, cache->container),                         icon_get_widget(ICON_CACHE_SIZE, cache->container),
210                         FALSE, FALSE, 0);                         FALSE, FALSE, 0);
211      gtk_table_attach(GTK_TABLE(table), ivbox, 0,1,1,2,  
212                       GTK_EXPAND | GTK_FILL, 0, GTK_FILL, 0);      pack_vcentered(colbox, ivbox);
213  #ifndef USE_MAEMO  #ifndef USE_MAEMO
214      gtk_tooltips_set_tip(tips, ivbox, _(cache_size_tip[cache->container]), NULL);      gtk_tooltips_set_tip(tips, ivbox, _(cache_size_tip[cache->container]), NULL);
215  #endif  #endif
216    }    }
217    
218      gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox);
219      colbox = gtk_vbox_new(FALSE, 0);
220    
221    /* ----------------------- id ---------------------------- */    /* ----------------------- id ---------------------------- */
222    if(cache->id) {    if(cache->id) {
223      int strike = cache->archived?STRIKETHROUGH_RED:      int strike = cache->archived?STRIKETHROUGH_RED:
# Line 146  static GtkWidget *cache_overview(cache_c Line 225  static GtkWidget *cache_overview(cache_c
225      GtkWidget *lbl = link_button_attrib(context->appdata,      GtkWidget *lbl = link_button_attrib(context->appdata,
226                                          cache->id, context->cache->url,                                          cache->id, context->cache->url,
227                                          SIZE_BIG, strike);                                          SIZE_BIG, strike);
228      gtk_table_attach(GTK_TABLE(table), lbl, 1,2,0,1, FALSE, FALSE, 0, 0);      pack_vcentered(colbox, lbl);
229    }    }
230    
231    /* --------------- box containing owner info ------------- */    /* --------------- box containing owner info ------------- */
232    if(cache->owner) {    if(cache->owner) {
233      ivbox = gtk_vbox_new(FALSE, 0);      gtk_box_pack_start_defaults(GTK_BOX(colbox), GTK_LABEL_SMALL(_("by")));
     gtk_box_pack_start_defaults(GTK_BOX(ivbox), GTK_LABEL_SMALL(_("by")));  
234    
235      static const char *owner_type = "profile/";      static const char *owner_type = "profile/";
236      gtk_box_pack_start_defaults(GTK_BOX(ivbox),      pack_vcentered(colbox,
237                  link_button_by_id(appdata, cache->owner->name,                  link_button_by_id(appdata, cache->owner->name,
238                                    owner_type, cache->owner->id));                                    owner_type, cache->owner->id));
     gtk_table_attach(GTK_TABLE(table), ivbox, 1,2,1,2, FALSE,FALSE,0,0);  
239    }    }
240    
241      gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox);
242    
243    /* ----------- vbox containing all ratings ---------- */    /* ----------- vbox containing all ratings ---------- */
244    GtkWidget *ratebox = gtk_vbox_new(FALSE, 0);    colbox = gtk_vbox_new(FALSE, 0);
245    
246    /* ----------- box containing difficulty rating ---------- */    /* ----------- box containing difficulty rating ---------- */
247    if(cache->difficulty != 0) {    if(cache->difficulty != 0) {
# Line 174  static GtkWidget *cache_overview(cache_c Line 253  static GtkWidget *cache_overview(cache_c
253                    icon_get_widget(ICON_STARS, (int)(cache->difficulty*2-2)),                    icon_get_widget(ICON_STARS, (int)(cache->difficulty*2-2)),
254                         FALSE, FALSE, 0);                         FALSE, FALSE, 0);
255    
256      GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);      pack_vcentered(colbox, ivbox);
     gtk_container_add(GTK_CONTAINER(align), ivbox);  
     gtk_box_pack_start_defaults(GTK_BOX(ratebox), align);  
257  #ifndef USE_MAEMO  #ifndef USE_MAEMO
258      sprintf(str, _("Difficulty: %.1f"), cache->difficulty);      sprintf(str, _("Difficulty: %.1f"), cache->difficulty);
259      gtk_tooltips_set_tip(tips, ivbox, str, NULL);      gtk_tooltips_set_tip(tips, ivbox, str, NULL);
# Line 191  static GtkWidget *cache_overview(cache_c Line 268  static GtkWidget *cache_overview(cache_c
268      gtk_box_pack_start(GTK_BOX(ivbox),      gtk_box_pack_start(GTK_BOX(ivbox),
269                         icon_get_widget(ICON_STARS, (int)(cache->terrain*2-2)),                         icon_get_widget(ICON_STARS, (int)(cache->terrain*2-2)),
270                         FALSE, FALSE, 0);                         FALSE, FALSE, 0);
271      GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);      pack_vcentered(colbox, ivbox);
     gtk_container_add(GTK_CONTAINER(align), ivbox);  
     gtk_box_pack_start_defaults(GTK_BOX(ratebox), align);  
272  #ifndef USE_MAEMO  #ifndef USE_MAEMO
273      sprintf(str, _("Terrain: %.1f"), cache->terrain);      sprintf(str, _("Terrain: %.1f"), cache->terrain);
274      gtk_tooltips_set_tip(tips, ivbox, str, NULL);      gtk_tooltips_set_tip(tips, ivbox, str, NULL);
# Line 201  static GtkWidget *cache_overview(cache_c Line 276  static GtkWidget *cache_overview(cache_c
276    }    }
277    
278    /* --------------------- GCVote ------------------------ */    /* --------------------- GCVote ------------------------ */
279    if(1) {    if(!appdata->disable_gcvote) {
280      float quality = 2.5;      vote_t *vote = gcvote_restore(appdata, cache);
     int votes = 2;  
281    
282      ivbox = gtk_vbox_new(FALSE, 0);      context->gcvote_request =
283          gcvote_request(appdata, gcvote_callback, cache->url, context);
     char *votes_str = g_strdup_printf(_("Quality (%d votes):"), votes);  
     gtk_box_pack_start(GTK_BOX(ivbox), GTK_LABEL_SMALL(votes_str),  
                        FALSE, FALSE, 0);  
     g_free(votes_str);  
     gtk_box_pack_start(GTK_BOX(ivbox),  
          icon_get_widget(ICON_STARS, (int)(quality*2-2)), FALSE, FALSE, 0);  
284    
285      GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);      context->votebox = gtk_vbox_new(FALSE, 0);
286      gtk_container_add(GTK_CONTAINER(align), ivbox);      pack_vcentered(colbox, context->votebox);
287      gtk_box_pack_start_defaults(GTK_BOX(ratebox), align);  
288  #ifndef USE_MAEMO      /* fill with vote if present on disk (will also free vote) */
289      sprintf(str, _("Quality: %.1f"), quality);      if(vote)
290      gtk_tooltips_set_tip(tips, ivbox, str, NULL);        gcvote_set(context, vote);
 #endif  
291    }    }
292    
293    gtk_table_attach_defaults(GTK_TABLE(table), ratebox, 2,3,0,2);    gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox);
294    
295    /* ----------------------------------------------------- */    /* ----------------------------------------------------- */
296    
297    
298    /* ----------------- the two coordinates ----------------- */    /* ----------------- the two coordinates ----------------- */
299    /* ----------------- and the heading/distance ------------ */    /* ----------------- and the heading/distance ------------ */
300      colbox = gtk_vbox_new(FALSE, 0);
301    
302    pos_t *refpos = get_pos(appdata);    pos_t *refpos = get_pos(appdata);
303    
304    ivbox = gtk_vbox_new(FALSE, 0);    ivbox = gtk_vbox_new(FALSE, 0);
# Line 237  static GtkWidget *cache_overview(cache_c Line 306  static GtkWidget *cache_overview(cache_c
306                    STRIKETHROUGH:STRIKETHROUGH_NONE;                    STRIKETHROUGH:STRIKETHROUGH_NONE;
307    
308    /* the original coordinate is being displayed */    /* the original coordinate is being displayed */
309    gtk_box_pack_start_defaults(GTK_BOX(ivbox),    gtk_box_pack_start(GTK_BOX(ivbox),
310         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);
311    gtk_box_pack_start_defaults(GTK_BOX(ivbox),    gtk_box_pack_start(GTK_BOX(ivbox),
312         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);
313    
314      pack_vcentered(colbox, ivbox);
315    
316    /* but calculations may be done with respect to the overriden one */    /* but calculations may be done with respect to the overriden one */
317    if(!isnan(cache->pos.lat) && !isnan(cache->pos.lon)) {    if(!isnan(cache->pos.lat) && !isnan(cache->pos.lon)) {
318      context->bearing_hbox = gtk_hbox_new(FALSE, 0);      context->bearing_hbox = gtk_hbox_new(FALSE, 0);
319      bearing_fill_hbox(context->bearing_hbox, appdata, *refpos,      bearing_fill_hbox(context->bearing_hbox, appdata, *refpos,
320                        gpx_cache_pos(cache));                        gpx_cache_pos(cache));
321      gtk_box_pack_start_defaults(GTK_BOX(ivbox), context->bearing_hbox);      pack_vcentered(colbox, context->bearing_hbox);
322    }    }
323    
324    gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 3,4,0,2);    gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox);
325    
326    /* ----------------------------------------------------- */    /* ----------------------------------------------------- */
   /* gcvote if present and possible */  
   
   gcvote_get(appdata, cache->url);  
   
   /* ----------------------------------------------------- */  
327    
328    gtk_box_pack_start(GTK_BOX(vbox), table, 0,0,0);    gtk_box_pack_start(GTK_BOX(vbox), ihbox, FALSE, FALSE, 0);
329    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);
330    
331    /* ----------------------------------------------------- */    /* ----------------------------------------------------- */
332    
# Line 382  static GtkWidget *cache_wpts(appdata_t * Line 448  static GtkWidget *cache_wpts(appdata_t *
448                        pos_lon(wpt->pos.lon, SIZE_BIG, STRIKETHROUGH_NONE),                        pos_lon(wpt->pos.lon, SIZE_BIG, STRIKETHROUGH_NONE),
449                        2,3, wpt_row, wpt_row+1);                        2,3, wpt_row, wpt_row+1);
450    
451      ihbox = gtk_hbox_new(FALSE, 0);      if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) {
452      gtk_box_pack_start(GTK_BOX(ihbox), gtk_image_new_from_pixbuf(        ihbox = gtk_hbox_new(FALSE, 0);
453          gtk_box_pack_start(GTK_BOX(ihbox), gtk_image_new_from_pixbuf(
454                             icon_bearing(*refpos, wpt->pos)),1,0,0);                             icon_bearing(*refpos, wpt->pos)),1,0,0);
455      gtk_box_pack_start_defaults(GTK_BOX(ihbox),        snprintf(str, sizeof(str), _("%.1f°"),
456            GTK_LABEL_SMALL((char*)pos_get_bearing_str(*refpos, wpt->pos)));                 gpx_pos_get_bearing(*refpos, wpt->pos));
457      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  
458    
459        gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_WORD);        gpx_pos_get_distance_str(str, sizeof(str),
460        gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);                                 *refpos, wpt->pos, appdata->imperial);
461        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);
462    
463          gtk_table_attach_defaults(GTK_TABLE(table), ihbox, 3,4,
464                                    wpt_row+0, wpt_row+1);
465        }
466    
467        gtk_table_attach_defaults(GTK_TABLE(table), textview, 0,4,      /* ------------------ description ------------------------- */
468        if(wpt->desc)
469          gtk_table_attach_defaults(GTK_TABLE(table),
470                                    simple_text_widget(wpt->desc), 0,4,
471                                  wpt_row+1, wpt_row+2);                                  wpt_row+1, wpt_row+2);
     }  
472    
473      /* ------------------ comment ------------------------- */      /* ------------------ comment ------------------------- */
474      if(wpt->cmt) {      if(wpt->cmt)
475        GtkTextBuffer *buffer = gtk_text_buffer_new(NULL);        gtk_table_attach_defaults(GTK_TABLE(table),
476        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,  
477                                  wpt_row+2, wpt_row+3);                                  wpt_row+2, wpt_row+3);
     }  
478    
479      /* --------------------- seperator -------------------------*/      /* --------------------- seperator -------------------------*/
480      if(wpt->next)      if(wpt->next) {
481          gtk_table_set_row_spacing(GTK_TABLE(table), wpt_row+2, 8);
482        gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(), 0,4,        gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(), 0,4,
483                                  wpt_row+3, wpt_row+4);                                  wpt_row+3, wpt_row+4);
484          gtk_table_set_row_spacing(GTK_TABLE(table), wpt_row+3, 8);
485        }
486    
487      wpt_row+=4;      wpt_row+=4;
488      wpt = wpt->next;      wpt = wpt->next;
# Line 481  static GtkWidget *cache_tbs(appdata_t *a Line 524  static GtkWidget *cache_tbs(appdata_t *a
524      static const char *tb_type = "track/details.aspx";      static const char *tb_type = "track/details.aspx";
525    
526      /* --------------------- icon/ref/name -------------------------*/      /* --------------------- icon/ref/name -------------------------*/
527      gtk_table_attach_defaults(GTK_TABLE(table), icon_get_widget(ICON_TB, 0),      GtkWidget *icon = NULL;
528                                0, 1, tb_row+0, tb_row+1);      if((strcasestr(tb->name, "coin") != 0) ||
529           (strcasestr(tb->name, "muenze") != 0) ||
530           (strcasestr(tb->name, "münze") != 0))
531          icon = icon_get_widget(ICON_TB, 1);   /* coin icon */
532        else
533          icon = icon_get_widget(ICON_TB, 0);   /* tb icon */
534    
535        gtk_table_attach_defaults(GTK_TABLE(table), icon,
536                                  0, 1, tb_row+0, tb_row+1);
537    
538      if(tb->ref) {      if(tb->ref) {
539        GtkWidget *ref = link_button_by_id(appdata, tb->ref, tb_type, tb->id);        GtkWidget *ref = link_button_by_id(appdata, tb->ref, tb_type, tb->id);
# Line 525  static void on_gclink_clicked(GtkButton Line 575  static void on_gclink_clicked(GtkButton
575  }  }
576  #endif  #endif
577    
578  static GtkWidget *cache_logs(appdata_t *appdata, cache_context_t *context, log_t *log, int is_html) {  static GtkWidget *cache_logs(appdata_t *appdata, cache_context_t *context,
579                                 log_t *log, int is_html) {
580  #ifndef  USE_PANNABLE_AREA  #ifndef  USE_PANNABLE_AREA
581    /* put this inside a scrolled view */    /* put this inside a scrolled view */
582    GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);    GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);
# Line 541  static GtkWidget *cache_logs(appdata_t * Line 592  static GtkWidget *cache_logs(appdata_t *
592  #define gc_link (FALSE)  #define gc_link (FALSE)
593  #endif  #endif
594    
595    GtkWidget *table = gtk_table_new(4*gpx_number_of_logs(log)+(gc_link?1:0), 3, FALSE);    GtkWidget *vbox = gtk_vbox_new(FALSE, 6);
   int cnt = 0;  
596    
597  #ifdef ENABLE_BROWSER_INTERFACE  #ifdef ENABLE_BROWSER_INTERFACE
598    if(gc_link) {    if(gc_link) {
599      GtkWidget *but = gtk_button_new_with_label(_("Post a new log entry for this geocache"));      GtkWidget *but =
600          gtk_button_new_with_label(_("Post a new log entry for this geocache"));
601    #if 0
602        gtk_button_set_image(GTK_BUTTON(but),
603            gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON));
604        gtk_button_set_image_position(GTK_BUTTON(but), GTK_POS_LEFT);
605    #endif
606  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
607    hildon_gtk_widget_set_theme_size(but,    hildon_gtk_widget_set_theme_size(but,
608             (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));             (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
# Line 554  static GtkWidget *cache_logs(appdata_t * Line 610  static GtkWidget *cache_logs(appdata_t *
610      gtk_signal_connect(GTK_OBJECT(but), "clicked",      gtk_signal_connect(GTK_OBJECT(but), "clicked",
611                         GTK_SIGNAL_FUNC(on_gclink_clicked), context);                         GTK_SIGNAL_FUNC(on_gclink_clicked), context);
612    
613      gtk_table_attach_defaults(GTK_TABLE(table), but, 0, 3, 0, 1);      gtk_box_pack_start(GTK_BOX(vbox), but, FALSE, FALSE, 0);
     cnt++;  
614    }    }
615  #endif  #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  #if 0  
628      static const char *log_type = "seek/log.aspx";      static const char *finder_type = "profile/";
629      GtkWidget *log_but =      GtkWidget *finder = link_button_by_id(appdata, log->finder->name,
630        link_icon_button_by_id(appdata, icon_get_widget(ICON_LOG, log->type),                                            finder_type, log->finder->id);
631                               log_type, log->id);  
632      gtk_table_attach(GTK_TABLE(table), log_but,      /* if the finder is a button make sure it's the right size and */
633                       0, 1, cnt+1, cnt+2, FALSE, FALSE, 0, 0);      /* does not exceed the size limits */
634  #else      if(GTK_WIDGET_TYPE(finder) == GTK_TYPE_BUTTON) {
635      gtk_table_attach_defaults(GTK_TABLE(table),  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
636                icon_get_widget(ICON_LOG, log->type), 0, 1, cnt+1, cnt+2);        hildon_gtk_widget_set_theme_size(finder,
637  #endif                     (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 583  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      static const char *finder_type = "profile/";      gtk_box_pack_start(GTK_BOX(ivbox), ihbox, FALSE, FALSE, 0);
     GtkWidget *finder = link_button_by_id(appdata, log->finder->name,  
                                           finder_type, log->finder->id);  
661    
662      gtk_table_attach(GTK_TABLE(table), finder,      gtk_table_attach(GTK_TABLE(table), ivbox, 0, 1,
663                       2, 3, cnt+1, cnt+2, FALSE, FALSE, 0, 0);                       2*log_cnt, 2*log_cnt+1, 0, GTK_EXPAND | GTK_FILL, 0, 0);
   
     gtk_table_attach_defaults(GTK_TABLE(table), gtk_hseparator_new(),  
                               0, 3, cnt+2, cnt+3);  
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,          html_view(appdata, log->text,
668                    is_html?HTML_HTML:HTML_CUSTOM_MARKUP, FALSE, NULL, NULL),                    is_html?HTML_HTML:HTML_CUSTOM_MARKUP, FALSE, NULL, NULL),
669                                  0, 3, cnt+3, cnt+4);                                  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 651  static void on_notebook_page_change(GtkN Line 728  static void on_notebook_page_change(GtkN
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);
   } else if(strcasecmp(name, _("TBs")) == 0) {  
     gtk_widget_queue_resize(w);  
731    } else if(strcasecmp(name, _("Goto")) == 0) {    } else if(strcasecmp(name, _("Goto")) == 0) {
732  #ifdef USE_MAEMO  #ifdef USE_MAEMO
733      context->handler_id = gtk_timeout_add(1000, screensaver_update,      context->handler_id = gtk_timeout_add(1000, screensaver_update,
734                                            context->appdata);                                            context->appdata);
735  #endif  #endif
736    
737      goto_coordinate_update(context);      goto_coordinate_update(context);
738    }    }
739    
# Line 673  static void on_notebook_destroy(GtkWidge Line 749  static void on_notebook_destroy(GtkWidge
749    
750    printf("destroying notebook\n");    printf("destroying notebook\n");
751    
752      /* cancel a pending gcvote request */
753      if(context->gcvote_request) {
754        gcvote_request_free(context->gcvote_request);
755        context->gcvote_request = NULL;
756      }
757    
758    notes_destroy_event(NULL, context);    notes_destroy_event(NULL, context);
759    goto_destroy_event(NULL, context);    goto_destroy_event(NULL, context);
760    
# Line 681  static void on_notebook_destroy(GtkWidge Line 763  static void on_notebook_destroy(GtkWidge
763      gtk_timeout_remove(context->handler_id);      gtk_timeout_remove(context->handler_id);
764  #endif  #endif
765    
766    free(user_data);  #ifdef USE_STACKABLE_WINDOW
767      if(context->notes_have_been_changed) {
768        printf("notes changed -> cachelist redraw\n");
769    
770        /* now the cachelist is visible again. so redraw it since it may */
771        /* have changed */
772        cachelist_redraw(context->appdata);
773      }
774    #endif
775    
776      printf("freeing cache context\n");
777      context->appdata->cache_context = NULL;
778      g_free(context);
779    }
780    
781    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
782    #define CUSTOM_NOTEBOOK
783    #endif
784    
785    static GtkWidget *notebook_new(void) {
786    #ifdef CUSTOM_NOTEBOOK
787      GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
788    
789      GtkWidget *notebook =  gtk_notebook_new();
790    
791      /* prevents user from accidentially touching the breadcrumb trail */
792      /* (looks ugly on fremantle as it isn't themed) */
793      //  gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM);
794    
795      /* solution for fremantle: we use a row of ordinary buttons instead */
796      /* of regular tabs */
797    
798      /* hide the regular tabs */
799      gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
800    
801      gtk_box_pack_start_defaults(GTK_BOX(vbox), notebook);
802    
803      /* store a reference to the notebook in the vbox */
804      g_object_set_data(G_OBJECT(vbox), "notebook", (gpointer)notebook);
805    
806      /* create a hbox for the buttons */
807      GtkWidget *hbox = gtk_hbox_new(TRUE, 0);
808      gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
809      g_object_set_data(G_OBJECT(vbox), "hbox", (gpointer)hbox);
810    
811      return vbox;
812    #else
813      return gtk_notebook_new();
814    #endif
815    }
816    
817    #ifdef CUSTOM_NOTEBOOK
818    static void on_notebook_button_clicked(GtkWidget *button, gpointer data) {
819      GtkNotebook *nb =
820        GTK_NOTEBOOK(g_object_get_data(G_OBJECT(data), "notebook"));
821    
822      gint page = (gint)g_object_get_data(G_OBJECT(button), "page");
823      gtk_notebook_set_current_page(nb, page);
824    }
825    #endif
826    
827    static void notebook_append_page(GtkWidget *notebook,
828                                     GtkWidget *page, char *label) {
829    #ifdef CUSTOM_NOTEBOOK
830      GtkNotebook *nb =
831        GTK_NOTEBOOK(g_object_get_data(G_OBJECT(notebook), "notebook"));
832    
833      gint page_num = gtk_notebook_append_page(nb, page, gtk_label_new(label));
834      GtkWidget *button = NULL;
835    
836      /* select button for page 0 by default */
837      if(!page_num) {
838        button = gtk_radio_button_new_with_label(NULL, label);
839        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
840        g_object_set_data(G_OBJECT(notebook), "group_master", (gpointer)button);
841      } else {
842        GtkWidget *master = g_object_get_data(G_OBJECT(notebook), "group_master");
843        button = gtk_radio_button_new_with_label_from_widget(
844                                     GTK_RADIO_BUTTON(master), label);
845      }
846    
847      gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE);
848      g_object_set_data(G_OBJECT(button), "page", (gpointer)page_num);
849    
850      gtk_signal_connect(GTK_OBJECT(button), "clicked",
851               GTK_SIGNAL_FUNC(on_notebook_button_clicked), notebook);
852    
853    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
854      hildon_gtk_widget_set_theme_size(button,
855               (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
856    #endif
857    
858      gtk_box_pack_start_defaults(
859         GTK_BOX(g_object_get_data(G_OBJECT(notebook), "hbox")),
860         button);
861    
862    #else
863      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, gtk_label_new(label));
864    #endif
865    }
866    
867    static GObject *notebook_object(GtkWidget *notebook) {
868    #ifdef CUSTOM_NOTEBOOK
869      return G_OBJECT(g_object_get_data(G_OBJECT(notebook), "notebook"));
870    #else
871      return G_OBJECT(notebook);
872    #endif
873  }  }
874    
875  GtkWidget *cache_view(appdata_t *appdata, cache_t *cache) {  GtkWidget *cache_view(appdata_t *appdata, cache_t *cache) {
876    GtkWidget *notebook;    GtkWidget *notebook;
877    
878    cache_context_t *cache_context = malloc(sizeof(cache_context_t));    cache_context_t *cache_context = g_new0(cache_context_t, 1);
879    memset(cache_context, 0, sizeof(cache_context_t));    appdata->cache_context = cache_context;
880    cache_context->appdata = appdata;    cache_context->appdata = appdata;
881    cache_context->cache = cache;    cache_context->cache = cache;
882    
# Line 700  GtkWidget *cache_view(appdata_t *appdata Line 888  GtkWidget *cache_view(appdata_t *appdata
888  #define TAB_WPTS   _("Waypoints")  #define TAB_WPTS   _("Waypoints")
889  #endif  #endif
890    
891    notebook =  gtk_notebook_new();    notebook = notebook_new();
892    
893  #ifdef USE_MAEMO    notebook_append_page(notebook,
894  #if MAEMO_VERSION_MAJOR >= 5         cache_overview(cache_context), _("Main"));
   /* prevents user from accidentially touching the breadcrumb trail */  
   gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM);  
 #endif  
 #endif  
   
   gtk_notebook_append_page(GTK_NOTEBOOK(notebook),  
        cache_overview(cache_context), gtk_label_new(_("Main")));  
895    
896    if(cache->long_description)    if(cache->long_description)
897      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
898             cache_description(appdata, cache), gtk_label_new(TAB_DESC));             cache_description(appdata, cache), TAB_DESC);
899    
900    if(cache->hint)    if(cache->hint)
901      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
902             cache_hint(appdata, cache), gtk_label_new(_("Hint")));             cache_hint(appdata, cache), _("Hint"));
903    
904    if(cache->log)    if(cache->log)
905      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
906       cache_logs(appdata, cache_context, cache->log, cache->logs_are_html),       cache_logs(appdata, cache_context, cache->log, cache->logs_are_html),
907             gtk_label_new(_("Logs")));             _("Logs"));
908    
909    if(cache->wpt)    if(cache->wpt)
910      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
911               cache_wpts(appdata, cache->wpt), gtk_label_new(TAB_WPTS));               cache_wpts(appdata, cache->wpt), TAB_WPTS);
912    
913    if(cache->tb)    if(cache->tb)
914      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),      notebook_append_page(notebook,
915               cache_tbs(appdata, cache->tb), gtk_label_new(_("TBs")));               cache_tbs(appdata, cache->tb), _("TBs"));
916    
917    gtk_notebook_append_page(GTK_NOTEBOOK(notebook),    notebook_append_page(notebook,
918             cache_notes(cache_context), gtk_label_new(_("Notes")));             cache_notes(cache_context), _("Notes"));
919    
920    gtk_notebook_append_page(GTK_NOTEBOOK(notebook),    notebook_append_page(notebook,
921             goto_cache(cache_context), gtk_label_new(_("Goto")));             goto_cache(cache_context), _("Goto"));
922    
923    g_signal_connect(G_OBJECT(notebook), "switch-page",    g_signal_connect(notebook_object(notebook), "switch-page",
924             G_CALLBACK(on_notebook_page_change), cache_context);             G_CALLBACK(on_notebook_page_change), cache_context);
925    
926    g_signal_connect(G_OBJECT(notebook), "destroy",    g_signal_connect(notebook_object(notebook), "destroy",
927             G_CALLBACK(on_notebook_destroy), cache_context);             G_CALLBACK(on_notebook_destroy), cache_context);
928    
929    return notebook;    return notebook;
# Line 773  void cache_dialog(appdata_t *appdata, ca Line 954  void cache_dialog(appdata_t *appdata, ca
954  static void on_cache_destroy (GtkWidget *widget, appdata_t *appdata) {  static void on_cache_destroy (GtkWidget *widget, appdata_t *appdata) {
955    appdata->cur_cache = NULL;    appdata->cur_cache = NULL;
956    
957      HildonWindowStack *stack = hildon_window_stack_get_default();
958      appdata->window = HILDON_WINDOW(hildon_window_stack_peek(stack));
959    
960    /* restore cur_view */    /* restore cur_view */
961    appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");    appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");
962  }  }
963    
964  void cache_dialog(appdata_t *appdata, cache_t *cache) {  void cache_dialog(appdata_t *appdata, cache_t *cache) {
965    GtkWidget *window = hildon_stackable_window_new();    GtkWidget *window = hildon_stackable_window_new();
966      appdata->window = HILDON_WINDOW(window);
967    
968    /* store last "cur_view" in window */    /* store last "cur_view" in window */
969    g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view);    g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view);
970    
971    appdata->cur_cache = cache;    appdata->cur_cache = cache;
972    char *title = g_strdup_printf("%s - GPXView", cache->name);    gtk_window_set_title(GTK_WINDOW(window), cache->name);
   gtk_window_set_title(GTK_WINDOW(window), title);  
   g_free(title);  
973    
974    /* create cache visualization widget */    /* create cache visualization widget */
975    appdata->cur_view = cache_view(appdata, cache);    appdata->cur_view = cache_view(appdata, cache);

Legend:
Removed from v.157  
changed lines
  Added in v.229