gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r19639 - gnunet-gtk/src/fs


From: gnunet
Subject: [GNUnet-SVN] r19639 - gnunet-gtk/src/fs
Date: Thu, 2 Feb 2012 17:42:51 +0100

Author: grothoff
Date: 2012-02-02 17:42:51 +0100 (Thu, 02 Feb 2012)
New Revision: 19639

Modified:
   gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
Log:
-more bugfixes and code cleanup

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c    2012-02-02 16:32:51 UTC 
(rev 19638)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c    2012-02-02 16:42:51 UTC 
(rev 19639)
@@ -1724,70 +1724,41 @@
 
 
 /**
- * FIXME: badly named!
+ * Close the master publish dialog.  If the response code was OK, starts
+ * the publishing operation.  Otherwise, this function just cleans up the
+ * memory and the window itself.
  *
  * @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?
+ * @return GNUNET_NO if we cannot clean up right now (sub-windows are still 
open)
  */
 static int
-hide_master_publish_dialog (struct MainPublishingDialogContext *ctx, gint ret)
+close_master_publish_dialog (struct MainPublishingDialogContext *ctx)
 {
   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)
+  /* Refuse to close until all scanners are finished */
+  /* FIXME: what about open-directory operations? */
+  if (NULL != ctx->adddir_head)
     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))
+  if (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));
+    while (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))
+  if (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));
+    while (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);
@@ -1796,41 +1767,90 @@
 
 
 /**
+ * The user pushed the 'execute' button.  Start the publishing
+ * operation and clean up the memory and the window itself.
+ *
+ * @param button the button that was clicked
  * @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)
+                                                            gpointer user_data)
 {
-  hide_master_publish_dialog (ctx, GTK_RESPONSE_OK);
+  struct MainPublishingDialogContext *ctx = user_data;
+  gpointer namespace;
+  gchar *namespace_id;
+  gchar *namespace_uid;
+  struct GNUNET_FS_FileInformation *fi;
+  GtkTreeIter iter;
+
+  if (NULL != ctx->adddir_head)
+  {
+    GNUNET_break (0);
+    return;
+  }
+  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);  
+  GNUNET_break (GNUNET_YES == close_master_publish_dialog (ctx));
 }
 
 
 /**
+ * The user pushed the 'cancel' button.  Close the master publish dialog.
+ *
+ * @param button the button that was clicked
  * @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)
+                                                          gpointer user_data)
 {
-  hide_master_publish_dialog (ctx, GTK_RESPONSE_CANCEL);
+  struct MainPublishingDialogContext *ctx = user_data;
+
+  GNUNET_break (GNUNET_YES == close_master_publish_dialog (ctx));
 }
 
 
 /**
+ * The user attempted to close the publish window.  Check if this is
+ * allowed and if so, close it.
+ *
+ * @param widget the widget that generated the close event
+ * @param even the close event
  * @param user_data master publishing dialog context of our window
-*/
+ * @return TRUE to refuse to close, FALSE if we closed the window
+ *         FIXME: are these return codes correct? 
+ */
 gboolean
 GNUNET_GTK_master_publish_dialog_delete_event_cb (GtkWidget * widget,
                                                   GdkEvent * event,
-                                                  struct 
MainPublishingDialogContext *ctx)
+                                                  gpointer user_data)
 {
-  /* 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? */
+  struct MainPublishingDialogContext *ctx = user_data;
 
-  if (GNUNET_NO == hide_master_publish_dialog (ctx, GTK_RESPONSE_CANCEL))
+  if (GNUNET_NO == close_master_publish_dialog (ctx))
     return TRUE;
   return FALSE;
 }




reply via email to

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