Diff of /trunk/src/cache.c

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

revision 199 by harbaum, Thu Nov 19 13:33:35 2009 UTC revision 303 by harbaum, Tue Sep 14 09:28:57 2010 UTC
# Line 21  Line 21 
21  #include <math.h>  #include <math.h>
22  #include <string.h>  #include <string.h>
23    
24    #if MAEMO_VERSION_MAJOR == 5
25    #include <gdk/gdkx.h>
26    #include <X11/Xatom.h>
27    #endif
28    
29  static GtkWidget *cache_description(appdata_t *appdata, cache_t *cache) {  static GtkWidget *cache_description(appdata_t *appdata, cache_t *cache) {
30    return html_view(appdata, cache->long_description,    return html_view(appdata, cache->long_description,
31             cache->long_is_html?HTML_HTML:HTML_PLAIN_TEXT, TRUE, cache, NULL);             cache->long_is_html?HTML_HTML:HTML_PLAIN_TEXT, TRUE, cache, NULL);
# Line 51  void bearing_fill_hbox(GtkWidget *hbox, Line 56  void bearing_fill_hbox(GtkWidget *hbox,
56    
57    if(!isnan(pos.lat) && !isnan(pos.lon)) {    if(!isnan(pos.lat) && !isnan(pos.lon)) {
58      gtk_box_pack_start(GTK_BOX(hbox), gtk_image_new_from_pixbuf(      gtk_box_pack_start(GTK_BOX(hbox), gtk_image_new_from_pixbuf(
59                                          icon_bearing(refpos, pos)),TRUE,FALSE,0);                          icon_bearing(refpos, pos)),TRUE,FALSE,0);
60    
61      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)));  
       gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL("  "));  
62        snprintf(str, sizeof(str), _("%.1f°"),        snprintf(str, sizeof(str), _("%.1f°"),
63                 gpx_pos_get_bearing(refpos, pos));                 gpx_pos_get_bearing(refpos, pos));
64        gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL(str));        gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL(str));
# Line 64  void bearing_fill_hbox(GtkWidget *hbox, Line 66  void bearing_fill_hbox(GtkWidget *hbox,
66                               refpos, pos, appdata->imperial);                               refpos, pos, appdata->imperial);
67        gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL("  "));        gtk_box_pack_start_defaults(GTK_BOX(hbox), GTK_LABEL_SMALL("  "));
68        gtk_box_pack_start(GTK_BOX(hbox),        gtk_box_pack_start(GTK_BOX(hbox),
69               gtk_label_attrib(str, SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0);            gtk_label_attrib(str, SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0);
70      } else      } else
71        gtk_box_pack_start(GTK_BOX(hbox),        gtk_box_pack_start(GTK_BOX(hbox),
72                           gtk_label_attrib(_("(no position)"),                   gtk_label_attrib(_("(no position)"),
73                           SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0);                   SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0);
74    } else    } else
75      gtk_box_pack_start(GTK_BOX(hbox),      gtk_box_pack_start(GTK_BOX(hbox),
76             gtk_label_attrib(_("(invalid position in notes)"),                         gtk_label_attrib(_("(invalid position in notes)"),
77                              SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0);                  SIZE_SMALL, STRIKETHROUGH_NONE),TRUE,FALSE,0);
78  }  }
79    
80  /* this function sets everything related to the coordinate. used to */  /* this function sets everything related to the coordinate. used to */
# Line 80  void bearing_fill_hbox(GtkWidget *hbox, Line 82  void bearing_fill_hbox(GtkWidget *hbox,
82  void overview_coordinate_update(cache_context_t *context) {  void overview_coordinate_update(cache_context_t *context) {
83    if(!context->notes.modified)    if(!context->notes.modified)
84      return;      return;
85    
86    /* update position labels */    /* update position labels */
87    int strike = notes_get_override(context)?STRIKETHROUGH:STRIKETHROUGH_NONE;    int strike = notes_get_override(context)?STRIKETHROUGH:STRIKETHROUGH_NONE;
88    char str[32];    lat_label_attrib_set(context->pos_lat_label,
89    pos_lat_str(str, sizeof(str), context->cache->pos.lat);                         context->cache->pos.lat, SIZE_BIG, strike);
90    gtk_label_attrib_set(context->pos_lat_label, str, SIZE_BIG, strike);    lon_label_attrib_set(context->pos_lon_label,
91    pos_lon_str(str, sizeof(str), context->cache->pos.lon);                         context->cache->pos.lon, SIZE_BIG, strike);
92    gtk_label_attrib_set(context->pos_lon_label, str, SIZE_BIG, strike);  
   
93    /* remove enire hbox and build a new one */    /* remove enire hbox and build a new one */
94    gtk_container_foreach(GTK_CONTAINER(context->bearing_hbox),    gtk_container_foreach(GTK_CONTAINER(context->bearing_hbox),
95                          (GtkCallback)gtk_widget_destroy, NULL);                          (GtkCallback)gtk_widget_destroy, NULL);
96    
97    /* update distance/etc */    /* update distance/etc */
98    if(!isnan(context->cache->pos.lat) &&    if(!isnan(context->cache->pos.lat) &&
99       !isnan(context->cache->pos.lon))       !isnan(context->cache->pos.lon))
100      bearing_fill_hbox(context->bearing_hbox, context->appdata,      bearing_fill_hbox(context->bearing_hbox, context->appdata,
101                        *get_pos(context->appdata), notes_get_pos(context));                        *get_pos(context->appdata), notes_get_pos(context));
102    
103    gtk_widget_show_all(context->bearing_hbox);    gtk_widget_show_all(context->bearing_hbox);
104  }  }
105    
106  static void gcvote_set(cache_context_t *context, vote_t *vote) {  static void gcvote_set(cache_context_t *context, vote_t *vote) {
107    if(!vote) return;    if(!vote) return;
108    
109    if(context->quality) {    if(context->quality) {
110      gtk_widget_destroy(context->quality);      gtk_widget_destroy(context->quality);
111      context->quality = NULL;      context->quality = NULL;
112    }    }
113    
114    if(context->votes) {    if(context->votes) {
115      gtk_widget_destroy(context->votes);      gtk_widget_destroy(context->votes);
116      context->votes = NULL;      context->votes = NULL;
117    }    }
118    
119    /* update/draw the voting */    /* update/draw the voting */
120  #ifndef USE_MAEMO  #ifndef USE_MAEMO
121    GtkTooltips *tips = gtk_tooltips_new();    GtkTooltips *tips = gtk_tooltips_new();
122  #endif  #endif
123    
124    char *votes_str = g_strdup_printf(_("Quality (%d %s):"), vote->votes,    char *votes_str = g_strdup_printf(_("Quality (%d %s):"), vote->votes,
125                                        (vote->votes == 1)?_("vote"):_("votes"));                                      (vote->votes == 1)?_("vote"):_("votes"));
126    context->votes = GTK_LABEL_SMALL(votes_str);    context->votes = GTK_LABEL_SMALL(votes_str);
127    gtk_box_pack_start(GTK_BOX(context->votebox),    gtk_box_pack_start(GTK_BOX(context->votebox),
128                       context->votes, FALSE, FALSE, 0);                       context->votes, FALSE, FALSE, 0);
# Line 129  static void gcvote_set(cache_context_t * Line 130  static void gcvote_set(cache_context_t *
130    context->quality = icon_get_widget(ICON_STARS, (int)(vote->quality*2-2));    context->quality = icon_get_widget(ICON_STARS, (int)(vote->quality*2-2));
131    gtk_box_pack_start(GTK_BOX(context->votebox), context->quality,    gtk_box_pack_start(GTK_BOX(context->votebox), context->quality,
132                       FALSE, FALSE, 0);                       FALSE, FALSE, 0);
133    
134  #ifndef USE_MAEMO  #ifndef USE_MAEMO
135    char *str = g_strdup_printf(_("Quality: %d"), vote->quality);    char *str = g_strdup_printf(_("Quality: %d"), vote->quality);
136    gtk_tooltips_set_tip(tips, context->votebox, str, NULL);    gtk_tooltips_set_tip(tips, context->votebox, str, NULL);
# Line 143  static void gcvote_set(cache_context_t * Line 144  static void gcvote_set(cache_context_t *
144    
145  static void gcvote_callback(vote_t *vote, gpointer data) {  static void gcvote_callback(vote_t *vote, gpointer data) {
146    cache_context_t *context = (cache_context_t*)data;    cache_context_t *context = (cache_context_t*)data;
147    
148    /* no vote returned: request failed, just cleanup */    /* no vote returned: request failed, just cleanup */
149    if(!vote) {    if(!vote) {
150      printf("gcvote: callback for failed request\n");      printf("gcvote: callback for failed request\n");
151    
152      gcvote_request_free(context->gcvote_request);      gcvote_request_free(context->gcvote_request);
153      context->gcvote_request = NULL;      context->gcvote_request = NULL;
154      return;      return;
# Line 157  static void gcvote_callback(vote_t *vote Line 158  static void gcvote_callback(vote_t *vote
158           vote->quality, vote->votes);           vote->quality, vote->votes);
159    
160    gcvote_set(context, vote);    gcvote_set(context, vote);
161    
162    gcvote_save(context->appdata, context->cache, &context->gcvote_request->mem);    gcvote_save(context->appdata, context->cache, &context->gcvote_request->mem);
163    
164    gcvote_request_free(context->gcvote_request);    gcvote_request_free(context->gcvote_request);
165    context->gcvote_request = NULL;    context->gcvote_request = NULL;
166  }  }
# Line 170  static void pack_vcentered(GtkWidget *vb Line 171  static void pack_vcentered(GtkWidget *vb
171    gtk_box_pack_start_defaults(GTK_BOX(vbox), align);    gtk_box_pack_start_defaults(GTK_BOX(vbox), align);
172  }  }
173    
174    #ifdef FREMANTLE
175    #define ICON_SIZE  ICON_CACHE_TYPE_2X
176    #else
177    #define ICON_SIZE  ICON_CACHE_TYPE_1_5X
178    #endif
179    
180  static GtkWidget *cache_overview(cache_context_t *context) {  static GtkWidget *cache_overview(cache_context_t *context) {
181    GtkWidget *vbox, *ivbox;    GtkWidget *vbox, *ivbox;
182    GtkWidget *colbox, *tip;    GtkWidget *colbox, *tip;
# Line 179  static GtkWidget *cache_overview(cache_c Line 186  static GtkWidget *cache_overview(cache_c
186  #endif  #endif
187    appdata_t *appdata = context->appdata;    appdata_t *appdata = context->appdata;
188    cache_t *cache = context->cache;    cache_t *cache = context->cache;
189    
190    vbox = gtk_vbox_new(FALSE, 4);    vbox = gtk_vbox_new(FALSE, 4);
191    
192    /* hbox containing the four columns of cache details */    /* hbox containing the four columns of cache details */
193    GtkWidget *ihbox = gtk_hbox_new(FALSE, 0);    GtkWidget *pbox = portrait_box_new(FALSE, 0);
194    
195      GtkWidget *ihbox = gtk_hbox_new(FALSE, 0);
196    
197    /* vbox containing leftmost column (icon and container) */    /* vbox containing leftmost column (icon and container) */
198    colbox = gtk_vbox_new(FALSE, 0);    colbox = gtk_vbox_new(FALSE, 0);
199    
200    if(cache->type != CACHE_TYPE_UNKNOWN) {    if(cache->type != CACHE_TYPE_UNKNOWN) {
201      gtk_box_pack_start_defaults(GTK_BOX(colbox),      gtk_box_pack_start_defaults(GTK_BOX(colbox),
202            tip = icon_get_widget(ICON_SIZE, cache->type));
203  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)  
     tip = icon_get_widget(ICON_CACHE_TYPE_2X, cache->type));  
 #else  
     tip = icon_get_widget(ICON_CACHE_TYPE_1_5X, cache->type));  
 #endif  
   
204  #ifndef USE_MAEMO  #ifndef USE_MAEMO
205      gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL);      gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL);
206  #endif  #endif
207    }    }
208    
209    /* ------------ box containing container info ------------ */    /* ------------ box containing container info ------------ */
210    if(cache->container != CACHE_CONT_UNKNOWN) {    if(cache->container != CACHE_CONT_UNKNOWN) {
211      ivbox = gtk_vbox_new(FALSE, 0);      ivbox = gtk_vbox_new(FALSE, 0);
# Line 211  static GtkWidget *cache_overview(cache_c Line 215  static GtkWidget *cache_overview(cache_c
215      gtk_box_pack_start(GTK_BOX(ivbox),      gtk_box_pack_start(GTK_BOX(ivbox),
216                         icon_get_widget(ICON_CACHE_SIZE, cache->container),                         icon_get_widget(ICON_CACHE_SIZE, cache->container),
217                         FALSE, FALSE, 0);                         FALSE, FALSE, 0);
218    
219      pack_vcentered(colbox, ivbox);      pack_vcentered(colbox, ivbox);
220  #ifndef USE_MAEMO  #ifndef USE_MAEMO
221      gtk_tooltips_set_tip(tips, ivbox, _(cache_size_tip[cache->container]), NULL);      gtk_tooltips_set_tip(tips, ivbox, _(cache_size_tip[cache->container]), NULL);
222  #endif  #endif
223    }    }
224    
225    gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox);    gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox);
226    colbox = gtk_vbox_new(FALSE, 0);    colbox = gtk_vbox_new(FALSE, 0);
227    
228    /* ----------------------- id ---------------------------- */    /* ----------------------- id ---------------------------- */
229    if(cache->id) {    if(cache->id) {
230      int strike = cache->archived?STRIKETHROUGH_RED:      int strike = cache->archived?STRIKETHROUGH_RED:
# Line 243  static GtkWidget *cache_overview(cache_c Line 247  static GtkWidget *cache_overview(cache_c
247    
248    gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox);    gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox);
249    
250      /* pack left two columns into portrait box */
251      gtk_box_pack_start_defaults(GTK_BOX(pbox), ihbox);
252      ihbox = gtk_hbox_new(FALSE, 0);
253    
254    /* ----------- vbox containing all ratings ---------- */    /* ----------- vbox containing all ratings ---------- */
255    colbox = gtk_vbox_new(FALSE, 0);    colbox = gtk_vbox_new(FALSE, 0);
256    
# Line 325  static GtkWidget *cache_overview(cache_c Line 333  static GtkWidget *cache_overview(cache_c
333    }    }
334    
335    gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox);    gtk_box_pack_start_defaults(GTK_BOX(ihbox), colbox);
336      gtk_box_pack_start_defaults(GTK_BOX(pbox), ihbox);
337    
338    /* ----------------------------------------------------- */    /* ----------------------------------------------------- */
339    
340    gtk_box_pack_start(GTK_BOX(vbox), ihbox, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(vbox), pbox, FALSE, FALSE, 0);
341    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);
342    
343    /* ----------------------------------------------------- */    /* ----------------------------------------------------- */
344    
345      if(cache->attribute) {
346        GtkWidget *thbox = gtk_hbox_new(FALSE, 0);
347        ihbox = gtk_hbox_new(FALSE, 0);
348    
349        attribute_t *att = cache->attribute;
350        while(att) {
351          if(att->inc)
352            tip = icon_get_widget(ICON_ATT, att->id+1);
353          else
354            tip = icon_get_widget_ovl(ICON_ATT, att->id+1, 0);
355    
356          gtk_box_pack_start(GTK_BOX(ihbox), tip, FALSE, FALSE, 4);
357    
358    #ifndef USE_MAEMO
359          gtk_tooltips_set_tip(tips, tip, _(att->name), NULL);
360    #endif
361    
362          att = att->next;
363        }
364    
365        gtk_box_pack_start(GTK_BOX(thbox), ihbox, TRUE, FALSE, 0);
366        gtk_box_pack_start(GTK_BOX(vbox), thbox, FALSE, FALSE, 0);
367        gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
368      }
369    
370      /* ----------------------------------------------------- */
371    
372    if(cache->short_description)    if(cache->short_description)
373      gtk_box_pack_start_defaults(GTK_BOX(vbox),      gtk_box_pack_start_defaults(GTK_BOX(vbox),
374          html_view(appdata, cache->short_description,          html_view(appdata, cache->short_description,
# Line 575  static void on_gclink_clicked(GtkButton Line 611  static void on_gclink_clicked(GtkButton
611    char *url = g_strdup_printf("http://www.geocaching.com/seek/log.aspx?wp=%s", context->cache->id);    char *url = g_strdup_printf("http://www.geocaching.com/seek/log.aspx?wp=%s", context->cache->id);
612    browser_url(context->appdata, url);    browser_url(context->appdata, url);
613    g_free(url);    g_free(url);
614    
615      notes_logged(context);
616  }  }
617  #endif  #endif
618    
# Line 601  static GtkWidget *cache_logs(appdata_t * Line 639  static GtkWidget *cache_logs(appdata_t *
639    if(gc_link) {    if(gc_link) {
640      GtkWidget *but =      GtkWidget *but =
641        gtk_button_new_with_label(_("Post a new log entry for this geocache"));        gtk_button_new_with_label(_("Post a new log entry for this geocache"));
 #if 0  
     gtk_button_set_image(GTK_BUTTON(but),  
         gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON));  
     gtk_button_set_image_position(GTK_BUTTON(but), GTK_POS_LEFT);  
 #endif  
642  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
643    hildon_gtk_widget_set_theme_size(but,    hildon_gtk_widget_set_theme_size(but,
644             (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));             (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
# Line 640  static GtkWidget *cache_logs(appdata_t * Line 673  static GtkWidget *cache_logs(appdata_t *
673                     (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));                     (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
674  #endif  #endif
675    
676        gtk_label_set_ellipsize(GTK_LABEL(gtk_bin_get_child(GTK_BIN(finder))),      gtk_label_set_ellipsize(GTK_LABEL(gtk_bin_get_child(GTK_BIN(finder))),
677                                PANGO_ELLIPSIZE_END);                                PANGO_ELLIPSIZE_END);
678      } else      } else
679        gtk_label_set_ellipsize(GTK_LABEL(finder), PANGO_ELLIPSIZE_END);        gtk_label_set_ellipsize(GTK_LABEL(finder), PANGO_ELLIPSIZE_END);
# Line 731  static void on_notebook_page_change(GtkN Line 764  static void on_notebook_page_change(GtkN
764    /* seems to work ... */    /* seems to work ... */
765    if(strcasecmp(name, _("Logs")) == 0) {    if(strcasecmp(name, _("Logs")) == 0) {
766      gtk_widget_queue_resize(w);      gtk_widget_queue_resize(w);
   } else if(strcasecmp(name, _("TBs")) == 0) {  
     gtk_widget_queue_resize(w);  
767    } else if(strcasecmp(name, _("Goto")) == 0) {    } else if(strcasecmp(name, _("Goto")) == 0) {
768  #ifdef USE_MAEMO  #ifdef USE_MAEMO
769      context->handler_id = gtk_timeout_add(1000, screensaver_update,      context->handler_id = gtk_timeout_add(1000, screensaver_update,
770                                            context->appdata);                                            context->appdata);
771  #endif  #endif
772    
773      goto_coordinate_update(context);      goto_coordinate_update(context);
774    }    }
775    
# Line 767  static void on_notebook_destroy(GtkWidge Line 799  static void on_notebook_destroy(GtkWidge
799      gtk_timeout_remove(context->handler_id);      gtk_timeout_remove(context->handler_id);
800  #endif  #endif
801    
802    free(user_data);  #ifdef USE_STACKABLE_WINDOW
803  }    if(context->notes_have_been_changed) {
804        printf("notes changed -> cachelist redraw\n");
 #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)  
 #define CUSTOM_NOTEBOOK  
 #endif  
   
 static GtkWidget *notebook_new(void) {  
 #ifdef CUSTOM_NOTEBOOK  
   GtkWidget *vbox = gtk_vbox_new(FALSE, 0);  
   
   GtkWidget *notebook =  gtk_notebook_new();  
   
   /* prevents user from accidentially touching the breadcrumb trail */  
   /* (looks ugly on fremantle as it isn't themed) */  
   //  gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM);  
   
   /* solution for fremantle: we use a row of ordinary buttons instead */  
   /* of regular tabs */  
   
   /* hide the regular tabs */  
   gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);  
   
   gtk_box_pack_start_defaults(GTK_BOX(vbox), notebook);  
   
   /* store a reference to the notebook in the vbox */  
   g_object_set_data(G_OBJECT(vbox), "notebook", (gpointer)notebook);  
   
   /* create a hbox for the buttons */  
   GtkWidget *hbox = gtk_hbox_new(TRUE, 0);  
   gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);  
   g_object_set_data(G_OBJECT(vbox), "hbox", (gpointer)hbox);  
   
   return vbox;  
 #else  
   return gtk_notebook_new();  
 #endif  
 }  
   
 #ifdef CUSTOM_NOTEBOOK  
 static void on_notebook_button_clicked(GtkWidget *button, gpointer data) {  
   GtkNotebook *nb =  
     GTK_NOTEBOOK(g_object_get_data(G_OBJECT(data), "notebook"));  
   
   gint page = (gint)g_object_get_data(G_OBJECT(button), "page");  
   gtk_notebook_set_current_page(nb, page);  
 }  
 #endif  
   
 static void notebook_append_page(GtkWidget *notebook,  
                                  GtkWidget *page, char *label) {  
 #ifdef CUSTOM_NOTEBOOK  
   GtkNotebook *nb =  
     GTK_NOTEBOOK(g_object_get_data(G_OBJECT(notebook), "notebook"));  
   
   gint page_num = gtk_notebook_append_page(nb, page, gtk_label_new(label));  
   GtkWidget *button = NULL;  
805    
806    /* select button for page 0 by default */      /* now the cachelist is visible again. so redraw it since it may */
807    if(!page_num) {      /* have changed */
808      button = gtk_radio_button_new_with_label(NULL, label);      cachelist_redraw(context->appdata);
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);  
     g_object_set_data(G_OBJECT(notebook), "group_master", (gpointer)button);  
   } else {  
     GtkWidget *master = g_object_get_data(G_OBJECT(notebook), "group_master");  
     button = gtk_radio_button_new_with_label_from_widget(  
                                  GTK_RADIO_BUTTON(master), label);  
809    }    }
   
   gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE);  
   g_object_set_data(G_OBJECT(button), "page", (gpointer)page_num);  
   
   gtk_signal_connect(GTK_OBJECT(button), "clicked",  
            GTK_SIGNAL_FUNC(on_notebook_button_clicked), notebook);  
   
 #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)  
   hildon_gtk_widget_set_theme_size(button,  
            (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));  
 #endif  
   
   gtk_box_pack_start_defaults(  
      GTK_BOX(g_object_get_data(G_OBJECT(notebook), "hbox")),  
      button);  
   
 #else  
   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, gtk_label_new(label));  
810  #endif  #endif
811    
812      printf("freeing cache context\n");
813      context->appdata->cache_context = NULL;
814      g_free(context);
815  }  }
816    
817  static GObject *notebook_object(GtkWidget *notebook) {  static GObject *notebook_object(GtkWidget *notebook) {
818  #ifdef CUSTOM_NOTEBOOK    return G_OBJECT(notebook_get_gtk_notebook(notebook));
   return G_OBJECT(g_object_get_data(G_OBJECT(notebook), "notebook"));  
 #else  
   return G_OBJECT(notebook);  
 #endif  
819  }  }
820    
821  GtkWidget *cache_view(appdata_t *appdata, cache_t *cache) {  GtkWidget *cache_view(appdata_t *appdata, cache_t *cache) {
822    GtkWidget *notebook;    GtkWidget *notebook;
823    
824    cache_context_t *cache_context = malloc(sizeof(cache_context_t));    cache_context_t *cache_context = g_new0(cache_context_t, 1);
825    memset(cache_context, 0, sizeof(cache_context_t));    appdata->cache_context = cache_context;
826    cache_context->appdata = appdata;    cache_context->appdata = appdata;
827    cache_context->cache = cache;    cache_context->cache = cache;
828    
# Line 893  GtkWidget *cache_view(appdata_t *appdata Line 847  GtkWidget *cache_view(appdata_t *appdata
847      notebook_append_page(notebook,      notebook_append_page(notebook,
848             cache_hint(appdata, cache), _("Hint"));             cache_hint(appdata, cache), _("Hint"));
849    
850    if(cache->log)    // always display log page to allow user to post a new log
851      if(cache->log
852    #ifdef ENABLE_BROWSER_INTERFACE
853         || (strncmp(cache->id, "GC", 2) == 0)
854    #endif
855         )
856      notebook_append_page(notebook,      notebook_append_page(notebook,
857       cache_logs(appdata, cache_context, cache->log, cache->logs_are_html),       cache_logs(appdata, cache_context, cache->log, cache->logs_are_html),
858             _("Logs"));             _("Logs"));
# Line 906  GtkWidget *cache_view(appdata_t *appdata Line 865  GtkWidget *cache_view(appdata_t *appdata
865      notebook_append_page(notebook,      notebook_append_page(notebook,
866               cache_tbs(appdata, cache->tb), _("TBs"));               cache_tbs(appdata, cache->tb), _("TBs"));
867    
868    notebook_append_page(notebook,    /* the demo caches don't have coordinates, so avoid */
869             cache_notes(cache_context), _("Notes"));    /* having to deal with them */
870      if(!isnan(cache->pos.lat) && !isnan(cache->pos.lon)) {
871        notebook_append_page(notebook,
872                             cache_notes(cache_context), _("Notes"));
873    
874    notebook_append_page(notebook,      notebook_append_page(notebook,
875             goto_cache(cache_context), _("Goto"));                           goto_cache(cache_context), _("Goto"));
876      }
877    
878    g_signal_connect(notebook_object(notebook), "switch-page",    g_signal_connect(notebook_object(notebook), "switch-page",
879             G_CALLBACK(on_notebook_page_change), cache_context);             G_CALLBACK(on_notebook_page_change), cache_context);
# Line 943  void cache_dialog(appdata_t *appdata, ca Line 906  void cache_dialog(appdata_t *appdata, ca
906    
907  #else  #else
908  #ifdef USE_STACKABLE_WINDOW  #ifdef USE_STACKABLE_WINDOW
909    
910    #if !defined(__i386__)
911    /* get access to zoom buttons */
912    static void
913    on_window_realize(GtkWidget *widget, gpointer data) {
914      if (widget->window) {
915        unsigned char value = 1;
916        Atom hildon_zoom_key_atom =
917          gdk_x11_get_xatom_by_name("_HILDON_ZOOM_KEY_ATOM"),
918          integer_atom = gdk_x11_get_xatom_by_name("INTEGER");
919        Display *dpy =
920          GDK_DISPLAY_XDISPLAY(gdk_drawable_get_display(widget->window));
921        Window w = GDK_WINDOW_XID(widget->window);
922    
923        XChangeProperty(dpy, w, hildon_zoom_key_atom,
924                        integer_atom, 8, PropModeReplace, &value, 1);
925      }
926    }
927    #endif
928    
929  static void on_cache_destroy (GtkWidget *widget, appdata_t *appdata) {  static void on_cache_destroy (GtkWidget *widget, appdata_t *appdata) {
930    appdata->cur_cache = NULL;    appdata->cur_cache = NULL;
931    
932      HildonWindowStack *stack = hildon_window_stack_get_default();
933      appdata->window = HILDON_WINDOW(hildon_window_stack_peek(stack));
934    
935    /* restore cur_view */    /* restore cur_view */
936    appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");    appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");
937  }  }
938    
939  void cache_dialog(appdata_t *appdata, cache_t *cache) {  void cache_dialog(appdata_t *appdata, cache_t *cache) {
940    GtkWidget *window = hildon_stackable_window_new();    GtkWidget *window = hildon_stackable_window_new();
941      appdata->window = HILDON_WINDOW(window);
942    
943    #if !defined(__i386__)
944      g_signal_connect(G_OBJECT(appdata->window), "realize",
945                       G_CALLBACK(on_window_realize), NULL);
946    #endif
947    
948      g_signal_connect(G_OBJECT(appdata->window), "key_press_event",
949                       G_CALLBACK(on_window_key_press), appdata);
950    
951    /* store last "cur_view" in window */    /* store last "cur_view" in window */
952    g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view);    g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view);
953    
954    appdata->cur_cache = cache;    appdata->cur_cache = cache;
955    char *title = g_strdup_printf("%s - GPXView", cache->name);    gtk_window_set_title(GTK_WINDOW(window), cache->name);
956    gtk_window_set_title(GTK_WINDOW(window), title);  
957    g_free(title);    /* make sure window can control gps */
958      g_signal_connect(G_OBJECT(window), "focus-in-event",
959                       G_CALLBACK(on_main_focus_change), appdata);
960    
961      g_signal_connect(G_OBJECT(window), "focus-out-event",
962                       G_CALLBACK(on_main_focus_change), appdata);
963    
964    /* create cache visualization widget */    /* create cache visualization widget */
965    appdata->cur_view = cache_view(appdata, cache);    appdata->cur_view = cache_view(appdata, cache);

Legend:
Removed from v.199  
changed lines
  Added in v.303