aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk-edit_publish_dialog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk-edit_publish_dialog.c')
-rw-r--r--src/fs/gnunet-fs-gtk-edit_publish_dialog.c220
1 files changed, 115 insertions, 105 deletions
diff --git a/src/fs/gnunet-fs-gtk-edit_publish_dialog.c b/src/fs/gnunet-fs-gtk-edit_publish_dialog.c
index 37fe1a2a..05761a87 100644
--- a/src/fs/gnunet-fs-gtk-edit_publish_dialog.c
+++ b/src/fs/gnunet-fs-gtk-edit_publish_dialog.c
@@ -30,21 +30,22 @@
30 30
31#define PUBSTATE "edit-publication-state" 31#define PUBSTATE "edit-publication-state"
32 32
33struct edit_publication_state 33struct EditPublicationState
34{ 34{
35 int *do_index; 35 int do_index;
36 char **short_fn; 36 char *short_fn;
37 guint *anonymity_level; 37 guint anonymity_level;
38 guint *priority; 38 guint priority;
39 struct GNUNET_FS_FileInformation *fip; 39 struct GNUNET_FS_FileInformation *fip;
40 gint preview_changed; 40 gint preview_changed;
41 gboolean allow_no_keywords; 41 gboolean allow_no_keywords;
42 gboolean is_directory; 42 gboolean is_directory;
43 GNUNET_FS_GTK_edit_publish_dialog_cb cb; 43 GNUNET_FS_GTK_EditPublishDialogCallback cb;
44 gchar *root; 44 gchar *root;
45 gpointer cls; 45 gpointer cls;
46}; 46};
47 47
48
48static void 49static void
49metadata_selection_changed_cb (GtkTreeSelection * ts, gpointer user_data) 50metadata_selection_changed_cb (GtkTreeSelection * ts, gpointer user_data)
50{ 51{
@@ -67,6 +68,7 @@ metadata_selection_changed_cb (GtkTreeSelection * ts, gpointer user_data)
67 gtk_tree_selection_get_selected (sel, NULL, NULL)); 68 gtk_tree_selection_get_selected (sel, NULL, NULL));
68} 69}
69 70
71
70static void 72static void
71keywords_selection_changed_cb (GtkTreeSelection * ts, gpointer user_data) 73keywords_selection_changed_cb (GtkTreeSelection * ts, gpointer user_data)
72{ 74{
@@ -100,7 +102,7 @@ keywords_selection_changed_cb (GtkTreeSelection * ts, gpointer user_data)
100 102
101void 103void
102GNUNET_GTK_edit_publication_window_realize_cb (GtkWidget *widget, 104GNUNET_GTK_edit_publication_window_realize_cb (GtkWidget *widget,
103 gpointer user_data) 105 gpointer user_data)
104{ 106{
105 GtkBuilder *builder; 107 GtkBuilder *builder;
106 GtkListStore *metatypes_list; 108 GtkListStore *metatypes_list;
@@ -135,9 +137,10 @@ GNUNET_GTK_edit_publication_window_realize_cb (GtkWidget *widget,
135 3, EXTRACTOR_metatype_to_description (type), -1); 137 3, EXTRACTOR_metatype_to_description (type), -1);
136} 138}
137 139
140
138void 141void
139GNUNET_GTK_edit_publication_add_button_clicked_cb (GtkButton *button, 142GNUNET_GTK_edit_publication_add_button_clicked_cb (GtkButton *button,
140 gpointer user_data) 143 gpointer user_data)
141{ 144{
142 GtkBuilder *builder; 145 GtkBuilder *builder;
143 GtkTreeView *meta_tree; 146 GtkTreeView *meta_tree;
@@ -155,9 +158,10 @@ GNUNET_GTK_edit_publication_add_button_clicked_cb (GtkButton *button,
155 2, _("Select a type"), 3, _("Specify a value"), 4, NULL, -1); 158 2, _("Select a type"), 3, _("Specify a value"), 4, NULL, -1);
156} 159}
157 160
161
158gboolean 162gboolean
159GNUNET_GTK_edit_publication_keyword_entry_key_press_event_cb (GtkWidget *widget, 163GNUNET_GTK_edit_publication_keyword_entry_key_press_event_cb (GtkWidget *widget,
160 GdkEventKey *event, gpointer user_data) 164 GdkEventKey *event, gpointer user_data)
161{ 165{
162 GtkBuilder *builder; 166 GtkBuilder *builder;
163 GtkButton *add_button; 167 GtkButton *add_button;
@@ -173,10 +177,11 @@ GNUNET_GTK_edit_publication_keyword_entry_key_press_event_cb (GtkWidget *widget,
173 return FALSE; 177 return FALSE;
174} 178}
175 179
180
176void 181void
177GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_edited_cb ( 182GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_edited_cb (GtkCellRendererText *renderer,
178 GtkCellRendererText *renderer, gchar *path, gchar *new_text, 183 gchar *path, gchar *new_text,
179 gpointer user_data) 184 gpointer user_data)
180{ 185{
181 GtkBuilder *builder; 186 GtkBuilder *builder;
182 GtkTreeView *meta_tree; 187 GtkTreeView *meta_tree;
@@ -212,6 +217,7 @@ GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_edited_cb (
212 g_free (description); 217 g_free (description);
213} 218}
214 219
220
215void 221void
216GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_changed_cb ( 222GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_changed_cb (
217 GtkCellRendererCombo *combo, gchar *path_string, GtkTreeIter *new_iter, 223 GtkCellRendererCombo *combo, gchar *path_string, GtkTreeIter *new_iter,
@@ -227,6 +233,7 @@ GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_changed_cb (
227 g_object_set_data (G_OBJECT (combo), "selected-type", pass_data); 233 g_object_set_data (G_OBJECT (combo), "selected-type", pass_data);
228} 234}
229 235
236
230void 237void
231GNUNET_GTK_edit_publication_metadata_tree_view_value_renderer_edited_cb ( 238GNUNET_GTK_edit_publication_metadata_tree_view_value_renderer_edited_cb (
232 GtkCellRendererText *renderer, gchar *path, gchar *new_text, 239 GtkCellRendererText *renderer, gchar *path, gchar *new_text,
@@ -243,7 +250,7 @@ GNUNET_GTK_edit_publication_metadata_tree_view_value_renderer_edited_cb (
243 char *pos; 250 char *pos;
244 251
245 GObject *pubwindow; 252 GObject *pubwindow;
246 struct edit_publication_state *state = NULL; 253 struct EditPublicationState *state = NULL;
247 254
248 builder = GTK_BUILDER (user_data); 255 builder = GTK_BUILDER (user_data);
249 meta_tree = GTK_TREE_VIEW (gtk_builder_get_object (builder, 256 meta_tree = GTK_TREE_VIEW (gtk_builder_get_object (builder,
@@ -296,9 +303,10 @@ GNUNET_GTK_edit_publication_metadata_tree_view_value_renderer_edited_cb (
296 GNUNET_free_non_null (avalue); 303 GNUNET_free_non_null (avalue);
297} 304}
298 305
306
299void 307void
300GNUNET_GTK_edit_publication_delete_button_clicked_cb (GtkButton *button, 308GNUNET_GTK_edit_publication_delete_button_clicked_cb (GtkButton *button,
301 gpointer user_data) 309 gpointer user_data)
302{ 310{
303 GtkTreeView *tv; 311 GtkTreeView *tv;
304 GtkTreeSelection *sel; 312 GtkTreeSelection *sel;
@@ -319,9 +327,10 @@ GNUNET_GTK_edit_publication_delete_button_clicked_cb (GtkButton *button,
319 gtk_tree_selection_select_iter (sel, &iter); 327 gtk_tree_selection_select_iter (sel, &iter);
320} 328}
321 329
330
322void 331void
323GNUNET_GTK_edit_publication_keyword_list_add_button_clicked_cb ( 332GNUNET_GTK_edit_publication_keyword_list_add_button_clicked_cb (
324 GtkButton *button, gpointer user_data) 333 GtkButton *button, gpointer user_data)
325{ 334{
326 const char *keyword; 335 const char *keyword;
327 GtkEntry *entry; 336 GtkEntry *entry;
@@ -348,15 +357,26 @@ GNUNET_GTK_edit_publication_keyword_list_add_button_clicked_cb (
348 gtk_entry_set_text (entry, ""); 357 gtk_entry_set_text (entry, "");
349} 358}
350 359
351gboolean 360
352gtk_tree_model_get_item_count_cb (GtkTreeModel *model, GtkTreePath *path, 361static gboolean
362gtk_tree_model_has_items_cb (GtkTreeModel *model, GtkTreePath *path,
353 GtkTreeIter *iter, gpointer data) 363 GtkTreeIter *iter, gpointer data)
354{ 364{
355 gint *counter = (gint *) data; 365 gboolean *val = (gboolean *) data;
356 *counter += 1; 366 *val = TRUE;
357 return FALSE; 367 return TRUE;
358} 368}
359 369
370
371static gboolean
372gtk_tree_model_has_items (GtkTreeModel *model)
373{
374 gboolean b = FALSE;
375 gtk_tree_model_foreach (model, &gtk_tree_model_has_items_cb, &b);
376 return b;
377}
378
379
360void 380void
361GNUNET_GTK_edit_publication_keyword_entry_changed_cb (GtkEditable *editable, 381GNUNET_GTK_edit_publication_keyword_entry_changed_cb (GtkEditable *editable,
362 gpointer user_data) 382 gpointer user_data)
@@ -380,31 +400,6 @@ GNUNET_GTK_edit_publication_keyword_entry_changed_cb (GtkEditable *editable,
380} 400}
381 401
382 402
383gint
384gtk_tree_model_get_item_count (GtkTreeModel *model)
385{
386 gint c = 0;
387 gtk_tree_model_foreach (model, &gtk_tree_model_get_item_count_cb, &c);
388 return c;
389}
390
391gboolean
392gtk_tree_model_has_items_cb (GtkTreeModel *model, GtkTreePath *path,
393 GtkTreeIter *iter, gpointer data)
394{
395 gboolean *val = (gboolean *) data;
396 *val = TRUE;
397 return TRUE;
398}
399
400gboolean
401gtk_tree_model_has_items (GtkTreeModel *model)
402{
403 gboolean b = FALSE;
404 gtk_tree_model_foreach (model, &gtk_tree_model_has_items_cb, &b);
405 return b;
406}
407
408void 403void
409GNUNET_GTK_edit_publication_keyword_list_del_button_clicked_cb ( 404GNUNET_GTK_edit_publication_keyword_list_del_button_clicked_cb (
410 GtkButton *button, gpointer user_data) 405 GtkButton *button, gpointer user_data)
@@ -416,7 +411,7 @@ GNUNET_GTK_edit_publication_keyword_list_del_button_clicked_cb (
416 GtkBuilder *builder; 411 GtkBuilder *builder;
417 GtkWidget *ok; 412 GtkWidget *ok;
418 GObject *pubwindow; 413 GObject *pubwindow;
419 struct edit_publication_state *state = NULL; 414 struct EditPublicationState *state = NULL;
420 builder = GTK_BUILDER (user_data); 415 builder = GTK_BUILDER (user_data);
421 416
422 tv = GTK_TREE_VIEW (gtk_builder_get_object 417 tv = GTK_TREE_VIEW (gtk_builder_get_object
@@ -448,6 +443,7 @@ GNUNET_GTK_edit_publication_keyword_list_del_button_clicked_cb (
448 gtk_widget_set_sensitive (ok, FALSE); 443 gtk_widget_set_sensitive (ok, FALSE);
449} 444}
450 445
446
451void 447void
452GNUNET_GTK_edit_publication_keyword_list_normalize_button_clicked_cb ( 448GNUNET_GTK_edit_publication_keyword_list_normalize_button_clicked_cb (
453 GtkButton *button, gpointer user_data) 449 GtkButton *button, gpointer user_data)
@@ -494,6 +490,7 @@ GNUNET_GTK_edit_publication_keyword_list_normalize_button_clicked_cb (
494 g_free (value); 490 g_free (value);
495} 491}
496 492
493
497void 494void
498GNUNET_GTK_edit_publication_normalization_checkbox_toggled_cb ( 495GNUNET_GTK_edit_publication_normalization_checkbox_toggled_cb (
499 GtkToggleButton *button, gpointer user_data) 496 GtkToggleButton *button, gpointer user_data)
@@ -507,6 +504,7 @@ GNUNET_GTK_edit_publication_normalization_checkbox_toggled_cb (
507 !gtk_toggle_button_get_active (norm_button)); 504 !gtk_toggle_button_get_active (norm_button));
508} 505}
509 506
507
510void 508void
511GNUNET_GTK_edit_publication_metadata_preview_file_chooser_button_file_set_cb ( 509GNUNET_GTK_edit_publication_metadata_preview_file_chooser_button_file_set_cb (
512 GtkFileChooserButton *widget, gpointer user_data) 510 GtkFileChooserButton *widget, gpointer user_data)
@@ -515,7 +513,7 @@ GNUNET_GTK_edit_publication_metadata_preview_file_chooser_button_file_set_cb (
515 GtkImage *image; 513 GtkImage *image;
516 GObject *pubwindow; 514 GObject *pubwindow;
517 GtkBuilder *builder = GTK_BUILDER (user_data); 515 GtkBuilder *builder = GTK_BUILDER (user_data);
518 struct edit_publication_state *state = NULL; 516 struct EditPublicationState *state = NULL;
519 517
520 pubwindow = gtk_builder_get_object (builder, 518 pubwindow = gtk_builder_get_object (builder,
521 "GNUNET_GTK_edit_publication_window"); 519 "GNUNET_GTK_edit_publication_window");
@@ -535,19 +533,22 @@ GNUNET_GTK_edit_publication_metadata_preview_file_chooser_button_file_set_cb (
535 state->preview_changed = GNUNET_YES; 533 state->preview_changed = GNUNET_YES;
536} 534}
537 535
538struct fiu_context 536
537struct FileInformationUpdateContext
539{ 538{
540 GtkBuilder *builder; 539 GtkBuilder *builder;
541 char **short_fn; 540 char *short_fn;
542 gchar *root; 541 gchar *root;
543 struct GNUNET_CONTAINER_MetaData *md; 542 struct GNUNET_CONTAINER_MetaData *md;
543 gboolean allow_no_keywords;
544}; 544};
545 545
546
546/** 547/**
547 * Copy binary meta data from to the new container and also 548 * Copy binary meta data from to the new container and also
548 * preserve all entries that were not changed. 549 * preserve all entries that were not changed.
549 * 550 *
550 * @param cls closure, new meta data container 551 * @param cls closure, a 'struct FileInformationUpdateContext'
551 * @param plugin_name name of the plugin that produced this value; 552 * @param plugin_name name of the plugin that produced this value;
552 * special values can be used (i.e. '<zlib>' for zlib being 553 * special values can be used (i.e. '<zlib>' for zlib being
553 * used in the main libextractor library and yielding 554 * used in the main libextractor library and yielding
@@ -567,7 +568,7 @@ preserve_meta_items (void *cls, const char *plugin_name,
567 const char *data_mime_type, const char *data, 568 const char *data_mime_type, const char *data,
568 size_t data_len) 569 size_t data_len)
569{ 570{
570 struct fiu_context *context = (struct fiu_context *) cls; 571 struct FileInformationUpdateContext *context = cls;
571 GtkBuilder *builder = context->builder; 572 GtkBuilder *builder = context->builder;
572 struct GNUNET_CONTAINER_MetaData *md = context->md; 573 struct GNUNET_CONTAINER_MetaData *md = context->md;
573 GtkTreeModel *tm; 574 GtkTreeModel *tm;
@@ -578,7 +579,7 @@ preserve_meta_items (void *cls, const char *plugin_name,
578 int keep; 579 int keep;
579 580
580 GObject *pubwindow; 581 GObject *pubwindow;
581 struct edit_publication_state *state = NULL; 582 struct EditPublicationState *state = NULL;
582 583
583 pubwindow = gtk_builder_get_object (builder, 584 pubwindow = gtk_builder_get_object (builder,
584 "GNUNET_GTK_edit_publication_window"); 585 "GNUNET_GTK_edit_publication_window");
@@ -636,7 +637,7 @@ preserve_meta_items (void *cls, const char *plugin_name,
636/** 637/**
637 * Function called to update the information in FI. 638 * Function called to update the information in FI.
638 * 639 *
639 * @param cls closure (short_fn to update) 640 * @param cls closure with a 'struct FileInformationUpdateContext *'
640 * @param fi the entry in the publish-structure 641 * @param fi the entry in the publish-structure
641 * @param length length of the file or directory 642 * @param length length of the file or directory
642 * @param meta metadata for the file or directory (can be modified) 643 * @param meta metadata for the file or directory (can be modified)
@@ -654,8 +655,8 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi,
654 struct GNUNET_FS_BlockOptions *bo, int *do_index, 655 struct GNUNET_FS_BlockOptions *bo, int *do_index,
655 void **client_info) 656 void **client_info)
656{ 657{
657 struct fiu_context *context = (struct fiu_context *) cls; 658 struct FileInformationUpdateContext *context = cls;
658 char **short_fn = context->short_fn; 659 char **short_fn = &context->short_fn;
659 GtkBuilder *builder = context->builder; 660 GtkBuilder *builder = context->builder;
660 struct GNUNET_CONTAINER_MetaData *nm; 661 struct GNUNET_CONTAINER_MetaData *nm;
661 GtkTreeModel *tm; 662 GtkTreeModel *tm;
@@ -673,9 +674,8 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi,
673 GFile *f; 674 GFile *f;
674 GFileInfo *finfo; 675 GFileInfo *finfo;
675 gboolean auto_normalize = FALSE; 676 gboolean auto_normalize = FALSE;
676
677 GObject *pubwindow; 677 GObject *pubwindow;
678 struct edit_publication_state *state = NULL; 678 struct EditPublicationState *state = NULL;
679 679
680 pubwindow = gtk_builder_get_object (builder, 680 pubwindow = gtk_builder_get_object (builder,
681 "GNUNET_GTK_edit_publication_window"); 681 "GNUNET_GTK_edit_publication_window");
@@ -708,13 +708,15 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi,
708 "GNUNET_GTK_edit_publication_expiration_year_spin_button")); 708 "GNUNET_GTK_edit_publication_expiration_year_spin_button"));
709 bo->expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); 709 bo->expiration_time = GNUNET_FS_GTK_get_expiration_time (sb);
710 710
711 g_free (context->root); 711 if (! context->allow_no_keywords)
712 context->root = 712 {
713 g_free (context->root);
714 context->root =
713 g_strdup (gtk_entry_get_text (GTK_ENTRY 715 g_strdup (gtk_entry_get_text (GTK_ENTRY
714 (gtk_builder_get_object 716 (gtk_builder_get_object
715 (builder, 717 (builder,
716 "GNUNET_GTK_edit_publication_root_entry")))); 718 "GNUNET_GTK_edit_publication_root_entry"))));
717 719 }
718 /* update URI */ 720 /* update URI */
719 if (NULL != (*uri)) 721 if (NULL != (*uri))
720 GNUNET_FS_uri_destroy (*uri); 722 GNUNET_FS_uri_destroy (*uri);
@@ -819,13 +821,14 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi,
819 return GNUNET_SYSERR; /* only visit top-level item */ 821 return GNUNET_SYSERR; /* only visit top-level item */
820} 822}
821 823
824
822void 825void
823GNUNET_GTK_edit_publication_cancel_button_clicked_cb ( 826GNUNET_GTK_edit_publication_cancel_button_clicked_cb (
824 GtkButton *button, gpointer user_data) 827 GtkButton *button, gpointer user_data)
825{ 828{
826 GtkBuilder *builder; 829 GtkBuilder *builder;
827 GObject *pubwindow; 830 GObject *pubwindow;
828 struct edit_publication_state *state = NULL; 831 struct EditPublicationState *state = NULL;
829 832
830 builder = GTK_BUILDER (user_data); 833 builder = GTK_BUILDER (user_data);
831 834
@@ -839,20 +842,20 @@ GNUNET_GTK_edit_publication_cancel_button_clicked_cb (
839 } 842 }
840 843
841 state->cb (state->cls, state->do_index, state->short_fn, 844 state->cb (state->cls, state->do_index, state->short_fn,
842 state->anonymity_level, state->priority, NULL, state->fip, GTK_RESPONSE_CANCEL); 845 state->anonymity_level, state->priority, NULL, GTK_RESPONSE_CANCEL);
843 g_free (state); 846 g_free (state);
844 g_object_set_data (pubwindow, PUBSTATE, NULL); 847 g_object_set_data (pubwindow, PUBSTATE, NULL);
845 gtk_widget_hide (GTK_WIDGET (pubwindow)); 848 gtk_widget_hide (GTK_WIDGET (pubwindow));
846} 849}
847 850
851
848void 852void
849GNUNET_GTK_edit_publication_confirm_button_clicked_cb ( 853GNUNET_GTK_edit_publication_confirm_button_clicked_cb (GtkButton *button, gpointer user_data)
850 GtkButton *button, gpointer user_data)
851{ 854{
852 GtkBuilder *builder; 855 GtkBuilder *builder;
853 GObject *pubwindow; 856 GObject *pubwindow;
854 struct edit_publication_state *state = NULL; 857 struct EditPublicationState *state;
855 struct fiu_context ctx; 858 struct FileInformationUpdateContext ctx;
856 859
857 builder = GTK_BUILDER (user_data); 860 builder = GTK_BUILDER (user_data);
858 861
@@ -869,30 +872,37 @@ GNUNET_GTK_edit_publication_confirm_button_clicked_cb (
869 ctx.short_fn = state->short_fn; 872 ctx.short_fn = state->short_fn;
870 ctx.root = NULL; 873 ctx.root = NULL;
871 ctx.md = NULL; 874 ctx.md = NULL;
875 ctx.allow_no_keywords = state->allow_no_keywords;
872 876
873 GNUNET_FS_file_information_inspect (state->fip, &file_information_update, &ctx); 877 GNUNET_FS_file_information_inspect (state->fip, &file_information_update, &ctx);
874 if (!GNUNET_GTK_get_selected_anonymity_level (builder, 878 if (!GNUNET_GTK_get_selected_anonymity_level (builder,
875 "GNUNET_GTK_edit_publication_anonymity_combobox", state->anonymity_level)) 879 "GNUNET_GTK_edit_publication_anonymity_combobox",
876 *state->priority = 880 &state->anonymity_level))
881 state->priority =
877 gtk_spin_button_get_value (GTK_SPIN_BUTTON 882 gtk_spin_button_get_value (GTK_SPIN_BUTTON
878 (gtk_builder_get_object 883 (gtk_builder_get_object
879 (builder, 884 (builder,
880 "GNUNET_GTK_edit_publication_priority_spin_button"))); 885 "GNUNET_GTK_edit_publication_priority_spin_button")));
881 *state->do_index = 886 state->do_index =
882 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 887 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
883 (gtk_builder_get_object 888 (gtk_builder_get_object
884 (builder, 889 (builder,
885 "GNUNET_GTK_edit_publication_index_checkbutton"))); 890 "GNUNET_GTK_edit_publication_index_checkbutton")));
886 891
887 892
888 state->cb (state->cls, state->do_index, state->short_fn, 893 state->cb (state->cls,
889 state->anonymity_level, state->priority, ctx.root, state->fip, 894 state->do_index,
890 GTK_RESPONSE_OK); 895 state->short_fn,
891 g_free (state); 896 state->anonymity_level,
897 state->priority, ctx.root,
898 GTK_RESPONSE_OK);
899 GNUNET_free (state->short_fn);
900 GNUNET_free (state);
892 g_object_set_data (pubwindow, PUBSTATE, NULL); 901 g_object_set_data (pubwindow, PUBSTATE, NULL);
893 gtk_widget_hide (GTK_WIDGET (pubwindow)); 902 gtk_widget_hide (GTK_WIDGET (pubwindow));
894} 903}
895 904
905
896/** 906/**
897 * Add each of the keywords to the keyword list store. 907 * Add each of the keywords to the keyword list store.
898 * 908 *
@@ -912,6 +922,7 @@ add_keyword (void *cls, const char *keyword, int is_mandatory)
912 return GNUNET_OK; 922 return GNUNET_OK;
913} 923}
914 924
925
915/** 926/**
916 * Function called to extract the information from FI. 927 * Function called to extract the information from FI.
917 * 928 *
@@ -973,7 +984,7 @@ file_information_extract (void *cls, struct GNUNET_FS_FileInformation *fi,
973 "GNUNET_GTK_edit_publication_expiration_year_spin_button")), 984 "GNUNET_GTK_edit_publication_expiration_year_spin_button")),
974 year); 985 year);
975 GNUNET_GTK_select_anonymity_level (builder, 986 GNUNET_GTK_select_anonymity_level (builder,
976 "GNUNET_GTK_edit_publication_anonymity_combobox", bo->anonymity_level); 987 "GNUNET_GTK_edit_publication_anonymity_combobox", bo->anonymity_level);
977 gtk_spin_button_set_value (GTK_SPIN_BUTTON 988 gtk_spin_button_set_value (GTK_SPIN_BUTTON
978 (gtk_builder_get_object 989 (gtk_builder_get_object
979 (builder, 990 (builder,
@@ -992,16 +1003,21 @@ file_information_extract (void *cls, struct GNUNET_FS_FileInformation *fi,
992 * Open the dialog to edit file information data. 1003 * Open the dialog to edit file information data.
993 */ 1004 */
994void 1005void
995GNUNET_FS_GTK_edit_publish_dialog (GtkBuilder *builder, GtkWindow *parent, int *do_index, 1006GNUNET_FS_GTK_edit_publish_dialog (GtkBuilder *builder,
996 char **short_fn, guint *anonymity_level, guint *priority, 1007 GtkWindow *parent,
997 struct GNUNET_FS_FileInformation *fip, gboolean allow_no_keywords, 1008 int do_index,
998 GNUNET_FS_GTK_edit_publish_dialog_cb cb, gpointer cls) 1009 const char *short_fn,
1010 uint32_t anonymity_level,
1011 uint32_t priority,
1012 struct GNUNET_FS_FileInformation *fip,
1013 gboolean allow_no_keywords,
1014 GNUNET_FS_GTK_EditPublishDialogCallback cb, gpointer cls)
999{ 1015{
1000 GtkWidget *dialog; 1016 GtkWidget *dialog;
1001 GObject *pubwindow; 1017 GObject *pubwindow;
1002 GtkEntry *entry; 1018 GtkEntry *entry;
1003 GtkWidget *ok; 1019 GtkWidget *ok;
1004 struct edit_publication_state *state; 1020 struct EditPublicationState *state;
1005 1021
1006 GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); 1022 GNUNET_FS_GTK_setup_expiration_year_adjustment (builder);
1007 if (GNUNET_FS_file_information_is_directory (fip)) 1023 if (GNUNET_FS_file_information_is_directory (fip))
@@ -1019,9 +1035,9 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkBuilder *builder, GtkWindow *parent, int *
1019 if (allow_no_keywords) 1035 if (allow_no_keywords)
1020 { 1036 {
1021 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (builder, 1037 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (builder,
1022 "GNUNET_GTK_edit_publication_root_entry"))); 1038 "GNUNET_GTK_edit_publication_root_entry")));
1023 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (builder, 1039 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (builder,
1024 "GNUNET_GTK_edit_publication_root_label"))); 1040 "GNUNET_GTK_edit_publication_root_label")));
1025 } 1041 }
1026 gtk_list_store_clear (GTK_LIST_STORE (gtk_builder_get_object ( 1042 gtk_list_store_clear (GTK_LIST_STORE (gtk_builder_get_object (
1027 builder, "GNUNET_GTK_publication_keywords_liststore"))); 1043 builder, "GNUNET_GTK_publication_keywords_liststore")));
@@ -1029,18 +1045,15 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkBuilder *builder, GtkWindow *parent, int *
1029 builder, "GNUNET_GTK_publication_metadata_liststore"))); 1045 builder, "GNUNET_GTK_publication_metadata_liststore")));
1030 1046
1031 GNUNET_FS_file_information_inspect (fip, &file_information_extract, builder); 1047 GNUNET_FS_file_information_inspect (fip, &file_information_extract, builder);
1032
1033 dialog = GTK_WIDGET (gtk_builder_get_object (builder, 1048 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
1034 "GNUNET_GTK_edit_publication_window")); 1049 "GNUNET_GTK_edit_publication_window"));
1035 1050 gtk_window_set_title (GTK_WINDOW (dialog), short_fn);
1036 gtk_window_set_title (GTK_WINDOW (dialog), *short_fn);
1037 1051
1038 state = g_new0 (struct edit_publication_state, 1); 1052 state = GNUNET_malloc (sizeof (struct EditPublicationState));
1039 state->do_index = do_index; 1053 state->do_index = do_index;
1040 state->short_fn = short_fn; 1054 state->short_fn = GNUNET_strdup (short_fn);
1041 state->root = NULL; 1055 state->anonymity_level = (guint) anonymity_level;
1042 state->anonymity_level = anonymity_level; 1056 state->priority = (guint) priority;
1043 state->priority = priority;
1044 state->fip = fip; 1057 state->fip = fip;
1045 state->preview_changed = GNUNET_NO; 1058 state->preview_changed = GNUNET_NO;
1046 state->allow_no_keywords = allow_no_keywords; 1059 state->allow_no_keywords = allow_no_keywords;
@@ -1052,18 +1065,15 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkBuilder *builder, GtkWindow *parent, int *
1052 GTK_ENTRY (gtk_builder_get_object 1065 GTK_ENTRY (gtk_builder_get_object
1053 (builder, "GNUNET_GTK_edit_publication_keyword_entry")); 1066 (builder, "GNUNET_GTK_edit_publication_keyword_entry"));
1054 gtk_entry_set_text (entry, ""); 1067 gtk_entry_set_text (entry, "");
1055
1056 pubwindow = gtk_builder_get_object (builder, 1068 pubwindow = gtk_builder_get_object (builder,
1057 "GNUNET_GTK_edit_publication_window"); 1069 "GNUNET_GTK_edit_publication_window");
1058 g_object_set_data (pubwindow, PUBSTATE, state); 1070 g_object_set_data (pubwindow, PUBSTATE, state);
1059
1060 ok = GTK_WIDGET (gtk_builder_get_object (builder, 1071 ok = GTK_WIDGET (gtk_builder_get_object (builder,
1061 "GNUNET_GTK_edit_publication_confirm_button")); 1072 "GNUNET_GTK_edit_publication_confirm_button"));
1062 gtk_widget_set_sensitive (ok, allow_no_keywords ? TRUE : FALSE); 1073 gtk_widget_set_sensitive (ok, allow_no_keywords ? TRUE : FALSE);
1063
1064 gtk_window_set_transient_for (GTK_WINDOW (pubwindow), parent); 1074 gtk_window_set_transient_for (GTK_WINDOW (pubwindow), parent);
1065
1066 gtk_window_present (GTK_WINDOW (dialog)); 1075 gtk_window_present (GTK_WINDOW (dialog));
1067} 1076}
1068 1077
1078
1069/* end of gnunet-fs-gtk-edit_publish_dialog.c */ 1079/* end of gnunet-fs-gtk-edit_publish_dialog.c */