gnunet-svn
[Top][All Lists]
Advanced

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

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


From: grothoff
Subject: [GNUnet-SVN] r3559 - in gnunet-gtk: . src/plugins/daemon src/plugins/fs
Date: Sat, 28 Oct 2006 23:16:07 -0700 (PDT)

Author: grothoff
Date: 2006-10-28 23:16:00 -0700 (Sat, 28 Oct 2006)
New Revision: 3559

Modified:
   gnunet-gtk/gnunet-gtk.glade
   gnunet-gtk/src/plugins/daemon/daemon.c
   gnunet-gtk/src/plugins/fs/fs.c
   gnunet-gtk/src/plugins/fs/fs.h
   gnunet-gtk/src/plugins/fs/helper.c
   gnunet-gtk/src/plugins/fs/meta.c
   gnunet-gtk/src/plugins/fs/meta.h
   gnunet-gtk/src/plugins/fs/namespace.c
   gnunet-gtk/src/plugins/fs/search.c
   gnunet-gtk/src/plugins/fs/search.h
   gnunet-gtk/src/plugins/fs/upload.c
Log:
improving fs search code

Modified: gnunet-gtk/gnunet-gtk.glade
===================================================================
--- gnunet-gtk/gnunet-gtk.glade 2006-10-28 22:59:13 UTC (rev 3558)
+++ gnunet-gtk/gnunet-gtk.glade 2006-10-29 06:16:00 UTC (rev 3559)
@@ -7820,4 +7820,82 @@
   </child>
 </widget>
 
+<widget class="GtkWindow" id="searchTabLabelWindow">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">Search Tab Label with Close 
Button</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="urgency_hint">False</property>
+
+  <child>
+    <widget class="GtkHBox" id="searchTabHBox">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child>
+       <widget class="GtkLabel" id="searchTabLabel">
+         <property name="visible">True</property>
+         <property name="can_focus">True</property>
+         <property name="label" translatable="yes">FIXME</property>
+         <property name="use_underline">True</property>
+         <property name="use_markup">False</property>
+         <property name="justify">GTK_JUSTIFY_LEFT</property>
+         <property name="wrap">False</property>
+         <property name="selectable">True</property>
+         <property name="xalign">0.5</property>
+         <property name="yalign">0.5</property>
+         <property name="xpad">5</property>
+         <property name="ypad">0</property>
+         <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+         <property name="width_chars">-1</property>
+         <property name="single_line_mode">True</property>
+         <property name="angle">0</property>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">False</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkButton" id="searchCloseButton">
+         <property name="visible">True</property>
+         <property name="tooltip" translatable="yes">Stop the 
search.</property>
+         <property name="relief">GTK_RELIEF_NONE</property>
+         <property name="focus_on_click">True</property>
+         <signal name="clicked" handler="on_closeSearchButton_clicked_fs" 
object="searchTabHBox" last_modification_time="Sun, 29 Oct 2006 06:09:02 GMT"/>
+
+         <child>
+           <widget class="GtkImage" id="image50">
+             <property name="visible">True</property>
+             <property name="stock">gtk-cancel</property>
+             <property name="icon_size">4</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xpad">0</property>
+             <property name="ypad">0</property>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">False</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>

Modified: gnunet-gtk/src/plugins/daemon/daemon.c
===================================================================
--- gnunet-gtk/src/plugins/daemon/daemon.c      2006-10-28 22:59:13 UTC (rev 
3558)
+++ gnunet-gtk/src/plugins/daemon/daemon.c      2006-10-29 06:16:00 UTC (rev 
3559)
@@ -101,6 +101,8 @@
                           "applicationList");
   gtk_tree_view_set_model(GTK_TREE_VIEW(w),
                          GTK_TREE_MODEL(model));
+  
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(searchList)),
+                             GTK_SELECTION_NONE);
   connection_destroy(sock);
 }
 

Modified: gnunet-gtk/src/plugins/fs/fs.c
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.c      2006-10-28 22:59:13 UTC (rev 3558)
+++ gnunet-gtk/src/plugins/fs/fs.c      2006-10-29 06:16:00 UTC (rev 3559)
@@ -112,6 +112,8 @@
     break;
  case FSUI_download_started:
     cls->ret = fs_download_started(event->data.DownloadStarted.dc.pos,
+                                  event->data.DownloadStarted.dc.pctx,
+                                  event->data.DownloadStarted.dc.sctx,
                                   event->data.DownloadStarted.total,
                                   event->data.DownloadStarted.anonymityLevel,
                                   &event->data.DownloadStarted.fi,
@@ -121,6 +123,8 @@
     break;
   case FSUI_download_resumed:
     cls->ret = fs_download_started(event->data.DownloadResumed.dc.pos,
+                                  event->data.DownloadStarted.dc.pctx,
+                                  event->data.DownloadStarted.dc.sctx,
                                   event->data.DownloadResumed.total,
                                   event->data.DownloadResumed.anonymityLevel,
                                   &event->data.DownloadResumed.fi,
@@ -213,13 +217,17 @@
 }
 
 void done_fs() {
-  DEBUG_BEGIN();
+  GtkWidget * tab;
+
+  tab
+    = glade_xml_get_widget(getMainXML(),
+                          "fsnotebook");
+  gtk_widget_hide(tab);
   fs_search_stop();
   fs_collection_stop();
   fs_namespace_stop();
   fs_upload_stop();
   FSUI_stop(ctx);
-  DEBUG_END();
 }
 
 /* end of fs.c */

Modified: gnunet-gtk/src/plugins/fs/fs.h
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.h      2006-10-28 22:59:13 UTC (rev 3558)
+++ gnunet-gtk/src/plugins/fs/fs.h      2006-10-29 06:16:00 UTC (rev 3559)
@@ -30,7 +30,25 @@
 #include <GNUnet/gnunet_ecrs_lib.h>
 #include <GNUnet/gnunet_fsui_lib.h>
 
+
+/**
+ * On search box, for namespace selection
+ * (for input of search URI; lists known namespaces).
+ */
 enum {
+  NS_SEARCH_DESCRIPTION = 0,
+  NS_SEARCH_ENCNAME,
+  NS_SEARCH_METADATA,
+  NS_SEARCH_FSUI,
+  NS_SEARCH_RATING,
+  NS_SEARCH_NUM,
+};
+
+/**
+ * For listing of search results for main search.
+ * Represents a search result.
+ */
+enum {
   SEARCH_NAME = 0,
   SEARCH_SIZE,
   SEARCH_HSIZE,
@@ -43,33 +61,25 @@
   SEARCH_NUM,
 };
 
+/**
+ * Search entry in search summary list.
+ * Represents a search process.
+ */
 enum {
-  NS_SEARCH_DESCRIPTION = 0,
-  NS_SEARCH_ENCNAME,
-  NS_SEARCH_METADATA,
-  NS_SEARCH_FSUI,
-  NS_SEARCH_RATING,
-  NS_SEARCH_NUM,
+  SEARCH_SUMMARY_NAME = 0,
+  SEARCH_SUMMARY_RESULT_COUNT,
+  SEARCH_SUMMARY_INTERNAL,
+  SEARCH_SUMMARY_NUM
 };
 
 enum {
-  SER_SUM_NAME = 0,
-  SER_SUM_COUNT,
-  SER_SUM_URI,
-  SER_SUM_FSUI,
-  SER_SUM_NUM
-};
-
-enum {
   DOWNLOAD_FILENAME = 0,
   DOWNLOAD_SHORTNAME,
   DOWNLOAD_SIZE,
   DOWNLOAD_HSIZE,
   DOWNLOAD_PROGRESS,
   DOWNLOAD_URISTRING,
-  DOWNLOAD_URI,
-  DOWNLOAD_TREEPATH,
-  DOWNLOAD_POS, /* struct DL */
+  DOWNLOAD_INTERNAL, /* struct DL */
   DOWNLOAD_NUM
 };
 

Modified: gnunet-gtk/src/plugins/fs/helper.c
===================================================================
--- gnunet-gtk/src/plugins/fs/helper.c  2006-10-28 22:59:13 UTC (rev 3558)
+++ gnunet-gtk/src/plugins/fs/helper.c  2006-10-29 06:16:00 UTC (rev 3559)
@@ -95,243 +95,4 @@
   return OK;
 }
 
-/**
- * FIXME: convert this into a glade widget!
- */
-GtkWidget *
-buildSearchTabLabel(GtkWidget *searchPage, 
-                   const char *title) {
-  GtkWidget *hbox;
-  GtkWidget *label_hbox;
-  GtkWidget *label_ebox;
-  GtkWidget *label;
-  GtkWidget *dummy_label;
-  GtkWidget *close_button;
-  GtkRcStyle *rcstyle;
-  GtkRequisition size;
-  GtkWidget *image;
-  char *short_title;
-  char *orig_title;
-  char *final_title;
-  char *short_title_end;
-  char *tip_title;
-  int short_title_len;
-  static GtkTooltips *searchTabLabelTooltip = NULL;
-  unsigned int *file_count;
 
-  if(!searchTabLabelTooltip)
-    searchTabLabelTooltip = gtk_tooltips_new();
-
-  hbox = gtk_hbox_new (FALSE, 2);
-
-  label_ebox = gtk_event_box_new ();
-  gtk_event_box_set_visible_window (GTK_EVENT_BOX (label_ebox), FALSE);
-  gtk_box_pack_start (GTK_BOX (hbox), label_ebox, TRUE, TRUE, 0);
-
-  label_hbox = gtk_hbox_new (FALSE, 2);
-  gtk_container_add (GTK_CONTAINER (label_ebox), label_hbox);
-
-  /* setup close button */
-  close_button = gtk_button_new ();
-  gtk_button_set_relief (GTK_BUTTON (close_button),
-                        GTK_RELIEF_NONE);
-  /* don't allow focus on the close button */
-  gtk_button_set_focus_on_click (GTK_BUTTON (close_button), FALSE);
-
-  /* make it as small as possible */
-  rcstyle = gtk_rc_style_new ();
-  rcstyle->xthickness = 0;
-  rcstyle->ythickness = 0;
-  gtk_widget_modify_style (close_button, rcstyle);
-  gtk_rc_style_unref (rcstyle),
-
-  image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
-                                   GTK_ICON_SIZE_MENU);
-  gtk_widget_size_request (image, &size);
-  gtk_widget_set_size_request (close_button, size.width, size.height);
-  gtk_container_add (GTK_CONTAINER (close_button), image);
-  gtk_box_pack_start (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
-
-  g_signal_connect_swapped(close_button,
-                          "clicked",
-                          G_CALLBACK (on_closeSearchButton_clicked_fs),
-                          searchPage);
-       
-  /* truncate the description if needed */
-  if(g_utf8_strlen(title, 16) > 15) {
-    short_title_end = g_utf8_offset_to_pointer (title, 15);
-    short_title_len = short_title_end - title;
-    short_title = g_strndup(title, short_title_len);
-    orig_title = g_strconcat(short_title, "...", NULL);
-    FREE(short_title); 
-  } else {
-    orig_title = STRDUP(title);
-  }
-
-  /* setup label */
-  final_title = g_strconcat(orig_title, " (0)", NULL);
-  label = gtk_label_new (final_title);
-  FREE(final_title);
-
-  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-  gtk_misc_set_padding (GTK_MISC (label), 0, 0);
-  gtk_box_pack_start (GTK_BOX (label_hbox), label, FALSE, FALSE, 0);
-
-  /* add a forced space before the button */
-  dummy_label = gtk_label_new ("");
-  gtk_box_pack_start (GTK_BOX (label_hbox), dummy_label, TRUE, TRUE, 0);
-
-  /* tooltips */
-  gtk_tooltips_set_tip(searchTabLabelTooltip, close_button,
-                      _("Close this search"), NULL);
-  tip_title = g_strconcat (_("Search: "), title, NULL);
-  gtk_tooltips_set_tip(searchTabLabelTooltip, label_ebox,
-                             tip_title, NULL);
-
-  /* store some references to access count & title later */
-  file_count = malloc(sizeof(unsigned int));
-  *file_count = 0;
-  g_object_set_data(G_OBJECT(searchPage),
-                    "file_count", (gpointer) file_count);
-  g_object_set_data(G_OBJECT(searchPage),
-                    "label", (gpointer) label);
-  g_object_set_data(G_OBJECT(searchPage),
-                    "title", (gpointer) orig_title);
-       
-  gtk_widget_show (hbox);
-  gtk_widget_show (label_ebox);
-  gtk_widget_show (label_hbox);
-  gtk_widget_show (label);
-  gtk_widget_show (dummy_label);       
-  gtk_widget_show (image);
-  gtk_widget_show (close_button);
-
-  return hbox;
-}
-
-
-
-GtkWidget * makeSearchResultFrame(struct GC_Configuration * cfg,
-                                 GtkWidget ** treeview,
-                                 GtkWidget ** anonSpin) {
-  GtkWidget * window;
-  GtkWidget * child;
-  GtkWidget * resultList;
-  GtkTreeViewColumn * column;
-  GtkCellRenderer * renderer;
-  GtkTreeStore * tree;
-  GladeXML * searchXML;
-  int col;
-
-  searchXML
-    = glade_xml_new(getGladeFileName(),
-                   "searchResultsFrame",
-                   PACKAGE_NAME);
-  connectGladeWithPlugins(searchXML);
-  window = glade_xml_get_widget(searchXML,
-                              "searchResultsFrame");
-  resultList = glade_xml_get_widget(searchXML,
-                                   "searchResults");
-  *anonSpin = glade_xml_get_widget(searchXML,
-                                  "downloadAnonymitySpinButton");
-  if (treeview != NULL)
-    (*treeview) = GTK_WIDGET(GTK_TREE_VIEW(resultList));
-  tree =
-    gtk_tree_store_new(SEARCH_NUM,
-                      G_TYPE_STRING, /* name */
-                      G_TYPE_UINT64,  /* size */
-                      G_TYPE_STRING,  /* human-readable size */
-                      G_TYPE_STRING, /* mime-type */
-                      G_TYPE_STRING, /* meta-data (some) */
-                      GDK_TYPE_PIXBUF, /* preview */   
-                      G_TYPE_POINTER,  /* url */
-                      G_TYPE_POINTER,  /* meta */
-                      G_TYPE_POINTER); /* internal: download info/NULL */
-  gtk_tree_view_set_model(GTK_TREE_VIEW(resultList),
-                         GTK_TREE_MODEL(tree));
-  renderer = gtk_cell_renderer_text_new();
-  col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
-                                             -1,
-                                             _("Name"),
-                                             renderer,
-                                             "text", SEARCH_NAME,
-                                             NULL);
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(resultList),
-                                   col - 1);
-  gtk_tree_view_column_set_resizable(column, TRUE);
-  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_NAME);
-  /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
-  renderer = gtk_cell_renderer_text_new();
-  g_object_set (renderer, "xalign", 1.00, NULL);
-  col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
-                                             -1,
-                                             _("Size"),
-                                             renderer,
-                                             "text", SEARCH_HSIZE,
-                                             NULL);
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(resultList),
-                                   col - 1);
-  gtk_tree_view_column_set_resizable(column, TRUE);
-  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_SIZE);
-  /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
-
-  renderer = gtk_cell_renderer_text_new();
-  col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
-                                             -1,
-                                             _("Mime-type"),
-                                             renderer,
-                                             "text", SEARCH_MIME,
-                                             NULL);
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(resultList),
-                                   col - 1);
-  gtk_tree_view_column_set_resizable(column, TRUE);
-  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_MIME);
-  /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
-  
-  renderer = gtk_cell_renderer_text_new();
-  col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
-                                             -1,
-                                             _("Meta-data"),
-                                             renderer,
-                                             "text", SEARCH_DESC,
-                                             NULL);
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(resultList),
-                                   col - 1);
-  gtk_tree_view_column_set_resizable(column, TRUE);
-  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_DESC);
-  /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
-  if (YES != GC_get_configuration_value_yesno(cfg,
-                                             "GNUNET-GTK",
-                                             "DISABLE-PREVIEWS",
-                                             NO)) {
-    renderer = gtk_cell_renderer_pixbuf_new();
-    col = 
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
-                                               -1,
-                                               _("Preview"),
-                                               renderer,
-                                               "pixbuf", SEARCH_PIXBUF,
-                                               NULL);
-    column = gtk_tree_view_get_column(GTK_TREE_VIEW(resultList),
-                                     col - 1);
-    gtk_tree_view_column_set_resizable(column, TRUE);
-    gtk_tree_view_column_set_reorderable(column, TRUE);
-    
gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(resultList),
-                                                col - 1),
-                                                TRUE);
-  }
-  child = gtk_bin_get_child(GTK_BIN(window));
-  gtk_widget_ref(GTK_WIDGET(child));
-  gtk_container_remove(GTK_CONTAINER(window),
-                      child);
-  gtk_widget_destroy(window);
-  UNREF(searchXML);
-  return child;
-}

Modified: gnunet-gtk/src/plugins/fs/meta.c
===================================================================
--- gnunet-gtk/src/plugins/fs/meta.c    2006-10-28 22:59:13 UTC (rev 3558)
+++ gnunet-gtk/src/plugins/fs/meta.c    2006-10-29 06:16:00 UTC (rev 3559)
@@ -112,6 +112,8 @@
                                               TRUE);
   gtk_tree_view_set_model(GTK_TREE_VIEW(metaList),
                          GTK_TREE_MODEL(metamodel));
+  
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(metaList)),
+                             GTK_SELECTION_MULTIPLE);
   if (init != NULL)
     ECRS_getMetaData(init,
                     &publishMetaData,
@@ -193,6 +195,8 @@
   /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
   gtk_tree_view_set_model(GTK_TREE_VIEW(keywordList),
                          GTK_TREE_MODEL(keymodel));
+  
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(keywordList)),
+                             GTK_SELECTION_MULTIPLE);
   if (init != NULL)
     ECRS_getKeywordsFromUri(init,
                            &publishKeyword,
@@ -470,8 +474,8 @@
                           interval);
 }
 
-unsigned int getAnonymityLevel(GladeXML * xml,
-                              const char * spinButtonName) {
+unsigned int getSpinButtonValue(GladeXML * xml,
+                               const char * spinButtonName) {
   GtkWidget * spin;
 
   spin = glade_xml_get_widget(xml,
@@ -481,4 +485,100 @@
 
 
 
+char * getMimeTypeFromMetaData(const struct ECRS_MetaData * meta) {
+  char * mime;
+  
+  mime = ECRS_getFromMetaData(meta,
+                             EXTRACTOR_MIMETYPE);
+  if (mime == NULL)
+    mime = STRDUP(_("unknown"));
+  return validate_utf8(mime);
+}
+
+char * getFileNameFromMetaData(const struct ECRS_MetaData * meta) {
+  char * name;
+
+  name = ECRS_getFirstFromMetaData(info->meta,
+                                  EXTRACTOR_FILENAME,
+                                  EXTRACTOR_TITLE,
+                                  EXTRACTOR_ARTIST,
+                                  EXTRACTOR_AUTHOR,
+                                  EXTRACTOR_PUBLISHER,
+                                  EXTRACTOR_CREATOR,
+                                  EXTRACTOR_PRODUCER,
+                                  EXTRACTOR_UNKNOWN,
+                                  -1);
+  if (name == NULL) {
+    name = STRDUP(_("no name given"));
+  } else {
+    char * dotdot;
+    
+    while (NULL != (dotdot = strstr(name, "..")))
+      dotdot[0] = dotdot[1] = '_';
+  }
+  return validate_utf8(name);
+}
+
+char * getDescriptionFromMetaData(const struct ECRS_MetaData * meta) {
+  char * desc;
+
+  desc = ECRS_getFirstFromMetaData(info->meta,
+                                  EXTRACTOR_DESCRIPTION,
+                                  EXTRACTOR_GENRE,
+                                  EXTRACTOR_ALBUM,
+                                  EXTRACTOR_COMMENT,
+                                  EXTRACTOR_SUBJECT,
+                                  EXTRACTOR_FORMAT,
+                                  EXTRACTOR_SIZE,
+                                  EXTRACTOR_KEYWORDS,
+                                  -1);
+  if (desc == NULL)
+    desc = STRDUP("");
+  return validate_utf8(desc);
+}
+
+GdkPixbuf * getThumbnailFromMetaData(const struct ECRS_MetaData * meta) {
+  GdkPixbuf * pxibuf;
+  GdkPixbufLoader * loader;
+  size_t ts;
+  unsigned char * thumb;
+  
+  thumb = NULL;
+  ts = ECRS_getThumbnailFromMetaData(meta,
+                                    &thumb);
+  if (ts != 0) {
+    loader = gdk_pixbuf_loader_new();
+    gdk_pixbuf_loader_write(loader,
+                           (const guchar*) thumb,
+                           ts,
+                           NULL);
+    pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
+    gdk_pixbuf_loader_close(loader,
+                           NULL);
+    if (pixbuf != NULL)
+      g_object_ref(pixbuf);
+    UNREF(loader);
+  } else {
+    pixbuf = NULL;
+  }
+  FREENONNULL(thumb);
+  return pixbuf;
+}
+
+GtkWidget * 
+extractMainWidgetFromWindow(GladeXML * xml,
+                           const char * windowName) {
+  GtkContainer * window;
+  GtkWidget * ret;
+
+  window = GTK_CONTAINER(glade_xml_get_widget(xml,
+                                             windowName));
+  ret = gtk_bin_get_child(GTK_BIN(window));
+  gtk_widget_ref(ret);
+  gtk_container_remove(window, ret);
+  gtk_widget_destroy(window);
+  return ret;
+}
+
+
 /* end of meta.c */

Modified: gnunet-gtk/src/plugins/fs/meta.h
===================================================================
--- gnunet-gtk/src/plugins/fs/meta.h    2006-10-28 22:59:13 UTC (rev 3558)
+++ gnunet-gtk/src/plugins/fs/meta.h    2006-10-29 06:16:00 UTC (rev 3559)
@@ -51,12 +51,14 @@
                              const char * valueInputLineName,
                              const char * metaDataListName);
 
-struct ECRS_MetaData * getMetaDataFromList(GladeXML * xml,
-                                          const char * name,
-                                          const char * preview);
+struct ECRS_MetaData * 
+getMetaDataFromList(GladeXML * xml,
+                   const char * name,
+                   const char * preview);
 
-struct ECRS_URI * getKeywordURIFromList(GladeXML * xml,
-                                       const char * name);
+struct ECRS_URI * 
+getKeywordURIFromList(GladeXML * xml,
+                     const char * name);
 
 char * updateIntervalToString(TIME_T interval);
 
@@ -67,8 +69,20 @@
 int parseTimeInterval(const char * frequency,
                      TIME_T * interval);
 
-unsigned int getAnonymityLevel(GladeXML * xml,
-                              const char * spinButtonName);
+unsigned int getSpinButtonValue(GladeXML * xml,
+                               const char * spinButtonName);
 
+char * getMimeTypeFromMetaData(const struct ECRS_MetaData * meta);
+
+char * getFileNameFromMetaData(const struct ECRS_MetaData * meta);
+
+char * getDescriptionFromMetaData(const struct ECRS_MetaData * meta);
+
+GdkPixbuf * getThumbnailFromMetaData(const struct ECRS_MetaData * meta);
+
+GtkWidget * extractMainWidgetFromWindow(GladeXML * xml,
+                                       const char * windowName);
+
+
 /* end of meta.h */
 #endif

Modified: gnunet-gtk/src/plugins/fs/namespace.c
===================================================================
--- gnunet-gtk/src/plugins/fs/namespace.c       2006-10-28 22:59:13 UTC (rev 
3558)
+++ gnunet-gtk/src/plugins/fs/namespace.c       2006-10-29 06:16:00 UTC (rev 
3559)
@@ -99,6 +99,8 @@
                       G_TYPE_POINTER);  /* META */
   gtk_tree_view_set_model(GTK_TREE_VIEW(resultList),
                          GTK_TREE_MODEL(model));
+  
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(resultList)),
+                             GTK_SELECTION_MULTIPLE);
   renderer = gtk_cell_renderer_text_new();
   col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
                                              -1,
@@ -915,8 +917,8 @@
                               "metaDataTreeView",
                               "namespaceInsertPreview");
     cls.anonymityLevel
-      = getAnonymityLevel(metaXML,
-                         "anonymitySpinButton");
+      = getSpinButtonValue(metaXML,
+                          "anonymitySpinButton");
     nameLine = glade_xml_get_widget(metaXML,
                                    "namespaceContentIdentifierEntry");
     identifierName = gtk_entry_get_text(GTK_ENTRY(nameLine));
@@ -1383,6 +1385,8 @@
                             G_TYPE_POINTER); /* uri */
   gtk_tree_view_set_model(GTK_TREE_VIEW(contentList),
                          GTK_TREE_MODEL(model));
+  
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(contentList)),
+                             GTK_SELECTION_MULTIPLE);
   renderer = gtk_cell_renderer_text_new();
   col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(contentList),
                                              -1,

Modified: gnunet-gtk/src/plugins/fs/search.c
===================================================================
--- gnunet-gtk/src/plugins/fs/search.c  2006-10-28 22:59:13 UTC (rev 3558)
+++ gnunet-gtk/src/plugins/fs/search.c  2006-10-29 06:16:00 UTC (rev 3559)
@@ -46,19 +46,102 @@
  */
 typedef struct SL {
   struct SL * next;
-  GtkWidget * treeview;
+  /**
+   * Reference to the glade XML context that was
+   * used to create the search page.
+   */
+  GladeXML * searchXML;
+
+  /**
+   * Reference to the glade XML context that was
+   * used to create the search label.
+   */
+  GladeXML * labelXML;
+
+  /**
+   * Tree view widget that is used to display the
+   * search results.
+   */
+  GtkTreeView * treeview;
+
+  /**
+   * Model of the tree view.
+   */
+  GtkTreeStore * tree;
+
+  /**
+   * The label used in the notebook page.
+   */
+  GtkLabel * tab_label;
+
+  /**
+   * The notebook page that is associated with this
+   * search.
+   */
   GtkWidget * searchpage;
-  GtkWidget * anonymityButton; /* FIXME: initialize! */
+
+  /**
+   * Path to the entry in the summary list
+   * for this search.
+   */
+  GtkTreeRowReference * summaryViewRowReference;
+
+  /**
+   * URI for this search.
+   */
   struct ECRS_URI * uri;
-  struct FSUI_SearchList * fsui_list; /* FIXME: initialize! */
+
+  /**
+   * String describing the search.
+   */
+  char * searchString;
+
+  /**
+   * Number of results received so far.
+   */
+  unsigned int resultsReceived;
+
+  /**
+   * FSUI search handle.
+   */
+  struct FSUI_SearchList * fsui_list; 
 } SearchList;
 
 typedef struct DL {
   struct DL * next;
+
+  /**
+   * URI of the download.
+   */
   struct ECRS_URI * uri;
+
+  /**
+   * Where is the download being saved to?
+   */
   char * filename;
-  GtkTreeRowReference * rr;
-  GtkTreeModel * model;
+
+  /**
+   * Path in the summary view for this download.
+   */
+  GtkTreeRowReference * summaryViewRowReference;
+
+  /**
+   * Search that this download belongs to.
+   * Maybe NULL.
+   */
+  struct SL * searchList;
+
+  /**
+   * Path in the search view that this
+   * download is represented by.  Maybe NULL
+   * if search has been closed or if download
+   * was initiated from URI without search.
+   */
+  GtkTreeRowReference * searchViewRowReference;
+
+  /**
+   * FSUI reference for the download.
+   */
   struct FSUI_DownloadList * fsui_list;
 } DownloadList;
 
@@ -74,40 +157,38 @@
 
 static struct GC_Configuration * cfg;
 
-
+/**
+ * The user has clicked the "SEARCH" button.
+ * Initiate a search.
+ */
 void on_fssearchbutton_clicked_fs(gpointer dummy2,
                                  GtkWidget * searchButton) {
   struct ECRS_URI * uri;
-  const char * ss;
-  const char * ns;
+  const char * searchString;
   gint pages;
-  const char * descStr;
-  char * ustring;
   gint i;
   SearchList * list;
-  GtkListStore * model;
-  GtkTreeModel * tmodel;
   GtkTreeIter iter;
   GtkWidget * searchKeywordGtkCB;
   GtkWidget * searchNamespaceGtkCB;
-  GtkWidget * entry;
-  GtkWidget * notebook;
-  GtkWidget * page;
+  GtkNotebook * notebook;
 
-  DEBUG_BEGIN();
   searchKeywordGtkCB
     = glade_xml_get_widget(getMainXML(),
                           "fssearchKeywordComboBoxEntry");
-  entry = gtk_bin_get_child(GTK_BIN(searchKeywordGtkCB));
-  ss = gtk_entry_get_text(GTK_ENTRY(entry));
-  if (ss == NULL) {
+  searchString = 
gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(searchKeywordGtkCB))));
+  if (searchString == NULL) {
     GE_LOG(ectx,
           GE_ERROR | GE_USER | GE_IMMEDIATE,
           _("Need a keyword to search!\n"));
     return;
   }
+  /* add the keyword to the list of keywords that have
+     been used so far */
   i = gtk_combo_box_get_active(GTK_COMBO_BOX(searchKeywordGtkCB));
   if (i == -1) {
+    GtkListStore * model;
+
     model = GTK_LIST_STORE
       (gtk_combo_box_get_model
        (GTK_COMBO_BOX(searchKeywordGtkCB)));
@@ -115,18 +196,22 @@
                           &iter);
     gtk_list_store_set(model,
                       &iter,
-                      0, ss,
+                      0, searchString,
                       -1);
   }
+  uri = NULL;
+  /* check for namespace search */
   searchNamespaceGtkCB
     = glade_xml_get_widget(getMainXML(),
                           "searchNamespaceComboBoxEntry");
-  tmodel = gtk_combo_box_get_model(GTK_COMBO_BOX(searchNamespaceGtkCB));
   if (TRUE == 
gtk_combo_box_get_active_iter(GTK_COMBO_BOX(searchNamespaceGtkCB),
                                            &iter)) {
+    const char * descStr;
+    const char * ns;
+
     ns = NULL;
     descStr = NULL;
-    gtk_tree_model_get(tmodel,
+    
gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(searchNamespaceGtkCB)),
                       &iter,
                       NS_SEARCH_DESCRIPTION, &descStr,
                       NS_SEARCH_ENCNAME, &ns,
@@ -141,43 +226,47 @@
       if (descStr == NULL)
        descStr = ns;
     }
-  }
-  if (ns != NULL) {
-    ustring = MALLOC(strlen(ss) + sizeof(EncName) +
-                    strlen(ECRS_URI_PREFIX) +
-                    strlen(ECRS_SUBSPACE_INFIX) + 10);
-    strcpy(ustring, ECRS_URI_PREFIX);
-    strcat(ustring, ECRS_SUBSPACE_INFIX);
-    strcat(ustring, ns);
-    strcat(ustring, "/");
-    strcat(ustring, ss);
-    uri = ECRS_stringToUri(ectx, ustring);
-    if (uri == NULL) {
-      GE_LOG(ectx,
-            GE_ERROR | GE_BULK | GE_USER,
-            _("Failed to create namespace URI from `%s'.\n"),
-            ustring);
+    if (ns != NULL) {
+      char * ustring;
+
+      ustring = MALLOC(strlen(searchString) + sizeof(EncName) +
+                      strlen(ECRS_URI_PREFIX) +
+                      strlen(ECRS_SUBSPACE_INFIX) + 10);
+      strcpy(ustring, ECRS_URI_PREFIX);
+      strcat(ustring, ECRS_SUBSPACE_INFIX);
+      strcat(ustring, ns);
+      strcat(ustring, "/");
+      strcat(ustring, searchString);
+      uri = ECRS_stringToUri(ectx, ustring);
+      if (uri == NULL) {
+       GE_LOG(ectx,
+              GE_ERROR | GE_BULK | GE_USER,
+              _("Failed to create namespace URI from `%s'.\n"),
+              ustring);
+      }
+      FREE(ustring);
     }
-    FREE(ustring);
-  } else {
-    uri = ECRS_parseCharKeywordURI(ectx, ss);
   }
   if (uri == NULL)
+    uri = ECRS_parseCharKeywordURI(ectx, searchString);
+  if (uri == NULL) {
+    GE_BREAK(ectx, 0);
     return;
+  }
   /* check if search is already running */
   notebook
-    = glade_xml_get_widget(getMainXML(),
-                          "downloadNotebook");
-  pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook));
+    = GTK_NOTEBOOK(glade_xml_get_widget(getMainXML(),
+                                       "downloadNotebook"));
+  pages = gtk_notebook_get_n_pages(notebook);
   list = search_head;
   while (list != NULL) {
     if (ECRS_equalsUri(list->uri,
                       uri)) {
       for (i=0;i<pages;i++) {
-       page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
-                                        i);
-       if (page == list->searchpage) {
-         gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook),
+       if (gtk_notebook_get_nth_page(notebook,
+                                     i)
+           == list->searchpage) {
+         gtk_notebook_set_current_page(notebook,
                                        i);
          ECRS_freeUri(uri);
          return;
@@ -188,35 +277,46 @@
     list = list->next;
   }
   FSUI_startSearch(ctx,
-                  getAnonymityLevel(getMainXML(),
-                                    "searchAnonymitySelectionSpinButton"),
-                  1000, /* FIXME: max results */
-                  99 * cronYEARS, /* FIXME: timeout */
+                  getSpinButtonValue(getMainXML(),
+                                     "searchAnonymitySelectionSpinButton"),    
+                  getSpinButtonValue(getMainXML(),
+                                     "maxResultsSpinButton"),  
+                  getSpinButtonValue(getMainXML(),
+                                     "searchDelaySpinButton") * cronSECONDS,
                   uri);
 }
 
+/**
+ * This method is called when the user clicks on either
+ * the "CLOSE" button (at the bottom of the search page)
+ * or on the "CANCEL (X)" button in the TAB of the
+ * search notebook.  Note that "searchPage" can thus
+ * either refer to the main page in the tab or to the
+ * main entry of the tab label.
+ */ 
 void on_closeSearchButton_clicked_fs(GtkWidget * searchPage,
                                     GtkWidget * closeButton) {
   SearchList * list;
 
-  DEBUG_BEGIN();
   list = search_head;
   while (list != NULL) {
-    if (list->searchpage == searchPage)
+    if ( (list->searchpage == searchPage) ||
+        (list->tab_label == searchPage) )
       break;
     list = list->next;
   }
   GE_ASSERT(ectx, list != NULL);
   FSUI_stopSearch(ctx,
                  list->fsui_list);
-  DEBUG_END();
 }
 
+/**
+ * The abort button was clicked.  Abort the search.
+ */
 void on_abortSearchButton_clicked_fs(GtkWidget * searchPage,
                                     GtkWidget * closeButton) {
   SearchList * list;
 
-  DEBUG_BEGIN();
   list = search_head;
   while (list != NULL) {
     if (list->searchpage == searchPage)
@@ -226,25 +326,27 @@
   GE_ASSERT(ectx, list != NULL);
   FSUI_abortSearch(ctx,
                   list->fsui_list);
-  DEBUG_END();
 }
 
 static void stopSearch(GtkTreeModel * model,
                       GtkTreePath * path,
                       GtkTreeIter * iter,
                       gpointer unused) {
-  struct FSUI_SearchList * s;
+  struct SL * s;
 
   s = NULL;
   gtk_tree_model_get(model,
                      iter,
-                    SER_SUM_FSUI, &s,
+                    SEARCH_SUMMARY_INTERNAL, &s,
                      -1);
   if (s != NULL)
     FSUI_stopSearch(ctx,
-                   s);
+                   s->fsui_list);
 }
 
+/**
+ * The stop button in the search summary was clicked.
+ */
 void on_closeSearchSummaryButton_clicked_fs(GtkWidget * treeview,
                                            GtkWidget * closeButton) {
   GtkTreeSelection * selection;
@@ -260,18 +362,21 @@
                        GtkTreePath * path,
                        GtkTreeIter * iter,
                        gpointer unused) {
-  struct FSUI_SearchList * s;
+  struct SL * s;
 
   s = NULL;
   gtk_tree_model_get(model,
                      iter,
-                    SER_SUM_FSUI, &s,
+                    SEARCH_SUMMARY_INTERNAL, &s,
                      -1);
   if (s != NULL)
     FSUI_abortSearch(ctx,
-                    s);
+                    s->fsui_list);
 }
 
+/**
+ * The abort button in the search summary was clicked.
+ */
 void on_abortSearchSummaryButton_clicked_fs(GtkWidget * treeview,
                                            GtkWidget * closeButton) {
   GtkTreeSelection * selection;
@@ -284,6 +389,42 @@
 }
 
 /**
+ * Update the number of results received for the given
+ * search in the summary and in the label of the tab.
+ */
+static void updateSearchSummary(struct SL * searchContext) {
+  GtkTreePath * path;
+  GtkTreeIter iter;
+  char * new_title;
+  GtkWidget * label;
+
+  path = 
gtk_tree_row_reference_get_path(searchContext->summaryViewRowReference);
+  if (TRUE != gtk_tree_model_get_iter(GTK_TREE_MODEL(search_summary),
+                                     &iter,
+                                     path)) {
+    GE_BREAK(ectx, 0);
+    return;
+  }
+  gtk_tree_path_free(path);
+  gtk_list_store_set(search_summary,
+                    &iter,
+                    SEARCH_SUMMARY_RESULT_COUNT, 
searchContext->resultsReceived,
+                    -1);
+  
+                         
+
+  /* update tab title with the number of results */
+  new_title =
+    g_strdup_printf("%s (%u)", 
+                   searchContext->searchString,
+                   searchContext->resultsReceived);
+  label = glade_xml_get_widget(searchContext->labelXML,
+                              "searchTabLabel");
+  gtk_label_set(label, new_title);
+  FREE(new_title);
+}
+
+/**
  * Add the given result to the model (search result
  * list).
  * 
@@ -297,85 +438,20 @@
   char * name;
   char * mime;
   char * desc;
-  unsigned char * thumb;
-  size_t ts;
-  GdkPixbuf * pixbuf;
-  GdkPixbufLoader * loader;
   unsigned long long size;
   char * size_h;
   GtkTreeStore * model;
   GtkTreeIter iter;
-  unsigned int * file_count;
-  GtkWidget * tab_label;
-  const char * tab_title;
-  char * new_title;
-  struct ECRS_URI * euri;
 
-  DEBUG_BEGIN();
+  mime = getMimeTypeFromMetaData(info->meta);
+  desc = getDescriptionFromMetaData(info->meta);
+  name = getFileNameFromMetaData(info->meta);    
+  size = ECRS_isFileUri(info->uri) ? ECRS_fileSize(info->uri) : 0
+  pixbuf = getThumbnailFromMetaData(info->meta);
+  size_h = string_get_fancy_byte_size(size);
   model = GTK_TREE_STORE
     (gtk_tree_view_get_model
      (GTK_TREE_VIEW(searchContext->treeview)));
-  mime = ECRS_getFromMetaData(info->meta,
-                             EXTRACTOR_MIMETYPE);
-  if (mime == NULL)
-    mime = STRDUP(_("unknown"));
-  mime = validate_utf8(mime);
-  desc = ECRS_getFirstFromMetaData(info->meta,
-                                  EXTRACTOR_DESCRIPTION,
-                                  EXTRACTOR_GENRE,
-                                  EXTRACTOR_ALBUM,
-                                  EXTRACTOR_COMMENT,
-                                  EXTRACTOR_SUBJECT,
-                                  EXTRACTOR_FORMAT,
-                                  EXTRACTOR_SIZE,
-                                  EXTRACTOR_KEYWORDS,
-                                  -1);
-  if (desc == NULL)
-    desc = STRDUP("");
-  desc = validate_utf8(desc);
-  name = ECRS_getFirstFromMetaData(info->meta,
-                                  EXTRACTOR_FILENAME,
-                                  EXTRACTOR_TITLE,
-                                  EXTRACTOR_ARTIST,
-                                  EXTRACTOR_AUTHOR,
-                                  EXTRACTOR_PUBLISHER,
-                                  EXTRACTOR_CREATOR,
-                                  EXTRACTOR_PRODUCER,
-                                  EXTRACTOR_UNKNOWN,
-                                  -1);
-  if (name == NULL) {
-    name = STRDUP(_("no name given"));
-  } else {
-    char * dotdot;
-    
-    while (NULL != (dotdot = strstr(name, "..")))
-      dotdot[0] = dotdot[1] = '_';
-  }
-  name = validate_utf8(name);
-    
-  if (ECRS_isFileUri(info->uri)) 
-    size = ECRS_fileSize(info->uri);
-  else 
-    size = 0;
-  thumb = NULL;
-  ts = ECRS_getThumbnailFromMetaData(info->meta,
-                                    &thumb);
-  if (ts != 0) {
-    loader = gdk_pixbuf_loader_new();
-    gdk_pixbuf_loader_write(loader,
-                           (const guchar*) thumb,
-                           ts,
-                           NULL);
-    pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
-    gdk_pixbuf_loader_close(loader,
-                           NULL);
-    if (pixbuf != NULL)
-      g_object_ref(pixbuf);
-    UNREF(loader);
-  } else {
-    pixbuf = NULL;
-  }
-  size_h = string_get_fancy_byte_size(size);
   gtk_tree_store_append(model,
                        &iter,
                        NULL);  
@@ -392,83 +468,36 @@
                     SEARCH_INTERNAL, searchContext,
                     -1);
   FREE(size_h);
+  FREE(name);
+  FREE(desc);
   FREE(mime);
-  FREE(desc);
-  FREE(name);
-  FREENONNULL(thumb);
-
-  /* update tab title with the number of results */
-  file_count = (unsigned int *)
-      g_object_get_data(G_OBJECT(searchContext->searchpage), "file_count");
-  (*file_count)++;
-  tab_label = (GtkWidget *)
-      g_object_get_data(G_OBJECT(searchContext->searchpage), "label");
-  tab_title = (const char *)
-      g_object_get_data(G_OBJECT(searchContext->searchpage), "title");
-  new_title =
-      g_strdup_printf("%s%s%u%s", 
-                     tab_title, " (", *file_count, ")");
-  gtk_label_set(GTK_LABEL(tab_label), new_title);
-  FREE(new_title);
-
-  if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(search_summary),
-                                     &iter)) {
-    GE_BREAK(ectx, 0);
-    return;
-  }
-
-  do { 
-    gtk_tree_model_get(GTK_TREE_MODEL(search_summary),
-                      &iter,
-                      SER_SUM_URI, &euri,
-                      -1);
-    if (ECRS_equalsUri(euri,
-                      uri)) {
-      gtk_list_store_set(GTK_LIST_STORE(search_summary),
-                        &iter,
-                        SER_SUM_COUNT, *file_count,
-                        -1);
-      DEBUG_END();
-      return;
-    }
-
-  } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(search_summary),
-                                   &iter));
+  /* UNREF pixbuf? */
+  searchContext->resultsReceived++;
+  updateSearchSummary(searchContext);
 }
 
-SearchList * 
+/**
+ * FSUI event: a search was started; create the
+ * tab and add an entry to the summary.
+ */
+struct SL * 
 fs_search_started(struct FSUI_SearchList * fsui_list,
                  const struct ECRS_URI * uri,
                  unsigned int anonymityLevel,
                  unsigned int resultCount,
                  const ECRS_FileInfo * results) {
-  GtkWidget * notebook;
-  GtkWidget * label;
-  GtkTreeIter iter;
-  SearchList * list;
-  char * tabtxt;
-  int i;
-  const char * dhead;
+  struct SL * list;
   gint pages;
   char * description;
+  const char * dhead;
+  GtkContainer * window;
+  GtkTreeViewColumn * column;
+  GtkCellRenderer * renderer;
+  int col;
+  GtkNotebook * notebook;
+  GtkTreePath * path;
+  GtkTreeIter iter;
 
-  notebook
-    = glade_xml_get_widget(getMainXML(),
-                          "downloadNotebook");
-  list
-    = MALLOC(sizeof(SearchList));
-  list->searchpage
-    = makeSearchResultFrame(cfg,
-                           &list->treeview,
-                           &list->anonymityButton);
-  list->uri
-    = ECRS_dupUri(uri);
-  list->next
-    = search_head;
-  list->fsui_list 
-    = fsui_list;
-  search_head = list;
-
   description = ECRS_uriToString(uri);
   if (description == NULL) {
     GE_BREAK(ectx, 0);
@@ -485,31 +514,169 @@
                        ECRS_SUBSPACE_INFIX,
                        strlen(ECRS_SUBSPACE_INFIX)))
     dhead = &dhead[strlen(ECRS_SUBSPACE_INFIX)];
+  list
+    = MALLOC(sizeof(struct SL));
+  memset(list,
+        0,
+        sizeof(struct SL));
+  list->searchString
+    = STRDUP(dhead);
+  FREE(description);
+  list->uri
+    = ECRS_dupUri(uri);
+  list->fsui_list 
+    = fsui_list;
+  list->next
+    = search_head;
+  search_head = list;
+  list->searchXML
+    = glade_xml_new(getGladeFileName(),
+                   "searchResultsFrame",
+                   PACKAGE_NAME);
+  connectGladeWithPlugins(list->searchXML);
+  list->searchpage 
+    = extractMainWidgetFromWindow(list->searchXML,
+                                 "searchResultsFrame");
+  /* setup tree view and renderers */
+  list->treeview = GTK_TREE_VIEW(glade_xml_get_widget(list->searchXML,
+                                                     "searchResults"));
 
-  tabtxt = STRDUP("foo"); /* FIXME! */
+  list->tree =
+    gtk_tree_store_new(SEARCH_NUM,
+                      G_TYPE_STRING, /* name */
+                      G_TYPE_UINT64,  /* size */
+                      G_TYPE_STRING,  /* human-readable size */
+                      G_TYPE_STRING, /* mime-type */
+                      G_TYPE_STRING, /* meta-data (some) */
+                      GDK_TYPE_PIXBUF, /* preview */   
+                      G_TYPE_POINTER,  /* url */
+                      G_TYPE_POINTER,  /* meta */
+                      G_TYPE_POINTER); /* internal: download info/NULL */
+
+  gtk_tree_view_set_model(list->treeview,
+                         GTK_TREE_MODEL(list->tree));
+  gtk_tree_selection_set_mode(gtk_tree_view_get_selection(list->treeview),
+                             GTK_SELECTION_MULTIPLE);
+
+  renderer = gtk_cell_renderer_text_new();
+  col = gtk_tree_view_insert_column_with_attributes(list->treeview,
+                                                   -1,
+                                                   _("Name"),
+                                                   renderer,
+                                                   "text", SEARCH_NAME,
+                                                   NULL);
+  column = gtk_tree_view_get_column(list->treeview,
+                                   col - 1);
+  gtk_tree_view_column_set_resizable(column, TRUE);
+  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_NAME);
+
+  renderer = gtk_cell_renderer_text_new();
+  g_object_set (renderer, "xalign", 1.00, NULL);
+  col = gtk_tree_view_insert_column_with_attributes(list->treeview,
+                                                   -1,
+                                                   _("Size"),
+                                                   renderer,
+                                                   "text", SEARCH_HSIZE,
+                                                   NULL);
+  column = gtk_tree_view_get_column(list->treeview,
+                                   col - 1);
+  gtk_tree_view_column_set_resizable(column, TRUE);
+  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_SIZE);
+
+  renderer = gtk_cell_renderer_text_new();
+  col = gtk_tree_view_insert_column_with_attributes(list->treeview,
+                                                   -1,
+                                                   _("Mime-type"),
+                                                   renderer,
+                                                   "text", SEARCH_MIME,
+                                                   NULL);
+  column = gtk_tree_view_get_column(list->treeview,
+                                   col - 1);
+  gtk_tree_view_column_set_resizable(column, TRUE);
+  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_MIME);
+  
+  renderer = gtk_cell_renderer_text_new();
+  col = gtk_tree_view_insert_column_with_attributes(list->treeview,
+                                             -1,
+                                             _("Meta-data"),
+                                             renderer,
+                                             "text", SEARCH_DESC,
+                                             NULL);
+  column = gtk_tree_view_get_column(list->treeview,
+                                   col - 1);
+  gtk_tree_view_column_set_resizable(column, TRUE);
+  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_DESC);
+  /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
+  if (YES != GC_get_configuration_value_yesno(cfg,
+                                             "GNUNET-GTK",
+                                             "DISABLE-PREVIEWS",
+                                             NO)) {
+    renderer = gtk_cell_renderer_pixbuf_new();
+    col = gtk_tree_view_insert_column_with_attributes(list->treeview,
+                                                     -1,
+                                                     _("Preview"),
+                                                     renderer,
+                                                     "pixbuf", SEARCH_PIXBUF,
+                                                     NULL);
+    column = gtk_tree_view_get_column(list->treeview,
+                                     col - 1);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_reorderable(column, TRUE);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+  }
+
+
+  /* add entry in search summary */
   gtk_list_store_append(search_summary,
                        &iter);
   gtk_list_store_set(search_summary,
                     &iter,
-                    SER_SUM_NAME, dhead,
-                    SER_SUM_COUNT, 0,
-                    SER_SUM_URI, ECRS_dupUri(uri),
+                    SEARCH_SUMMARY_NAME, dhead,
+                    SEARCH_SUMMARY_RESULT_COUNT, 0,
+                    SEARCH_SUMMARY_INTERNAL, list,
                     -1);
-  label = buildSearchTabLabel(list->searchpage, 
-                             dhead);
-  pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook));
-  gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
-                          list->searchpage,
-                          label);
-  gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook),
-                               pages);
-  gtk_widget_show(notebook);
-  FREE(description);
+  path = gtk_tree_model_get_path(GTK_TREE_MODEL(search_summary),
+                                &iter);
+  list->summaryViewRowReference
+    = gtk_tree_row_reference_new(GTK_TREE_MODEL(search_summary),
+                                path);
+  gtk_tree_path_free(path);
+  
+  /* load label */
+  list->labelXML
+    = glade_xml_new(getGladeFileName(),
+                   "searchTabLabelWindow",
+                   PACKAGE_NAME);
+  list->tab_label 
+    = extractMainWidgetFromWindow(list->labelXML,
+                                 "searchTabLabelWindow");
+
+  /* process existing results */
   for (i=0;i<resultCount;i++)
     fs_search_result_received(list,
                              &results[i],
                              uri);
-  DEBUG_END();
+  
+  /* insert new page into search notebook */
+  notebook
+    = GTK_NOTEBOOK(glade_xml_get_widget(getMainXML(),
+                                       "downloadNotebook"));  
+  pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook));
+  gtk_notebook_append_page(notebook,
+                          list->searchpage,
+                          list->tab_label);
+  gtk_notebook_set_current_page(notebook,
+                               pages);
+  gtk_widget_show(GTK_WIDGET(notebook)); /* may have been hidden! */
+  
   return list;
 }
 
@@ -548,15 +715,21 @@
                                    iter));
 }
 
+/**
+ * FSUI event: a search was stopped.  Remove the
+ * respective tab and its entry in the summary.
+ */
 void fs_search_stopped(SearchList * list) {
-  GtkWidget * notebook;
+  GtkNotebook * notebook;
   int index;
   int i;
   GtkTreeIter iter;
   struct ECRS_URI * euri;
   SearchList * prev;
+  DownloadList * downloads;
+  GtkTreePath * path;
 
-  DEBUG_BEGIN();
+  /* remove from linked list */
   if (search_head == list) {
     search_head = search_head->next;
   } else {
@@ -565,48 +738,53 @@
       prev = prev->next;
     prev->next = list->next;
   }
+
+  /* remove links from download views */
+  downloads = download_head;
+  while (downloads != NULL) {
+    if (download->searchList == list) {
+      gtk_tree_row_reference_free(download->searchViewRowReference);
+      download->searchViewRowReference = NULL;
+      download->searchList = NULL;
+    }
+    downloads = downloads->next;
+  }
+
+  /* remove page from notebook */
   notebook
-    = glade_xml_get_widget(getMainXML(),
-                          "downloadNotebook");
+    = GTK_NOTEBOOK(glade_xml_get_widget(getMainXML(),
+                                       "downloadNotebook"));
   index = -1;
-  for (i=gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook))-1;i>=0;i--)
-    if (list->searchpage == gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
+  for (i=gtk_notebook_get_n_pages(notebook)-1;i>=0;i--)
+    if (list->searchpage == gtk_notebook_get_nth_page(notebook,
                                                      i))
       index = i;
-  gtk_notebook_remove_page(GTK_NOTEBOOK(notebook),
+  GE_BREAK(ectx, index != -1);
+  gtk_notebook_remove_page(notebook,
                           index);
-#if 0
-  /* recursively free download tree */
+  
+  /* recursively free search model */
   if (gtk_tree_model_get_iter_first(list->model,
                                    &iter))
     freeIterSubtree(list->model,
                    &iter);
-#endif
-  if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(search_summary),
-                                     &iter)) {
-    GE_BREAK(ectx, 0);
-    ECRS_freeUri(list->uri);
-    FREE(list);
-    DEBUG_END();
-    return;
-  }
-  do { 
-    gtk_tree_model_get(GTK_TREE_MODEL(search_summary),
-                      &iter,
-                      SER_SUM_URI, &euri,
-                      -1);
-    if (ECRS_equalsUri(euri,
-                      list->uri)) {
-      gtk_list_store_remove(GTK_LIST_STORE(search_summary),
-                           &iter);
-      ECRS_freeUri(euri);
-      break;
-    }
-  } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(search_summary),
-                                   &iter));
+  
+  /* destroy entry in summary */
+  path = gtk_tree_row_reference_get_path(list->summaryViewRowReference);
+  gtk_tree_model_get_iter(GTK_TREE_MODEL(search_summary),
+                         &iter,
+                         path);
+  gtk_tree_path_free(path);
+  gtk_list_store_remove(search_summary,
+                       &iter);
+
+  /* free list state itself */
+  UNREF(list->searchXML);
+  UNREF(list->labelXML);
+  gtk_tree_row_reference_free(list->summaryViewRowReference);
+  FREE(list->searchString);
   ECRS_freeUri(list->uri);
   FREE(list);
-  DEBUG_END();
 }
 
 
@@ -678,12 +856,16 @@
 }
 #endif
 
+
 /**
- * FIXME: somehow need way to pass
- * tree path for search into this download!
+ * A download has been started.  Add an entry
+ * to the search tree view (if applicable) and
+ * the download summary.
  */
 struct DL *
 fs_download_started(struct FSUI_DownloadList * fsui_dl,
+                   struct DL * dl_parent,
+                   struct SL * sl_parent,
                    unsigned long long total,
                    unsigned int anonymityLevel,
                    const ECRS_FileInfo * fi,
@@ -1209,25 +1391,28 @@
 
 
 
+/* *************** startup/shutdown ****************** */
 
-
+/**
+ * Setup the summary views (in particular the models
+ * and the renderers).  
+ */
 void fs_search_start(struct GE_Context * e,
                     struct GC_Configuration * c) {
-  GtkWidget * searchCB;
-  GtkWidget * searchList;
+  GtkComboBoxEntry * searchCB;
+  GtkTreeView * searchList;
+  GtkTreeView * downloadList;
   GtkListStore * model;
   GtkCellRenderer * renderer;
   GtkTreeViewColumn * column;
   int col;
-  GtkWidget * downloadList;
   
   ectx = e;
   cfg = c;
-  DEBUG_BEGIN();
   searchCB
-    = glade_xml_get_widget(getMainXML(),
-                          "fssearchKeywordComboBoxEntry");
-
+    = GTK_COMBO_BOX_ENTRY(glade_xml_get_widget(getMainXML(),
+                                              "fssearchKeywordComboBoxEntry"));
+  
   model = gtk_list_store_new(NS_SEARCH_NUM,
                             G_TYPE_STRING, /* what we show */
                             G_TYPE_STRING, /* EncName of namespace */
@@ -1236,54 +1421,52 @@
                             G_TYPE_INT);  /* Meta-data about namespace */
   gtk_combo_box_set_model(GTK_COMBO_BOX(searchCB),
                          GTK_TREE_MODEL(model));
-  gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(searchCB),
+  gtk_combo_box_entry_set_text_column(searchCB,
                                      NS_SEARCH_DESCRIPTION);
-  searchList = glade_xml_get_widget(getMainXML(),
-                                   "activeSearchesSummary");
+  searchList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(),
+                                                 "activeSearchesSummary"));
   search_summary =
     gtk_list_store_new(SER_SUM_NUM,
                       G_TYPE_STRING, /* name */
                       G_TYPE_INT,    /* # results */
-                      G_TYPE_POINTER,  /* internal: FSUI search list */
-                      G_TYPE_POINTER);  /* internal: uri */
-  gtk_tree_view_set_model(GTK_TREE_VIEW(searchList),
+                      G_TYPE_POINTER);  /* internal: search list */
+  gtk_tree_view_set_model(searchList,
                          GTK_TREE_MODEL(search_summary));
+  gtk_tree_selection_set_mode(gtk_tree_view_get_selection(searchList),
+                             GTK_SELECTION_MULTIPLE);
+
   renderer = gtk_cell_renderer_text_new();
-  col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(searchList),
-                                             -1,
-                                             _("Query"),
-                                             renderer,
-                                             "text", SER_SUM_NAME,
+  col = gtk_tree_view_insert_column_with_attributes(searchList,
+                                                   -1,
+                                                   _("Query"),
+                                                   renderer,
+                                                   "text", 
SERARCH_SUMMARY_NAME,
                                              NULL);
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(searchList),
+  column = gtk_tree_view_get_column(searchList,
                                    col - 1);
   gtk_tree_view_column_set_resizable(column, TRUE);
   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, SER_SUM_NAME);
-  
gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(searchList),
-                                              col - 1),
-                                              TRUE);
+  gtk_tree_view_column_set_resizable(column, TRUE);
   renderer = gtk_cell_renderer_text_new();
-  col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(searchList),
-                                             -1,
-                                             _("Results"),
-                                             renderer,
-                                             "text", SER_SUM_COUNT,
-                                             NULL);
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(searchList),
+  col = gtk_tree_view_insert_column_with_attributes(searchList,
+                                                   -1,
+                                                   _("Results"),
+                                                   renderer,
+                                                   "text", 
SERARCH_SUMMARY_RESULT_COUNT,
+                                                   NULL);
+  column = gtk_tree_view_get_column(searchList,
                                    col - 1);
   gtk_tree_view_column_set_resizable(column, TRUE);
   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, SER_SUM_COUNT);
-  
gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(searchList),
-                                              col - 1),
-                                              TRUE);
+  gtk_tree_view_column_set_resizable(column, TRUE);
 
 
-  downloadList = glade_xml_get_widget(getMainXML(),
-                                      "activeDownloadsList");
+  downloadList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(),
+                                                   "activeDownloadsList"));
   download_summary =
     gtk_tree_store_new(DOWNLOAD_NUM,
                        G_TYPE_STRING, /* name (full-path file name) */
@@ -1291,68 +1474,73 @@
                        G_TYPE_UINT64,  /* size */
                       G_TYPE_STRING, /* human readable size */
                        G_TYPE_INT,  /* progress */
-                       G_TYPE_STRING, /* uri */
-                       G_TYPE_POINTER,  /* url */
-                       G_TYPE_POINTER, /* internal: gtk tree path / NULL */
-                      G_TYPE_POINTER); /* directory path if file is inside a 
dir */
-  gtk_tree_view_set_model(GTK_TREE_VIEW(downloadList),
+                       G_TYPE_STRING, /* uri as string */
+                      G_TYPE_POINTER); /* internal download list ptr */
+  gtk_tree_view_set_model(downloadList,
                           GTK_TREE_MODEL(download_summary));
+  gtk_tree_selection_set_mode(gtk_tree_view_get_selection(downloadList),
+                             GTK_SELECTION_MULTIPLE);
   renderer = gtk_cell_renderer_progress_new();
-  col = 
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList),
-                                              -1,
-                                              _("Name"),
-                                              renderer,
-                                              "value", DOWNLOAD_PROGRESS,
-                                              "text", DOWNLOAD_SHORTNAME,
-                                              NULL);
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
+  col = gtk_tree_view_insert_column_with_attributes(downloadList,
+                                                   -1,
+                                                   _("Name"),
+                                                   renderer,
+                                                   "value", DOWNLOAD_PROGRESS,
+                                                   "text", DOWNLOAD_SHORTNAME,
+                                                   NULL);
+  column = gtk_tree_view_get_column(downloadList,
                                    col - 1);
   gtk_tree_view_column_set_resizable(column, TRUE);
   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, DOWNLOAD_PROGRESS);
   /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
-  
gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
-                                              col - 1),
-                                              TRUE);
+  gtk_tree_view_column_set_resizable(column, TRUE);
   renderer = gtk_cell_renderer_text_new();
   g_object_set (renderer, "xalign", 1.00, NULL);
-  col = 
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList),
-                                              -1,
-                                              _("Size"),
-                                              renderer,
-                                              "text", DOWNLOAD_HSIZE,
-                                              NULL);
+  col = gtk_tree_view_insert_column_with_attributes(downloadList,
+                                                   -1,
+                                                   _("Size"),
+                                                   renderer,
+                                                   "text", DOWNLOAD_HSIZE,
+                                                   NULL);
   
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
+  column = gtk_tree_view_get_column(downloadList,
                                    col - 1);
   gtk_tree_view_column_set_resizable(column, TRUE);
   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, DOWNLOAD_SIZE);
   /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
-  
gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
-                                              col - 1),
-                                              TRUE);
+  gtk_tree_view_column_set_resizable(column, TRUE);
   renderer = gtk_cell_renderer_text_new();
-  col = 
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList),
-                                              -1,
-                                              _("URI"),
-                                              renderer,
-                                              "text", DOWNLOAD_URISTRING,
-                                              NULL);
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
+  col = gtk_tree_view_insert_column_with_attributes(downloadList,
+                                                   -1,
+                                                   _("URI"),
+                                                   renderer,
+                                                   "text", DOWNLOAD_URISTRING,
+                                                   NULL);
+  column = gtk_tree_view_get_column(downloadList,
                                    col - 1);
   gtk_tree_view_column_set_resizable(column, TRUE);
   gtk_tree_view_column_set_reorderable(column, TRUE);
   /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
-  
gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
-                                              col - 1),
-                                              TRUE);
-  DEBUG_END();
+  gtk_tree_view_column_set_resizable(column, TRUE);
 }
 
+/**
+ * Shutdown.
+ */
 void fs_search_stop() {
+  GtkComboBox * searchCB;
+  GtkListStore * model;
+
+  searchCB
+    = GTK_COMBO_BOX(glade_xml_get_widget(getMainXML(),
+                                        "fssearchKeywordComboBoxEntry"));
+  model = gtk_combo_box_get_model(searchCB);
+  /* FIXME: iterate over model entries
+     and free URIs and MetaData! */
 }
 
 

Modified: gnunet-gtk/src/plugins/fs/search.h
===================================================================
--- gnunet-gtk/src/plugins/fs/search.h  2006-10-28 22:59:13 UTC (rev 3558)
+++ gnunet-gtk/src/plugins/fs/search.h  2006-10-29 06:16:00 UTC (rev 3559)
@@ -36,6 +36,8 @@
 
 struct DL *
 fs_download_started(struct FSUI_DownloadList * fsui_dl,
+                   struct DL * dl_parent,
+                   struct SL * sl_parent,
                    unsigned long long total,
                    unsigned int anonymityLevel,
                    const ECRS_FileInfo * fi,

Modified: gnunet-gtk/src/plugins/fs/upload.c
===================================================================
--- gnunet-gtk/src/plugins/fs/upload.c  2006-10-28 22:59:13 UTC (rev 3558)
+++ gnunet-gtk/src/plugins/fs/upload.c  2006-10-29 06:16:00 UTC (rev 3559)
@@ -362,6 +362,8 @@
                       G_TYPE_STRING);  /* URI (as string) - after completion */
   gtk_tree_view_set_model(GTK_TREE_VIEW(uploadList),
                          GTK_TREE_MODEL(summary));
+  
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(uploadList)),
+                             GTK_SELECTION_MULTIPLE);
   renderer = gtk_cell_renderer_progress_new();
   col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(uploadList),
                                              -1,





reply via email to

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