aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-16 00:24:13 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-16 00:24:13 +0000
commit00202c91999fc4113d84b6380a4d780aeba14155 (patch)
tree25456ad1b270660c4a67766930682d96e6e83a43
parent484136c1b55c2c20d5ea6c16ccf5acb535a2f63b (diff)
downloadgnunet-gtk-00202c91999fc4113d84b6380a4d780aeba14155.tar.gz
gnunet-gtk-00202c91999fc4113d84b6380a4d780aeba14155.zip
-implementing clear button for publish dialog (#2184)
-rw-r--r--contrib/gnunet_fs_gtk_publish_dialog.glade20
-rw-r--r--src/fs/gnunet-fs-gtk_publish-dialog.c86
2 files changed, 105 insertions, 1 deletions
diff --git a/contrib/gnunet_fs_gtk_publish_dialog.glade b/contrib/gnunet_fs_gtk_publish_dialog.glade
index 797bbcab..6758cd2b 100644
--- a/contrib/gnunet_fs_gtk_publish_dialog.glade
+++ b/contrib/gnunet_fs_gtk_publish_dialog.glade
@@ -419,6 +419,24 @@
419 </packing> 419 </packing>
420 </child> 420 </child>
421 <child> 421 <child>
422 <object class="GtkButton" id="GNUNET_GTK_master_publish_dialog_clear_button">
423 <property name="label" translatable="yes">Remove all _Keywords</property>
424 <property name="use_action_appearance">False</property>
425 <property name="visible">True</property>
426 <property name="can_focus">True</property>
427 <property name="receives_default">True</property>
428 <property name="use_underline">True</property>
429 <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>
430 <signal name="clicked" handler="GNUNET_GTK_master_publish_dialog_clear_button_clicked_cb" swapped="no"/>
431 </object>
432 <packing>
433 <property name="expand">False</property>
434 <property name="fill">False</property>
435 <property name="pack_type">end</property>
436 <property name="position">1</property>
437 </packing>
438 </child>
439 <child>
422 <object class="GtkButton" id="GNUNET_GTK_master_publish_dialog_cancel_button"> 440 <object class="GtkButton" id="GNUNET_GTK_master_publish_dialog_cancel_button">
423 <property name="label" translatable="yes">_Cancel</property> 441 <property name="label" translatable="yes">_Cancel</property>
424 <property name="use_action_appearance">False</property> 442 <property name="use_action_appearance">False</property>
@@ -432,7 +450,7 @@
432 <property name="expand">False</property> 450 <property name="expand">False</property>
433 <property name="fill">False</property> 451 <property name="fill">False</property>
434 <property name="pack_type">end</property> 452 <property name="pack_type">end</property>
435 <property name="position">1</property> 453 <property name="position">2</property>
436 </packing> 454 </packing>
437 </child> 455 </child>
438 </object> 456 </object>
diff --git a/src/fs/gnunet-fs-gtk_publish-dialog.c b/src/fs/gnunet-fs-gtk_publish-dialog.c
index f2968261..7c6ebb87 100644
--- a/src/fs/gnunet-fs-gtk_publish-dialog.c
+++ b/src/fs/gnunet-fs-gtk_publish-dialog.c
@@ -1931,6 +1931,92 @@ GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb (GtkButton * button,
1931 1931
1932 1932
1933/** 1933/**
1934 * Function called on entries in a GNUNET_FS_FileInformation publish-structure.
1935 *
1936 * @param cls closure, unused
1937 * @param fi the entry in the publish-structure
1938 * @param length length of the file or directory
1939 * @param meta metadata for the file or directory (can be modified)
1940 * @param uri pointer to the keywords that will be used for this entry (will be set to NULL)
1941 * @param bo block options (can be modified)
1942 * @param do_index should we index (can be modified)
1943 * @param client_info pointer to client context set upon creation (can be modified)
1944 * @return GNUNET_OK (to continue)
1945 */
1946static int
1947clear_keywords_in_file_information (void *cls,
1948 struct GNUNET_FS_FileInformation *fi,
1949 uint64_t length,
1950 struct
1951 GNUNET_CONTAINER_MetaData *
1952 meta,
1953 struct GNUNET_FS_Uri ** uri,
1954 struct GNUNET_FS_BlockOptions
1955 * bo, int *do_index,
1956 void **client_info)
1957{
1958 if (NULL == *uri)
1959 return GNUNET_OK;
1960 GNUNET_FS_uri_destroy (*uri);
1961 *uri = NULL;
1962 return GNUNET_OK;
1963}
1964
1965
1966/**
1967 * Remove all of the keywords from the file information in the tree store
1968 *
1969 * @param tm tree model / store
1970 * @param iter current position in the recursion
1971 */
1972static void
1973clear_keywords_from_file_information_in_tree_store (GtkTreeModel * tm,
1974 GtkTreeIter * iter)
1975{
1976 GtkTreeIter child;
1977 struct GNUNET_FS_FileInformation *fip;
1978
1979 gtk_tree_model_get (tm, iter, PUBLISH_MC_FILE_INFORMATION_STRUCT, &fip, -1);
1980 if (NULL != fip)
1981 {
1982 GNUNET_FS_file_information_inspect (fip, &clear_keywords_in_file_information, NULL);
1983 }
1984 /* recursively clean up children */
1985 if (gtk_tree_model_iter_children (tm, &child, iter))
1986 {
1987 do
1988 {
1989 clear_keywords_from_file_information_in_tree_store (tm, &child);
1990 }
1991 while (gtk_tree_model_iter_next (tm, &child));
1992 }
1993}
1994
1995
1996/**
1997 * The user pushed the 'clear' button. Remove all keywords.
1998 *
1999 * @param button the button that was clicked
2000 * @param user_data master publishing dialog context of our window
2001 */
2002void
2003GNUNET_GTK_master_publish_dialog_clear_button_clicked_cb (GtkButton * button,
2004 gpointer user_data)
2005{
2006 struct MainPublishingDialogContext *ctx = user_data;
2007 GtkTreeIter iter;
2008
2009 /* clear keywords from 'tm' */
2010 if (gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter))
2011 do
2012 {
2013 clear_keywords_from_file_information_in_tree_store (ctx->file_info_treemodel, &iter);
2014 }
2015 while (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter));
2016}
2017
2018
2019/**
1934 * The user pushed the 'cancel' button. Close the master publish dialog. 2020 * The user pushed the 'cancel' button. Close the master publish dialog.
1935 * 2021 *
1936 * @param button the button that was clicked 2022 * @param button the button that was clicked