aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-02-02 23:13:22 +0000
committerChristian Grothoff <christian@grothoff.org>2012-02-02 23:13:22 +0000
commit12f830715ab602abcdfd58fe6137d2485b504416 (patch)
treecaf452e1d53c2acf79506d8050824aa4839d792e
parent49f29dd99d3f331aecabced77ec12f0e5749d2f9 (diff)
downloadgnunet-gtk-12f830715ab602abcdfd58fe6137d2485b504416.tar.gz
gnunet-gtk-12f830715ab602abcdfd58fe6137d2485b504416.zip
-factoring out remove subtree API, using it to better clean up publish dialog
-rw-r--r--src/fs/gnunet-fs-gtk_publish-dialog.c31
-rw-r--r--src/include/gnunet_gtk.h10
-rw-r--r--src/lib/glade.c17
3 files changed, 32 insertions, 26 deletions
diff --git a/src/fs/gnunet-fs-gtk_publish-dialog.c b/src/fs/gnunet-fs-gtk_publish-dialog.c
index 9dd07700..fe00a328 100644
--- a/src/fs/gnunet-fs-gtk_publish-dialog.c
+++ b/src/fs/gnunet-fs-gtk_publish-dialog.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2005, 2006, 2010 Christian Grothoff (and other contributing authors) 3 (C) 2005, 2006, 2010, 2012 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -414,27 +414,9 @@ create_dir_at_iter (struct MainPublishingDialogContext *ctx,
414 414
415 415
416/** 416/**
417 * Remove the given entry and all of its children from the tree store.
418 *
419 * @param ts tree store to edit
420 * @param root root of the subtree to remove
421 */
422static void
423remove_old_entry (GtkTreeStore * ts,
424 GtkTreeIter * root)
425{
426 GtkTreeIter child;
427
428 while (gtk_tree_model_iter_children (GTK_TREE_MODEL (ts), &child, root))
429 remove_old_entry (ts, &child);
430 gtk_tree_store_remove (ts, root);
431}
432
433
434/**
435 * Copy an entry in the tree from the 'old' position to the 'new' 417 * Copy an entry in the tree from the 'old' position to the 'new'
436 * position. All of the fields are copied, plain pointers will be 418 * position. All of the fields are copied, plain pointers will be
437 * aliased (model will thus be inconsistent until 'remove_old_entry' 419 * aliased (model will thus be inconsistent until the subtree remover
438 * is called on the 'old' entry). 420 * is called on the 'old' entry).
439 * 421 *
440 * @param ctx main publishing context 422 * @param ctx main publishing context
@@ -641,7 +623,7 @@ GNUNET_GTK_master_publish_dialog_right_button_clicked_cb (GtkWidget * dummy,
641 return; 623 return;
642 } 624 }
643 copy_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES); 625 copy_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES);
644 remove_old_entry (GTK_TREE_STORE (ctx->file_info_treemodel), &iter); 626 GNUNET_FS_GTK_remove_treestore_subtree (GTK_TREE_STORE (ctx->file_info_treemodel), &iter);
645} 627}
646 628
647 629
@@ -860,11 +842,8 @@ GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy,
860 } 842 }
861 gtk_tree_model_get (ctx->file_info_treemodel, &iter, 5, &fip, -1); 843 gtk_tree_model_get (ctx->file_info_treemodel, &iter, 5, &fip, -1);
862 GNUNET_FS_file_information_destroy (fip, &free_fi_row_reference, NULL); 844 GNUNET_FS_file_information_destroy (fip, &free_fi_row_reference, NULL);
863 /* FIXME-BUG: the call above frees the row references in the entire 845 GNUNET_FS_GTK_remove_treestore_subtree (GTK_TREE_STORE (ctx->file_info_treemodel),
864 subtree; however, with the 'remove' operation below we 846 &iter);
865 ONLY delete the top-level entry; we probably want to delete
866 the entire directory subtree here... */
867 gtk_tree_store_remove (GTK_TREE_STORE (ctx->file_info_treemodel), &iter);
868 update_selectivity (ctx); 847 update_selectivity (ctx);
869} 848}
870 849
diff --git a/src/include/gnunet_gtk.h b/src/include/gnunet_gtk.h
index cfd24543..c1528759 100644
--- a/src/include/gnunet_gtk.h
+++ b/src/include/gnunet_gtk.h
@@ -158,6 +158,16 @@ char *
158GNUNET_GTK_filechooser_get_filename_utf8 (GtkFileChooser * fc); 158GNUNET_GTK_filechooser_get_filename_utf8 (GtkFileChooser * fc);
159 159
160 160
161/**
162 * Remove the given entry and all of its children from the tree store.
163 *
164 * @param ts tree store to change
165 * @param root root of the subtree to remove
166 */
167void
168GNUNET_FS_GTK_remove_treestore_subtree (GtkTreeStore * ts,
169 GtkTreeIter * root);
170
161 171
162/* ******************* main loop ***************** */ 172/* ******************* main loop ***************** */
163 173
diff --git a/src/lib/glade.c b/src/lib/glade.c
index 180a808b..f15dfca6 100644
--- a/src/lib/glade.c
+++ b/src/lib/glade.c
@@ -127,5 +127,22 @@ GNUNET_GTK_get_new_builder (const char *filename,
127} 127}
128 128
129 129
130/**
131 * Remove the given entry and all of its children from the tree store.
132 *
133 * @param ts tree store to change
134 * @param root root of the subtree to remove
135 */
136void
137GNUNET_FS_GTK_remove_treestore_subtree (GtkTreeStore * ts,
138 GtkTreeIter * root)
139{
140 GtkTreeIter child;
141
142 while (gtk_tree_model_iter_children (GTK_TREE_MODEL (ts), &child, root))
143 GNUNET_FS_GTK_remove_treestore_subtree (ts, &child);
144 gtk_tree_store_remove (ts, root);
145}
146
130 147
131/* end of glade.c */ 148/* end of glade.c */