Diff of /trunk/src/cache.c

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

revision 165 by harbaum, Sun Nov 8 20:32:55 2009 UTC revision 180 by harbaum, Fri Nov 13 12:11:00 2009 UTC
# Line 19  Line 19 
19    
20  #include "gpxview.h"  #include "gpxview.h"
21  #include <math.h>  #include <math.h>
22    #include <string.h>
23    
24  static GtkWidget *cache_description(appdata_t *appdata, cache_t *cache) {  static GtkWidget *cache_description(appdata_t *appdata, cache_t *cache) {
25    return html_view(appdata, cache->long_description,    return html_view(appdata, cache->long_description,
# Line 178  static GtkWidget *cache_overview(cache_c Line 179  static GtkWidget *cache_overview(cache_c
179    
180    if(cache->type != CACHE_TYPE_UNKNOWN) {    if(cache->type != CACHE_TYPE_UNKNOWN) {
181      gtk_table_attach(GTK_TABLE(table),      gtk_table_attach(GTK_TABLE(table),
182               tip = icon_get_widget(ICON_CACHE_TYPE, cache->type), 0,1,0,1,  
183               GTK_FILL, 0, GTK_FILL, 0);  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
184                 tip = icon_get_widget(ICON_CACHE_TYPE_2X, cache->type),
185    #else
186                 tip = icon_get_widget(ICON_CACHE_TYPE_1_5X, cache->type),
187    #endif
188                         0,1,0,1, GTK_FILL, 0, GTK_FILL, 0);
189    
190  #ifndef USE_MAEMO  #ifndef USE_MAEMO
191      gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL);      gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL);
192  #endif  #endif
# Line 263  static GtkWidget *cache_overview(cache_c Line 270  static GtkWidget *cache_overview(cache_c
270    }    }
271    
272    /* --------------------- GCVote ------------------------ */    /* --------------------- GCVote ------------------------ */
273      if(!appdata->disable_gcvote) {
274    vote_t *vote = gcvote_restore(appdata, cache);      vote_t *vote = gcvote_restore(appdata, cache);
275    
276        context->gcvote_request =
277          gcvote_request(appdata, gcvote_callback, cache->url, context);
278    
279    context->gcvote_request =      context->votebox = gtk_vbox_new(FALSE, 0);
280      gcvote_request(appdata, gcvote_callback, cache->url, context);      GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
281        gtk_container_add(GTK_CONTAINER(align), context->votebox);
282        gtk_box_pack_start_defaults(GTK_BOX(ratebox), align);
283    
284    context->votebox = gtk_vbox_new(FALSE, 0);      /* fill with vote if present on disk (will also free vote) */
285    GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);      if(vote)
286    gtk_container_add(GTK_CONTAINER(align), context->votebox);        gcvote_set(context, vote);
287    gtk_box_pack_start_defaults(GTK_BOX(ratebox), align);    }
   
   /* fill with vote if present on disk (will also free vote) */  
   if(vote)  
     gcvote_set(context, vote);  
288    
289    gtk_table_attach_defaults(GTK_TABLE(table), ratebox, 2,3,0,2);    gtk_table_attach_defaults(GTK_TABLE(table), ratebox, 2,3,0,2);
290    
# Line 507  static GtkWidget *cache_tbs(appdata_t *a Line 515  static GtkWidget *cache_tbs(appdata_t *a
515      static const char *tb_type = "track/details.aspx";      static const char *tb_type = "track/details.aspx";
516    
517      /* --------------------- icon/ref/name -------------------------*/      /* --------------------- icon/ref/name -------------------------*/
518      gtk_table_attach_defaults(GTK_TABLE(table), icon_get_widget(ICON_TB, 0),      GtkWidget *icon = NULL;
519                                0, 1, tb_row+0, tb_row+1);      if((strcasestr(tb->name, "coin") != 0) ||
520           (strcasestr(tb->name, "muenze") != 0) ||
521           (strcasestr(tb->name, "münze") != 0))
522          icon = icon_get_widget(ICON_TB, 1);   /* coin icon */
523        else
524          icon = icon_get_widget(ICON_TB, 0);   /* tb icon */
525    
526        gtk_table_attach_defaults(GTK_TABLE(table), icon,
527                                  0, 1, tb_row+0, tb_row+1);
528    
529      if(tb->ref) {      if(tb->ref) {
530        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 774  static GtkWidget *notebook_new(void) { Line 789  static GtkWidget *notebook_new(void) {
789  #endif  #endif
790  }  }
791    
792    #ifdef CUSTOM_NOTEBOOK
793  static void on_notebook_button_clicked(GtkWidget *button, gpointer data) {  static void on_notebook_button_clicked(GtkWidget *button, gpointer data) {
794    GtkNotebook *nb =    GtkNotebook *nb =
795      GTK_NOTEBOOK(g_object_get_data(G_OBJECT(data), "notebook"));      GTK_NOTEBOOK(g_object_get_data(G_OBJECT(data), "notebook"));
796    
797    /* get previously selected page */    gint page = (gint)g_object_get_data(G_OBJECT(button), "page");
   gint page = gtk_notebook_get_current_page(nb);  
   char *id_str = g_strdup_printf("button_%d", page);  
   gtk_toggle_button_set_active(  
      GTK_TOGGLE_BUTTON(g_object_get_data(G_OBJECT(data), id_str)), FALSE);  
   g_free(id_str);  
   
   page = (gint)g_object_get_data(G_OBJECT(button), "page");  
798    gtk_notebook_set_current_page(nb, page);    gtk_notebook_set_current_page(nb, page);
   
  //  gtk_widget_set_state(button, GTK_STATE_ACTIVE);   // or: SELECTED, ACTIVE  
  //  gtk_widget_show_all(button);  
799  }  }
800    #endif
801    
802  static void notebook_append_page(GtkWidget *notebook,  static void notebook_append_page(GtkWidget *notebook,
803                                   GtkWidget *page, char *label) {                                   GtkWidget *page, char *label) {
# Line 800  static void notebook_append_page(GtkWidg Line 806  static void notebook_append_page(GtkWidg
806      GTK_NOTEBOOK(g_object_get_data(G_OBJECT(notebook), "notebook"));      GTK_NOTEBOOK(g_object_get_data(G_OBJECT(notebook), "notebook"));
807    
808    gint page_num = gtk_notebook_append_page(nb, page, gtk_label_new(label));    gint page_num = gtk_notebook_append_page(nb, page, gtk_label_new(label));
809      GtkWidget *button = NULL;
   GtkWidget *button = gtk_toggle_button_new_with_label(label);  
   g_object_set_data(G_OBJECT(button), "page", (gpointer)page_num);  
810    
811    /* select button for page 0 by default */    /* select button for page 0 by default */
812    if(!page_num)    if(!page_num) {
813        button = gtk_radio_button_new_with_label(NULL, label);
814      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
815        g_object_set_data(G_OBJECT(notebook), "group_master", (gpointer)button);
816      } else {
817        GtkWidget *master = g_object_get_data(G_OBJECT(notebook), "group_master");
818        button = gtk_radio_button_new_with_label_from_widget(
819                                     GTK_RADIO_BUTTON(master), label);
820      }
821    
822      gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE);
823      g_object_set_data(G_OBJECT(button), "page", (gpointer)page_num);
824    
825    gtk_signal_connect(GTK_OBJECT(button), "clicked",    gtk_signal_connect(GTK_OBJECT(button), "clicked",
826             GTK_SIGNAL_FUNC(on_notebook_button_clicked), notebook);             GTK_SIGNAL_FUNC(on_notebook_button_clicked), notebook);
827    
   g_object_set_data(G_OBJECT(button), "page", (gpointer)page_num);  
   
828  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
829    hildon_gtk_widget_set_theme_size(button,    hildon_gtk_widget_set_theme_size(button,
830             (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));             (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
831  #endif  #endif
832    
   char *id_str = g_strdup_printf("button_%d", page_num);  
   g_object_set_data(G_OBJECT(notebook), id_str, (gpointer)button);  
   g_free(id_str);  
   
833    gtk_box_pack_start_defaults(    gtk_box_pack_start_defaults(
834       GTK_BOX(g_object_get_data(G_OBJECT(notebook), "hbox")),       GTK_BOX(g_object_get_data(G_OBJECT(notebook), "hbox")),
835       button);       button);

Legend:
Removed from v.165  
changed lines
  Added in v.180