gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r19645 - in gnunet-gtk: contrib src/fs
Date: Thu, 2 Feb 2012 18:56:03 +0100

Author: grothoff
Date: 2012-02-02 18:56:03 +0100 (Thu, 02 Feb 2012)
New Revision: 19645

Modified:
   gnunet-gtk/contrib/gnunet_fs_gtk_select_pseudonym_dialog.glade
   gnunet-gtk/src/fs/gnunet-fs-gtk_advertise-pseudonym.c
   gnunet-gtk/src/fs/gnunet-fs-gtk_create-pseudonym.c
   gnunet-gtk/src/fs/gnunet-fs-gtk_download-save-as.c
   gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
Log:
-misc fixes

Modified: gnunet-gtk/contrib/gnunet_fs_gtk_select_pseudonym_dialog.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_select_pseudonym_dialog.glade      
2012-02-02 17:34:54 UTC (rev 19644)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_select_pseudonym_dialog.glade      
2012-02-02 17:56:03 UTC (rev 19645)
@@ -27,6 +27,7 @@
     <property name="title" translatable="yes">Select pseudonym...</property>
     <property name="modal">True</property>
     <property name="type_hint">normal</property>
+    <signal name="response" 
handler="GNUNET_GTK_select_pseudonym_dialog_response_cb" swapped="no"/>
     <child internal-child="vbox">
       <object class="GtkBox" id="GNUNET_GTK_select_pseudonym_dialog_vbox">
         <property name="visible">True</property>
@@ -75,6 +76,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
+            <property name="pack_type">end</property>
             <property name="position">0</property>
           </packing>
         </child>

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_advertise-pseudonym.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_advertise-pseudonym.c       2012-02-02 
17:34:54 UTC (rev 19644)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_advertise-pseudonym.c       2012-02-02 
17:56:03 UTC (rev 19645)
@@ -21,6 +21,9 @@
 /**
  * @file src/fs/gnunet-fs-gtk_advertise-pseudonym.c
  * @author Christian Grothoff
+ * @brief allow the user to select a pseudonym to advertise and
+ *        then run the advertising dialog (using the edit-publish 
+ *        dialog functions) and finally do the advertising
  */
 #include "gnunet-fs-gtk_common.h"
 #include "gnunet-fs-gtk.h"
@@ -31,29 +34,29 @@
 
 
 /**
- *
+ * Closure for 'advertise_namespace' and the callback from the editing dialog.
  */
 struct NamespaceAdvertisementContext
 {
   /**
-   *
+   * Handle to the namespace to advertise.
    */
   struct GNUNET_FS_Namespace *ns;
 
   /**
-   *
+   * Root of the namespace is stored here temporarily.
    */
   const char *root;
 
   /**
-   *
+   * File information structure (fake) which we use to run the 'edit' dialog.
    */
   struct GNUNET_FS_FileInformation *fip;
 };
 
 
 /**
- * Function called on entries in a GNUNET_FS_FileInformation publish-structure.
+ * Actually perform the advertising with the information collected.
  *
  * @param cls closure, a 'struct NamespaceAdvertisementContext *'
  * @param fi the entry in the publish-structure
@@ -77,14 +80,22 @@
 {
   struct NamespaceAdvertisementContext *nds = cls;
 
-  GNUNET_FS_namespace_advertise (GNUNET_FS_GTK_get_fs_handle (), *uri, nds->ns,
-                                 meta, bo, nds->root, NULL, NULL);
+  GNUNET_FS_namespace_advertise (GNUNET_FS_GTK_get_fs_handle (), 
+                                *uri, 
+                                nds->ns,
+                                 meta, bo, nds->root, 
+                                NULL, NULL);
   return GNUNET_SYSERR;
 }
 
 
 /**
+ * Callback invoked from the editing dialog upon completion of the
+ * meta data editing for the advertisement.
  *
+ * @param cls the 'struct NamespaceAdvertisementContext'
+ * @param ret return value from the dialog
+ * @param root namespace root to use
  */
 static void
 adv_pseudonym_edit_publish_dialog_cb (gpointer cls, 
@@ -106,7 +117,11 @@
 
 
 /**
+ * Function called from the pseudonym selection dialog upon completion.
  *
+ * @param dialog the pseudonym selection dialog
+ * @param response_id response code from the dialog
+ * @param user_data the builder of the dialog
  */
 void
 GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog,
@@ -114,7 +129,6 @@
                                                 gpointer user_data)
 {
   GtkBuilder *builder = GTK_BUILDER (user_data);
-  GtkWidget *ad;
   GtkTreeView *tv;
   GtkTreeSelection *sel;
   GtkTreeModel *tm;
@@ -127,24 +141,25 @@
   struct GNUNET_CONTAINER_MetaData *meta;
   struct GNUNET_FS_BlockOptions bo;
 
-  ad = GTK_WIDGET (gtk_builder_get_object
-                   (builder, "GNUNET_GTK_select_pseudonym_dialog"));
-
-  anon_liststore = GTK_LIST_STORE (gtk_builder_get_object (builder, 
"main_window_search_anonymity_liststore"));
-
-  if (response_id != -5)
+  if (-5 != response_id)
   {
-    gtk_widget_hide (ad);
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    g_object_unref (G_OBJECT (builder));
     return;
   }
   tv = GTK_TREE_VIEW (gtk_builder_get_object
                       (builder, "GNUNET_GTK_select_pseudonym_tree_view"));
   sel = gtk_tree_view_get_selection (tv);
-
-  GNUNET_assert (TRUE == gtk_tree_selection_get_selected (sel, &tm, &iter));
+  if (! gtk_tree_selection_get_selected (sel, &tm, &iter))
+  {
+    GNUNET_break (0);
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    g_object_unref (G_OBJECT (builder));
+    return;
+  }
   gtk_tree_model_get (tm, &iter, 1, &ns, -1);
   /* free all namespaces from list store except "ns" */
-  if (TRUE == gtk_tree_model_get_iter_first (tm, &iter))
+  if (gtk_tree_model_get_iter_first (tm, &iter))
   {
     do
     {
@@ -152,27 +167,29 @@
       if (ns != nso)
         GNUNET_FS_namespace_delete (nso, GNUNET_NO);
     }
-    while (TRUE == gtk_tree_model_iter_next (tm, &iter));
+    while (gtk_tree_model_iter_next (tm, &iter));
   }
-  transient = gtk_window_get_transient_for (GTK_WINDOW (ad));
-  gtk_widget_hide (ad);
+  transient = gtk_window_get_transient_for (GTK_WINDOW (dialog));
 
-  meta = GNUNET_CONTAINER_meta_data_create ();
+  gtk_widget_destroy (GTK_WIDGET (dialog));
+  g_object_unref (G_OBJECT (builder));
 
   nds = GNUNET_malloc (sizeof (struct NamespaceAdvertisementContext));
   nds->ns = ns;
-  /* This is a bogus fileinfo. It's needed because edit_publish_dialog
-   * was written to work with fileinfo, and return a fileinfo.
-   */
   memset (&bo, 0, sizeof (struct GNUNET_FS_BlockOptions));
-  bo.expiration_time =
-    GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2);
+  bo.expiration_time = GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 
2);
   bo.anonymity_level = 1;
   bo.content_priority = 1000;
+  /* create fake file information to run the 'edit' dialog with */
+  meta = GNUNET_CONTAINER_meta_data_create ();
   nds->fip =
       GNUNET_FS_file_information_create_empty_directory (NULL, NULL, NULL, 
meta,
                                                          &bo, NULL);
   GNUNET_CONTAINER_meta_data_destroy (meta);
+
+  /* FIXME: bad sharing of anon-liststore; also, this store is not even
+     in this builder... */
+  anon_liststore = GTK_LIST_STORE (gtk_builder_get_object (builder, 
"main_window_search_anonymity_liststore"));
   GNUNET_FS_GTK_edit_publish_dialog (transient, 
                                     nds->fip, 
                                     GNUNET_NO,
@@ -188,7 +205,7 @@
  * @param widget the dialog
  * @param event the destroying event
  * @param user_data the builder of the dialog
- * @return TRUE
+ * @return TRUE (allow destruction)
  */
 gboolean
 GNUNET_GTK_select_pseudonym_dialog_delete_event_cb (GtkWidget *widget,
@@ -196,10 +213,24 @@
                                                     gpointer user_data)
 {
   GtkBuilder *builder = GTK_BUILDER (user_data);
+  GtkTreeModel *tm;
+  GtkTreeIter iter;
 
-  /* FIXME: do we need to also explicitly destroy the window? */
+  tm = GTK_TREE_MODEL (gtk_builder_get_object (builder,
+                                              
"GNUNET_GTK_select_pseudonym_liststore"));
+  if (gtk_tree_model_get_iter_first (tm, &iter))
+  {
+    do
+    {
+      struct GNUNET_FS_Namespace *nso;
+
+      gtk_tree_model_get (tm, &iter, 1, &nso, -1);
+      GNUNET_FS_namespace_delete (nso, GNUNET_NO);
+    }
+    while (gtk_tree_model_iter_next (tm, &iter));
+  }
   g_object_unref (G_OBJECT (builder));
- return TRUE;
+  return TRUE;
 }
 
 

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_create-pseudonym.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_create-pseudonym.c  2012-02-02 17:34:54 UTC 
(rev 19644)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_create-pseudonym.c  2012-02-02 17:56:03 UTC 
(rev 19645)
@@ -42,13 +42,10 @@
   GtkBuilder *builder = GTK_BUILDER (user_data);
   const char *name;
   struct GNUNET_FS_Namespace *ns;
-  GtkWidget *ad;
 
-  ad = GTK_WIDGET (gtk_builder_get_object
-                   (builder, "GNUNET_GTK_create_namespace_dialog"));
   if (response_id != -5)
   {
-    gtk_widget_destroy (ad);
+    gtk_widget_destroy (GTK_WIDGET (dialog));
     g_object_unref (G_OBJECT (builder));
     return;
   }
@@ -60,7 +57,7 @@
     ns = GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), name);
     GNUNET_FS_namespace_delete (ns, GNUNET_NO);
   }
-  gtk_widget_destroy (ad);
+  gtk_widget_destroy (GTK_WIDGET (dialog));
   g_object_unref (G_OBJECT (builder));
 }
 

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_download-save-as.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_download-save-as.c  2012-02-02 17:34:54 UTC 
(rev 19644)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_download-save-as.c  2012-02-02 17:56:03 UTC 
(rev 19645)
@@ -145,8 +145,6 @@
      call the handler manually */
   GNUNET_GTK_save_as_dialog_delete_event_cb (GTK_WIDGET (dialog), NULL,
                                              user_data);
-  /* FIXME-BUG-MAYBE: isn't the dialog going to be destroyed with the builder? 
-     Is this legal and/or required? */
   gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c    2012-02-02 17:34:54 UTC 
(rev 19644)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c    2012-02-02 17:56:03 UTC 
(rev 19645)
@@ -1259,7 +1259,6 @@
                                      gpointer user_data)
 {
   struct MainPublishingDialogContext *ctx = user_data;
-  GtkWidget *ad;
 
   /* FIXME-UGLY: how about using a separate closure and not needing this mess? 
      In fact, even without it I don't see why we need to disconnect the 
handler... */
@@ -1267,16 +1266,13 @@
     g_signal_handler_disconnect (G_OBJECT (dialog), 
ctx->open_directory_handler_id);
   ctx->open_directory_handler_id = 0;
 
-  ad = GTK_WIDGET (gtk_builder_get_object
-                   (ctx->open_directory_builder,
-                   "GNUNET_GTK_publish_directory_dialog"));
   if (response_id == -5 /* OK */)
   {
     char *filename;
     int do_index;
     struct GNUNET_FS_BlockOptions bo;
 
-    filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER 
(ad));
+    filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER 
(dialog));
     if (! GNUNET_GTK_get_selected_anonymity_level
         (ctx->open_directory_builder, 
         "GNUNET_GTK_publish_directory_dialog_anonymity_combobox",
@@ -1311,8 +1307,7 @@
     scan_file_or_directory (ctx, filename, &bo, do_index);
     g_free (filename);
   }
-  /* FIXME: do we need to do widget-destroy + builder destroy? */
-  gtk_widget_destroy (ad);
+  gtk_widget_destroy (GTK_WIDGET (dialog));
   g_object_unref (G_OBJECT (ctx->open_directory_builder));
   ctx->open_directory_builder = NULL;
 }
@@ -1331,7 +1326,6 @@
                                 gpointer user_data)
 {
   struct MainPublishingDialogContext *ctx = user_data;
-  GtkWidget *ad;
 
   /* FIXME-UGLY: how about using a separate closure and not needing this mess? 
      In fact, even without it I don't see why we need to disconnect the 
handler... */
@@ -1339,15 +1333,13 @@
     g_signal_handler_disconnect (G_OBJECT (dialog), ctx->open_file_handler_id);
   ctx->open_file_handler_id = 0;
 
-  ad = GTK_WIDGET (gtk_builder_get_object
-                   (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog"));
   if (response_id == -5 /* OK */)
   {
     char *filename;
     struct GNUNET_FS_BlockOptions bo;
     int do_index;
 
-    filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER 
(ad));
+    filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER 
(dialog));
     if (!GNUNET_GTK_get_selected_anonymity_level
         (ctx->open_file_builder, 
"GNUNET_GTK_publish_file_dialog_anonymity_combobox",
          &bo.anonymity_level))
@@ -1382,8 +1374,7 @@
     scan_file_or_directory (ctx, filename, &bo, do_index);
     g_free (filename);
   }
-  /* FIXME: do we need to do widget-destroy + builder destroy? */
-  gtk_widget_destroy (ad);
+  gtk_widget_destroy (GTK_WIDGET (dialog));
   g_object_unref (G_OBJECT (ctx->open_file_builder));
   ctx->open_file_builder = NULL;
 }




reply via email to

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