gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r19635 - in gnunet-gtk: contrib src/fs


From: gnunet
Subject: [GNUnet-SVN] r19635 - in gnunet-gtk: contrib src/fs
Date: Thu, 2 Feb 2012 16:19:25 +0100

Author: grothoff
Date: 2012-02-02 16:19:25 +0100 (Thu, 02 Feb 2012)
New Revision: 19635

Modified:
   gnunet-gtk/contrib/gnunet_fs_gtk_edit_publication.glade
   gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
   gnunet-gtk/src/fs/gnunet-fs-gtk_publish-edit-dialog.c
Log:
-more code cleanup

Modified: gnunet-gtk/contrib/gnunet_fs_gtk_edit_publication.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_edit_publication.glade     2012-02-02 
14:41:20 UTC (rev 19634)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_edit_publication.glade     2012-02-02 
15:19:25 UTC (rev 19635)
@@ -91,7 +91,6 @@
     <property name="destroy_with_parent">True</property>
     <property name="skip_taskbar_hint">True</property>
     <property name="skip_pager_hint">True</property>
-    <signal name="realize" 
handler="GNUNET_GTK_edit_publication_window_realize_cb" swapped="no"/>
     <child>
       <object class="GtkVBox" id="GNUNET_GTK_edit_publication_master_vbox">
         <property name="visible">True</property>

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c    2012-02-02 14:41:20 UTC 
(rev 19634)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c    2012-02-02 15:19:25 UTC 
(rev 19635)
@@ -30,75 +30,221 @@
 
 #define MARKER_DIR_FILE_SIZE "-"
 
+/**
+ * Be very verbose when reporting progress (usually bad as it takes more time
+ * to display this than to make progress).
+ */
 #define VERBOSE_PROGRESS GNUNET_NO
 
+
+/**
+ * Context we create when we are scanning a directory.
+ */
 struct AddDirClientContext;
 
+
+/**
+ * Main handle of the dialog for a publish operation.
+ */
 struct MainPublishingDialogContext
 {
+  /**
+   * Main builder for the publishing dialog.
+   */
   GtkBuilder *builder;
+  
+  /**
+   * Builder for the master window (FIXME: remove)
+   */
   GtkBuilder *main_window_builder;
-  GtkTreeView *pseudonym_treeview;
+
+  /**
+   * Handle to the main window of the publishing dialog.
+   */
+  GtkWindow *master_pubdialog;
+
+  /**
+   * Selected pseudonym.
+   */
   GtkTreeSelection *pseudonym_selection;
+
+  /**
+   * Model with the list of (our) pseudonyms.
+   */
   GtkTreeModel *pseudonym_treemodel;
+
+  /**
+   * Tree view listing files to be published.
+   */
+  GtkTreeView *file_info_treeview;
+
+  /**
+   * Selected file in the 'file_info_treeview'
+   */
+  GtkTreeSelection *file_info_selection;
+
+  /**
+   * Model with the list of files to be shared.
+   */
+  GtkTreeModel *file_info_treemodel;  
+
+  /**
+   * Button to move selected file upwards
+   */
   GtkWidget *up_button;
+
+  /**
+   * Button to move selected file downwards
+   */
   GtkWidget *down_button;
+
+  /**
+   * Button to move selected file left (make sibling of current parent)
+   */
   GtkWidget *left_button;
+
+  /**
+   * Button to move selected file right (make child of predecessor)
+   */
   GtkWidget *right_button;
+
+  /**
+   * Button to delete selected file from the list
+   */
   GtkWidget *delete_button;
+
+  /**
+   * Button to edit meta data of the selected file
+   */
   GtkWidget *edit_button;
+
+  /**
+   * Button to publish all files from the dialog
+   */
   GtkWidget *execute_button;
+
+  /**
+   * Button to abort the publishing operation
+   */
   GtkWidget *cancel_button;
-  GtkTreeView *file_info_treeview;
-  GtkTreeSelection *file_info_selection;
-  GtkTreeModel *file_info_treemodel;  
-  GtkWindow *master_pubdialog;
 
+  /**
+   * FIXME: ugly, keep?
+   */
   gulong open_directory_handler_id;
+
+  /**
+   * FIXME: ugly, keep?
+   */
   GtkBuilder *open_directory_builder;
 
+  /**
+   * FIXME: ugly, keep?
+   */
   gulong open_file_handler_id;
+
+  /**
+   * FIXME: ugly, keep?
+   */
   GtkBuilder *open_file_builder;
 
-  /* To keep multiple scanners running */
+  /**
+   * Head of linked list of active open-directory operations.
+   */
   struct AddDirClientContext *adddir_head;
+
+  /**
+   * Tail of linked list of active open-directory operations.
+   */
   struct AddDirClientContext *adddir_tail;
 };
 
-/* One of these is kept for every directory being opened */
+
+/**
+ * Context we create when we are scanning a directory.
+ */
 struct AddDirClientContext
 {
-  struct AddDirClientContext *prev;
+  /**
+   * This is a doubly-linked list.
+   */
   struct AddDirClientContext *next;
 
-  struct GNUNET_FS_ProcessMetadataContext *pmc;
+  /**
+   * This is a doubly-linked list.
+   */
+  struct AddDirClientContext *prev;
 
+  /**
+   * Handle of the master publish window.
+   */
   struct MainPublishingDialogContext *ctx;
-  struct GNUNET_FS_DirScanner *ds;
 
-  struct GNUNET_FS_ShareTreeItem *directory_scan_result;
+  /**
+   * Builder for the progress dialog that is displayed during the scan.
+   */
+  GtkBuilder *progress_dialog_builder;
 
-  struct GNUNET_FS_BlockOptions directory_scan_bo;
-  int directory_scan_do_index;
+  /**
+   * The progress dialog itself.
+   */
+  GtkWidget *progress_dialog;
 
-  GtkBuilder *progress_dialog_builder;
-  GtkWidget *progress_dialog;
+  /**
+   * The progress bar of the progress dialog.
+   */
   GtkProgressBar *progress_dialog_bar;
-  GtkButton *progress_dialog_cancel;
+
+  /**
+   * Text view in the progress dialog (for error messages).
+   */
   GtkTextView *progress_dialog_textview;
+
+  /**
+   * Text buffer of the text view in the progress dialog.
+   */
   GtkTextBuffer *progress_dialog_textbuffer;
-  GtkTextMark *progress_dialog_textmark;
-  GtkAdjustment *textview_vertial_adjustment;
 
+  /**
+   * Adjustment (for scrolling) of the text view in the progress dialog.
+   */
+  GtkAdjustment *textview_vertical_adjustment;
+
+  /**
+   * Handle to the active directory scanning operation.
+   */
+  struct GNUNET_FS_DirScanner *ds;
+
+  /**
+   * Default options to use for sharing when adding files during the scan.
+   */
+  struct GNUNET_FS_BlockOptions directory_scan_bo;
+
+  /**
+   * Default "index" option to use for sharing when adding files during the 
scan.
+   */
+  int directory_scan_do_index;
+
+  /**
+   * Number of files that have had their meta data extracted (once done==total
+   * we're finished processing).
+   */
   unsigned int done;
+
+  /**
+   * Total number of files that we have found in the directory structure and 
that
+   * will need to be processed.
+   */
   unsigned int total;
+
 };
 
 
-static void
-selection_changed_cb (GtkTreeSelection * ts, struct 
MainPublishingDialogContext *ctx);
 
+/* ************************ editing operations inside the master dialog 
********************* */
 
+
+
 /**
  * Check if two GtkTreeIters refer to the same element.
  *
@@ -108,7 +254,9 @@
  * @return GNUNET_YES if they are equal
  */
 static int
-gtk_tree_iter_equals (GtkTreeModel * tm, GtkTreeIter * i1, GtkTreeIter * i2)
+gtk_tree_iter_equals (GtkTreeModel * tm,
+                     GtkTreeIter * i1, 
+                     GtkTreeIter * i2)
 {
   GtkTreePath *p1;
   GtkTreePath *p2;
@@ -122,49 +270,11 @@
   return (0 == ret) ? GNUNET_YES : GNUNET_NO;
 }
 
-/* Fill out the main publishing dialog context structure */
-static void
-init_ctx (struct MainPublishingDialogContext *ctx)
-{
-  ctx->pseudonym_treeview = GTK_TREE_VIEW (gtk_builder_get_object
-      (ctx->builder, "GNUNET_GTK_master_publish_dialog_pseudonym_tree_view"));
 
-  ctx->up_button = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder, "GNUNET_GTK_master_publish_dialog_up_button"));
-  ctx->down_button = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder, "GNUNET_GTK_master_publish_dialog_down_button"));
-  ctx->left_button = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder, "GNUNET_GTK_master_publish_dialog_left_button"));
-  ctx->right_button = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder, "GNUNET_GTK_master_publish_dialog_right_button"));
-  ctx->delete_button = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder, "GNUNET_GTK_master_publish_dialog_delete_button"));
-  ctx->edit_button = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder, "GNUNET_GTK_master_publish_dialog_edit_button"));
-  ctx->execute_button = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder, "GNUNET_GTK_master_publish_dialog_execute_button"));
-  ctx->cancel_button = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder , "GNUNET_GTK_master_publish_dialog_cancel_button"));
-  ctx->file_info_treeview = GTK_TREE_VIEW (gtk_builder_get_object
-      (ctx->builder, 
"GNUNET_GTK_master_publish_dialog_file_information_tree_view"));
-
-  ctx->master_pubdialog =
-      GTK_WINDOW (gtk_builder_get_object
-                  (ctx->builder, "GNUNET_GTK_master_publish_dialog"));
-
-  ctx->file_info_selection = gtk_tree_view_get_selection 
(ctx->file_info_treeview);
-  ctx->file_info_treemodel = gtk_tree_view_get_model (ctx->file_info_treeview);
-  ctx->pseudonym_selection = gtk_tree_view_get_selection 
(ctx->pseudonym_treeview);
-  ctx->pseudonym_treemodel = gtk_tree_view_get_model (ctx->pseudonym_treeview);
-
-  g_signal_connect (G_OBJECT (ctx->file_info_selection), "changed",
-                    G_CALLBACK (selection_changed_cb), ctx);
-  g_signal_connect (G_OBJECT (ctx->pseudonym_selection), "changed",
-                    G_CALLBACK (selection_changed_cb), ctx);
-}
-
 /**
- * Update selectivity in the master dialog.
+ * Update selectivity of buttons (up/down/left/right/cancel/execute) in the 
master dialog.
+ *
+ * @param ctx master dialog to update selectivity for
  */
 static void
 update_selectivity (struct MainPublishingDialogContext *ctx)
@@ -177,8 +287,9 @@
   int ns_ok;
   gchar *namespace_id;
 
+  /* find out if a namespace was selected */
   ns_ok = GNUNET_YES;
-  if (TRUE == gtk_tree_selection_get_selected (ctx->pseudonym_selection, NULL, 
&iter))
+  if (gtk_tree_selection_get_selected (ctx->pseudonym_selection, NULL, &iter))
   {
     gtk_tree_model_get (ctx->pseudonym_treemodel, &iter, 2, &namespace_id, -1);
     if (namespace_id == NULL)
@@ -186,19 +297,26 @@
     else
       g_free (namespace_id);
   }
+
   /* Don't let the user close the dialog until all scanners are finished and
-   * their windows are closed
-   */
-  if ((gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter))
-      && (ns_ok == GNUNET_YES) && ctx->adddir_head == NULL)
+     their windows are closed */
+  /* FIXME: what about open-directory operations? */
+  if ( (gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter)) && 
+       (ns_ok == GNUNET_YES) && 
+       (ctx->adddir_head == NULL) )
     gtk_widget_set_sensitive (ctx->execute_button, TRUE);
   else
     gtk_widget_set_sensitive (ctx->execute_button, FALSE);
+
+  /* if an 'edit' operation is open, don't even allow "cancel" */
+  /* FIXME: what about open-directory operations? */
   if (ctx->adddir_head == NULL)
     gtk_widget_set_sensitive (ctx->cancel_button, TRUE);
   else
     gtk_widget_set_sensitive (ctx->cancel_button, FALSE);
-  if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
+
+  /* now for the editing buttons... */
+  if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
   {
     gtk_widget_set_sensitive (ctx->up_button, FALSE);
     gtk_widget_set_sensitive (ctx->down_button, FALSE);
@@ -211,26 +329,22 @@
   gtk_widget_set_sensitive (ctx->delete_button, TRUE);
   gtk_widget_set_sensitive (ctx->edit_button, TRUE);
 
-  /* now figure out which move operations are currently legal */
-  GNUNET_assert (TRUE == gtk_tree_selection_get_selected 
(ctx->file_info_selection, NULL, &iter));
-  if (TRUE == gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter))
-  {
-    gtk_widget_set_sensitive (ctx->down_button, TRUE);
-  }
-  else
-  {
+  /* figure out which move operations are currently legal */
+  GNUNET_assert (gtk_tree_selection_get_selected (ctx->file_info_selection, 
NULL, &iter));
+  if (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter))  
+    gtk_widget_set_sensitive (ctx->down_button, TRUE);  
+  else  
     gtk_widget_set_sensitive (ctx->down_button, FALSE);
-  }
-  GNUNET_assert (TRUE == gtk_tree_selection_get_selected 
(ctx->file_info_selection, NULL, &iter));
-  if (TRUE == gtk_tree_model_iter_parent (ctx->file_info_treemodel, &parent, 
&iter))
+  GNUNET_assert (gtk_tree_selection_get_selected (ctx->file_info_selection, 
NULL, &iter));
+  if (gtk_tree_model_iter_parent (ctx->file_info_treemodel, &parent, &iter))
   {
     gtk_widget_set_sensitive (ctx->left_button, TRUE);
-    GNUNET_assert (TRUE == gtk_tree_model_iter_children 
(ctx->file_info_treemodel, &pred, &parent));
+    GNUNET_assert (gtk_tree_model_iter_children (ctx->file_info_treemodel, 
&pred, &parent));
   }
   else
   {
     gtk_widget_set_sensitive (ctx->left_button, FALSE);
-    GNUNET_assert (TRUE == gtk_tree_model_get_iter_first 
(ctx->file_info_treemodel, &pred));
+    GNUNET_assert (gtk_tree_model_get_iter_first (ctx->file_info_treemodel, 
&pred));
   }
   /* iterate over 'next' of pred to find out if our
    * predecessor is a directory! */
@@ -239,38 +353,49 @@
   {
     gtk_tree_model_get (ctx->file_info_treemodel, &pred, 5, &fip, -1);
     is_dir = GNUNET_FS_file_information_is_directory (fip);
-    GNUNET_assert (TRUE == gtk_tree_model_iter_next (ctx->file_info_treemodel, 
&pred));
+    GNUNET_assert (gtk_tree_model_iter_next (ctx->file_info_treemodel, &pred));
   }
-  if (GNUNET_YES == is_dir)
-  {
-    gtk_widget_set_sensitive (ctx->right_button, TRUE);
-  }
-  else
-  {
-    gtk_widget_set_sensitive (ctx->right_button, FALSE);
-  }
-  if (GNUNET_SYSERR != is_dir)
-  {
-    gtk_widget_set_sensitive (ctx->up_button, TRUE);
-  }
-  else
-  {
-    gtk_widget_set_sensitive (ctx->up_button, FALSE);
-  }
+  if (GNUNET_YES == is_dir)  
+    gtk_widget_set_sensitive (ctx->right_button, TRUE);  
+  else  
+    gtk_widget_set_sensitive (ctx->right_button, FALSE);  
+  if (GNUNET_SYSERR != is_dir)  
+    gtk_widget_set_sensitive (ctx->up_button, TRUE);  
+  else  
+    gtk_widget_set_sensitive (ctx->up_button, FALSE);  
 }
 
 
 /**
+ * The selection in the file list tree view changed; update the button 
sensitivity.
+ *
+ * @param ts the changed selection
+ * @param user_data master publishing dialog context of our window
+ */
+static void
+selection_changed_cb (GtkTreeSelection * ts, 
+                     gpointer user_data)
+{
+  struct MainPublishingDialogContext *ctx = user_data;
+
+  update_selectivity (ctx);
+}
+
+
+/**
  * Add an empty directory to the tree model.
  *
+ * @param ctx master publishing dialog context of our window
  * @param name name for the directory
  * @param bo block options
  * @param iter parent entry, or NULL for top-level addition
  * @param pos iterator to set to the location of the new element
  */
 static void
-create_dir_at_iter (struct MainPublishingDialogContext *ctx, const char *name,
-                    const struct GNUNET_FS_BlockOptions *bo, GtkTreeIter * 
iter,
+create_dir_at_iter (struct MainPublishingDialogContext *ctx, 
+                   const char *name,
+                    const struct GNUNET_FS_BlockOptions *bo, 
+                   GtkTreeIter * iter,
                     GtkTreeIter * pos)
 {
   struct GNUNET_FS_FileInformation *fi;
@@ -291,62 +416,97 @@
   fi = GNUNET_FS_file_information_create_empty_directory
       (GNUNET_FS_GTK_get_fs_handle (), row_reference, NULL, meta, bo, name);
   GNUNET_CONTAINER_meta_data_destroy (meta);
-  gtk_tree_store_set (GTK_TREE_STORE (ctx->file_info_treemodel), pos, 0, 
MARKER_DIR_FILE_SIZE, 1, (gboolean) GNUNET_NO,
-                      2, name, 3, (guint) bo->anonymity_level, 4,
-                      (guint) bo->content_priority, 5, fi,
+  gtk_tree_store_set (GTK_TREE_STORE (ctx->file_info_treemodel), pos, 
+                     0, MARKER_DIR_FILE_SIZE, 
+                     1, (gboolean) GNUNET_NO,
+                      2, name, 
+                     3, (guint) bo->anonymity_level, 
+                     4, (guint) bo->content_priority, 
+                     5, fi,
                      6, (guint64) bo->expiration_time.abs_value,
                      7, (guint) bo->replication_level,
                      -1);
   update_selectivity (ctx);
 }
 
-static void
-selection_changed_cb (GtkTreeSelection * ts, struct 
MainPublishingDialogContext *ctx)
-{
-  update_selectivity (ctx);
-}
 
+/**
+ * Remove the given entry and all of its children from the tree store.
+ *
+ * @param ts tree store to edit
+ * @param root root of the subtree to remove
+ */
 static void
-remove_old_entry (GtkTreeStore * ts, GtkTreeIter * root)
+remove_old_entry (GtkTreeStore * ts,
+                 GtkTreeIter * root)
 {
   GtkTreeIter child;
 
-  while (TRUE ==
-         gtk_tree_model_iter_children (GTK_TREE_MODEL (ts), &child, root))
+  while (gtk_tree_model_iter_children (GTK_TREE_MODEL (ts), &child, root))
     remove_old_entry (ts, &child);
   gtk_tree_store_remove (ts, root);
 }
 
 
 /**
- * Move an entry in the tree.
+ * Copy an entry in the tree from the 'old' position to the 'new'
+ * position.  All of the fields are copied, plain pointers will be
+ * aliased (model will thus be inconsistent until 'remove_old_entry'
+ * is called on the 'old' entry).
+ *
+ * @param ctx main publishing context
+ * @param tm tree model for the move operation
+ * @param old old position (source of the copy operation)
+ * @param newpos destination of the copy operation
+ * @param dsel GNUNET_YES for the top-level operation,
+ *             GNUNET_NO for the recursive calls; if GNUNET_YES,
+ *             we ensure that the tree view is expanded to cover
+ *             the element; the element is also then selected
  */
 static void
-move_entry (struct MainPublishingDialogContext *ctx, GtkTreeModel * tm, 
GtkTreeIter * old,
+copy_entry (struct MainPublishingDialogContext *ctx, GtkTreeModel * tm, 
GtkTreeIter * old,
             GtkTreeIter * newpos, int dsel)
 {
-  struct GNUNET_FS_FileInformation *fip;
-  gint do_index;
-  gchar *short_fn;
-  guint anonymity_level;
-  guint priority;
-  guint replication_level;
-  guint64 expiration_time_abs;
-  char *fsf;
   GtkTreePath *path;
   GtkTreeIter child;
-  GtkTreeIter cnewpos;
   GtkTreeRowReference *rr;
-  GtkTreeRowReference *rr2;
 
-  gtk_tree_model_get (tm, old, 0, &fsf, 1, &do_index, 2, &short_fn, 3,
-                      &anonymity_level, 4, &priority, 5, &fip, 
-                     6, &expiration_time_abs, 7, &replication_level, -1);
-  gtk_tree_store_set (GTK_TREE_STORE (tm), newpos, 0, fsf, 1, do_index, 2,
-                      short_fn, 3, (guint) anonymity_level, 4, (guint) 
priority,
-                      5, fip, 
-                     6, expiration_time_abs,
-                     7, replication_level, -1);
+  /* first, move the data */
+  {
+    struct GNUNET_FS_FileInformation *fip;
+    gint do_index;
+    gchar *short_fn;
+    guint anonymity_level;
+    guint priority;
+    guint replication_level;
+    guint64 expiration_time_abs;
+    char *fsf;
+
+    gtk_tree_model_get (tm, old,
+                       0, &fsf, 
+                       1, &do_index, 
+                       2, &short_fn, 
+                       3, &anonymity_level, 
+                       4, &priority,
+                       5, &fip, 
+                       6, &expiration_time_abs,
+                       7, &replication_level, 
+                       -1);
+    gtk_tree_store_set (GTK_TREE_STORE (tm), newpos, 
+                       0, fsf, 
+                       1, do_index, 
+                       2, short_fn, 
+                       3, anonymity_level, 
+                       4, priority,
+                       5, fip, 
+                       6, expiration_time_abs,
+                       7, replication_level, 
+                       -1);
+    g_free (short_fn);
+    g_free (fsf);
+  }
+
+  /* remember our destination location if needed */
   if (dsel == GNUNET_YES)
   {
     path = gtk_tree_model_get_path (tm, newpos);
@@ -357,25 +517,30 @@
   {
     rr = NULL;
   }
-  if (TRUE == gtk_tree_model_iter_children (tm, &child, old))
+
+  /* recursively move children */
+  if (gtk_tree_model_iter_children (tm, &child, old))
   {
     do
     {
+      GtkTreeRowReference *crr;
+      GtkTreeIter cnewpos;
+
       path = gtk_tree_model_get_path (tm, &child);
-      rr2 = gtk_tree_row_reference_new (tm, path);
+      crr = gtk_tree_row_reference_new (tm, path);
       gtk_tree_path_free (path);
       gtk_tree_store_insert_before (GTK_TREE_STORE (tm), &cnewpos, newpos,
                                     NULL);
-      move_entry (ctx, tm, &child, &cnewpos, GNUNET_NO);
-      path = gtk_tree_row_reference_get_path (rr2);
-      gtk_tree_row_reference_free (rr2);
+      copy_entry (ctx, tm, &child, &cnewpos, GNUNET_NO);
+      path = gtk_tree_row_reference_get_path (crr);
+      gtk_tree_row_reference_free (crr);
       GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &child, path));
       gtk_tree_path_free (path);
     }
-    while (TRUE == gtk_tree_model_iter_next (tm, &child));
+    while (gtk_tree_model_iter_next (tm, &child));
   }
-  g_free (short_fn);
-  g_free (fsf);
+
+  /* update selection, etc. if applicable */
   if (dsel == GNUNET_YES)
   {
     path = gtk_tree_row_reference_get_path (rr);
@@ -384,28 +549,37 @@
     GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, newpos, path));
     gtk_tree_path_free (path);
     gtk_tree_selection_select_iter (ctx->file_info_selection, newpos);
+    update_selectivity (ctx);
   }
-  update_selectivity (ctx);
 }
 
 
 /**
- * User has changed the "current" identifier for the content in
+ * User has changed the "update" identifier for the content in
  * the GtkTreeView.  Update the model.
+ *
+ * @param renderer pseudonym renderer that notified us about the edit
+ * @param cpath where the edit happened
+ * @param new_text the new value
+ * @param user_data master publishing dialog context of our window
  */
-void GNUNET_GTK_master_publish_dialog_pseudonym_updates_renderer_edited_cb
-    (GtkCellRendererText * renderer, gchar * cpath, gchar * new_text,
-     struct MainPublishingDialogContext *ctx)
+void 
+GNUNET_GTK_master_publish_dialog_pseudonym_updates_renderer_edited_cb 
(GtkCellRendererText * renderer, 
+                                                                      gchar * 
cpath,
+                                                                      gchar * 
new_text,
+                                                                      gpointer 
user_data)
 {
+  struct MainPublishingDialogContext *ctx = user_data;
   GtkTreeIter iter;
 
-  if (TRUE !=
-      gtk_tree_model_get_iter_from_string (ctx->pseudonym_treemodel, &iter, 
cpath))
+  if (! gtk_tree_model_get_iter_from_string (ctx->pseudonym_treemodel, &iter, 
cpath))
   {
     GNUNET_break (0);
     return;
   }
-  gtk_tree_store_set (GTK_TREE_STORE (ctx->pseudonym_treemodel), &iter, 5, 
new_text, -1);
+  gtk_tree_store_set (GTK_TREE_STORE (ctx->pseudonym_treemodel), &iter, 
+                     5, new_text, 
+                     -1);
   update_selectivity (ctx);
 }
 
@@ -413,45 +587,60 @@
 /**
  * User has changed the "current" identifier for the content in
  * the GtkTreeView.  Update the model.
+ *
+ * @param renderer pseudonym renderer that notified us about the edit
+ * @param cpath where the edit happened
+ * @param new_text the new value
+  * @param user_data master publishing dialog context of our window
  */
-void GNUNET_GTK_master_publish_dialog_pseudonym_identifier_renderer_edited_cb
-    (GtkCellRendererText * renderer, gchar * cpath, gchar * new_text,
-     struct MainPublishingDialogContext *ctx)
+void
+GNUNET_GTK_master_publish_dialog_pseudonym_identifier_renderer_edited_cb 
(GtkCellRendererText * renderer, 
+                                                                         gchar 
* cpath, 
+                                                                         gchar 
* new_text,
+                                                                         
gpointer user_data)
 {
+  struct MainPublishingDialogContext *ctx = user_data;
   GtkTreeIter iter;
 
-  if (TRUE !=
-      gtk_tree_model_get_iter_from_string (ctx->pseudonym_treemodel, &iter, 
cpath))
+  if (! gtk_tree_model_get_iter_from_string (ctx->pseudonym_treemodel, &iter, 
cpath))
   {
     GNUNET_break (0);
     return;
   }
-  gtk_tree_store_set (GTK_TREE_STORE (ctx->pseudonym_treemodel), &iter, 2, 
new_text, -1);
+  gtk_tree_store_set (GTK_TREE_STORE (ctx->pseudonym_treemodel), &iter, 
+                     2, new_text, 
+                     -1);
   update_selectivity (ctx);
 }
 
 
+/**
+ * User has clicked on the 'right' button to move files in the master
+ * edit dialog tree view.  Execute the move.
+ *
+ * @param dummy the button
+ * @param user_data master publishing dialog context of our window
+ */
 void
 GNUNET_GTK_master_publish_dialog_right_button_clicked_cb (GtkWidget * dummy,
-                                                          struct 
MainPublishingDialogContext *ctx)
+                                                          gpointer user_data)
 {
+  struct MainPublishingDialogContext *ctx = user_data;
   GtkTreeIter iter;
   GtkTreeIter parent;
   GtkTreeIter pred;
   GtkTreeIter prev;
   GtkTreeIter pos;
 
-  if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
+  if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
   {
     GNUNET_break (0);
     return;
   }
-  if (TRUE == gtk_tree_model_iter_parent (ctx->file_info_treemodel, &parent, 
&iter))
+  if (gtk_tree_model_iter_parent (ctx->file_info_treemodel, &parent, &iter))
+    GNUNET_assert (gtk_tree_model_iter_children (ctx->file_info_treemodel, 
&pred, &parent));
+  else if (! gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &pred))
   {
-    GNUNET_assert (TRUE == gtk_tree_model_iter_children 
(ctx->file_info_treemodel, &pred, &parent));
-  }
-  else if (TRUE != gtk_tree_model_get_iter_first (ctx->file_info_treemodel, 
&pred))
-  {
     GNUNET_break (0);
     return;
   }
@@ -460,53 +649,68 @@
   while (GNUNET_YES != gtk_tree_iter_equals (ctx->file_info_treemodel, &pred, 
&iter))
   {
     prev = pred;
-    GNUNET_assert (TRUE == gtk_tree_model_iter_next (ctx->file_info_treemodel, 
&pred));
+    GNUNET_assert (gtk_tree_model_iter_next (ctx->file_info_treemodel, &pred));
   }
   gtk_tree_store_insert_before (GTK_TREE_STORE (ctx->file_info_treemodel), 
&pos, &prev, NULL);
-  if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
+  if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
   {
     GNUNET_break (0);
     return;
   }
-  move_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES);
+  copy_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES);
   remove_old_entry (GTK_TREE_STORE (ctx->file_info_treemodel), &iter);
 }
 
 
+/**
+ * User has clicked on the 'left' button to move files in the master
+ * edit dialog tree view.  Execute the move.
+ *
+ * @param dummy the button
+ * @param user_data master publishing dialog context of our window
+ */
 void
 GNUNET_GTK_master_publish_dialog_left_button_clicked_cb (GtkWidget * dummy,
-                                                         struct 
MainPublishingDialogContext *ctx)
+                                                        gpointer user_data)
 {
+  struct MainPublishingDialogContext *ctx = user_data;
   GtkTreeIter iter;
   GtkTreeIter parent;
   GtkTreeIter pos;
 
-
-  if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
+  if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
   {
     GNUNET_break (0);
     return;
   }
-  if (TRUE != gtk_tree_model_iter_parent (ctx->file_info_treemodel, &parent, 
&iter))
+  if (! gtk_tree_model_iter_parent (ctx->file_info_treemodel, &parent, &iter))
   {
     GNUNET_break (0);
     return;
   }
   gtk_tree_store_insert_after (GTK_TREE_STORE (ctx->file_info_treemodel), 
&pos, NULL, &parent);
-  if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
+  if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
   {
     GNUNET_break (0);
     return;
   }
-  move_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES);
+  copy_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES);
   remove_old_entry (GTK_TREE_STORE (ctx->file_info_treemodel), &iter);
 }
 
 
+/**
+ * User has clicked on the 'up' button to move files in the master
+ * edit dialog tree view.  Execute the move.
+ *
+ * @param dummy the button
+ * @param user_data master publishing dialog context of our window
+ */
 void
 GNUNET_GTK_master_publish_dialog_up_button_clicked_cb (GtkWidget * dummy,
-                                                       struct 
MainPublishingDialogContext *ctx)
+                                                      gpointer user_data)
 {
+  struct MainPublishingDialogContext *ctx = user_data;
   GtkTreeIter iter;
   GtkTreeIter parent;
   GtkTreeIter pred;
@@ -514,115 +718,267 @@
   GtkTreeIter *pprev;
   GtkTreeIter pos;
 
-  if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
+  if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
   {
     GNUNET_break (0);
     return;
   }
-  if (TRUE == gtk_tree_model_iter_parent (ctx->file_info_treemodel, &parent, 
&iter))
+  if (! gtk_tree_model_iter_parent (ctx->file_info_treemodel, &parent, &iter))
   {
     GNUNET_assert (TRUE == gtk_tree_model_iter_children 
(ctx->file_info_treemodel, &pred, &parent));
     pprev = &parent;
   }
-  else if (TRUE == gtk_tree_model_get_iter_first (ctx->file_info_treemodel, 
&pred))
+  else if (! gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &pred))  
   {
-    pprev = NULL;
-  }
-  else
-  {
     GNUNET_break (0);
     return;
-  }
+  } else
+    pprev = NULL;    
   /* iterate over 'next' of pred to find out who our predecessor is! */
   while (GNUNET_YES != gtk_tree_iter_equals (ctx->file_info_treemodel, &pred, 
&iter))
   {
     prev = pred;
     pprev = &prev;
-    GNUNET_assert (TRUE == gtk_tree_model_iter_next (ctx->file_info_treemodel, 
&pred));
+    GNUNET_assert (gtk_tree_model_iter_next (ctx->file_info_treemodel, &pred));
   }
   gtk_tree_store_insert_before (GTK_TREE_STORE (ctx->file_info_treemodel), 
&pos, NULL, pprev);
-  if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
+  if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
   {
     GNUNET_break (0);
     return;
   }
-  move_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES);
+  copy_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES);
   remove_old_entry (GTK_TREE_STORE (ctx->file_info_treemodel), &iter);
 }
 
 
+/**
+ * User has clicked on the 'down' button to move files in the master
+ * edit dialog tree view.  Execute the move.
+ *
+ * @param dummy the button
+ * @param user_data master publishing dialog context of our window
+ */
 void
 GNUNET_GTK_master_publish_dialog_down_button_clicked_cb (GtkWidget * dummy,
-                                                         struct 
MainPublishingDialogContext *ctx)
+                                                        gpointer user_data)
 {
+  struct MainPublishingDialogContext *ctx = user_data;
   GtkTreeIter iter;
   GtkTreeIter next;
   GtkTreeIter pos;
 
-  if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
+  if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
   {
     GNUNET_break (0);
     return;
   }
-  if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&next))
+  if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&next))
   {
     GNUNET_break (0);
     return;
   }
-  GNUNET_assert (TRUE == gtk_tree_model_iter_next (ctx->file_info_treemodel, 
&next));
+  GNUNET_assert (gtk_tree_model_iter_next (ctx->file_info_treemodel, &next));
   gtk_tree_store_insert_after (GTK_TREE_STORE (ctx->file_info_treemodel), 
&pos, NULL, &next);
-  if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
+  if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
   {
     GNUNET_break (0);
     return;
   }
-  move_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES);
+  copy_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES);
   remove_old_entry (GTK_TREE_STORE (ctx->file_info_treemodel), &iter);
 }
 
 
+/**
+ * User has clicked on the 'new' button to add an empty directory in the master
+ * edit dialog tree view.  Add an empty directory.
+ *
+ * @param dummy the button
+ * @param user_data master publishing dialog context of our window
+ */
 void
 GNUNET_GTK_master_publish_dialog_new_button_clicked_cb (GtkWidget * dummy,
-                                                        struct 
MainPublishingDialogContext *ctx)
+                                                       gpointer user_data)
 {
+  struct MainPublishingDialogContext *ctx = user_data;
   GtkTreeIter iter;
   GtkTreeIter pos;
   struct GNUNET_FS_BlockOptions bo;
 
-  /* FIXME: consider opening a dialog to get
-   * anonymity, priority and expiration prior
-   * to calling this function (currently we
-   * use default values for those).
-   * Or getting these values from the configuration.
-   */
+  /* FIXME-FEATURE: consider opening a dialog to get anonymity,
+     priority and expiration prior to calling this function (currently
+     we use default values for those).  Or getting these values from
+     the configuration. */
   bo.anonymity_level = 1;
   bo.content_priority = 1000;
-  bo.expiration_time =
-      GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS);
+  bo.expiration_time = GNUNET_TIME_relative_to_absolute 
(GNUNET_TIME_UNIT_YEARS);
   bo.replication_level = 1;
-  if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
+  if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
+    create_dir_at_iter (ctx, "unnamed/", &bo, NULL, &pos);
+  else
+    create_dir_at_iter (ctx, "unnamed/", &bo, &iter, &pos);
+}
+
+
+/**
+ * Free row reference stored in the file information's
+ * client-info pointer.
+ *
+ * @param cls always NULL
+ * @param fi the file information that is being destroyed, unused
+ * @param length length of the file, unused
+ * @param meta meta data, unused
+ * @param uri keyword URI, unused
+ * @param bo publishing options, unused
+ * @param do_index indexing option, unused
+ * @param client_info pointer to the GtkTreeRowReference, freed
+ * @return GNUNET_OK to traverse entire subtree 
+ */
+static int
+free_fi_row_reference (void *cls, struct GNUNET_FS_FileInformation *fi,
+                       uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
+                       struct GNUNET_FS_Uri **uri,
+                       struct GNUNET_FS_BlockOptions *bo, int *do_index,
+                       void **client_info)
+{
+  GtkTreeRowReference *row = *client_info;
+
+  if (row == NULL)
   {
-    create_dir_at_iter (ctx, "unnamed/", &bo, NULL, &pos);
+    GNUNET_break (0);
+    return GNUNET_OK;
+  }
+  gtk_tree_row_reference_free (row);
+  *client_info = NULL;
+  return GNUNET_OK;
+}
+
+
+/**
+ * User has clicked on the 'delete' button to delete a file or directory in 
the master
+ * edit dialog tree view.  Delete the selected entry.
+ *
+ * @param dummy the button
+ * @param user_data master publishing dialog context of our window
+ */
+void
+GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy,
+                                                          gpointer user_data)
+{
+  struct MainPublishingDialogContext *ctx = user_data;
+  GtkTreeIter iter;
+  struct GNUNET_FS_FileInformation *fip;
+
+  if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
+  {
+    GNUNET_break (0);
     return;
   }
-  create_dir_at_iter (ctx, "unnamed/", &bo, &iter, &pos);
+  gtk_tree_model_get (ctx->file_info_treemodel, &iter, 5, &fip, -1);
+  GNUNET_FS_file_information_destroy (fip, &free_fi_row_reference, NULL);
+  /* FIXME-BUG: the call above frees the row references in the entire 
+     subtree; however, with the 'remove' operation below we
+     ONLY delete the top-level entry; we probably want to delete
+     the entire directory subtree here... */
+  gtk_tree_store_remove (GTK_TREE_STORE (ctx->file_info_treemodel), &iter);
+  update_selectivity (ctx);
 }
 
 
+
+/* ******************** progress dialog / import of directories * 
********************** */
+
+
+/**
+ * Close the progress dialog and free its handle.
+ *
+ * @param adcc context for the progress dialog to close
+ */
 static void
+destroy_progress_dialog (struct AddDirClientContext *adcc)
+{
+  GNUNET_assert (NULL == adcc->ds);
+  gtk_widget_destroy (adcc->progress_dialog);
+  g_object_unref (G_OBJECT (adcc->progress_dialog_builder));  
+  GNUNET_CONTAINER_DLL_remove (adcc->ctx->adddir_head,
+                              adcc->ctx->adddir_tail, 
+                              adcc);
+  update_selectivity (adcc->ctx);
+  GNUNET_free (adcc);
+}
+
+
+/**
+ * User clicked on the 'cancel' button of the progress dialog.
+ * Cancel the operation.
+ *
+ * @param button the cancel button
+ * @param user_data progress dialog context of our window
+ */
+void
+GNUNET_FS_GTK_progress_dialog_cancel_button_clicked_cb (GtkButton *button,
+                                                       gpointer user_data)
+{
+  struct AddDirClientContext *adcc = user_data;
+
+  if (NULL == adcc->ds)
+  {
+    GNUNET_break (0);
+  }
+  else
+  {
+    /* signal the scanner to finish */
+    GNUNET_FS_directory_scan_abort (adcc->ds);
+    adcc->ds = NULL;
+  }
+  destroy_progress_dialog (adcc);
+}
+
+
+/**
+ * User attempted to close the progress dialog.  Refuse.
+ *
+ * @param widget the widget emitting the event
+ * @param event the event
+ * @param user_data progress dialog context of our window
+ * @return FALSE to refuse to close
+ */
+gboolean
+GNUNET_FS_GTK_progress_dialog_delete_event_cb (GtkWidget *widget,
+                                              GdkEvent * event,
+                                              void *cls)
+{
+  /* Don't allow GTK to kill the window, until the scan is finished */
+  return FALSE;
+}
+
+
+/**
+ * Display some additional information in the text area of the 
+ * progress dialog.
+ *
+ * @param adcc  progress dialog context of our window
+ * @param text text to add
+ */
+static void
 insert_progress_dialog_text (struct AddDirClientContext *adcc,
                             const char *text)
 {
   gtk_text_buffer_insert_at_cursor (adcc->progress_dialog_textbuffer,
                                    text, -1);
   gtk_text_view_place_cursor_onscreen (adcc->progress_dialog_textview);
-  gtk_adjustment_set_value (adcc->textview_vertial_adjustment,
-                           gtk_adjustment_get_upper 
(adcc->textview_vertial_adjustment));
+  gtk_adjustment_set_value (adcc->textview_vertical_adjustment,
+                           gtk_adjustment_get_upper 
(adcc->textview_vertical_adjustment));
 }
 
 
+/**
+ *
+ */
 static void
-add_item (struct AddDirClientContext *adcc, GtkTreeStore *ts,
+add_item (struct AddDirClientContext *adcc, 
+         GtkTreeStore *ts,
          struct GNUNET_FS_ShareTreeItem *item, 
          GtkTreeIter *parent, 
          GtkTreeIter *sibling,
@@ -640,12 +996,10 @@
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "stat", item->filename);
     return;
   }
-
   gtk_tree_store_insert_after (ts, item_iter, parent, sibling);
   path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), item_iter);
   row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), path);
   gtk_tree_path_free (path);
-
   if (item->is_directory)
   {
     if (NULL != item->meta)
@@ -675,14 +1029,15 @@
   else
     file_size_fancy = GNUNET_STRINGS_byte_size_fancy (sbuf.st_size);
   
-  gtk_tree_store_set (ts, item_iter, 0, file_size_fancy,
-      1, (gboolean) adcc->directory_scan_do_index,
-      2, item->short_filename,
-      3, (guint) adcc->directory_scan_bo.anonymity_level,
-      4, (guint) adcc->directory_scan_bo.content_priority,
-      5, fi,
-      6, (guint64) adcc->directory_scan_bo.expiration_time.abs_value,
-      7, (guint) adcc->directory_scan_bo.replication_level, -1);
+  gtk_tree_store_set (ts, item_iter, 
+                     0, file_size_fancy,
+                     1, (gboolean) adcc->directory_scan_do_index,
+                     2, item->short_filename,
+                     3, (guint) adcc->directory_scan_bo.anonymity_level,
+                     4, (guint) adcc->directory_scan_bo.content_priority,
+                     5, fi,
+                     6, (guint64) 
adcc->directory_scan_bo.expiration_time.abs_value,
+                     7, (guint) adcc->directory_scan_bo.replication_level, -1);
   GNUNET_free (file_size_fancy);
 }
 
@@ -715,20 +1070,10 @@
 }
 
 
+/**
+ *
+ */
 static void
-close_scan (struct AddDirClientContext *adcc)
-{
-  gtk_widget_destroy (adcc->progress_dialog);
-  g_object_unref (G_OBJECT (adcc->progress_dialog_builder));  
-  GNUNET_CONTAINER_DLL_remove (adcc->ctx->adddir_head,
-                              adcc->ctx->adddir_tail, 
-                              adcc);
-  update_selectivity (adcc->ctx);
-  GNUNET_free (adcc);
-}
-
-
-static void
 directory_scan_cb (void *cls, 
                   const char *filename, int is_directory,
                   enum GNUNET_FS_DirScannerProgressUpdateReason reason)
@@ -810,17 +1155,20 @@
     adcc->ds = NULL;
     break;
   case GNUNET_FS_DIRSCANNER_FINISHED:
-    insert_progress_dialog_text (adcc, _("Scanner has finished.\n"));
-    adcc->directory_scan_result = GNUNET_FS_directory_scan_get_result 
(adcc->ds);
-    adcc->ds = NULL;
-    GNUNET_FS_share_tree_trim (adcc->directory_scan_result);
-    add_share_items_to_treestore (adcc, 
-                                 adcc->directory_scan_result,
-                                 NULL);
-    GNUNET_FS_share_tree_free (adcc->directory_scan_result);
-    adcc->directory_scan_result = NULL;
-    update_selectivity (adcc->ctx);
-    close_scan (adcc);
+    {
+      struct GNUNET_FS_ShareTreeItem *directory_scan_result;
+
+      insert_progress_dialog_text (adcc, _("Scanner has finished.\n"));
+      directory_scan_result = GNUNET_FS_directory_scan_get_result (adcc->ds);
+      adcc->ds = NULL;
+      GNUNET_FS_share_tree_trim (directory_scan_result);
+      add_share_items_to_treestore (adcc, 
+                                   directory_scan_result,
+                                   NULL);
+      GNUNET_FS_share_tree_free (directory_scan_result);
+      update_selectivity (adcc->ctx);
+      destroy_progress_dialog (adcc);
+    }
     break;
   default:
     GNUNET_break (0);
@@ -829,6 +1177,9 @@
 }
 
 
+/**
+ *
+ */
 static void
 scan_file_or_directory (struct MainPublishingDialogContext *ctx, 
                        gchar *filename,
@@ -854,13 +1205,10 @@
   adcc->progress_dialog_bar = GTK_PROGRESS_BAR (gtk_builder_get_object (
       adcc->progress_dialog_builder,
       "GNUNET_FS_GTK_progress_dialog_progressbar"));
-  adcc->progress_dialog_cancel = GTK_BUTTON (gtk_builder_get_object (
-      adcc->progress_dialog_builder,
-      "GNUNET_FS_GTK_progress_dialog_cancel_button"));
   adcc->progress_dialog_textview = GTK_TEXT_VIEW (
       gtk_builder_get_object (adcc->progress_dialog_builder,
       "GNUNET_FS_GTK_progress_dialog_textview"));
-  adcc->textview_vertial_adjustment  = GTK_ADJUSTMENT (
+  adcc->textview_vertical_adjustment  = GTK_ADJUSTMENT (
       gtk_builder_get_object (adcc->progress_dialog_builder,
       "GNUNET_FS_GTK_progress_dialog_textview_vertical_adjustment"));
   adcc->progress_dialog_textbuffer = GTK_TEXT_BUFFER (
@@ -868,9 +1216,6 @@
       "GNUNET_FS_GTK_progress_dialog_textbuffer"));
   gtk_text_buffer_get_end_iter (adcc->progress_dialog_textbuffer,
       &iter);
-  adcc->progress_dialog_textmark = gtk_text_buffer_create_mark (
-      adcc->progress_dialog_textbuffer, "scroll",
-      &iter, FALSE);
 #if VERBOSE_PROGRESS
   gtk_widget_show (GTK_WIDGET (gtk_builder_get_object 
(adcc->progress_dialog_builder,
                                                       
"GNUNET_FS_GTK_progress_dialog_scrolled_window")));
@@ -884,6 +1229,9 @@
 }
 
 
+/**
+ * @param user_data master publishing dialog context of our window
+ */
 static void
 publish_directory_dialog_response_cb (GtkDialog * dialog,
                                      gint response_id,
@@ -936,6 +1284,9 @@
 }
 
 
+/**
+ * @param user_data master publishing dialog context of our window
+ */
 static void
 publish_file_dialog_response_cb (GtkDialog * dialog,
                                 gint response_id,
@@ -996,45 +1347,113 @@
 }
 
 
+/**
+ * User clicked on the 'add' button in the master publish dialog.
+ * Create the dialog to allow the user to select a file to add.
+ * 
+ * FIXME-UGLY: lots of code duplication between files & directories here...
+ *
+ * @param dummy the button that was pressed
+ * @param user_data master publishing dialog context of our window
+ */
 void
 GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy,
-                                                        struct 
MainPublishingDialogContext *ctx)
+                                                         gpointer user_data)
 {
+  struct MainPublishingDialogContext *ctx = user_data;
   GtkWidget *ad;
-
   GtkComboBox *combo;
   GtkTreeModel *anon_treemodel;
 
+  /* FIXME-UGLY: should we use a fresh, specific context for this dialog?
+     FIXME-BUG: how does this right now prevent two dialogs from being opened?
+     (or the master dialog from being closed in the meantime?) */
   ctx->open_file_builder = GNUNET_GTK_get_new_builder 
("gnunet_fs_gtk_publish_file_dialog.glade", ctx);
   GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->open_file_builder);
   ad = GTK_WIDGET (gtk_builder_get_object
                    (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog"));
 
-  /* FIXME: Use some kind of adjustable defaults instead of 1000, 0 and TRUE */
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (
-      ctx->open_file_builder,
-      "GNUNET_GTK_publish_file_dialog_priority_spin_button")), 1000);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (
-      ctx->open_file_builder,
-      "GNUNET_GTK_publish_file_dialog_replication_spin_button")), 0);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (
-      ctx->open_file_builder,
-      "GNUNET_GTK_publish_file_dialog_do_index_checkbutton")), TRUE);
+  /* FIXME-FEATURE: Use some kind of adjustable defaults instead of 1000, 0 
and TRUE */
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object 
(ctx->open_file_builder,
+                                                                     
"GNUNET_GTK_publish_file_dialog_priority_spin_button")), 1000);
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object 
(ctx->open_file_builder,
+                                                                     
"GNUNET_GTK_publish_file_dialog_replication_spin_button")), 0);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object 
(ctx->open_file_builder,
+                                                                          
"GNUNET_GTK_publish_file_dialog_do_index_checkbutton")), TRUE);
+  
+  ctx->open_file_handler_id = g_signal_connect (G_OBJECT (ad), "response",
+                                               G_CALLBACK 
(publish_file_dialog_response_cb), ctx);
 
-  ctx->open_file_handler_id = g_signal_connect (G_OBJECT (ad), "response", 
G_CALLBACK (publish_file_dialog_response_cb), ctx);
-
+  /* FIXME-BUG-MAYBE: possibly bad sharing of the anonymity tree model */
   anon_treemodel = GTK_TREE_MODEL (gtk_builder_get_object 
(ctx->main_window_builder,
-      "main_window_search_anonymity_liststore"));
+                                                          
"main_window_search_anonymity_liststore"));
   combo = GTK_COMBO_BOX (gtk_builder_get_object (ctx->open_file_builder,
-      "GNUNET_GTK_publish_file_dialog_anonymity_combobox"));
+                                                
"GNUNET_GTK_publish_file_dialog_anonymity_combobox"));
   gtk_combo_box_set_model (combo, anon_treemodel);
+  
+  /* show dialog */
+  gtk_window_set_transient_for (GTK_WINDOW (ad), ctx->master_pubdialog);
+  gtk_window_present (GTK_WINDOW (ad));
+}
 
+
+/**
+ * User clicked on the 'open' button in the master publish dialog.
+ * Create the dialog to allow the user to select a directory.
+ *
+ * FIXME-UGLY: lots of code duplication between files & directories here...
+ *
+ * @param dummy the button that was pressed
+ * @param user_data master publishing dialog context of our window
+ */
+void
+GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy,
+                                                         gpointer user_data)
+{
+  struct MainPublishingDialogContext *ctx = user_data;
+  GtkWidget *ad;
+  GtkComboBox *combo;
+  GtkTreeModel *anon_treemodel;
+
+  /* FIXME-UGLY: should we use a fresh, specific context for this dialog?
+     FIXME-BUG: how does this right now prevent two dialogs from being opened? 
+     (or the master dialog from being closed in the meantime?) */
+
+  ctx->open_directory_builder = GNUNET_GTK_get_new_builder 
("gnunet_fs_gtk_publish_directory_dialog.glade", ctx);
+  GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->open_directory_builder);
+
+  /* FIXME-FEATURE: Use some kind of adjustable defaults instead of 1000, 0 
and TRUE */
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object 
(ctx->open_directory_builder,
+                                                                     
"GNUNET_GTK_publish_directory_dialog_priority_spin_button")), 1000);
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object 
(ctx->open_directory_builder,
+                                                                     
"GNUNET_GTK_publish_directory_dialog_replication_spin_button")), 0);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object 
(ctx->open_directory_builder,
+                                                                          
"GNUNET_GTK_publish_directory_dialog_do_index_checkbutton")), TRUE);
+
+  ad = GTK_WIDGET (gtk_builder_get_object
+                   (ctx->open_directory_builder, 
"GNUNET_GTK_publish_directory_dialog"));
+
+  ctx->open_directory_handler_id = g_signal_connect (G_OBJECT (ad), "response",
+                                                    G_CALLBACK 
(publish_directory_dialog_response_cb), ctx);
+
+  /* FIXME-BUG-MAYBE: possibly bad sharing of the anonymity tree model */
+  anon_treemodel = GTK_TREE_MODEL (gtk_builder_get_object 
(ctx->main_window_builder,
+                                                          
"main_window_search_anonymity_liststore"));
+  combo = GTK_COMBO_BOX (gtk_builder_get_object (ctx->open_directory_builder,
+                                                
"GNUNET_GTK_publish_directory_dialog_anonymity_combobox"));
+  gtk_combo_box_set_model (combo, anon_treemodel);
+
+  /* show dialog */
   gtk_window_set_transient_for (GTK_WINDOW (ad), ctx->master_pubdialog);
-
   gtk_window_present (GTK_WINDOW (ad));
 }
 
 
+
+/* ********************************* editing sub-dialog 
****************************************** */
+
+
+
 struct EditPublishContext
 {
   struct GNUNET_FS_FileInformation *fip;
@@ -1101,6 +1520,9 @@
 }
 
 
+/**
+ * @param user_data master publishing dialog context of our window
+*/
 void
 GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy,
                                                          struct 
MainPublishingDialogContext *ctx)
@@ -1132,147 +1554,208 @@
 }
 
 
+
+/* ******************** master edit dialog shutdown *********************** */
+
+
+
 /**
- * Free row reference stored in the file information's
- * client-info pointer.
+ * Get the file information struct corresponding to the
+ * given iter in the publish dialog tree model.  Recursively
+ * builds the file information struct from the subtree.
+ *
+ * @param tm model to grab fi from
+ * @param iter position to grab fi from
+ * @return file information from the given position (never NULL)
  */
-static int
-free_fi_row_reference (void *cls, struct GNUNET_FS_FileInformation *fi,
-                       uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
-                       struct GNUNET_FS_Uri **uri,
-                       struct GNUNET_FS_BlockOptions *bo, int *do_index,
-                       void **client_info)
+static struct GNUNET_FS_FileInformation *
+get_file_information (GtkTreeModel * tm, GtkTreeIter * iter)
 {
-  GtkTreeRowReference *row = *client_info;
+  struct GNUNET_FS_FileInformation *fi;
+  struct GNUNET_FS_FileInformation *fic;
+  GtkTreeIter child;
 
-  if (row == NULL)
+  gtk_tree_model_get (tm, iter, 5, &fi, -1);
+  gtk_tree_store_set (GTK_TREE_STORE (tm), iter, 5, NULL, -1);
+  GNUNET_assert (fi != NULL);
+  if (gtk_tree_model_iter_children (tm, &child, iter))
   {
-    GNUNET_break (0);
-    return GNUNET_OK;
+    GNUNET_break (GNUNET_YES == GNUNET_FS_file_information_is_directory (fi));
+    do
+    {
+      fic = get_file_information (tm, &child);
+      GNUNET_break (GNUNET_OK == GNUNET_FS_file_information_add (fi, fic));
+    }
+    while (gtk_tree_model_iter_next (tm, &child));
   }
-  gtk_tree_row_reference_free (row);
-  return GNUNET_OK;
+  return fi;
 }
 
 
-void
-GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy,
-                                                           struct 
MainPublishingDialogContext *ctx)
+
+static void
+free_pseudonym_tree_store (GtkTreeModel * tm, GtkTreeIter * iter)
 {
-  GtkTreeIter iter;
-  struct GNUNET_FS_FileInformation *fip;
+  struct GNUNET_CONTAINER_MetaData *meta;
+  struct GNUNET_FS_Namespace *ns;
+  GtkTreeIter child;
 
-  if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, 
&iter))
+  gtk_tree_model_get (tm, iter, 1, &ns, 4, &meta, -1);
+  if (meta != NULL)
+    GNUNET_CONTAINER_meta_data_destroy (meta);
+  if (ns != NULL)
   {
-    GNUNET_break (0);
-    return;
+    // FIXME: delete ns?
+    // GNUNET_FS_namespace_delete (nso, GNUNET_NO);
   }
-  gtk_tree_model_get (ctx->file_info_treemodel, &iter, 5, &fip, -1);
-  GNUNET_FS_file_information_destroy (fip, &free_fi_row_reference, NULL);
-  gtk_tree_store_remove (GTK_TREE_STORE (ctx->file_info_treemodel), &iter);
-  update_selectivity (ctx);
+  if (TRUE == gtk_tree_model_iter_children (tm, &child, iter))
+  {
+    do
+    {
+      free_pseudonym_tree_store (tm, &child);
+    }
+    while (TRUE == gtk_tree_model_iter_next (tm, &child));
+  }
 }
 
 
-void
-GNUNET_FS_GTK_progress_dialog_cancel_button_clicked_cb (GtkButton *button,
-                                                       void *cls)
+static void
+free_file_information_tree_store (GtkTreeModel * tm, GtkTreeIter * iter)
 {
-  struct AddDirClientContext *adcc = cls;
+  GtkTreeIter child;
+  struct GNUNET_FS_FileInformation *fip;
 
-  if (adcc->ds != NULL)
+  gtk_tree_model_get (tm, iter, 5, &fip, -1);
+  if (fip != NULL)
+    GNUNET_FS_file_information_destroy (fip, NULL, NULL);
+  if (TRUE == gtk_tree_model_iter_children (tm, &child, iter))
   {
-    /* Still scanning - signal the scanner to finish */
-    GNUNET_FS_directory_scan_abort (adcc->ds);
-    adcc->ds = NULL;
+    do
+    {
+      free_file_information_tree_store (tm, &child);
+    }
+    while (TRUE == gtk_tree_model_iter_next (tm, &child));
   }
-  close_scan (adcc);
 }
 
 
-gboolean
-GNUNET_FS_GTK_progress_dialog_delete_event_cb (GtkWidget *widget,
-                                              GdkEvent * event,
-                                              void *cls)
+/**
+ * FIXME: badly named!
+ *
+ * @param ctx master dialog context
+ * @param ret GTK_RESPONSE_OK if the dialog 'execute' button was pressed,
+ *            GTK_RESPONSE_CANCEL if the dialog was aborted
+ * @return WHAT?
+ */
+static int
+hide_master_publish_dialog (struct MainPublishingDialogContext *ctx, gint ret)
 {
-  /* Don't allow GTK to kill the window, until the scan is finished */
-  return GNUNET_NO;
-}
+  GtkTreeIter iter;
+  gpointer namespace;
+  gchar *namespace_id;
+  gchar *namespace_uid;
+  struct GNUNET_FS_FileInformation *fi;
 
+  /* Don't close until all scanners are finished */
+  if (ctx->adddir_head != NULL)
+    return GNUNET_NO;
 
-void
-GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy,
-                                                         struct 
MainPublishingDialogContext *ctx)
-{
-  GtkWidget *ad;
+  if (ret == GTK_RESPONSE_OK)
+  {
+    if (TRUE == gtk_tree_selection_get_selected (ctx->pseudonym_selection, 
NULL, &iter))
+    {
+      gtk_tree_model_get (ctx->pseudonym_treemodel, &iter, 1, &namespace, 2, 
&namespace_id, 5,
+                          &namespace_uid, -1);
+    }
+    else
+    {
+      namespace = NULL;
+      namespace_id = NULL;
+      namespace_uid = NULL;
+    }
+    if (gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter))
+      do
+      {
+        fi = get_file_information (ctx->file_info_treemodel, &iter);
+        /* FIXME: should we convert namespace id and uid from UTF8? */
+        GNUNET_FS_publish_start (GNUNET_FS_GTK_get_fs_handle (), fi, namespace,
+                                 namespace_id, namespace_uid,
+                                 GNUNET_FS_PUBLISH_OPTION_NONE);
+      }
+      while (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter));
+    g_free (namespace_id);
+    g_free (namespace_uid);
+  }
 
-  GtkComboBox *combo;
-  GtkTreeModel *anon_treemodel;
+  /* free state from 'ptm' */
+  if (TRUE == gtk_tree_model_get_iter_first (ctx->pseudonym_treemodel, &iter))
+    do
+    {
+      free_pseudonym_tree_store (ctx->pseudonym_treemodel, &iter);
+    }
+    while (TRUE == gtk_tree_model_iter_next (ctx->pseudonym_treemodel, &iter));
+  gtk_tree_store_clear (GTK_TREE_STORE (ctx->pseudonym_treemodel));
 
-  ctx->open_directory_builder = GNUNET_GTK_get_new_builder 
("gnunet_fs_gtk_publish_directory_dialog.glade", ctx);
-  GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->open_directory_builder);
+  /* free state from 'tm' */
+  if (TRUE == gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter))
+    do
+    {
+      free_file_information_tree_store (ctx->file_info_treemodel, &iter);
+    }
+    while (TRUE == gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter));
+  gtk_tree_store_clear (GTK_TREE_STORE (ctx->file_info_treemodel));
+  gtk_widget_destroy (GTK_WIDGET (ctx->master_pubdialog));
+  g_object_unref (G_OBJECT (ctx->builder));
+  GNUNET_free (ctx);
+  return GNUNET_YES;
+}
 
-  /* FIXME: Use some kind of adjustable defaults instead of 1000, 0 and TRUE */
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (
-      ctx->open_directory_builder,
-      "GNUNET_GTK_publish_directory_dialog_priority_spin_button")), 1000);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (
-      ctx->open_directory_builder,
-      "GNUNET_GTK_publish_directory_dialog_replication_spin_button")), 0);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (
-      ctx->open_directory_builder,
-      "GNUNET_GTK_publish_directory_dialog_do_index_checkbutton")), TRUE);
 
-  ad = GTK_WIDGET (gtk_builder_get_object
-                   (ctx->open_directory_builder, 
"GNUNET_GTK_publish_directory_dialog"));
+/**
+ * @param user_data master publishing dialog context of our window
+*/
+void
+GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb (GtkButton * button,
+                                                            struct 
MainPublishingDialogContext *ctx)
+{
+  hide_master_publish_dialog (ctx, GTK_RESPONSE_OK);
+}
 
-  ctx->open_directory_handler_id = g_signal_connect (G_OBJECT (ad), 
"response", G_CALLBACK (publish_directory_dialog_response_cb), ctx);
 
-  anon_treemodel = GTK_TREE_MODEL (gtk_builder_get_object 
(ctx->main_window_builder,
-      "main_window_search_anonymity_liststore"));
-  combo = GTK_COMBO_BOX (gtk_builder_get_object (ctx->open_directory_builder,
-      "GNUNET_GTK_publish_directory_dialog_anonymity_combobox"));
-  gtk_combo_box_set_model (combo, anon_treemodel);
-
-  gtk_window_set_transient_for (GTK_WINDOW (ad), ctx->master_pubdialog);
-
-  gtk_window_present (GTK_WINDOW (ad));
+/**
+ * @param user_data master publishing dialog context of our window
+*/
+void
+GNUNET_GTK_master_publish_dialog_cancel_button_clicked_cb (GtkButton * button,
+                                                           struct 
MainPublishingDialogContext *ctx)
+{
+  hide_master_publish_dialog (ctx, GTK_RESPONSE_CANCEL);
 }
 
 
 /**
- * Get the file information struct corresponding to the
- * given iter in the publish dialog tree model.  Recursively
- * builds the file information struct from the subtree.
- *
- * @param tm model to grab fi from
- * @param iter position to grab fi from
- * @return file information from the given position (never NULL)
- */
-static struct GNUNET_FS_FileInformation *
-get_file_information (GtkTreeModel * tm, GtkTreeIter * iter)
+ * @param user_data master publishing dialog context of our window
+*/
+gboolean
+GNUNET_GTK_master_publish_dialog_delete_event_cb (GtkWidget * widget,
+                                                  GdkEvent * event,
+                                                  struct 
MainPublishingDialogContext *ctx)
 {
-  struct GNUNET_FS_FileInformation *fi;
-  struct GNUNET_FS_FileInformation *fic;
-  GtkTreeIter child;
+  /* Don't allow GTK to kill the window, until all edit dialogs are closed */
+  if (NULL != ctx->adddir_head)
+    return FALSE;
+  /* FIXME: what about open-directory operations? */
 
-  gtk_tree_model_get (tm, iter, 5, &fi, -1);
-  gtk_tree_store_set (GTK_TREE_STORE (tm), iter, 5, NULL, -1);
-  GNUNET_assert (fi != NULL);
-  if (gtk_tree_model_iter_children (tm, &child, iter))
-  {
-    GNUNET_break (GNUNET_YES == GNUNET_FS_file_information_is_directory (fi));
-    do
-    {
-      fic = get_file_information (tm, &child);
-      GNUNET_break (GNUNET_OK == GNUNET_FS_file_information_add (fi, fic));
-    }
-    while (gtk_tree_model_iter_next (tm, &child));
-  }
-  return fi;
+  if (GNUNET_NO == hide_master_publish_dialog (ctx, GTK_RESPONSE_CANCEL))
+    return TRUE;
+  return FALSE;
 }
 
 
+
+/* ******************** master edit dialog initialization 
*********************** */
+
+
 /**
  * Closure for 'add_updateable_to_ts'.
  */
@@ -1433,164 +1916,75 @@
 }
 
 
-static void
-free_pseudonym_tree_store (GtkTreeModel * tm, GtkTreeIter * iter)
-{
-  struct GNUNET_CONTAINER_MetaData *meta;
-  struct GNUNET_FS_Namespace *ns;
-  GtkTreeIter child;
 
-  gtk_tree_model_get (tm, iter, 1, &ns, 4, &meta, -1);
-  if (meta != NULL)
-    GNUNET_CONTAINER_meta_data_destroy (meta);
-  if (ns != NULL)
-  {
-    // FIXME: delete ns?
-    // GNUNET_FS_namespace_delete (nso, GNUNET_NO);
-  }
-  if (TRUE == gtk_tree_model_iter_children (tm, &child, iter))
-  {
-    do
-    {
-      free_pseudonym_tree_store (tm, &child);
-    }
-    while (TRUE == gtk_tree_model_iter_next (tm, &child));
-  }
-}
-
-
-static void
-free_file_information_tree_store (GtkTreeModel * tm, GtkTreeIter * iter)
-{
-  GtkTreeIter child;
-  struct GNUNET_FS_FileInformation *fip;
-
-  gtk_tree_model_get (tm, iter, 5, &fip, -1);
-  if (fip != NULL)
-    GNUNET_FS_file_information_destroy (fip, NULL, NULL);
-  if (TRUE == gtk_tree_model_iter_children (tm, &child, iter))
-  {
-    do
-    {
-      free_file_information_tree_store (tm, &child);
-    }
-    while (TRUE == gtk_tree_model_iter_next (tm, &child));
-  }
-}
-
-static int
-hide_master_publish_dialog (struct MainPublishingDialogContext *ctx, gint ret)
-{
-  GtkTreeIter iter;
-  gpointer namespace;
-  gchar *namespace_id;
-  gchar *namespace_uid;
-  struct GNUNET_FS_FileInformation *fi;
-
-  /* Don't close until all scanners are finished */
-  if (ctx->adddir_head != NULL)
-    return GNUNET_NO;
-
-  if (ret == GTK_RESPONSE_OK)
-  {
-    if (TRUE == gtk_tree_selection_get_selected (ctx->pseudonym_selection, 
NULL, &iter))
-    {
-      gtk_tree_model_get (ctx->pseudonym_treemodel, &iter, 1, &namespace, 2, 
&namespace_id, 5,
-                          &namespace_uid, -1);
-    }
-    else
-    {
-      namespace = NULL;
-      namespace_id = NULL;
-      namespace_uid = NULL;
-    }
-    if (gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter))
-      do
-      {
-        fi = get_file_information (ctx->file_info_treemodel, &iter);
-        /* FIXME: should we convert namespace id and uid from UTF8? */
-        GNUNET_FS_publish_start (GNUNET_FS_GTK_get_fs_handle (), fi, namespace,
-                                 namespace_id, namespace_uid,
-                                 GNUNET_FS_PUBLISH_OPTION_NONE);
-      }
-      while (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter));
-    g_free (namespace_id);
-    g_free (namespace_uid);
-  }
-
-  /* free state from 'ptm' */
-  if (TRUE == gtk_tree_model_get_iter_first (ctx->pseudonym_treemodel, &iter))
-    do
-    {
-      free_pseudonym_tree_store (ctx->pseudonym_treemodel, &iter);
-    }
-    while (TRUE == gtk_tree_model_iter_next (ctx->pseudonym_treemodel, &iter));
-  gtk_tree_store_clear (GTK_TREE_STORE (ctx->pseudonym_treemodel));
-
-  /* free state from 'tm' */
-  if (TRUE == gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter))
-    do
-    {
-      free_file_information_tree_store (ctx->file_info_treemodel, &iter);
-    }
-    while (TRUE == gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter));
-  gtk_tree_store_clear (GTK_TREE_STORE (ctx->file_info_treemodel));
-  gtk_widget_destroy (GTK_WIDGET (ctx->master_pubdialog));
-  g_object_unref (G_OBJECT (ctx->builder));
-  GNUNET_free (ctx);
-  return GNUNET_YES;
-}
-
-
-void
-GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb (GtkButton * button,
-                                                            struct 
MainPublishingDialogContext *ctx)
-{
-  hide_master_publish_dialog (ctx, GTK_RESPONSE_OK);
-}
-
-
-void
-GNUNET_GTK_master_publish_dialog_cancel_button_clicked_cb (GtkButton * button,
-                                                           struct 
MainPublishingDialogContext *ctx)
-{
-  hide_master_publish_dialog (ctx, GTK_RESPONSE_CANCEL);
-}
-
-
-gboolean
-GNUNET_GTK_master_publish_dialog_delete_event_cb (GtkWidget * widget,
-                                                  GdkEvent * event,
-                                                  struct 
MainPublishingDialogContext *ctx)
-{
-  if (GNUNET_NO == hide_master_publish_dialog (ctx, GTK_RESPONSE_CANCEL))
-    return TRUE;
-  return FALSE;
-}
-
-
 /**
+ * Run the file-publishing operation (by opening the master publishing dialog).
+ * 
+ * @param dummy widget that triggered the action
+ * @param user_data builder of the main window
  */
 void
 GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, gpointer 
user_data)
 {
   struct MainPublishingDialogContext *ctx;
+  GtkTreeView *pseudonym_treeview;
 
   ctx = GNUNET_malloc (sizeof (struct MainPublishingDialogContext));
+  /* FIXME-UNCLEAN: why bother keeping this one? */
+  ctx->main_window_builder = GTK_BUILDER (user_data);
+
   ctx->builder = GNUNET_GTK_get_new_builder 
("gnunet_fs_gtk_publish_dialog.glade", ctx);
-
   if (ctx->builder == NULL)
   {
+    GNUNET_break (0);
     GNUNET_free (ctx);
     return;
   }
 
-  init_ctx (ctx);
-  ctx->main_window_builder = GTK_BUILDER (user_data);
+  /* initialize widget references */
+  ctx->up_button = GTK_WIDGET (gtk_builder_get_object
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_up_button"));
+  ctx->down_button = GTK_WIDGET (gtk_builder_get_object
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_down_button"));
+  ctx->left_button = GTK_WIDGET (gtk_builder_get_object
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_left_button"));
+  ctx->right_button = GTK_WIDGET (gtk_builder_get_object
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_right_button"));
+  ctx->delete_button = GTK_WIDGET (gtk_builder_get_object
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_delete_button"));
+  ctx->edit_button = GTK_WIDGET (gtk_builder_get_object
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_edit_button"));
+  ctx->execute_button = GTK_WIDGET (gtk_builder_get_object
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_execute_button"));
+  ctx->cancel_button = GTK_WIDGET (gtk_builder_get_object
+      (ctx->builder , "GNUNET_GTK_master_publish_dialog_cancel_button"));
+  ctx->file_info_treeview = GTK_TREE_VIEW (gtk_builder_get_object
+      (ctx->builder, 
"GNUNET_GTK_master_publish_dialog_file_information_tree_view"));
+  ctx->file_info_selection = gtk_tree_view_get_selection 
(ctx->file_info_treeview);
+  ctx->file_info_treemodel = gtk_tree_view_get_model (ctx->file_info_treeview);
+  ctx->master_pubdialog =
+      GTK_WINDOW (gtk_builder_get_object
+                  (ctx->builder, "GNUNET_GTK_master_publish_dialog"));
+  pseudonym_treeview = GTK_TREE_VIEW (gtk_builder_get_object
+                                     (ctx->builder, 
+                                      
"GNUNET_GTK_master_publish_dialog_pseudonym_tree_view"));
+  ctx->pseudonym_selection = gtk_tree_view_get_selection (pseudonym_treeview);
+  ctx->pseudonym_treemodel = gtk_tree_view_get_model (pseudonym_treeview);
+
+  /* connect signals; FIXME-UNCLEAN: these could be connected with (modern) 
Glade */
+  g_signal_connect (G_OBJECT (ctx->file_info_selection), "changed",
+                    G_CALLBACK (selection_changed_cb), ctx);
+  g_signal_connect (G_OBJECT (ctx->pseudonym_selection), "changed",
+                    G_CALLBACK (selection_changed_cb), ctx);
+
+  /* populate namespace model */
   GNUNET_FS_namespace_list (GNUNET_FS_GTK_get_fs_handle (),
-                            &add_namespace_to_ts, GTK_TREE_STORE 
(ctx->pseudonym_treemodel));
+                            &add_namespace_to_ts,
+                           GTK_TREE_STORE (ctx->pseudonym_treemodel));
+
+  /* show dialog */
   gtk_window_present (GTK_WINDOW (ctx->master_pubdialog));
 }
 
 
-/* end of gnunet-fs-gtk-main_window_file_publish.c */
+/* end of gnunet-fs-gtk_publish-dialog.c */

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_publish-edit-dialog.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_publish-edit-dialog.c       2012-02-02 
14:41:20 UTC (rev 19634)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_publish-edit-dialog.c       2012-02-02 
15:19:25 UTC (rev 19635)
@@ -179,7 +179,7 @@
 free_edit_dialog_context (struct EditPublicationDialogContext *ctx)
 {
   gtk_widget_destroy (GTK_WIDGET (ctx->edit_publication_window));
-  // FIXME-LEAK: destroy builder!
+  g_object_unref (G_OBJECT (ctx->builder));
   GNUNET_free (ctx);
 }
 




reply via email to

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