Diff of /trunk/src/cache.c

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

revision 166 by harbaum, Sun Nov 8 20:34:22 2009 UTC revision 178 by harbaum, Thu Nov 12 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 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,  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
183               GTK_FILL, 0, GTK_FILL, 0);               tip = icon_get_widget(ICON_CACHE_TYPE_2X, cache->type),
184    #else
185                 tip = icon_get_widget(ICON_CACHE_TYPE_1_5X, cache->type),
186    #endif
187                         0,1,0,1, GTK_FILL, 0, GTK_FILL, 0);
188  #ifndef USE_MAEMO  #ifndef USE_MAEMO
189      gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL);      gtk_tooltips_set_tip(tips, tip, _(cache_type_tip[cache->type]), NULL);
190  #endif  #endif
# Line 263  static GtkWidget *cache_overview(cache_c Line 268  static GtkWidget *cache_overview(cache_c
268    }    }
269    
270    /* --------------------- GCVote ------------------------ */    /* --------------------- GCVote ------------------------ */
271      if(!appdata->disable_gcvote) {
272    vote_t *vote = gcvote_restore(appdata, cache);      vote_t *vote = gcvote_restore(appdata, cache);
273    
274    context->gcvote_request =      context->gcvote_request =
275      gcvote_request(appdata, gcvote_callback, cache->url, context);        gcvote_request(appdata, gcvote_callback, cache->url, context);
276    
277    context->votebox = gtk_vbox_new(FALSE, 0);      context->votebox = gtk_vbox_new(FALSE, 0);
278    GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);      GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
279    gtk_container_add(GTK_CONTAINER(align), context->votebox);      gtk_container_add(GTK_CONTAINER(align), context->votebox);
280    gtk_box_pack_start_defaults(GTK_BOX(ratebox), align);      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);  
281    
282    gtk_table_attach_defaults(GTK_TABLE(table), ratebox, 2,3,0,2);      /* fill with vote if present on disk (will also free vote) */
283        if(vote)
284          gcvote_set(context, vote);
285    
286        gtk_table_attach_defaults(GTK_TABLE(table), ratebox, 2,3,0,2);
287      }
288    
289    /* ----------------------------------------------------- */    /* ----------------------------------------------------- */
290    
# Line 507  static GtkWidget *cache_tbs(appdata_t *a Line 513  static GtkWidget *cache_tbs(appdata_t *a
513      static const char *tb_type = "track/details.aspx";      static const char *tb_type = "track/details.aspx";
514    
515      /* --------------------- icon/ref/name -------------------------*/      /* --------------------- icon/ref/name -------------------------*/
516      gtk_table_attach_defaults(GTK_TABLE(table), icon_get_widget(ICON_TB, 0),      GtkWidget *icon = NULL;
517                                0, 1, tb_row+0, tb_row+1);      if(strcasestr(tb->name, "coin") != 0)
518          icon = icon_get_widget(ICON_TB, 1);   /* coin icon */
519        else
520          icon = icon_get_widget(ICON_TB, 0);   /* tb icon */
521    
522        gtk_table_attach_defaults(GTK_TABLE(table), icon,
523                                  0, 1, tb_row+0, tb_row+1);
524    
525      if(tb->ref) {      if(tb->ref) {
526        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 778  static void on_notebook_button_clicked(G Line 789  static void on_notebook_button_clicked(G
789    GtkNotebook *nb =    GtkNotebook *nb =
790      GTK_NOTEBOOK(g_object_get_data(G_OBJECT(data), "notebook"));      GTK_NOTEBOOK(g_object_get_data(G_OBJECT(data), "notebook"));
791    
792    /* 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");  
793    gtk_notebook_set_current_page(nb, page);    gtk_notebook_set_current_page(nb, page);
794  }  }
795    
# Line 796  static void notebook_append_page(GtkWidg Line 800  static void notebook_append_page(GtkWidg
800      GTK_NOTEBOOK(g_object_get_data(G_OBJECT(notebook), "notebook"));      GTK_NOTEBOOK(g_object_get_data(G_OBJECT(notebook), "notebook"));
801    
802    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));
803      GtkWidget *button = NULL;
   GtkWidget *button = gtk_toggle_button_new_with_label(label);  
   g_object_set_data(G_OBJECT(button), "page", (gpointer)page_num);  
804    
805    /* select button for page 0 by default */    /* select button for page 0 by default */
806    if(!page_num)    if(!page_num) {
807        button = gtk_radio_button_new_with_label(NULL, label);
808      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
809        g_object_set_data(G_OBJECT(notebook), "group_master", (gpointer)button);
810      } else {
811        GtkWidget *master = g_object_get_data(G_OBJECT(notebook), "group_master");
812        button = gtk_radio_button_new_with_label_from_widget(
813                                     GTK_RADIO_BUTTON(master), label);
814      }
815    
816      gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE);
817      g_object_set_data(G_OBJECT(button), "page", (gpointer)page_num);
818    
819    gtk_signal_connect(GTK_OBJECT(button), "clicked",    gtk_signal_connect(GTK_OBJECT(button), "clicked",
820             GTK_SIGNAL_FUNC(on_notebook_button_clicked), notebook);             GTK_SIGNAL_FUNC(on_notebook_button_clicked), notebook);
821    
   g_object_set_data(G_OBJECT(button), "page", (gpointer)page_num);  
   
822  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)  #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
823    hildon_gtk_widget_set_theme_size(button,    hildon_gtk_widget_set_theme_size(button,
824             (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));             (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
825  #endif  #endif
826    
   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);  
   
827    gtk_box_pack_start_defaults(    gtk_box_pack_start_defaults(
828       GTK_BOX(g_object_get_data(G_OBJECT(notebook), "hbox")),       GTK_BOX(g_object_get_data(G_OBJECT(notebook), "hbox")),
829       button);       button);

Legend:
Removed from v.166  
changed lines
  Added in v.178