gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r11983 - gnunet-gtk/src


From: gnunet
Subject: [GNUnet-SVN] r11983 - gnunet-gtk/src
Date: Sun, 27 Jun 2010 16:31:53 +0200

Author: grothoff
Date: 2010-06-27 16:31:53 +0200 (Sun, 27 Jun 2010)
New Revision: 11983

Modified:
   gnunet-gtk/src/fs_event_handler.c
   gnunet-gtk/src/fs_event_handler.h
   gnunet-gtk/src/main_window_open_directory.c
Log:
fixes

Modified: gnunet-gtk/src/fs_event_handler.c
===================================================================
--- gnunet-gtk/src/fs_event_handler.c   2010-06-27 14:30:36 UTC (rev 11982)
+++ gnunet-gtk/src/fs_event_handler.c   2010-06-27 14:31:53 UTC (rev 11983)
@@ -28,48 +28,52 @@
 #include "fs_event_handler.h"
 #include <string.h>
 
-
-/**
- * Context we keep for a search tab.
- */
-struct SearchTab
-{
-  struct SearchTab *next;
-  struct SearchTab *prev;
-  struct GNUNET_FS_SearchContext *sc;
-  char *query_txt;
-  GtkBuilder *builder;
-  GtkWidget *frame;
-  GtkWidget *tab_label;
-  GtkWidget *close_button;
-  GtkWidget *clear_button;
-  GtkWidget *play_button;
-  GtkWidget *pause_button;
-  GtkLabel *label;
-  unsigned int num_results;
-};
-
-
 static struct SearchTab *search_tab_head;
 
 static struct SearchTab *search_tab_tail;
 
 struct PublishTab
 {
+  /**
+   * This is a doubly-linked list.
+   */
   struct PublishTab *next;
+
+  /**
+   * This is a doubly-linked list.
+   */
   struct PublishTab *prev;
+
   GtkWidget *frame;
+
   GtkBuilder *builder;
+
+  /**
+   * Associated (top-level) FS publish operation.
+   */
   struct GNUNET_FS_PublishContext *pc;
+
   GtkTreeStore *ts;
 };
 
 
 struct PublishEntry
 {
+  /**
+   * Associated FS publish operation.
+   */
   struct GNUNET_FS_PublishContext *pc;
+
+  /**
+   * Tab storing this entry.
+   */ 
   struct PublishTab *tab;
+
+  /**
+   * Where in the tab is this entry?
+   */ 
   GtkTreeRowReference *rr;
+
   int is_top;
 };
 
@@ -79,9 +83,27 @@
 
 struct SearchResult 
 {
+  /**
+   * Where in the tab is this result?
+   */ 
   GtkTreeRowReference *rr;
+
+  /**
+   * Tab storing this result.
+   */ 
   struct SearchTab *tab;
+
+  /**
+   * Search result for top-level results and
+   * namespace-update results.
+   */
   struct GNUNET_FS_SearchResult *result;
+
+  /**
+   * Parent for results that are not top-level.
+   */
+  struct SearchResult *parent;
+
   /* FIXME: keep download status here? */
 };
 
@@ -89,12 +111,17 @@
 struct DownloadEntry
 {
   struct DownloadEntry *pde;
+
   struct SearchResult *sr;
+
   struct GNUNET_FS_DownloadContext *dc;
+
   struct GNUNET_FS_Uri *uri;
+
   struct GNUNET_CONTAINER_MetaData *meta;
 
   GtkTreeRowReference *rr;
+
   GtkTreeStore *ts;
 };
 
@@ -228,12 +255,15 @@
 {
   GtkTreeIter iter;
   GtkTreePath *path;
+  struct SearchTab *tab;
 
   gtk_tree_row_reference_free (de->rr);
   de->sr = NULL;
-  de->ts = GNUNET_GTK_add_to_uri_tab (&iter,
-                                     de->meta,
-                                     de->uri);
+  tab = GNUNET_GTK_add_to_uri_tab (&iter,
+                                  NULL,
+                                  de->meta,
+                                  de->uri);
+  de->ts = tab->ts;
   path = gtk_tree_model_get_path (GTK_TREE_MODEL (de->ts),
                                  &iter);
   de->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (de->ts),
@@ -278,6 +308,7 @@
   struct DownloadEntry *de;
   GtkTreeIter iter;
   GtkTreePath *path;
+  struct SearchTab *tab;
 
   de = GNUNET_malloc (sizeof (struct DownloadEntry));
   de->pde = pde;
@@ -294,15 +325,15 @@
   else if (sr != NULL)
     {
       de->rr = gtk_tree_row_reference_copy (sr->rr);      
-      de->ts = GTK_TREE_STORE (gtk_builder_get_object (sr->tab->builder,
-                                                      
"GNUNET_GTK_file_sharing_result_tree_store"));
-      
+      de->ts = sr->tab->ts;
     }
   else
     {
-      de->ts = GNUNET_GTK_add_to_uri_tab (&iter,
-                                         meta,
-                                         uri);
+      tab = GNUNET_GTK_add_to_uri_tab (&iter,
+                                      NULL,
+                                      meta,
+                                      uri);
+      de->ts = tab->ts;
       path = gtk_tree_model_get_path (GTK_TREE_MODEL (de->ts),
                                      &iter);
       de->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (de->ts),
@@ -345,7 +376,7 @@
   char *mime;
   struct DownloadContext *dlc;
 
-  GNUNET_assert (tab->sc != NULL);
+  GNUNET_assert (tab != NULL);
   tm = gtk_tree_view_get_model (tree_view);
   if (TRUE != gtk_tree_model_get_iter (tm, &iter, path))
     {
@@ -723,7 +754,8 @@
        tab->query_txt = GNUNET_FS_uri_to_string (query);
     }
   tab->builder = GNUNET_GTK_get_new_builder ("search_tab.glade");
-
+  tab->ts = GTK_TREE_STORE (gtk_builder_get_object (tab->builder,
+                                                   
"GNUNET_GTK_file_sharing_result_tree_store"));
   /* load frame */
   sf = GTK_WINDOW (gtk_builder_get_object (tab->builder,
                                           "_search_result_frame_window"));
@@ -792,22 +824,37 @@
 }
 
 
-static struct SearchResult *
-add_search_result (struct SearchTab *tab,
-                  GtkTreeIter *iter,
-                  void *parent,
-                  const struct GNUNET_FS_Uri *uri,
-                  const struct GNUNET_CONTAINER_MetaData *meta,
-                  struct GNUNET_FS_SearchResult *result,
-                  uint32_t applicability_rank)
+/**
+ * Add a search result to the given search tab.
+ *
+ * @param tab search tab to extend
+ * @param iter set to position where search result is added
+ * @param parent parent entry in search tab
+ * @param uri uri to add
+ * @param meta metadata of the entry
+ * @param result associated FS search result (can be NULL)
+ * @param applicability_rank how relevant is the result
+ * @return entry for the search result
+ */
+struct SearchResult *
+GNUNET_GTK_add_search_result (struct SearchTab *tab,
+                             GtkTreeIter *iter,
+                             struct SearchResult *parent,
+                             const struct GNUNET_FS_Uri *uri,
+                             const struct GNUNET_CONTAINER_MetaData *meta,
+                             struct GNUNET_FS_SearchResult *result,
+                             uint32_t applicability_rank)
 {
   struct SearchResult *sr;
   GtkTreePath *tp;
-  GtkTreeStore *ts;
   char *desc;
   char *mime;
   char *uris;
   GdkPixbuf *pixbuf;
+  GtkTreeIter *pitr;
+  GtkTreeIter pmem;
+  GtkTreePath *path;
+  GtkTreeModel *tm;  
 
   if ( (uri != NULL) &&
        (!GNUNET_FS_uri_test_loc (uri)) &&
@@ -841,13 +888,35 @@
                                                        -1);
   pixbuf = GNUNET_GTK_get_thumbnail_from_meta_data (meta);
   sr = GNUNET_malloc (sizeof (struct SearchResult));
+  sr->parent = parent;
   sr->result = result;
   sr->tab = tab;
-  ts = GTK_TREE_STORE (gtk_builder_get_object (tab->builder,
-                                              
"GNUNET_GTK_file_sharing_result_tree_store"));
-  gtk_tree_store_insert_with_values (ts,
+  if (parent != NULL)
+    {
+      /* get piter from parent */
+      path = gtk_tree_row_reference_get_path (parent->rr);
+      tm = gtk_tree_row_reference_get_model (parent->rr);
+      if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (tm), 
+                                          &pmem, path))
+       {
+         GNUNET_break (0);
+         gtk_tree_path_free (path);
+         /* desperate measure: make top-level entry */
+         pitr = NULL;
+       }
+      else
+       {
+         pitr = &pmem;
+       }
+    }
+  else
+    {
+      /* top-level result */
+      pitr = NULL;
+    }
+  gtk_tree_store_insert_with_values (tab->ts,
                                     iter,
-                                    NULL,
+                                    pitr,
                                     G_MAXINT,
                                     0, GNUNET_CONTAINER_meta_data_duplicate 
(meta),
                                     1, (uri == NULL) ? NULL : 
GNUNET_FS_uri_dup (uri),
@@ -870,9 +939,9 @@
   GNUNET_free (uris);
   GNUNET_free (desc);
   GNUNET_free_non_null (mime);
-  tp = gtk_tree_model_get_path (GTK_TREE_MODEL (ts),
+  tp = gtk_tree_model_get_path (GTK_TREE_MODEL (tab->ts),
                                iter);
-  sr->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts),
+  sr->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (tab->ts),
                                       tp);
   gtk_tree_path_free (tp);
   return sr;
@@ -891,8 +960,8 @@
   struct SearchResult *sr;
   GtkTreeIter iter;
 
-  sr = add_search_result (tab, &iter, parent, uri,
-                         meta, result, applicability_rank);
+  sr = GNUNET_GTK_add_search_result (tab, &iter, parent, uri,
+                                    meta, result, applicability_rank);
   update_search_label (tab);
   return sr;
 }
@@ -903,12 +972,14 @@
  * the URI tab first.
  *
  * @param iter set to the new entry
+ * @param srp set to search result 
  * @param meta metadata for the new entry
  * @param uri URI for the new entry
  * @return NULL on error, otherwise tree store matching iter
  */
-GtkTreeStore *
+struct SearchTab *
 GNUNET_GTK_add_to_uri_tab (GtkTreeIter *iter,
+                          struct SearchResult **srp,
                           const struct GNUNET_CONTAINER_MetaData *meta,
                           const struct GNUNET_FS_Uri *uri)
 {
@@ -918,8 +989,9 @@
   utab = search_tab_head;
   while (utab != NULL)
     {
-      if (utab->sc != NULL)
-       utab = utab->next;
+      if (utab->sc == NULL)
+       break;
+      utab = utab->next;
     }
   if (utab == NULL)
     {
@@ -934,12 +1006,13 @@
       /* FIXME: make 'utab' the current page */
       GNUNET_break (0);
     }
-  sr = add_search_result (utab, iter,
-                         NULL, uri, meta,
-                         NULL, 0);
+  sr = GNUNET_GTK_add_search_result (utab, iter,
+                                    NULL, uri, meta,
+                                    NULL, 0);
   
-  return GTK_TREE_STORE (gtk_builder_get_object (utab->builder,
-                                                
"GNUNET_GTK_file_sharing_result_tree_store"));
+  if (NULL != srp)
+    *srp = sr;
+  return utab;
 }
 
 

Modified: gnunet-gtk/src/fs_event_handler.h
===================================================================
--- gnunet-gtk/src/fs_event_handler.h   2010-06-27 14:30:36 UTC (rev 11982)
+++ gnunet-gtk/src/fs_event_handler.h   2010-06-27 14:31:53 UTC (rev 11983)
@@ -27,21 +27,91 @@
 
 
 /**
+ * Context we keep for a search tab.
+ */
+struct SearchTab
+{
+  /**
+   * This is a doubly-linked list.
+   */
+  struct SearchTab *next;
+
+  /**
+   * This is a doubly-linked list.
+   */
+  struct SearchTab *prev;
+
+  struct GNUNET_FS_SearchContext *sc;
+
+  char *query_txt;
+
+  GtkBuilder *builder;
+
+  GtkWidget *frame;
+
+  GtkWidget *tab_label;
+
+  GtkWidget *close_button;
+
+  GtkWidget *clear_button;
+
+  GtkWidget *play_button;
+
+  GtkWidget *pause_button;
+
+  GtkLabel *label;
+
+  GtkTreeStore *ts;
+
+  unsigned int num_results;
+
+};
+
+
+struct SearchResult;
+
+
+/**
  * Setup a new top-level entry in the URI tab.  If necessary, create
  * the URI tab first.
  *
  * @param iter set to the new entry
+ * @param srp set to search result 
  * @param meta metadata for the new entry
  * @param uri URI for the new entry
- * @return NULL on error, otherwise tree store matching iter
+ * @return NULL on error, otherwise search tab with the new entry
  */
-GtkTreeStore *
+struct SearchTab *
 GNUNET_GTK_add_to_uri_tab (GtkTreeIter *iter,
+                          struct SearchResult **sr,
                           const struct GNUNET_CONTAINER_MetaData *meta,
                           const struct GNUNET_FS_Uri *uri);
 
 
+
 /**
+ * Add a search result to the given search tab.
+ *
+ * @param tab search tab to extend
+ * @param iter set to position where search result is added
+ * @param parent parent entry in search tab
+ * @param uri uri to add
+ * @param meta metadata of the entry
+ * @param result associated FS search result (can be NULL)
+ * @param applicability_rank how relevant is the result
+ * @return entry for the search result
+ */
+struct SearchResult *
+GNUNET_GTK_add_search_result (struct SearchTab *tab,
+                             GtkTreeIter *iter,
+                             struct SearchResult *parent,
+                             const struct GNUNET_FS_Uri *uri,
+                             const struct GNUNET_CONTAINER_MetaData *meta,
+                             struct GNUNET_FS_SearchResult *result,
+                             uint32_t applicability_rank);
+
+
+/**
  * Notification of FS to a client about the progress of an 
  * operation.  Callbacks of this type will be used for uploads,
  * downloads and searches.  Some of the arguments depend a bit 

Modified: gnunet-gtk/src/main_window_open_directory.c
===================================================================
--- gnunet-gtk/src/main_window_open_directory.c 2010-06-27 14:30:36 UTC (rev 
11982)
+++ gnunet-gtk/src/main_window_open_directory.c 2010-06-27 14:31:53 UTC (rev 
11983)
@@ -29,6 +29,8 @@
 {
   const char *filename;
   GtkTreeStore *ts;
+  struct SearchTab *tab;
+  struct SearchResult *par;
   GtkTreeIter iter; 
 };
 
@@ -58,6 +60,7 @@
 {
   struct AddChildContext *acc = cls;
   struct GNUNET_CONTAINER_MetaData *dmeta;
+  GtkTreeIter iter;
 
   if (uri == NULL)
     {
@@ -70,17 +73,23 @@
                                         "text/plain",
                                         acc->filename,
                                         strlen (acc->filename) + 1);
-      acc->ts = GNUNET_GTK_add_to_uri_tab (&acc->iter,
-                                          dmeta,
-                                          NULL); 
+      acc->tab = GNUNET_GTK_add_to_uri_tab (&acc->iter,
+                                           &acc->par,
+                                           dmeta,
+                                           NULL); 
+      acc->ts = acc->tab->ts;
       GNUNET_CONTAINER_meta_data_destroy (dmeta);
       return;
     }
   if (acc->ts == NULL)
     return;
-  /* FIXME */
-  GNUNET_break (0); 
-  acc = NULL;
+  GNUNET_GTK_add_search_result (acc->tab,
+                               &iter,
+                               acc->par,
+                               uri,
+                               meta,
+                               NULL,
+                               0);
 }
 
 




reply via email to

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