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 158 by harbaum, Wed Nov 4 14:54:52 2009 UTC
# Line 100  void overview_coordinate_update(cache_co Line 100  void overview_coordinate_update(cache_co
100    gtk_widget_show_all(context->bearing_hbox);    gtk_widget_show_all(context->bearing_hbox);
101  }  }
102    
103    static void gcvote_callback(vote_t *vote, gpointer data) {
104      cache_context_t *context = (cache_context_t*)data;
105    
106      /* no vote returned: request failed, just cleanup */
107      if(!vote) {
108        printf("gcvote callback for failed request\n");
109    
110        gcvote_request_free(context->gcvote_request);
111        context->gcvote_request = NULL;
112        return FALSE;
113      }
114    
115      printf("gcvote callback is being called with a %d/%d\n",
116             vote->quality, vote->votes);
117    
118      /* update/draw the voting */
119      if(!context->quality) {
120    #ifndef USE_MAEMO
121        GtkTooltips *tips = gtk_tooltips_new();
122    #endif
123    
124        GtkWidget *ivbox = gtk_vbox_new(FALSE, 0);
125    
126        char *votes_str = g_strdup_printf(_("Quality (%d %s):"), vote->votes,
127                                          (vote->votes == 1)?_("vote"):_("votes"));
128        context->votes = GTK_LABEL_SMALL(votes_str);
129        gtk_box_pack_start(GTK_BOX(ivbox), context->votes, FALSE, FALSE, 0);
130        g_free(votes_str);
131        context->quality = icon_get_widget(ICON_STARS, (int)(vote->quality*2-2));
132        gtk_box_pack_start(GTK_BOX(ivbox), context->quality,
133                                   FALSE, FALSE, 0);
134    
135        GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
136        gtk_container_add(GTK_CONTAINER(align), ivbox);
137        gtk_box_pack_start_defaults(GTK_BOX(context->ratebox), align);
138    #ifndef USE_MAEMO
139        char *str = g_strdup_printf(_("Quality: %d"), vote->quality);
140        gtk_tooltips_set_tip(tips, ivbox, str, NULL);
141        g_free(str);
142    #endif
143    
144        gtk_widget_show_all(context->ratebox);
145    
146        gcvote_request_free(context->gcvote_request);
147        context->gcvote_request = NULL;
148      }
149    }
150    
151  static GtkWidget *cache_overview(cache_context_t *context) {  static GtkWidget *cache_overview(cache_context_t *context) {
152    GtkWidget *vbox, *ivbox;    GtkWidget *vbox, *ivbox;
153    GtkWidget *table, *tip;    GtkWidget *table, *tip;
# Line 162  static GtkWidget *cache_overview(cache_c Line 210  static GtkWidget *cache_overview(cache_c
210    }    }
211    
212    /* ----------- vbox containing all ratings ---------- */    /* ----------- vbox containing all ratings ---------- */
213    GtkWidget *ratebox = gtk_vbox_new(FALSE, 0);    GtkWidget *ratebox = context->ratebox = gtk_vbox_new(FALSE, 0);
214    
215    /* ----------- box containing difficulty rating ---------- */    /* ----------- box containing difficulty rating ---------- */
216    if(cache->difficulty != 0) {    if(cache->difficulty != 0) {
# Line 201  static GtkWidget *cache_overview(cache_c Line 249  static GtkWidget *cache_overview(cache_c
249    }    }
250    
251    /* --------------------- GCVote ------------------------ */    /* --------------------- GCVote ------------------------ */
252    if(1) {    /* gcvote if present and possible */
253      float quality = 2.5;  
254      int votes = 2;    context->gcvote_request =
255        gcvote_request(appdata, gcvote_callback, cache->url, context);
256    
257    #if 0
258      vote_t *vote = gcvote_get(appdata, cache->url);
259      if(vote) {
260      ivbox = gtk_vbox_new(FALSE, 0);      ivbox = gtk_vbox_new(FALSE, 0);
261    
262      char *votes_str = g_strdup_printf(_("Quality (%d votes):"), votes);      char *votes_str = g_strdup_printf(_("Quality (%d %s):"), vote->votes,
263                                          (vote->votes == 1)?_("vote"):_("votes"));
264      gtk_box_pack_start(GTK_BOX(ivbox), GTK_LABEL_SMALL(votes_str),      gtk_box_pack_start(GTK_BOX(ivbox), GTK_LABEL_SMALL(votes_str),
265                         FALSE, FALSE, 0);                         FALSE, FALSE, 0);
266      g_free(votes_str);      g_free(votes_str);
267      gtk_box_pack_start(GTK_BOX(ivbox),      gtk_box_pack_start(GTK_BOX(ivbox),
268           icon_get_widget(ICON_STARS, (int)(quality*2-2)), FALSE, FALSE, 0);           icon_get_widget(ICON_STARS, (int)(vote->quality*2-2)), FALSE, FALSE, 0);
269    
270      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);
271      gtk_container_add(GTK_CONTAINER(align), ivbox);      gtk_container_add(GTK_CONTAINER(align), ivbox);
272      gtk_box_pack_start_defaults(GTK_BOX(ratebox), align);      gtk_box_pack_start_defaults(GTK_BOX(ratebox), align);
273  #ifndef USE_MAEMO  #ifndef USE_MAEMO
274      sprintf(str, _("Quality: %.1f"), quality);      sprintf(str, _("Quality: %d"), vote->quality);
275      gtk_tooltips_set_tip(tips, ivbox, str, NULL);      gtk_tooltips_set_tip(tips, ivbox, str, NULL);
276  #endif  #endif
277    
278        gcvote_free(vote);
279    }    }
280    #endif
281    
282    gtk_table_attach_defaults(GTK_TABLE(table), ratebox, 2,3,0,2);    gtk_table_attach_defaults(GTK_TABLE(table), ratebox, 2,3,0,2);
283    
# Line 253  static GtkWidget *cache_overview(cache_c Line 309  static GtkWidget *cache_overview(cache_c
309    gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 3,4,0,2);    gtk_table_attach_defaults(GTK_TABLE(table), ivbox, 3,4,0,2);
310    
311    /* ----------------------------------------------------- */    /* ----------------------------------------------------- */
   /* gcvote if present and possible */  
   
   gcvote_get(appdata, cache->url);  
   
   /* ----------------------------------------------------- */  
312    
313    gtk_box_pack_start(GTK_BOX(vbox), table, 0,0,0);    gtk_box_pack_start(GTK_BOX(vbox), table, 0,0,0);
314    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);

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