aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2008-05-27 02:22:14 +0000
committerChristian Grothoff <christian@grothoff.org>2008-05-27 02:22:14 +0000
commit3e6dd769be73e1110935ec7400388d16ded16693 (patch)
tree6d55a31531d1ab40f1fd80a4d746a6c128515f16
parent77a59adc55f943d9b5d54be01540a035831017a8 (diff)
downloadgnunet-gtk-3e6dd769be73e1110935ec7400388d16ded16693.tar.gz
gnunet-gtk-3e6dd769be73e1110935ec7400388d16ded16693.zip
fixing warning; towards visualizing rankings
-rw-r--r--src/plugins/fs/search.c87
1 files changed, 57 insertions, 30 deletions
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c
index d0f8e7ca..c21a97a5 100644
--- a/src/plugins/fs/search.c
+++ b/src/plugins/fs/search.c
@@ -235,9 +235,18 @@ void fs_search_update (SearchList * searchContext,
235 (GNUNET_ECRS_uri_test_equal (have, info->uri)) ) 235 (GNUNET_ECRS_uri_test_equal (have, info->uri)) )
236 { 236 {
237 /* gotcha, create pixbuf and rank info! */ 237 /* gotcha, create pixbuf and rank info! */
238 rank = (applicability_rank << 30) + (availability_rank * availability_certainty); 238 if (availability_rank < 0)
239#define P_HEIGHT 11 239 rank = applicability_rank - (((-availability_rank) * availability_certainty) << 16);
240#define P_WIDTH 10 240 else
241 rank = applicability_rank + ((availability_rank * availability_certainty) << 16);
242 if (rank > 1000000)
243 fprintf(stderr,
244 "RANK: %llu from %d %u %u\n", rank,
245 applicability_rank,
246 availability_rank,
247 availability_certainty);
248#define P_HEIGHT 21
249#define P_WIDTH 100
241 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, 250 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
242 TRUE, /* alpha */ 251 TRUE, /* alpha */
243 8, /* bits per sample */ 252 8, /* bits per sample */
@@ -255,31 +264,26 @@ void fs_search_update (SearchList * searchContext,
255#define PX_GREEN 1 264#define PX_GREEN 1
256#define PX_BLUE 2 265#define PX_BLUE 2
257#define PX_ALPHA 3 266#define PX_ALPHA 3
267 pixel[PX_RED] = 0;
268 pixel[PX_GREEN] = 0;
269 pixel[PX_BLUE] = 0;
270 pixel[PX_ALPHA] = 0;
258 if (y < P_HEIGHT / 2) 271 if (y < P_HEIGHT / 2)
259 { 272 {
260 /* applicability */ 273 /* applicability */
261 if (x * kwords < applicability_rank * P_WIDTH) 274 if (x * kwords < applicability_rank * P_WIDTH)
262 { 275 {
263 pixel[PX_RED] = 0; 276 pixel[PX_RED] = 0;
264 pixel[PX_GREEN] = 255;
265 pixel[PX_BLUE] = 0;
266 pixel[PX_ALPHA] = 0;
267 }
268 else
269 {
270 pixel[PX_RED] = 0;
271 pixel[PX_GREEN] = 0; 277 pixel[PX_GREEN] = 0;
272 pixel[PX_BLUE] = 0; 278 pixel[PX_BLUE] = 255;
273 pixel[PX_ALPHA] = 255; 279 pixel[PX_ALPHA] = 255;
274 } 280 }
275 } 281 }
276 else if (y > P_HEIGHT / 2) 282 else if ( (y > P_HEIGHT / 2) &&
283 ( (y-P_HEIGHT/2) * GNUNET_FSUI_MAX_PROBES
284 < availability_certainty * P_HEIGHT / 2) )
277 { 285 {
278 /* availability */ 286 /* availability */
279 pixel[PX_RED] = 0;
280 pixel[PX_GREEN] = 0;
281 pixel[PX_BLUE] = 0;
282 pixel[PX_ALPHA] = 255;
283 if (availability_rank < 0) 287 if (availability_rank < 0)
284 { 288 {
285 if ( (x * GNUNET_FSUI_MAX_PROBES > -availability_rank * P_WIDTH/2) && 289 if ( (x * GNUNET_FSUI_MAX_PROBES > -availability_rank * P_WIDTH/2) &&
@@ -288,18 +292,18 @@ void fs_search_update (SearchList * searchContext,
288 pixel[PX_RED] = 255; 292 pixel[PX_RED] = 255;
289 pixel[PX_GREEN] = 0; 293 pixel[PX_GREEN] = 0;
290 pixel[PX_BLUE] = 0; 294 pixel[PX_BLUE] = 0;
291 pixel[PX_ALPHA] = 0; 295 pixel[PX_ALPHA] = 255;
292 } 296 }
293 } 297 }
294 else if (availability_rank > 0) 298 else if (availability_rank > 0)
295 { 299 {
296 if ( (x - (P_WIDTH/2) * GNUNET_FSUI_MAX_PROBES < availability_rank * P_WIDTH/2) && 300 if ( (x >= P_WIDTH/2) &&
297 (x >= P_WIDTH/2) ) 301 ( (x - (P_WIDTH/2)) * GNUNET_FSUI_MAX_PROBES < availability_rank * P_WIDTH/2) )
298 { 302 {
299 pixel[PX_RED] = 0; 303 pixel[PX_RED] = 0;
300 pixel[PX_GREEN] = 255; 304 pixel[PX_GREEN] = 255;
301 pixel[PX_BLUE] = 0; 305 pixel[PX_BLUE] = 0;
302 pixel[PX_ALPHA] = 0; 306 pixel[PX_ALPHA] = 255;
303 } 307 }
304 } 308 }
305 else 309 else
@@ -310,18 +314,10 @@ void fs_search_update (SearchList * searchContext,
310 pixel[PX_RED] = 255; 314 pixel[PX_RED] = 255;
311 pixel[PX_GREEN] = 255; 315 pixel[PX_GREEN] = 255;
312 pixel[PX_BLUE] = 0; 316 pixel[PX_BLUE] = 0;
313 pixel[PX_ALPHA] = 0; 317 pixel[PX_ALPHA] = 255;
314 } 318 }
315 } 319 }
316 } 320 }
317 else
318 {
319 /* 1px separator bar */
320 pixel[PX_RED] = 0;
321 pixel[PX_GREEN] = 0;
322 pixel[PX_BLUE] = 0;
323 pixel[PX_ALPHA] = 255;
324 }
325 } 321 }
326 322
327 gtk_tree_store_set(searchContext->tree, 323 gtk_tree_store_set(searchContext->tree,
@@ -692,6 +688,37 @@ fs_search_started (struct GNUNET_FSUI_SearchList * fsui_list,
692 gtk_tree_view_column_set_sort_column_id (column, SEARCH_MIME); 688 gtk_tree_view_column_set_sort_column_id (column, SEARCH_MIME);
693 689
694 690
691
692 renderer = gtk_cell_renderer_text_new ();
693 gtk_tree_view_insert_column_with_attributes (list->treeview,
694 -1,
695 _("Availability"),
696 renderer,
697 "text", SEARCH_AVAILABILITY_RANK,
698 NULL);
699 renderer = gtk_cell_renderer_text_new ();
700 gtk_tree_view_insert_column_with_attributes (list->treeview,
701 -1,
702 _("Certainty"),
703 renderer,
704 "text", SEARCH_AVAILABILITY_CERTAINTY,
705 NULL);
706 renderer = gtk_cell_renderer_text_new ();
707 gtk_tree_view_insert_column_with_attributes (list->treeview,
708 -1,
709 _("Applicability"),
710 renderer,
711 "text", SEARCH_APPLICABILITY_RANK,
712 NULL);
713 renderer = gtk_cell_renderer_text_new ();
714 gtk_tree_view_insert_column_with_attributes (list->treeview,
715 -1,
716 _("Sort"),
717 renderer,
718 "text", SEARCH_RANK_SORT,
719 NULL);
720
721
695 renderer = gtk_cell_renderer_pixbuf_new (); 722 renderer = gtk_cell_renderer_pixbuf_new ();
696 col = gtk_tree_view_insert_column_with_attributes (list->treeview, 723 col = gtk_tree_view_insert_column_with_attributes (list->treeview,
697 -1, 724 -1,