aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-02-02 17:56:03 +0000
committerChristian Grothoff <christian@grothoff.org>2012-02-02 17:56:03 +0000
commitadc307636ba3ee27b0ffde8cc21d7b09601ec672 (patch)
tree11eac106a08659cbbfc5e922f169827783907762
parenta84f12987f2ab515b93b9928b751b438d058f326 (diff)
downloadgnunet-gtk-adc307636ba3ee27b0ffde8cc21d7b09601ec672.tar.gz
gnunet-gtk-adc307636ba3ee27b0ffde8cc21d7b09601ec672.zip
-misc fixes
-rw-r--r--contrib/gnunet_fs_gtk_select_pseudonym_dialog.glade2
-rw-r--r--src/fs/gnunet-fs-gtk_advertise-pseudonym.c91
-rw-r--r--src/fs/gnunet-fs-gtk_create-pseudonym.c7
-rw-r--r--src/fs/gnunet-fs-gtk_download-save-as.c2
-rw-r--r--src/fs/gnunet-fs-gtk_publish-dialog.c17
5 files changed, 69 insertions, 50 deletions
diff --git a/contrib/gnunet_fs_gtk_select_pseudonym_dialog.glade b/contrib/gnunet_fs_gtk_select_pseudonym_dialog.glade
index 9c673e21..e8b82388 100644
--- a/contrib/gnunet_fs_gtk_select_pseudonym_dialog.glade
+++ b/contrib/gnunet_fs_gtk_select_pseudonym_dialog.glade
@@ -27,6 +27,7 @@
27 <property name="title" translatable="yes">Select pseudonym...</property> 27 <property name="title" translatable="yes">Select pseudonym...</property>
28 <property name="modal">True</property> 28 <property name="modal">True</property>
29 <property name="type_hint">normal</property> 29 <property name="type_hint">normal</property>
30 <signal name="response" handler="GNUNET_GTK_select_pseudonym_dialog_response_cb" swapped="no"/>
30 <child internal-child="vbox"> 31 <child internal-child="vbox">
31 <object class="GtkBox" id="GNUNET_GTK_select_pseudonym_dialog_vbox"> 32 <object class="GtkBox" id="GNUNET_GTK_select_pseudonym_dialog_vbox">
32 <property name="visible">True</property> 33 <property name="visible">True</property>
@@ -75,6 +76,7 @@
75 <packing> 76 <packing>
76 <property name="expand">False</property> 77 <property name="expand">False</property>
77 <property name="fill">True</property> 78 <property name="fill">True</property>
79 <property name="pack_type">end</property>
78 <property name="position">0</property> 80 <property name="position">0</property>
79 </packing> 81 </packing>
80 </child> 82 </child>
diff --git a/src/fs/gnunet-fs-gtk_advertise-pseudonym.c b/src/fs/gnunet-fs-gtk_advertise-pseudonym.c
index 7f8ab544..09debe9b 100644
--- a/src/fs/gnunet-fs-gtk_advertise-pseudonym.c
+++ b/src/fs/gnunet-fs-gtk_advertise-pseudonym.c
@@ -21,6 +21,9 @@
21/** 21/**
22 * @file src/fs/gnunet-fs-gtk_advertise-pseudonym.c 22 * @file src/fs/gnunet-fs-gtk_advertise-pseudonym.c
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 * @brief allow the user to select a pseudonym to advertise and
25 * then run the advertising dialog (using the edit-publish
26 * dialog functions) and finally do the advertising
24 */ 27 */
25#include "gnunet-fs-gtk_common.h" 28#include "gnunet-fs-gtk_common.h"
26#include "gnunet-fs-gtk.h" 29#include "gnunet-fs-gtk.h"
@@ -31,29 +34,29 @@
31 34
32 35
33/** 36/**
34 * 37 * Closure for 'advertise_namespace' and the callback from the editing dialog.
35 */ 38 */
36struct NamespaceAdvertisementContext 39struct NamespaceAdvertisementContext
37{ 40{
38 /** 41 /**
39 * 42 * Handle to the namespace to advertise.
40 */ 43 */
41 struct GNUNET_FS_Namespace *ns; 44 struct GNUNET_FS_Namespace *ns;
42 45
43 /** 46 /**
44 * 47 * Root of the namespace is stored here temporarily.
45 */ 48 */
46 const char *root; 49 const char *root;
47 50
48 /** 51 /**
49 * 52 * File information structure (fake) which we use to run the 'edit' dialog.
50 */ 53 */
51 struct GNUNET_FS_FileInformation *fip; 54 struct GNUNET_FS_FileInformation *fip;
52}; 55};
53 56
54 57
55/** 58/**
56 * Function called on entries in a GNUNET_FS_FileInformation publish-structure. 59 * Actually perform the advertising with the information collected.
57 * 60 *
58 * @param cls closure, a 'struct NamespaceAdvertisementContext *' 61 * @param cls closure, a 'struct NamespaceAdvertisementContext *'
59 * @param fi the entry in the publish-structure 62 * @param fi the entry in the publish-structure
@@ -77,14 +80,22 @@ advertise_namespace (void *cls,
77{ 80{
78 struct NamespaceAdvertisementContext *nds = cls; 81 struct NamespaceAdvertisementContext *nds = cls;
79 82
80 GNUNET_FS_namespace_advertise (GNUNET_FS_GTK_get_fs_handle (), *uri, nds->ns, 83 GNUNET_FS_namespace_advertise (GNUNET_FS_GTK_get_fs_handle (),
81 meta, bo, nds->root, NULL, NULL); 84 *uri,
85 nds->ns,
86 meta, bo, nds->root,
87 NULL, NULL);
82 return GNUNET_SYSERR; 88 return GNUNET_SYSERR;
83} 89}
84 90
85 91
86/** 92/**
93 * Callback invoked from the editing dialog upon completion of the
94 * meta data editing for the advertisement.
87 * 95 *
96 * @param cls the 'struct NamespaceAdvertisementContext'
97 * @param ret return value from the dialog
98 * @param root namespace root to use
88 */ 99 */
89static void 100static void
90adv_pseudonym_edit_publish_dialog_cb (gpointer cls, 101adv_pseudonym_edit_publish_dialog_cb (gpointer cls,
@@ -106,7 +117,11 @@ adv_pseudonym_edit_publish_dialog_cb (gpointer cls,
106 117
107 118
108/** 119/**
120 * Function called from the pseudonym selection dialog upon completion.
109 * 121 *
122 * @param dialog the pseudonym selection dialog
123 * @param response_id response code from the dialog
124 * @param user_data the builder of the dialog
110 */ 125 */
111void 126void
112GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog, 127GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog,
@@ -114,7 +129,6 @@ GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog,
114 gpointer user_data) 129 gpointer user_data)
115{ 130{
116 GtkBuilder *builder = GTK_BUILDER (user_data); 131 GtkBuilder *builder = GTK_BUILDER (user_data);
117 GtkWidget *ad;
118 GtkTreeView *tv; 132 GtkTreeView *tv;
119 GtkTreeSelection *sel; 133 GtkTreeSelection *sel;
120 GtkTreeModel *tm; 134 GtkTreeModel *tm;
@@ -127,24 +141,25 @@ GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog,
127 struct GNUNET_CONTAINER_MetaData *meta; 141 struct GNUNET_CONTAINER_MetaData *meta;
128 struct GNUNET_FS_BlockOptions bo; 142 struct GNUNET_FS_BlockOptions bo;
129 143
130 ad = GTK_WIDGET (gtk_builder_get_object 144 if (-5 != response_id)
131 (builder, "GNUNET_GTK_select_pseudonym_dialog"));
132
133 anon_liststore = GTK_LIST_STORE (gtk_builder_get_object (builder, "main_window_search_anonymity_liststore"));
134
135 if (response_id != -5)
136 { 145 {
137 gtk_widget_hide (ad); 146 gtk_widget_destroy (GTK_WIDGET (dialog));
147 g_object_unref (G_OBJECT (builder));
138 return; 148 return;
139 } 149 }
140 tv = GTK_TREE_VIEW (gtk_builder_get_object 150 tv = GTK_TREE_VIEW (gtk_builder_get_object
141 (builder, "GNUNET_GTK_select_pseudonym_tree_view")); 151 (builder, "GNUNET_GTK_select_pseudonym_tree_view"));
142 sel = gtk_tree_view_get_selection (tv); 152 sel = gtk_tree_view_get_selection (tv);
143 153 if (! gtk_tree_selection_get_selected (sel, &tm, &iter))
144 GNUNET_assert (TRUE == gtk_tree_selection_get_selected (sel, &tm, &iter)); 154 {
155 GNUNET_break (0);
156 gtk_widget_destroy (GTK_WIDGET (dialog));
157 g_object_unref (G_OBJECT (builder));
158 return;
159 }
145 gtk_tree_model_get (tm, &iter, 1, &ns, -1); 160 gtk_tree_model_get (tm, &iter, 1, &ns, -1);
146 /* free all namespaces from list store except "ns" */ 161 /* free all namespaces from list store except "ns" */
147 if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) 162 if (gtk_tree_model_get_iter_first (tm, &iter))
148 { 163 {
149 do 164 do
150 { 165 {
@@ -152,27 +167,29 @@ GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog,
152 if (ns != nso) 167 if (ns != nso)
153 GNUNET_FS_namespace_delete (nso, GNUNET_NO); 168 GNUNET_FS_namespace_delete (nso, GNUNET_NO);
154 } 169 }
155 while (TRUE == gtk_tree_model_iter_next (tm, &iter)); 170 while (gtk_tree_model_iter_next (tm, &iter));
156 } 171 }
157 transient = gtk_window_get_transient_for (GTK_WINDOW (ad)); 172 transient = gtk_window_get_transient_for (GTK_WINDOW (dialog));
158 gtk_widget_hide (ad);
159 173
160 meta = GNUNET_CONTAINER_meta_data_create (); 174 gtk_widget_destroy (GTK_WIDGET (dialog));
175 g_object_unref (G_OBJECT (builder));
161 176
162 nds = GNUNET_malloc (sizeof (struct NamespaceAdvertisementContext)); 177 nds = GNUNET_malloc (sizeof (struct NamespaceAdvertisementContext));
163 nds->ns = ns; 178 nds->ns = ns;
164 /* This is a bogus fileinfo. It's needed because edit_publish_dialog
165 * was written to work with fileinfo, and return a fileinfo.
166 */
167 memset (&bo, 0, sizeof (struct GNUNET_FS_BlockOptions)); 179 memset (&bo, 0, sizeof (struct GNUNET_FS_BlockOptions));
168 bo.expiration_time = 180 bo.expiration_time = GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2);
169 GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2);
170 bo.anonymity_level = 1; 181 bo.anonymity_level = 1;
171 bo.content_priority = 1000; 182 bo.content_priority = 1000;
183 /* create fake file information to run the 'edit' dialog with */
184 meta = GNUNET_CONTAINER_meta_data_create ();
172 nds->fip = 185 nds->fip =
173 GNUNET_FS_file_information_create_empty_directory (NULL, NULL, NULL, meta, 186 GNUNET_FS_file_information_create_empty_directory (NULL, NULL, NULL, meta,
174 &bo, NULL); 187 &bo, NULL);
175 GNUNET_CONTAINER_meta_data_destroy (meta); 188 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"));
176 GNUNET_FS_GTK_edit_publish_dialog (transient, 193 GNUNET_FS_GTK_edit_publish_dialog (transient,
177 nds->fip, 194 nds->fip,
178 GNUNET_NO, 195 GNUNET_NO,
@@ -188,7 +205,7 @@ GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog,
188 * @param widget the dialog 205 * @param widget the dialog
189 * @param event the destroying event 206 * @param event the destroying event
190 * @param user_data the builder of the dialog 207 * @param user_data the builder of the dialog
191 * @return TRUE 208 * @return TRUE (allow destruction)
192 */ 209 */
193gboolean 210gboolean
194GNUNET_GTK_select_pseudonym_dialog_delete_event_cb (GtkWidget *widget, 211GNUNET_GTK_select_pseudonym_dialog_delete_event_cb (GtkWidget *widget,
@@ -196,10 +213,24 @@ GNUNET_GTK_select_pseudonym_dialog_delete_event_cb (GtkWidget *widget,
196 gpointer user_data) 213 gpointer user_data)
197{ 214{
198 GtkBuilder *builder = GTK_BUILDER (user_data); 215 GtkBuilder *builder = GTK_BUILDER (user_data);
216 GtkTreeModel *tm;
217 GtkTreeIter iter;
199 218
200 /* FIXME: do we need to also explicitly destroy the window? */ 219 tm = GTK_TREE_MODEL (gtk_builder_get_object (builder,
220 "GNUNET_GTK_select_pseudonym_liststore"));
221 if (gtk_tree_model_get_iter_first (tm, &iter))
222 {
223 do
224 {
225 struct GNUNET_FS_Namespace *nso;
226
227 gtk_tree_model_get (tm, &iter, 1, &nso, -1);
228 GNUNET_FS_namespace_delete (nso, GNUNET_NO);
229 }
230 while (gtk_tree_model_iter_next (tm, &iter));
231 }
201 g_object_unref (G_OBJECT (builder)); 232 g_object_unref (G_OBJECT (builder));
202 return TRUE; 233 return TRUE;
203} 234}
204 235
205 236
diff --git a/src/fs/gnunet-fs-gtk_create-pseudonym.c b/src/fs/gnunet-fs-gtk_create-pseudonym.c
index 650017ee..708ace52 100644
--- a/src/fs/gnunet-fs-gtk_create-pseudonym.c
+++ b/src/fs/gnunet-fs-gtk_create-pseudonym.c
@@ -42,13 +42,10 @@ GNUNET_GTK_create_namespace_dialog_response_cb (GtkDialog * dialog,
42 GtkBuilder *builder = GTK_BUILDER (user_data); 42 GtkBuilder *builder = GTK_BUILDER (user_data);
43 const char *name; 43 const char *name;
44 struct GNUNET_FS_Namespace *ns; 44 struct GNUNET_FS_Namespace *ns;
45 GtkWidget *ad;
46 45
47 ad = GTK_WIDGET (gtk_builder_get_object
48 (builder, "GNUNET_GTK_create_namespace_dialog"));
49 if (response_id != -5) 46 if (response_id != -5)
50 { 47 {
51 gtk_widget_destroy (ad); 48 gtk_widget_destroy (GTK_WIDGET (dialog));
52 g_object_unref (G_OBJECT (builder)); 49 g_object_unref (G_OBJECT (builder));
53 return; 50 return;
54 } 51 }
@@ -60,7 +57,7 @@ GNUNET_GTK_create_namespace_dialog_response_cb (GtkDialog * dialog,
60 ns = GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), name); 57 ns = GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), name);
61 GNUNET_FS_namespace_delete (ns, GNUNET_NO); 58 GNUNET_FS_namespace_delete (ns, GNUNET_NO);
62 } 59 }
63 gtk_widget_destroy (ad); 60 gtk_widget_destroy (GTK_WIDGET (dialog));
64 g_object_unref (G_OBJECT (builder)); 61 g_object_unref (G_OBJECT (builder));
65} 62}
66 63
diff --git a/src/fs/gnunet-fs-gtk_download-save-as.c b/src/fs/gnunet-fs-gtk_download-save-as.c
index 46f381a1..170f1bc9 100644
--- a/src/fs/gnunet-fs-gtk_download-save-as.c
+++ b/src/fs/gnunet-fs-gtk_download-save-as.c
@@ -145,8 +145,6 @@ GNUNET_GTK_save_as_dialog_response_cb (GtkDialog * dialog,
145 call the handler manually */ 145 call the handler manually */
146 GNUNET_GTK_save_as_dialog_delete_event_cb (GTK_WIDGET (dialog), NULL, 146 GNUNET_GTK_save_as_dialog_delete_event_cb (GTK_WIDGET (dialog), NULL,
147 user_data); 147 user_data);
148 /* FIXME-BUG-MAYBE: isn't the dialog going to be destroyed with the builder?
149 Is this legal and/or required? */
150 gtk_widget_destroy (GTK_WIDGET (dialog)); 148 gtk_widget_destroy (GTK_WIDGET (dialog));
151} 149}
152 150
diff --git a/src/fs/gnunet-fs-gtk_publish-dialog.c b/src/fs/gnunet-fs-gtk_publish-dialog.c
index 15c6767b..73160fdd 100644
--- a/src/fs/gnunet-fs-gtk_publish-dialog.c
+++ b/src/fs/gnunet-fs-gtk_publish-dialog.c
@@ -1259,7 +1259,6 @@ publish_directory_dialog_response_cb (GtkDialog * dialog,
1259 gpointer user_data) 1259 gpointer user_data)
1260{ 1260{
1261 struct MainPublishingDialogContext *ctx = user_data; 1261 struct MainPublishingDialogContext *ctx = user_data;
1262 GtkWidget *ad;
1263 1262
1264 /* FIXME-UGLY: how about using a separate closure and not needing this mess? 1263 /* FIXME-UGLY: how about using a separate closure and not needing this mess?
1265 In fact, even without it I don't see why we need to disconnect the handler... */ 1264 In fact, even without it I don't see why we need to disconnect the handler... */
@@ -1267,16 +1266,13 @@ publish_directory_dialog_response_cb (GtkDialog * dialog,
1267 g_signal_handler_disconnect (G_OBJECT (dialog), ctx->open_directory_handler_id); 1266 g_signal_handler_disconnect (G_OBJECT (dialog), ctx->open_directory_handler_id);
1268 ctx->open_directory_handler_id = 0; 1267 ctx->open_directory_handler_id = 0;
1269 1268
1270 ad = GTK_WIDGET (gtk_builder_get_object
1271 (ctx->open_directory_builder,
1272 "GNUNET_GTK_publish_directory_dialog"));
1273 if (response_id == -5 /* OK */) 1269 if (response_id == -5 /* OK */)
1274 { 1270 {
1275 char *filename; 1271 char *filename;
1276 int do_index; 1272 int do_index;
1277 struct GNUNET_FS_BlockOptions bo; 1273 struct GNUNET_FS_BlockOptions bo;
1278 1274
1279 filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (ad)); 1275 filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog));
1280 if (! GNUNET_GTK_get_selected_anonymity_level 1276 if (! GNUNET_GTK_get_selected_anonymity_level
1281 (ctx->open_directory_builder, 1277 (ctx->open_directory_builder,
1282 "GNUNET_GTK_publish_directory_dialog_anonymity_combobox", 1278 "GNUNET_GTK_publish_directory_dialog_anonymity_combobox",
@@ -1311,8 +1307,7 @@ publish_directory_dialog_response_cb (GtkDialog * dialog,
1311 scan_file_or_directory (ctx, filename, &bo, do_index); 1307 scan_file_or_directory (ctx, filename, &bo, do_index);
1312 g_free (filename); 1308 g_free (filename);
1313 } 1309 }
1314 /* FIXME: do we need to do widget-destroy + builder destroy? */ 1310 gtk_widget_destroy (GTK_WIDGET (dialog));
1315 gtk_widget_destroy (ad);
1316 g_object_unref (G_OBJECT (ctx->open_directory_builder)); 1311 g_object_unref (G_OBJECT (ctx->open_directory_builder));
1317 ctx->open_directory_builder = NULL; 1312 ctx->open_directory_builder = NULL;
1318} 1313}
@@ -1331,7 +1326,6 @@ publish_file_dialog_response_cb (GtkDialog * dialog,
1331 gpointer user_data) 1326 gpointer user_data)
1332{ 1327{
1333 struct MainPublishingDialogContext *ctx = user_data; 1328 struct MainPublishingDialogContext *ctx = user_data;
1334 GtkWidget *ad;
1335 1329
1336 /* FIXME-UGLY: how about using a separate closure and not needing this mess? 1330 /* FIXME-UGLY: how about using a separate closure and not needing this mess?
1337 In fact, even without it I don't see why we need to disconnect the handler... */ 1331 In fact, even without it I don't see why we need to disconnect the handler... */
@@ -1339,15 +1333,13 @@ publish_file_dialog_response_cb (GtkDialog * dialog,
1339 g_signal_handler_disconnect (G_OBJECT (dialog), ctx->open_file_handler_id); 1333 g_signal_handler_disconnect (G_OBJECT (dialog), ctx->open_file_handler_id);
1340 ctx->open_file_handler_id = 0; 1334 ctx->open_file_handler_id = 0;
1341 1335
1342 ad = GTK_WIDGET (gtk_builder_get_object
1343 (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog"));
1344 if (response_id == -5 /* OK */) 1336 if (response_id == -5 /* OK */)
1345 { 1337 {
1346 char *filename; 1338 char *filename;
1347 struct GNUNET_FS_BlockOptions bo; 1339 struct GNUNET_FS_BlockOptions bo;
1348 int do_index; 1340 int do_index;
1349 1341
1350 filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (ad)); 1342 filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog));
1351 if (!GNUNET_GTK_get_selected_anonymity_level 1343 if (!GNUNET_GTK_get_selected_anonymity_level
1352 (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog_anonymity_combobox", 1344 (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog_anonymity_combobox",
1353 &bo.anonymity_level)) 1345 &bo.anonymity_level))
@@ -1382,8 +1374,7 @@ publish_file_dialog_response_cb (GtkDialog * dialog,
1382 scan_file_or_directory (ctx, filename, &bo, do_index); 1374 scan_file_or_directory (ctx, filename, &bo, do_index);
1383 g_free (filename); 1375 g_free (filename);
1384 } 1376 }
1385 /* FIXME: do we need to do widget-destroy + builder destroy? */ 1377 gtk_widget_destroy (GTK_WIDGET (dialog));
1386 gtk_widget_destroy (ad);
1387 g_object_unref (G_OBJECT (ctx->open_file_builder)); 1378 g_object_unref (G_OBJECT (ctx->open_file_builder));
1388 ctx->open_file_builder = NULL; 1379 ctx->open_file_builder = NULL;
1389} 1380}