aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-02-02 19:58:43 +0000
committerChristian Grothoff <christian@grothoff.org>2012-02-02 19:58:43 +0000
commitb26ff78504dc772409c6d090f9a2b5b1b39c465f (patch)
tree6885ba0d2b1632217e796bd8e4eefc6ad29f58da
parente5ec5bf2594f50c89d50503c727fa8ce53bca834 (diff)
downloadgnunet-gtk-b26ff78504dc772409c6d090f9a2b5b1b39c465f.tar.gz
gnunet-gtk-b26ff78504dc772409c6d090f9a2b5b1b39c465f.zip
-make sharing of the anonymity level liststore very explicit by making it global
-rw-r--r--contrib/gnunet_fs_gtk_main_window.glade4
-rw-r--r--src/fs/gnunet-fs-gtk.c12
-rw-r--r--src/fs/gnunet-fs-gtk.h10
-rw-r--r--src/fs/gnunet-fs-gtk_advertise-pseudonym.c6
-rw-r--r--src/fs/gnunet-fs-gtk_publish-dialog.c14
-rw-r--r--src/fs/gnunet-fs-gtk_publish-edit-dialog.c4
-rw-r--r--src/fs/gnunet-fs-gtk_publish-edit-dialog.h2
7 files changed, 27 insertions, 25 deletions
diff --git a/contrib/gnunet_fs_gtk_main_window.glade b/contrib/gnunet_fs_gtk_main_window.glade
index 9aeab4a9..9e28e368 100644
--- a/contrib/gnunet_fs_gtk_main_window.glade
+++ b/contrib/gnunet_fs_gtk_main_window.glade
@@ -434,7 +434,7 @@
434 <object class="GtkComboBox" id="main_window_search_anonymity_combobox"> 434 <object class="GtkComboBox" id="main_window_search_anonymity_combobox">
435 <property name="visible">True</property> 435 <property name="visible">True</property>
436 <property name="can_focus">False</property> 436 <property name="can_focus">False</property>
437 <property name="model">main_window_search_anonymity_liststore</property> 437 <property name="model">anonymity_level_liststore</property>
438 <property name="active">1</property> 438 <property name="active">1</property>
439 <child> 439 <child>
440 <object class="GtkCellRendererText" id="main_window_search_anonymity_combobox_renderer"/> 440 <object class="GtkCellRendererText" id="main_window_search_anonymity_combobox_renderer"/>
@@ -722,7 +722,7 @@
722 <property name="can_focus">False</property> 722 <property name="can_focus">False</property>
723 <property name="stock">gtk-index</property> 723 <property name="stock">gtk-index</property>
724 </object> 724 </object>
725 <object class="GtkListStore" id="main_window_search_anonymity_liststore"> 725 <object class="GtkListStore" id="anonymity_level_liststore">
726 <columns> 726 <columns>
727 <!-- column-name Name --> 727 <!-- column-name Name -->
728 <column type="gchararray"/> 728 <column type="gchararray"/>
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c
index e50476b5..8d092ba2 100644
--- a/src/fs/gnunet-fs-gtk.c
+++ b/src/fs/gnunet-fs-gtk.c
@@ -81,6 +81,18 @@ GNUNET_FS_GTK_get_main_window_object (const char *name)
81 81
82 82
83/** 83/**
84 * Return the list store with anonymity levels.
85 *
86 * @return the list store
87 */
88GtkTreeModel *
89GNUNET_FS_GTK_get_anonymity_level_list_store ()
90{
91 return GTK_TREE_MODEL (GNUNET_FS_GTK_get_main_window_object ("anonymity_level_liststore"));
92}
93
94
95/**
84 * Task run on shutdown. 96 * Task run on shutdown.
85 * FIXME: does this need to be a separate task!? 97 * FIXME: does this need to be a separate task!?
86 * 98 *
diff --git a/src/fs/gnunet-fs-gtk.h b/src/fs/gnunet-fs-gtk.h
index 567b2ea0..4f5c7476 100644
--- a/src/fs/gnunet-fs-gtk.h
+++ b/src/fs/gnunet-fs-gtk.h
@@ -39,6 +39,15 @@ GNUNET_FS_GTK_get_configuration (void);
39 39
40 40
41/** 41/**
42 * Return the list store with anonymity levels.
43 *
44 * @return the list store
45 */
46GtkTreeModel *
47GNUNET_FS_GTK_get_anonymity_level_list_store (void);
48
49
50/**
42 * Return our handle for file-sharing operations. 51 * Return our handle for file-sharing operations.
43 * 52 *
44 * @return NULL on error 53 * @return NULL on error
@@ -46,6 +55,7 @@ GNUNET_FS_GTK_get_configuration (void);
46struct GNUNET_FS_Handle * 55struct GNUNET_FS_Handle *
47GNUNET_FS_GTK_get_fs_handle (void); 56GNUNET_FS_GTK_get_fs_handle (void);
48 57
58
49/** 59/**
50 * Get an object from the main window. 60 * Get an object from the main window.
51 * 61 *
diff --git a/src/fs/gnunet-fs-gtk_advertise-pseudonym.c b/src/fs/gnunet-fs-gtk_advertise-pseudonym.c
index 07562f38..f6714010 100644
--- a/src/fs/gnunet-fs-gtk_advertise-pseudonym.c
+++ b/src/fs/gnunet-fs-gtk_advertise-pseudonym.c
@@ -136,7 +136,6 @@ GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog,
136 struct GNUNET_FS_Namespace *ns; 136 struct GNUNET_FS_Namespace *ns;
137 struct GNUNET_FS_Namespace *nso; 137 struct GNUNET_FS_Namespace *nso;
138 GtkWindow *transient; 138 GtkWindow *transient;
139 GtkListStore *anon_liststore;
140 struct NamespaceAdvertisementContext *nds; 139 struct NamespaceAdvertisementContext *nds;
141 struct GNUNET_CONTAINER_MetaData *meta; 140 struct GNUNET_CONTAINER_MetaData *meta;
142 struct GNUNET_FS_BlockOptions bo; 141 struct GNUNET_FS_BlockOptions bo;
@@ -186,14 +185,9 @@ GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog,
186 GNUNET_FS_file_information_create_empty_directory (NULL, NULL, NULL, meta, 185 GNUNET_FS_file_information_create_empty_directory (NULL, NULL, NULL, meta,
187 &bo, NULL); 186 &bo, NULL);
188 GNUNET_CONTAINER_meta_data_destroy (meta); 187 GNUNET_CONTAINER_meta_data_destroy (meta);
189
190 /* FIXME: bad sharing of anon-liststore; also, this store is not even
191 in this builder... */
192 anon_liststore = GTK_LIST_STORE (gtk_builder_get_object (builder, "main_window_search_anonymity_liststore"));
193 GNUNET_FS_GTK_edit_publish_dialog (transient, 188 GNUNET_FS_GTK_edit_publish_dialog (transient,
194 nds->fip, 189 nds->fip,
195 GNUNET_NO, 190 GNUNET_NO,
196 anon_liststore,
197 &adv_pseudonym_edit_publish_dialog_cb, 191 &adv_pseudonym_edit_publish_dialog_cb,
198 nds); 192 nds);
199} 193}
diff --git a/src/fs/gnunet-fs-gtk_publish-dialog.c b/src/fs/gnunet-fs-gtk_publish-dialog.c
index 73160fdd..914c62f5 100644
--- a/src/fs/gnunet-fs-gtk_publish-dialog.c
+++ b/src/fs/gnunet-fs-gtk_publish-dialog.c
@@ -1396,7 +1396,6 @@ GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy,
1396 struct MainPublishingDialogContext *ctx = user_data; 1396 struct MainPublishingDialogContext *ctx = user_data;
1397 GtkWidget *ad; 1397 GtkWidget *ad;
1398 GtkComboBox *combo; 1398 GtkComboBox *combo;
1399 GtkTreeModel *anon_treemodel;
1400 1399
1401 /* FIXME-UGLY: should we use a fresh, specific context for this dialog? 1400 /* FIXME-UGLY: should we use a fresh, specific context for this dialog?
1402 FIXME-BUG: how does this right now prevent two dialogs from being opened? 1401 FIXME-BUG: how does this right now prevent two dialogs from being opened?
@@ -1416,13 +1415,10 @@ GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy,
1416 1415
1417 ctx->open_file_handler_id = g_signal_connect (G_OBJECT (ad), "response", 1416 ctx->open_file_handler_id = g_signal_connect (G_OBJECT (ad), "response",
1418 G_CALLBACK (publish_file_dialog_response_cb), ctx); 1417 G_CALLBACK (publish_file_dialog_response_cb), ctx);
1419
1420 /* FIXME-BUG-MAYBE: possibly bad sharing of the anonymity tree model */
1421 anon_treemodel = GTK_TREE_MODEL (gtk_builder_get_object (ctx->main_window_builder,
1422 "main_window_search_anonymity_liststore"));
1423 combo = GTK_COMBO_BOX (gtk_builder_get_object (ctx->open_file_builder, 1418 combo = GTK_COMBO_BOX (gtk_builder_get_object (ctx->open_file_builder,
1424 "GNUNET_GTK_publish_file_dialog_anonymity_combobox")); 1419 "GNUNET_GTK_publish_file_dialog_anonymity_combobox"));
1425 gtk_combo_box_set_model (combo, anon_treemodel); 1420 gtk_combo_box_set_model (combo,
1421 GNUNET_FS_GTK_get_anonymity_level_list_store ());
1426 1422
1427 /* show dialog */ 1423 /* show dialog */
1428 gtk_window_set_transient_for (GTK_WINDOW (ad), ctx->master_pubdialog); 1424 gtk_window_set_transient_for (GTK_WINDOW (ad), ctx->master_pubdialog);
@@ -1589,10 +1585,7 @@ GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy,
1589{ 1585{
1590 struct MainPublishingDialogContext *ctx = user_data; 1586 struct MainPublishingDialogContext *ctx = user_data;
1591 struct EditPublishContext *epc; 1587 struct EditPublishContext *epc;
1592 GtkListStore *anon_liststore;
1593 1588
1594 anon_liststore = GTK_LIST_STORE (gtk_builder_get_object (ctx->main_window_builder,
1595 "main_window_search_anonymity_liststore"));
1596 epc = GNUNET_malloc (sizeof (struct EditPublishContext)); 1589 epc = GNUNET_malloc (sizeof (struct EditPublishContext));
1597 epc->tm = ctx->file_info_treemodel; 1590 epc->tm = ctx->file_info_treemodel;
1598 if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &epc->iter)) 1591 if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &epc->iter))
@@ -1605,12 +1598,9 @@ GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy,
1605 &epc->iter, 1598 &epc->iter,
1606 5, &epc->fip, 1599 5, &epc->fip,
1607 -1); 1600 -1);
1608 /* FIXME-UGLY: can we just give our anon_liststore out like this? What about
1609 (unintended) sharing of state? */
1610 GNUNET_FS_GTK_edit_publish_dialog (ctx->master_pubdialog, 1601 GNUNET_FS_GTK_edit_publish_dialog (ctx->master_pubdialog,
1611 epc->fip, 1602 epc->fip,
1612 GNUNET_YES, 1603 GNUNET_YES,
1613 anon_liststore,
1614 &master_publish_edit_publish_dialog_cb, 1604 &master_publish_edit_publish_dialog_cb,
1615 epc); 1605 epc);
1616} 1606}
diff --git a/src/fs/gnunet-fs-gtk_publish-edit-dialog.c b/src/fs/gnunet-fs-gtk_publish-edit-dialog.c
index 88ae8549..d49396a1 100644
--- a/src/fs/gnunet-fs-gtk_publish-edit-dialog.c
+++ b/src/fs/gnunet-fs-gtk_publish-edit-dialog.c
@@ -1008,7 +1008,6 @@ file_information_import (void *cls,
1008 * @param allow_no_keywords is it OK to close the dialog without any keywords? 1008 * @param allow_no_keywords is it OK to close the dialog without any keywords?
1009 * also used to indicate that this is a namespace operation 1009 * also used to indicate that this is a namespace operation
1010 * (FIXME-UNCLEAN: overloaded/badly-named argument) 1010 * (FIXME-UNCLEAN: overloaded/badly-named argument)
1011 * @param anon_liststore liststore with anonymity options (FIXME-UNCLEAN: bad sharing)
1012 * @param cb function to call when the dialog is closed 1011 * @param cb function to call when the dialog is closed
1013 * @param cb_cls closure for 'cb' 1012 * @param cb_cls closure for 'cb'
1014 */ 1013 */
@@ -1016,7 +1015,6 @@ void
1016GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, 1015GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent,
1017 struct GNUNET_FS_FileInformation *fip, 1016 struct GNUNET_FS_FileInformation *fip,
1018 int allow_no_keywords, 1017 int allow_no_keywords,
1019 GtkListStore *anon_liststore,
1020 GNUNET_FS_GTK_EditPublishDialogCallback cb, 1018 GNUNET_FS_GTK_EditPublishDialogCallback cb,
1021 gpointer cb_cls) 1019 gpointer cb_cls)
1022{ 1020{
@@ -1099,7 +1097,7 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent,
1099 1097
1100 /* Basic initialization of widgets models and visibility */ 1098 /* Basic initialization of widgets models and visibility */
1101 gtk_combo_box_set_model (ctx->anonymity_combo, 1099 gtk_combo_box_set_model (ctx->anonymity_combo,
1102 GTK_TREE_MODEL (anon_liststore)); 1100 GNUNET_FS_GTK_get_anonymity_level_list_store ());
1103 GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->builder); 1101 GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->builder);
1104 1102
1105 /* FIXME-UNCLEAN: are the following three even required anymore? */ 1103 /* FIXME-UNCLEAN: are the following three even required anymore? */
diff --git a/src/fs/gnunet-fs-gtk_publish-edit-dialog.h b/src/fs/gnunet-fs-gtk_publish-edit-dialog.h
index 4db3cd5e..8ee7d52c 100644
--- a/src/fs/gnunet-fs-gtk_publish-edit-dialog.h
+++ b/src/fs/gnunet-fs-gtk_publish-edit-dialog.h
@@ -50,7 +50,6 @@ typedef void (*GNUNET_FS_GTK_EditPublishDialogCallback) (gpointer cls,
50 * @param allow_no_keywords is it OK to close the dialog without any keywords? 50 * @param allow_no_keywords is it OK to close the dialog without any keywords?
51 * also used to indicate that this is a namespace operation 51 * also used to indicate that this is a namespace operation
52 * (FIXME: overloaded/badly-named argument) 52 * (FIXME: overloaded/badly-named argument)
53 * @param anon_liststore liststore with anonymity options (FIXME: bad sharing)
54 * @param cb function to call when the dialog is closed 53 * @param cb function to call when the dialog is closed
55 * @param cb_cls closure for 'cb' 54 * @param cb_cls closure for 'cb'
56 */ 55 */
@@ -58,7 +57,6 @@ void
58GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, 57GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent,
59 struct GNUNET_FS_FileInformation *fip, 58 struct GNUNET_FS_FileInformation *fip,
60 int allow_no_keywords, 59 int allow_no_keywords,
61 GtkListStore *anon_liststore,
62 GNUNET_FS_GTK_EditPublishDialogCallback cb, 60 GNUNET_FS_GTK_EditPublishDialogCallback cb,
63 gpointer cls); 61 gpointer cls);
64 62