diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-07-28 22:08:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-07-28 22:08:38 +0000 |
commit | d6703b8e9011268e9db4aa9c72c46ba10eb68fad (patch) | |
tree | acbc2f91ed9fbda9dcbe51c677da606c572d2aa2 | |
parent | c6894eed74f55eb54391891a6ca9b112161ebd26 (diff) | |
download | gnunet-gtk-d6703b8e9011268e9db4aa9c72c46ba10eb68fad.tar.gz gnunet-gtk-d6703b8e9011268e9db4aa9c72c46ba10eb68fad.zip |
new features
-rw-r--r-- | contrib/publish-directory-dialog.glade | 154 | ||||
-rw-r--r-- | contrib/publish-file-dialog.glade | 40 | ||||
-rw-r--r-- | src/edit_publish_dialog.c | 10 | ||||
-rw-r--r-- | src/gnunet-gtk.c | 3 | ||||
-rw-r--r-- | src/main_window_file_publish.c | 195 |
5 files changed, 347 insertions, 55 deletions
diff --git a/contrib/publish-directory-dialog.glade b/contrib/publish-directory-dialog.glade index 03a28f34..25290803 100644 --- a/contrib/publish-directory-dialog.glade +++ b/contrib/publish-directory-dialog.glade | |||
@@ -2,20 +2,156 @@ | |||
2 | <interface> | 2 | <interface> |
3 | <requires lib="gtk+" version="2.20"/> | 3 | <requires lib="gtk+" version="2.20"/> |
4 | <!-- interface-naming-policy project-wide --> | 4 | <!-- interface-naming-policy project-wide --> |
5 | <object class="GtkAdjustment" id="anonymity_adjustment"> | ||
6 | <property name="upper">10000000</property> | ||
7 | <property name="value">1</property> | ||
8 | <property name="step_increment">1</property> | ||
9 | <property name="page_increment">10</property> | ||
10 | </object> | ||
5 | <object class="GtkFileChooserDialog" id="GNUNET_GTK_publish_directory_dialog"> | 11 | <object class="GtkFileChooserDialog" id="GNUNET_GTK_publish_directory_dialog"> |
6 | <property name="can_default">True</property> | 12 | <property name="can_default">True</property> |
7 | <property name="border_width">5</property> | 13 | <property name="border_width">5</property> |
8 | <property name="type_hint">normal</property> | 14 | <property name="type_hint">normal</property> |
9 | <property name="has_separator">False</property> | 15 | <property name="has_separator">False</property> |
10 | <property name="select_multiple">True</property> | ||
11 | <property name="action">select-folder</property> | 16 | <property name="action">select-folder</property> |
12 | <property name="create_folders">False</property> | 17 | <property name="create_folders">False</property> |
18 | <property name="select_multiple">True</property> | ||
13 | <child internal-child="vbox"> | 19 | <child internal-child="vbox"> |
14 | <object class="GtkVBox" id="dialog-vbox2"> | 20 | <object class="GtkVBox" id="dialog-vbox2"> |
15 | <property name="visible">True</property> | 21 | <property name="visible">True</property> |
16 | <property name="spacing">2</property> | 22 | <property name="spacing">2</property> |
17 | <child> | 23 | <child> |
18 | <placeholder/> | 24 | <object class="GtkVBox" id="vbox1"> |
25 | <property name="visible">True</property> | ||
26 | <child> | ||
27 | <object class="GtkHBox" id="hbox1"> | ||
28 | <property name="visible">True</property> | ||
29 | <child> | ||
30 | <object class="GtkCheckButton" id="GNUNET_GTK_publish_directory_dialog_do_index_checkbutton"> | ||
31 | <property name="label" translatable="yes">Index files</property> | ||
32 | <property name="visible">True</property> | ||
33 | <property name="can_focus">True</property> | ||
34 | <property name="receives_default">False</property> | ||
35 | <property name="use_action_appearance">False</property> | ||
36 | <property name="use_underline">True</property> | ||
37 | <property name="active">True</property> | ||
38 | <property name="draw_indicator">True</property> | ||
39 | </object> | ||
40 | <packing> | ||
41 | <property name="expand">False</property> | ||
42 | <property name="fill">False</property> | ||
43 | <property name="padding">20</property> | ||
44 | <property name="position">0</property> | ||
45 | </packing> | ||
46 | </child> | ||
47 | <child> | ||
48 | <placeholder/> | ||
49 | </child> | ||
50 | <child> | ||
51 | <object class="GtkLabel" id="GNUNET_GTK_publish_directory_dialog_priority_label"> | ||
52 | <property name="visible">True</property> | ||
53 | <property name="label" translatable="yes">Priority:</property> | ||
54 | </object> | ||
55 | <packing> | ||
56 | <property name="expand">False</property> | ||
57 | <property name="padding">13</property> | ||
58 | <property name="position">2</property> | ||
59 | </packing> | ||
60 | </child> | ||
61 | <child> | ||
62 | <object class="GtkSpinButton" id="GNUNET_GTK_publish_directory_dialog_priority_spin_button"> | ||
63 | <property name="visible">True</property> | ||
64 | <property name="can_focus">True</property> | ||
65 | <property name="invisible_char">•</property> | ||
66 | <property name="adjustment">priority_adjustment</property> | ||
67 | <property name="numeric">True</property> | ||
68 | </object> | ||
69 | <packing> | ||
70 | <property name="expand">False</property> | ||
71 | <property name="padding">20</property> | ||
72 | <property name="position">3</property> | ||
73 | </packing> | ||
74 | </child> | ||
75 | </object> | ||
76 | <packing> | ||
77 | <property name="expand">False</property> | ||
78 | <property name="fill">False</property> | ||
79 | <property name="position">0</property> | ||
80 | </packing> | ||
81 | </child> | ||
82 | <child> | ||
83 | <object class="GtkHBox" id="hbox2"> | ||
84 | <property name="visible">True</property> | ||
85 | <child> | ||
86 | <object class="GtkLabel" id="GNUNET_GTK_publish_directory_dialog_expiration_label"> | ||
87 | <property name="visible">True</property> | ||
88 | <property name="label" translatable="yes">Expires in:</property> | ||
89 | </object> | ||
90 | <packing> | ||
91 | <property name="expand">False</property> | ||
92 | <property name="fill">False</property> | ||
93 | <property name="padding">20</property> | ||
94 | <property name="position">0</property> | ||
95 | </packing> | ||
96 | </child> | ||
97 | <child> | ||
98 | <object class="GtkComboBox" id="GNUNET_GTK_publish_directory_dialog_expiration_combo_box"> | ||
99 | <property name="visible">True</property> | ||
100 | <property name="active">0</property> | ||
101 | <property name="model">GNUNET_GTK_publish_directory_dialog_expiration_list_store</property> | ||
102 | <child> | ||
103 | <object class="GtkCellRendererText" id="GNUNET_GTK_publish_directory_dialog_expiration_box_time_renderer"/> | ||
104 | <attributes> | ||
105 | <attribute name="text">0</attribute> | ||
106 | </attributes> | ||
107 | </child> | ||
108 | </object> | ||
109 | <packing> | ||
110 | <property name="expand">False</property> | ||
111 | <property name="fill">False</property> | ||
112 | <property name="padding">5</property> | ||
113 | <property name="position">1</property> | ||
114 | </packing> | ||
115 | </child> | ||
116 | <child> | ||
117 | <placeholder/> | ||
118 | </child> | ||
119 | <child> | ||
120 | <object class="GtkLabel" id="GNUNET_GTK_publish_directory_dialog_anonymity_label"> | ||
121 | <property name="visible">True</property> | ||
122 | <property name="label" translatable="yes">Anonymity:</property> | ||
123 | </object> | ||
124 | <packing> | ||
125 | <property name="expand">False</property> | ||
126 | <property name="padding">5</property> | ||
127 | <property name="position">3</property> | ||
128 | </packing> | ||
129 | </child> | ||
130 | <child> | ||
131 | <object class="GtkSpinButton" id="GNUNET_GTK_publish_directory_dialog_anonymity_spin_button"> | ||
132 | <property name="visible">True</property> | ||
133 | <property name="can_focus">True</property> | ||
134 | <property name="invisible_char">•</property> | ||
135 | <property name="adjustment">anonymity_adjustment</property> | ||
136 | <property name="numeric">True</property> | ||
137 | <signal name="value-changed" handler="GNUNET_GTK_anonymity_spin_button_value_changed_cb" swapped="no"/> | ||
138 | </object> | ||
139 | <packing> | ||
140 | <property name="expand">False</property> | ||
141 | <property name="padding">20</property> | ||
142 | <property name="position">4</property> | ||
143 | </packing> | ||
144 | </child> | ||
145 | </object> | ||
146 | <packing> | ||
147 | <property name="expand">False</property> | ||
148 | <property name="position">1</property> | ||
149 | </packing> | ||
150 | </child> | ||
151 | </object> | ||
152 | <packing> | ||
153 | <property name="position">2</property> | ||
154 | </packing> | ||
19 | </child> | 155 | </child> |
20 | <child internal-child="action_area"> | 156 | <child internal-child="action_area"> |
21 | <object class="GtkHButtonBox" id="dialog-action_area3"> | 157 | <object class="GtkHButtonBox" id="dialog-action_area3"> |
@@ -66,4 +202,18 @@ | |||
66 | <action-widget response="-5">GNUNET_GTK_publish_directory_dialog_ok_button</action-widget> | 202 | <action-widget response="-5">GNUNET_GTK_publish_directory_dialog_ok_button</action-widget> |
67 | </action-widgets> | 203 | </action-widgets> |
68 | </object> | 204 | </object> |
205 | <object class="GtkListStore" id="GNUNET_GTK_publish_directory_dialog_expiration_list_store"> | ||
206 | <columns> | ||
207 | <!-- column-name human_readable_time --> | ||
208 | <column type="gchararray"/> | ||
209 | <!-- column-name time_in_ms --> | ||
210 | <column type="guint64"/> | ||
211 | </columns> | ||
212 | </object> | ||
213 | <object class="GtkAdjustment" id="priority_adjustment"> | ||
214 | <property name="upper">100000000</property> | ||
215 | <property name="value">1000</property> | ||
216 | <property name="step_increment">1</property> | ||
217 | <property name="page_increment">10</property> | ||
218 | </object> | ||
69 | </interface> | 219 | </interface> |
diff --git a/contrib/publish-file-dialog.glade b/contrib/publish-file-dialog.glade index 2ebe4f30..28bf4287 100644 --- a/contrib/publish-file-dialog.glade +++ b/contrib/publish-file-dialog.glade | |||
@@ -2,26 +2,6 @@ | |||
2 | <interface> | 2 | <interface> |
3 | <requires lib="gtk+" version="2.20"/> | 3 | <requires lib="gtk+" version="2.20"/> |
4 | <!-- interface-naming-policy project-wide --> | 4 | <!-- interface-naming-policy project-wide --> |
5 | <object class="GtkAdjustment" id="anonymity_adjustment"> | ||
6 | <property name="upper">10000000</property> | ||
7 | <property name="value">1</property> | ||
8 | <property name="step_increment">1</property> | ||
9 | <property name="page_increment">10</property> | ||
10 | </object> | ||
11 | <object class="GtkListStore" id="GNUNET_GTK_publish_file_dialog_expiration_list_store"> | ||
12 | <columns> | ||
13 | <!-- column-name human_readable_time --> | ||
14 | <column type="gchararray"/> | ||
15 | <!-- column-name time_in_ms --> | ||
16 | <column type="guint64"/> | ||
17 | </columns> | ||
18 | </object> | ||
19 | <object class="GtkAdjustment" id="priority_adjustment"> | ||
20 | <property name="upper">100000000</property> | ||
21 | <property name="value">1000</property> | ||
22 | <property name="step_increment">1</property> | ||
23 | <property name="page_increment">10</property> | ||
24 | </object> | ||
25 | <object class="GtkFileChooserDialog" id="GNUNET_GTK_publish_file_dialog"> | 5 | <object class="GtkFileChooserDialog" id="GNUNET_GTK_publish_file_dialog"> |
26 | <property name="can_default">True</property> | 6 | <property name="can_default">True</property> |
27 | <property name="border_width">5</property> | 7 | <property name="border_width">5</property> |
@@ -216,4 +196,24 @@ | |||
216 | <action-widget response="-5">GNUNET_GTK_publish_file_dialog_ok_button</action-widget> | 196 | <action-widget response="-5">GNUNET_GTK_publish_file_dialog_ok_button</action-widget> |
217 | </action-widgets> | 197 | </action-widgets> |
218 | </object> | 198 | </object> |
199 | <object class="GtkAdjustment" id="priority_adjustment"> | ||
200 | <property name="upper">100000000</property> | ||
201 | <property name="value">1000</property> | ||
202 | <property name="step_increment">1</property> | ||
203 | <property name="page_increment">10</property> | ||
204 | </object> | ||
205 | <object class="GtkListStore" id="GNUNET_GTK_publish_file_dialog_expiration_list_store"> | ||
206 | <columns> | ||
207 | <!-- column-name human_readable_time --> | ||
208 | <column type="gchararray"/> | ||
209 | <!-- column-name time_in_ms --> | ||
210 | <column type="guint64"/> | ||
211 | </columns> | ||
212 | </object> | ||
213 | <object class="GtkAdjustment" id="anonymity_adjustment"> | ||
214 | <property name="upper">10000000</property> | ||
215 | <property name="value">1</property> | ||
216 | <property name="step_increment">1</property> | ||
217 | <property name="page_increment">10</property> | ||
218 | </object> | ||
219 | </interface> | 219 | </interface> |
diff --git a/src/edit_publish_dialog.c b/src/edit_publish_dialog.c index 16cee5ac..abb6beb4 100644 --- a/src/edit_publish_dialog.c +++ b/src/edit_publish_dialog.c | |||
@@ -644,6 +644,16 @@ GNUNET_GTK_edit_publish_dialog (int *do_index, | |||
644 | GNUNET_break (0); | 644 | GNUNET_break (0); |
645 | return; | 645 | return; |
646 | } | 646 | } |
647 | if (GNUNET_FS_file_information_is_directory (fip)) | ||
648 | { | ||
649 | /* indexing does not apply to directories */ | ||
650 | gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (builder, | ||
651 | "GNUNET_GTK_edit_file_information_index_check_button"))); | ||
652 | gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (builder, | ||
653 | "GNUNET_GTK_edit_file_information_index_label"))); | ||
654 | |||
655 | } | ||
656 | |||
647 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 657 | ad = GTK_WIDGET (gtk_builder_get_object (builder, |
648 | "GNUNET_GTK_edit_file_information_dialog")); | 658 | "GNUNET_GTK_edit_file_information_dialog")); |
649 | ls = GTK_LIST_STORE (gtk_builder_get_object (builder, | 659 | ls = GTK_LIST_STORE (gtk_builder_get_object (builder, |
diff --git a/src/gnunet-gtk.c b/src/gnunet-gtk.c index f3f9a19f..215d4d8c 100644 --- a/src/gnunet-gtk.c +++ b/src/gnunet-gtk.c | |||
@@ -363,9 +363,8 @@ GNUNET_GTK_get_new_builder (const char *filename) | |||
363 | ret = gtk_builder_new (); | 363 | ret = gtk_builder_new (); |
364 | gtk_builder_set_translation_domain (ret, "gnunet-gtk"); | 364 | gtk_builder_set_translation_domain (ret, "gnunet-gtk"); |
365 | GNUNET_asprintf (&glade_path, | 365 | GNUNET_asprintf (&glade_path, |
366 | "%s/%s/%s", | 366 | "%s%s", |
367 | GNUNET_GTK_get_data_dir (), | 367 | GNUNET_GTK_get_data_dir (), |
368 | PACKAGE_NAME, | ||
369 | filename); | 368 | filename); |
370 | error = NULL; | 369 | error = NULL; |
371 | if (0 == gtk_builder_add_from_file (ret, glade_path, &error)) | 370 | if (0 == gtk_builder_add_from_file (ret, glade_path, &error)) |
diff --git a/src/main_window_file_publish.c b/src/main_window_file_publish.c index d44c3137..58352b77 100644 --- a/src/main_window_file_publish.c +++ b/src/main_window_file_publish.c | |||
@@ -179,7 +179,7 @@ static void | |||
179 | add_file_at_iter (const char *filename, | 179 | add_file_at_iter (const char *filename, |
180 | uint32_t anonymity_level, | 180 | uint32_t anonymity_level, |
181 | uint32_t priority, | 181 | uint32_t priority, |
182 | struct GNUNET_TIME_Relative expiration, | 182 | struct GNUNET_TIME_Absolute expiration, |
183 | int do_index, | 183 | int do_index, |
184 | GtkTreeIter *iter) | 184 | GtkTreeIter *iter) |
185 | { | 185 | { |
@@ -240,7 +240,7 @@ add_file_at_iter (const char *filename, | |||
240 | do_index, | 240 | do_index, |
241 | anonymity_level, | 241 | anonymity_level, |
242 | priority, | 242 | priority, |
243 | GNUNET_TIME_relative_to_absolute (expiration)); | 243 | expiration); |
244 | GNUNET_CONTAINER_meta_data_destroy (meta); | 244 | GNUNET_CONTAINER_meta_data_destroy (meta); |
245 | GNUNET_FS_uri_destroy (ksk_uri); | 245 | GNUNET_FS_uri_destroy (ksk_uri); |
246 | file_size_fancy = GNUNET_STRINGS_byte_size_fancy (file_size); | 246 | file_size_fancy = GNUNET_STRINGS_byte_size_fancy (file_size); |
@@ -260,24 +260,24 @@ add_file_at_iter (const char *filename, | |||
260 | 260 | ||
261 | /** | 261 | /** |
262 | * Add an empty directory to the tree model. | 262 | * Add an empty directory to the tree model. |
263 | * FIXME: consider opening a dialog to get | ||
264 | * anonymity, priority and expiration prior | ||
265 | * to calling this function (currently we | ||
266 | * use default values for those). | ||
267 | * | 263 | * |
268 | * @param name name for the directory | 264 | * @param name name for the directory |
269 | * @param iter parent entry, or NULL for top-level addition | 265 | * @param iter parent entry, or NULL for top-level addition |
266 | * @param pos iterator to set to the location of the new element | ||
270 | */ | 267 | */ |
271 | static void | 268 | static void |
272 | create_dir_at_iter (const char *name, | 269 | create_dir_at_iter (const char *name, |
273 | GtkTreeIter *iter) | 270 | uint32_t anonymity, |
271 | uint32_t priority, | ||
272 | struct GNUNET_TIME_Absolute expiration, | ||
273 | GtkTreeIter *iter, | ||
274 | GtkTreeIter *pos) | ||
274 | { | 275 | { |
275 | struct GNUNET_FS_FileInformation *fi; | 276 | struct GNUNET_FS_FileInformation *fi; |
276 | GtkTreeRowReference *row_reference; | 277 | GtkTreeRowReference *row_reference; |
277 | GtkTreePath *path; | 278 | GtkTreePath *path; |
278 | struct GNUNET_CONTAINER_MetaData *meta; | 279 | struct GNUNET_CONTAINER_MetaData *meta; |
279 | GtkTreeStore *ts; | 280 | GtkTreeStore *ts; |
280 | GtkTreeIter pos; | ||
281 | 281 | ||
282 | ts = GTK_TREE_STORE (gtk_builder_get_object (master_builder, | 282 | ts = GTK_TREE_STORE (gtk_builder_get_object (master_builder, |
283 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | 283 | "GNUNET_GTK_file_sharing_publishing_tree_store")); |
@@ -291,11 +291,11 @@ create_dir_at_iter (const char *name, | |||
291 | name, | 291 | name, |
292 | strlen(name)+1); | 292 | strlen(name)+1); |
293 | gtk_tree_store_insert_before (ts, | 293 | gtk_tree_store_insert_before (ts, |
294 | &pos, | 294 | pos, |
295 | iter, | 295 | iter, |
296 | NULL); | 296 | NULL); |
297 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), | 297 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), |
298 | &pos); | 298 | pos); |
299 | row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), | 299 | row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), |
300 | path); | 300 | path); |
301 | gtk_tree_path_free (path); | 301 | gtk_tree_path_free (path); |
@@ -303,21 +303,68 @@ create_dir_at_iter (const char *name, | |||
303 | row_reference, | 303 | row_reference, |
304 | NULL, | 304 | NULL, |
305 | meta, | 305 | meta, |
306 | 1 /* anonymity */, 1000 /* priority */, | 306 | anonymity, |
307 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS)); | 307 | priority, |
308 | expiration); | ||
308 | GNUNET_CONTAINER_meta_data_destroy (meta); | 309 | GNUNET_CONTAINER_meta_data_destroy (meta); |
309 | gtk_tree_store_set (ts, &pos, | 310 | gtk_tree_store_set (ts, pos, |
310 | 0, "0", | 311 | 0, "0", |
311 | 1, (gboolean) GNUNET_NO, | 312 | 1, (gboolean) GNUNET_NO, |
312 | 2, name, | 313 | 2, name, |
313 | 3, (guint) 1 /* anonymity */, | 314 | 3, (guint) anonymity, |
314 | 4, (guint) 1000 /* priority */, | 315 | 4, (guint) priority, |
315 | 5, fi, | 316 | 5, fi, |
316 | -1); | 317 | -1); |
317 | update_selectivity (); | 318 | update_selectivity (); |
318 | } | 319 | } |
319 | 320 | ||
320 | 321 | ||
322 | struct AddDirContext | ||
323 | { | ||
324 | GtkTreeIter *parent; | ||
325 | uint32_t anonymity_level; | ||
326 | uint32_t priority; | ||
327 | struct GNUNET_TIME_Absolute expiration; | ||
328 | int do_index; | ||
329 | }; | ||
330 | |||
331 | |||
332 | /** | ||
333 | * Add a directory to the tree model. | ||
334 | * | ||
335 | * @param filename directory name to add | ||
336 | * @param iter parent entry, or NULL for top-level addition | ||
337 | */ | ||
338 | static void | ||
339 | add_dir_at_iter (const char *filename, | ||
340 | uint32_t anonymity_level, | ||
341 | uint32_t priority, | ||
342 | struct GNUNET_TIME_Absolute expiration, | ||
343 | int do_index, | ||
344 | GtkTreeIter *iter); | ||
345 | |||
346 | |||
347 | /** | ||
348 | * Function called by the directory iterator to | ||
349 | * (recursively) add all of the files in the | ||
350 | * directory to the tree. | ||
351 | */ | ||
352 | static int | ||
353 | scan_cb (void *cls, | ||
354 | const char *filename) | ||
355 | { | ||
356 | struct AddDirContext *adc = cls; | ||
357 | |||
358 | add_dir_at_iter (filename, | ||
359 | adc->anonymity_level, | ||
360 | adc->priority, | ||
361 | adc->expiration, | ||
362 | adc->do_index, | ||
363 | adc->parent); | ||
364 | return GNUNET_OK; | ||
365 | } | ||
366 | |||
367 | |||
321 | /** | 368 | /** |
322 | * Add a directory to the tree model. | 369 | * Add a directory to the tree model. |
323 | * | 370 | * |
@@ -326,10 +373,44 @@ create_dir_at_iter (const char *name, | |||
326 | */ | 373 | */ |
327 | static void | 374 | static void |
328 | add_dir_at_iter (const char *filename, | 375 | add_dir_at_iter (const char *filename, |
376 | uint32_t anonymity_level, | ||
377 | uint32_t priority, | ||
378 | struct GNUNET_TIME_Absolute expiration, | ||
379 | int do_index, | ||
329 | GtkTreeIter *iter) | 380 | GtkTreeIter *iter) |
330 | { | 381 | { |
331 | GNUNET_break (0); | 382 | struct stat sbuf; |
332 | update_selectivity (); | 383 | struct AddDirContext scan_ctx; |
384 | GtkTreeIter pos; | ||
385 | |||
386 | fprintf (stderr, "Adding %s\n", filename); | ||
387 | if (0 != STAT (filename, &sbuf)) | ||
388 | return; | ||
389 | if (S_ISDIR (sbuf.st_mode)) | ||
390 | { | ||
391 | create_dir_at_iter (filename, | ||
392 | anonymity_level, | ||
393 | priority, | ||
394 | expiration, | ||
395 | iter, &pos); | ||
396 | scan_ctx.parent = &pos; | ||
397 | scan_ctx.anonymity_level = anonymity_level; | ||
398 | scan_ctx.priority = priority; | ||
399 | scan_ctx.expiration = expiration; | ||
400 | scan_ctx.do_index = do_index; | ||
401 | GNUNET_DISK_directory_scan (filename, | ||
402 | &scan_cb, | ||
403 | &scan_ctx); | ||
404 | } | ||
405 | else | ||
406 | { | ||
407 | add_file_at_iter (filename, | ||
408 | anonymity_level, | ||
409 | priority, | ||
410 | expiration, | ||
411 | do_index, | ||
412 | iter); | ||
413 | } | ||
333 | } | 414 | } |
334 | 415 | ||
335 | 416 | ||
@@ -648,18 +729,32 @@ GNUNET_GTK_master_publish_dialog_new_button_clicked_cb (GtkWidget * dummy, | |||
648 | GtkTreeView *tv; | 729 | GtkTreeView *tv; |
649 | GtkTreeSelection *sel; | 730 | GtkTreeSelection *sel; |
650 | GtkTreeIter iter; | 731 | GtkTreeIter iter; |
732 | GtkTreeIter pos; | ||
651 | 733 | ||
652 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, | 734 | tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, |
653 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 735 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
654 | sel = gtk_tree_view_get_selection (tv); | 736 | sel = gtk_tree_view_get_selection (tv); |
737 | /* FIXME: consider opening a dialog to get | ||
738 | * anonymity, priority and expiration prior | ||
739 | * to calling this function (currently we | ||
740 | * use default values for those). | ||
741 | */ | ||
655 | if (TRUE != gtk_tree_selection_get_selected (sel, | 742 | if (TRUE != gtk_tree_selection_get_selected (sel, |
656 | NULL, | 743 | NULL, |
657 | &iter)) | 744 | &iter)) |
658 | { | 745 | { |
659 | create_dir_at_iter ("unnamed/", NULL); | 746 | create_dir_at_iter ("unnamed/", |
747 | 1 /* anonymity */, | ||
748 | 1000 /* priority */, | ||
749 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS) /* expiration */, | ||
750 | NULL, &pos); | ||
660 | return; | 751 | return; |
661 | } | 752 | } |
662 | create_dir_at_iter ("unnamed/", &iter); | 753 | create_dir_at_iter ("unnamed/", |
754 | 1 /* anonymity */, | ||
755 | 1000 /* priority */, | ||
756 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS) /* expiration */, | ||
757 | &iter, &pos); | ||
663 | } | 758 | } |
664 | 759 | ||
665 | 760 | ||
@@ -670,19 +765,21 @@ struct ListValue | |||
670 | }; | 765 | }; |
671 | 766 | ||
672 | 767 | ||
768 | static struct ListValue list_values[] = | ||
769 | { | ||
770 | { gettext_noop ("1 year"), 1000LL * 60 * 60 * 24 * 365 }, | ||
771 | { gettext_noop ("1 month"), 1000LL * 60 * 60 * 24 * 30 }, | ||
772 | { gettext_noop ("1 day"), 1000LL * 60 * 60 * 24 }, | ||
773 | { gettext_noop ("1 hour"), 1000LL * 60 * 60 }, | ||
774 | { gettext_noop ("1 minute"), 1000LL * 60 }, | ||
775 | { NULL, 0} | ||
776 | }; | ||
777 | |||
778 | |||
673 | void | 779 | void |
674 | GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy, | 780 | GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy, |
675 | gpointer data) | 781 | gpointer data) |
676 | { | 782 | { |
677 | static struct ListValue list_values[] = | ||
678 | { | ||
679 | { gettext_noop ("1 year"), 1000LL * 60 * 60 * 24 * 365 }, | ||
680 | { gettext_noop ("1 month"), 1000LL * 60 * 60 * 24 * 30 }, | ||
681 | { gettext_noop ("1 day"), 1000LL * 60 * 60 * 24 }, | ||
682 | { gettext_noop ("1 hour"), 1000LL * 60 * 60 }, | ||
683 | { gettext_noop ("1 minute"), 1000LL * 60 }, | ||
684 | { NULL, 0} | ||
685 | }; | ||
686 | GtkWidget *ad; | 783 | GtkWidget *ad; |
687 | GtkBuilder *builder; | 784 | GtkBuilder *builder; |
688 | char *filename; | 785 | char *filename; |
@@ -734,7 +831,8 @@ GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy, | |||
734 | gtk_combo_box_get_active_iter (cb, &iter); | 831 | gtk_combo_box_get_active_iter (cb, &iter); |
735 | gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, 1, &exp.value, -1); | 832 | gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, 1, &exp.value, -1); |
736 | add_file_at_iter (filename, anonymity, | 833 | add_file_at_iter (filename, anonymity, |
737 | priority, exp, do_index, | 834 | priority, |
835 | GNUNET_TIME_relative_to_absolute (exp), do_index, | ||
738 | NULL); | 836 | NULL); |
739 | gtk_widget_destroy (ad); | 837 | gtk_widget_destroy (ad); |
740 | g_object_unref (G_OBJECT (builder)); | 838 | g_object_unref (G_OBJECT (builder)); |
@@ -860,6 +958,14 @@ GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy, | |||
860 | GtkWidget *ad; | 958 | GtkWidget *ad; |
861 | GtkBuilder *builder; | 959 | GtkBuilder *builder; |
862 | char *filename; | 960 | char *filename; |
961 | uint32_t anonymity; | ||
962 | uint32_t priority; | ||
963 | struct GNUNET_TIME_Relative exp; | ||
964 | int do_index; | ||
965 | GtkComboBox *cb; | ||
966 | GtkListStore *ls; | ||
967 | GtkTreeIter iter; | ||
968 | int i; | ||
863 | 969 | ||
864 | builder = GNUNET_GTK_get_new_builder ("publish-directory-dialog.glade"); | 970 | builder = GNUNET_GTK_get_new_builder ("publish-directory-dialog.glade"); |
865 | if (builder == NULL) | 971 | if (builder == NULL) |
@@ -869,6 +975,22 @@ GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy, | |||
869 | } | 975 | } |
870 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 976 | ad = GTK_WIDGET (gtk_builder_get_object (builder, |
871 | "GNUNET_GTK_publish_directory_dialog")); | 977 | "GNUNET_GTK_publish_directory_dialog")); |
978 | cb = GTK_COMBO_BOX (gtk_builder_get_object (builder, | ||
979 | "GNUNET_GTK_publish_directory_dialog_expiration_combo_box")); | ||
980 | |||
981 | ls = GTK_LIST_STORE (gtk_builder_get_object (builder, | ||
982 | "GNUNET_GTK_publish_directory_dialog_expiration_list_store")); | ||
983 | i = 0; | ||
984 | while (list_values[i].text != NULL) | ||
985 | { | ||
986 | gtk_list_store_insert_before (ls, &iter, NULL); | ||
987 | gtk_list_store_set (ls, &iter, | ||
988 | 0, gettext (list_values[i].text), | ||
989 | 1, list_values[i].value, | ||
990 | -1); | ||
991 | i++; | ||
992 | } | ||
993 | |||
872 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | 994 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) |
873 | { | 995 | { |
874 | gtk_widget_destroy (ad); | 996 | gtk_widget_destroy (ad); |
@@ -876,10 +998,21 @@ GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy, | |||
876 | return; | 998 | return; |
877 | } | 999 | } |
878 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad)); | 1000 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad)); |
879 | add_dir_at_iter (filename, NULL); | 1001 | anonymity = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, |
880 | GNUNET_break (0); | 1002 | "GNUNET_GTK_publish_directory_dialog_anonymity_spin_button"))); |
1003 | priority = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | ||
1004 | "GNUNET_GTK_publish_directory_dialog_priority_spin_button"))); | ||
1005 | do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, | ||
1006 | "GNUNET_GTK_publish_directory_dialog_do_index_checkbutton"))); | ||
1007 | gtk_combo_box_get_active_iter (cb, &iter); | ||
1008 | gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, 1, &exp.value, -1); | ||
881 | gtk_widget_destroy (ad); | 1009 | gtk_widget_destroy (ad); |
882 | g_object_unref (G_OBJECT (builder)); | 1010 | g_object_unref (G_OBJECT (builder)); |
1011 | /* FIXME: open progress dialog here... */ | ||
1012 | add_dir_at_iter (filename, anonymity, priority, | ||
1013 | GNUNET_TIME_relative_to_absolute (exp), | ||
1014 | do_index, | ||
1015 | NULL); | ||
883 | g_free (filename); | 1016 | g_free (filename); |
884 | update_selectivity (); | 1017 | update_selectivity (); |
885 | } | 1018 | } |