gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r22034 - in gnunet-gtk: contrib src/fs
Date: Sat, 16 Jun 2012 02:24:13 +0200

Author: grothoff
Date: 2012-06-16 02:24:13 +0200 (Sat, 16 Jun 2012)
New Revision: 22034

Modified:
   gnunet-gtk/contrib/gnunet_fs_gtk_publish_dialog.glade
   gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
Log:
-implementing clear button for publish dialog (#2184)

Modified: gnunet-gtk/contrib/gnunet_fs_gtk_publish_dialog.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_publish_dialog.glade       2012-06-16 
00:21:30 UTC (rev 22033)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_publish_dialog.glade       2012-06-16 
00:24:13 UTC (rev 22034)
@@ -419,6 +419,24 @@
               </packing>
             </child>
             <child>
+              <object class="GtkButton" 
id="GNUNET_GTK_master_publish_dialog_clear_button">
+                <property name="label" translatable="yes">Remove all 
_Keywords</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+                <property name="tooltip_text" translatable="yes">This button 
removes all keywords from all files and directories in this dialog.  This is 
useful if you want to get rid of the automatically extracted keywords to make 
sure that your published file(s) are only available from the resulting URI or 
from keywords that you manually enter after clicking this button.  Note that 
meta data is unaffected when using this function.</property>
+                <signal name="clicked" 
handler="GNUNET_GTK_master_publish_dialog_clear_button_clicked_cb" 
swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="pack_type">end</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkButton" 
id="GNUNET_GTK_master_publish_dialog_cancel_button">
                 <property name="label" translatable="yes">_Cancel</property>
                 <property name="use_action_appearance">False</property>
@@ -432,7 +450,7 @@
                 <property name="expand">False</property>
                 <property name="fill">False</property>
                 <property name="pack_type">end</property>
-                <property name="position">1</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </object>

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c    2012-06-16 00:21:30 UTC 
(rev 22033)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c    2012-06-16 00:24:13 UTC 
(rev 22034)
@@ -1931,6 +1931,92 @@
 
 
 /**
+ * Function called on entries in a GNUNET_FS_FileInformation publish-structure.
+ *
+ * @param cls closure, unused
+ * @param fi the entry in the publish-structure
+ * @param length length of the file or directory
+ * @param meta metadata for the file or directory (can be modified)
+ * @param uri pointer to the keywords that will be used for this entry (will 
be set to NULL)
+ * @param bo block options (can be modified)
+ * @param do_index should we index (can be modified)
+ * @param client_info pointer to client context set upon creation (can be 
modified)
+ * @return GNUNET_OK (to continue)
+ */
+static int
+clear_keywords_in_file_information (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)
+{
+  if (NULL == *uri)
+    return GNUNET_OK;
+  GNUNET_FS_uri_destroy (*uri);
+  *uri = NULL;
+  return GNUNET_OK;
+}
+
+
+/**
+ * Remove all of the keywords from the file information in the tree store
+ *
+ * @param tm tree model / store
+ * @param iter current position in the recursion
+ */
+static void
+clear_keywords_from_file_information_in_tree_store (GtkTreeModel * tm,
+                                                   GtkTreeIter * iter)
+{
+  GtkTreeIter child;
+  struct GNUNET_FS_FileInformation *fip;
+  
+  gtk_tree_model_get (tm, iter, PUBLISH_MC_FILE_INFORMATION_STRUCT, &fip, -1);
+  if (NULL != fip)
+  {
+    GNUNET_FS_file_information_inspect (fip, 
&clear_keywords_in_file_information, NULL);
+  }
+  /* recursively clean up children */
+  if (gtk_tree_model_iter_children (tm, &child, iter))
+  {
+    do
+    {
+      clear_keywords_from_file_information_in_tree_store (tm, &child);
+    }
+    while (gtk_tree_model_iter_next (tm, &child));
+  }
+}
+
+
+/**
+ * The user pushed the 'clear' button.  Remove all keywords.
+ *
+ * @param button the button that was clicked
+ * @param user_data master publishing dialog context of our window
+ */
+void
+GNUNET_GTK_master_publish_dialog_clear_button_clicked_cb (GtkButton * button,
+                                                         gpointer user_data)
+{
+  struct MainPublishingDialogContext *ctx = user_data;
+  GtkTreeIter iter;
+
+  /* clear keywords from 'tm' */
+  if (gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter))
+    do
+    {
+      clear_keywords_from_file_information_in_tree_store 
(ctx->file_info_treemodel, &iter);
+    }
+    while (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter));
+}
+
+
+/**
  * The user pushed the 'cancel' button.  Close the master publish dialog.
  *
  * @param button the button that was clicked




reply via email to

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