gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r6899 - in gnunet-gtk: . src/plugins/fs


From: gnunet
Subject: [GNUnet-SVN] r6899 - in gnunet-gtk: . src/plugins/fs
Date: Mon, 26 May 2008 19:25:55 -0600 (MDT)

Author: grothoff
Date: 2008-05-26 19:25:54 -0600 (Mon, 26 May 2008)
New Revision: 6899

Modified:
   gnunet-gtk/gnunet-gtk.glade
   gnunet-gtk/src/plugins/fs/fs.h
   gnunet-gtk/src/plugins/fs/search.c
Log:
fixing warning; towards visualizing rankings

Modified: gnunet-gtk/gnunet-gtk.glade
===================================================================
--- gnunet-gtk/gnunet-gtk.glade 2008-05-27 00:32:22 UTC (rev 6898)
+++ gnunet-gtk/gnunet-gtk.glade 2008-05-27 01:25:54 UTC (rev 6899)
@@ -3,7 +3,6 @@
 <!--*- mode: xml -*-->
 <glade-interface>
   <widget class="GtkWindow" id="mainWindow">
-    <property name="can_default">True</property>
     <property name="title" translatable="yes">GNUnet, GNU's Peer-to-Peer 
Network</property>
     <property name="default_width">700</property>
     <property name="default_height">500</property>
@@ -39,7 +38,6 @@
                               <widget class="GtkButton" id="aboutButton">
                                 <property name="can_focus">True</property>
                                 <property name="can_default">True</property>
-                                <property name="has_default">True</property>
                                 <property name="tooltip" 
translatable="yes">Show credits</property>
                                 <property name="label">gtk-about</property>
                                 <property name="use_stock">True</property>

Modified: gnunet-gtk/src/plugins/fs/fs.h
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.h      2008-05-27 00:32:22 UTC (rev 6898)
+++ gnunet-gtk/src/plugins/fs/fs.h      2008-05-27 01:25:54 UTC (rev 6899)
@@ -67,6 +67,8 @@
   SEARCH_AVAILABILITY_RANK,
   SEARCH_AVAILABILITY_CERTAINTY,
   SEARCH_APPLICABILITY_RANK,
+  SEARCH_RANK_PIXBUF,
+  SEARCH_RANK_SORT,
   SEARCH_NUM,
 };
 

Modified: gnunet-gtk/src/plugins/fs/search.c
===================================================================
--- gnunet-gtk/src/plugins/fs/search.c  2008-05-27 00:32:22 UTC (rev 6898)
+++ gnunet-gtk/src/plugins/fs/search.c  2008-05-27 01:25:54 UTC (rev 6899)
@@ -211,7 +211,17 @@
   GtkTreeStore *model;
   GtkTreeIter iter;
   struct GNUNET_ECRS_URI *have;
+  GdkPixbuf *pixbuf;
+  guchar * pixels;
+  guchar * pixel;
+  long long rank;
+  int n_channels;
+  int rowstride;
+  unsigned int x;
+  unsigned int y;
+  unsigned int kwords;
 
+  kwords = GNUNET_ECRS_uri_get_keyword_count_from_ksk(searchContext->uri);
   model = GTK_TREE_STORE (gtk_tree_view_get_model (searchContext->treeview));
   /* find existing entry */
   if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
@@ -224,13 +234,105 @@
           if ( (have != NULL) && 
               (GNUNET_ECRS_uri_test_equal (have, info->uri)) )
            {
-             /* gotcha! */
+             /* gotcha, create pixbuf and rank info! */
+             rank = (applicability_rank << 30) + (availability_rank * 
availability_certainty);
+#define P_HEIGHT 11
+#define P_WIDTH 10 
+             pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
+                                     TRUE, /* alpha */
+                                     8, /* bits per sample */
+                                     P_WIDTH, /* width */
+                                     P_HEIGHT /* height */
+                                     );
+             n_channels = gdk_pixbuf_get_n_channels (pixbuf);
+             pixels = gdk_pixbuf_get_pixels(pixbuf);
+             rowstride = gdk_pixbuf_get_rowstride(pixbuf);
+             for (x=0;x<P_WIDTH;x++)
+               for (y=0;y<P_HEIGHT;y++)
+                 {
+                   pixel = pixels + y * rowstride + x * n_channels;
+#define PX_RED 0
+#define PX_GREEN 1
+#define PX_BLUE 2
+#define PX_ALPHA 3
+                   if (y < P_HEIGHT / 2)
+                     {
+                       /* applicability */
+                       if (x * kwords < applicability_rank * P_WIDTH)
+                         {
+                           pixel[PX_RED]   = 0;
+                           pixel[PX_GREEN] = 255;
+                           pixel[PX_BLUE]  = 0;
+                           pixel[PX_ALPHA] = 0;
+                         }
+                       else
+                         {
+                           pixel[PX_RED]   = 0;
+                           pixel[PX_GREEN] = 0;
+                           pixel[PX_BLUE]  = 0;
+                           pixel[PX_ALPHA] = 255;
+                         }
+                     }
+                   else if (y > P_HEIGHT / 2)
+                     {
+                       /* availability */
+                       pixel[PX_RED]   = 0;
+                       pixel[PX_GREEN] = 0;
+                       pixel[PX_BLUE]  = 0;
+                       pixel[PX_ALPHA] = 255;
+                       if (availability_rank < 0)
+                         {
+                           if ( (x * GNUNET_FSUI_MAX_PROBES > 
-availability_rank * P_WIDTH/2) &&
+                                (x <= P_WIDTH/2) )
+                             {
+                               pixel[PX_RED]   = 255;
+                               pixel[PX_GREEN] = 0;
+                               pixel[PX_BLUE]  = 0;
+                               pixel[PX_ALPHA] = 0;
+                             }
+                         }
+                       else if (availability_rank > 0)
+                         {     
+                           if ( (x - (P_WIDTH/2) * GNUNET_FSUI_MAX_PROBES < 
availability_rank * P_WIDTH/2) &&
+                                (x >= P_WIDTH/2) )
+                             {
+                               pixel[PX_RED]   = 0;
+                               pixel[PX_GREEN] = 255;
+                               pixel[PX_BLUE]  = 0;
+                               pixel[PX_ALPHA] = 0;
+                             }
+                         }
+                       else
+                         {
+                           if (x == P_WIDTH / 2)
+                             {
+                               /* yellow */
+                               pixel[PX_RED]   = 255;
+                               pixel[PX_GREEN] = 255;
+                               pixel[PX_BLUE]  = 0;
+                               pixel[PX_ALPHA] = 0;
+                             }
+                         }
+                     }
+                   else
+                     {
+                       /* 1px separator bar */
+                       pixel[PX_RED]   = 0;
+                       pixel[PX_GREEN] = 0;
+                       pixel[PX_BLUE]  = 0;
+                       pixel[PX_ALPHA] = 255;
+                     }
+                 }
+             
              gtk_tree_store_set(searchContext->tree,
                                 &iter,
                                 SEARCH_AVAILABILITY_RANK, availability_rank,
                                 SEARCH_AVAILABILITY_CERTAINTY, 
availability_certainty,
                                 SEARCH_APPLICABILITY_RANK, applicability_rank,
+                                SEARCH_RANK_PIXBUF, pixbuf,
+                                SEARCH_RANK_SORT, rank,
                                 -1);
+             g_object_unref (pixbuf);
              return; /* done! */
            }
         }
@@ -512,7 +614,9 @@
                                    G_TYPE_STRING,       /* status */
                                   G_TYPE_INT,          /* availability rank */
                                   G_TYPE_UINT,         /* availability 
certainty */
-                                  G_TYPE_UINT          /* applicability rank */
+                                  G_TYPE_UINT,         /* applicability rank */
+                                  GDK_TYPE_PIXBUF,     /* ranking 
visualization */
+                                  G_TYPE_INT64         /* numeric sort */
                                   );     
 
   gtk_tree_view_set_model (list->treeview, GTK_TREE_MODEL (list->tree));
@@ -587,6 +691,21 @@
   gtk_tree_view_column_set_reorderable (column, TRUE);
   gtk_tree_view_column_set_sort_column_id (column, SEARCH_MIME);
 
+
+  renderer = gtk_cell_renderer_pixbuf_new ();
+  col = gtk_tree_view_insert_column_with_attributes (list->treeview,
+                                                     -1,
+                                                     _("Ranking"),
+                                                     renderer,
+                                                     "pixbuf", 
SEARCH_RANK_PIXBUF,
+                                                     NULL);
+  column = gtk_tree_view_get_column (list->treeview, col - 1);
+  gtk_tree_view_column_set_resizable (column, FALSE);
+  gtk_tree_view_column_set_clickable (column, TRUE);
+  gtk_tree_view_column_set_reorderable (column, TRUE);
+  gtk_tree_view_column_set_sort_column_id (column, SEARCH_RANK_SORT);
+
+
   if (GNUNET_YES != GNUNET_GC_get_configuration_value_yesno (cfg,
                                                              "GNUNET-GTK",
                                                              
"DISABLE-PREVIEWS",





reply via email to

[Prev in Thread] Current Thread [Next in Thread]