diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk-edit_publish_dialog.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk-edit_publish_dialog.c | 127 |
1 files changed, 66 insertions, 61 deletions
diff --git a/src/fs/gnunet-fs-gtk-edit_publish_dialog.c b/src/fs/gnunet-fs-gtk-edit_publish_dialog.c index 62ed17fd..61832925 100644 --- a/src/fs/gnunet-fs-gtk-edit_publish_dialog.c +++ b/src/fs/gnunet-fs-gtk-edit_publish_dialog.c | |||
@@ -163,12 +163,6 @@ struct EditPublicationDialogContext | |||
163 | struct GNUNET_FS_FileInformation *fip; | 163 | struct GNUNET_FS_FileInformation *fip; |
164 | 164 | ||
165 | /** | 165 | /** |
166 | * Overall options for the publish operation. This is also what | ||
167 | * we are primarily editing. | ||
168 | */ | ||
169 | struct GNUNET_FS_BlockOptions bo; | ||
170 | |||
171 | /** | ||
172 | * Flag to track if we changed the preview and thus should keep/discard | 166 | * Flag to track if we changed the preview and thus should keep/discard |
173 | * certain metadata. (FIXME: yucky!) | 167 | * certain metadata. (FIXME: yucky!) |
174 | */ | 168 | */ |
@@ -642,12 +636,46 @@ GNUNET_GTK_edit_publication_keyword_entry_key_press_event_cb (GtkWidget * | |||
642 | } | 636 | } |
643 | 637 | ||
644 | 638 | ||
639 | |||
645 | /* ****************** handlers for closing the dialog ******************** */ | 640 | /* ****************** handlers for closing the dialog ******************** */ |
646 | 641 | ||
647 | 642 | ||
643 | /** | ||
644 | * The user clicked the 'cancel' button. Abort the operation. | ||
645 | * | ||
646 | * @param button the cancel button | ||
647 | * @param user_data the 'struct EditPublicationDialogContext' | ||
648 | */ | ||
649 | void | ||
650 | GNUNET_GTK_edit_publication_cancel_button_clicked_cb (GtkButton * button, | ||
651 | gpointer user_data) | ||
652 | { | ||
653 | struct EditPublicationDialogContext *ctx = user_data; | ||
648 | 654 | ||
655 | ctx->cb (ctx->cb_cls, GNUNET_SYSERR, NULL, NULL, NULL, GTK_RESPONSE_CANCEL); | ||
656 | free_edit_dialog_context (ctx); | ||
657 | } | ||
649 | 658 | ||
650 | 659 | ||
660 | /** | ||
661 | * The user closed the window. Abort the operation. | ||
662 | * | ||
663 | * @param widget the window | ||
664 | * @param event the event that caused the window to close | ||
665 | * @param user_data the 'struct EditPublicationDialogContext' | ||
666 | * @return TRUE (always) | ||
667 | */ | ||
668 | gboolean | ||
669 | GNUNET_GTK_edit_publication_window_delete_event_cb (GtkWidget * widget, | ||
670 | GdkEvent * event, | ||
671 | gpointer user_data) | ||
672 | { | ||
673 | struct EditPublicationDialogContext *ctx = user_data; | ||
674 | |||
675 | ctx->cb (ctx->cb_cls, GNUNET_SYSERR, NULL, NULL, NULL, GTK_RESPONSE_CANCEL); | ||
676 | free_edit_dialog_context (ctx); | ||
677 | return TRUE; | ||
678 | } | ||
651 | 679 | ||
652 | 680 | ||
653 | /** | 681 | /** |
@@ -759,13 +787,7 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
759 | GFileInfo *finfo; | 787 | GFileInfo *finfo; |
760 | char *sfn; | 788 | char *sfn; |
761 | 789 | ||
762 | if (!GNUNET_GTK_get_selected_anonymity_combo_level | ||
763 | (ctx->anonymity_combo, &ctx->bo.anonymity_level)) | ||
764 | return GNUNET_SYSERR; | ||
765 | ctx->bo.content_priority = gtk_spin_button_get_value (ctx->priority_spin); | ||
766 | ctx->bo.replication_level = gtk_spin_button_get_value (ctx->replication_spin); | ||
767 | *do_index = gtk_toggle_button_get_active (ctx->index_checkbutton); | 790 | *do_index = gtk_toggle_button_get_active (ctx->index_checkbutton); |
768 | ctx->bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (ctx->expiration_year_spin); | ||
769 | 791 | ||
770 | /* update URI */ | 792 | /* update URI */ |
771 | if (NULL != (*uri)) | 793 | if (NULL != (*uri)) |
@@ -792,7 +814,9 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
792 | 814 | ||
793 | /* update meta */ | 815 | /* update meta */ |
794 | ctx->md = GNUNET_CONTAINER_meta_data_create (); | 816 | ctx->md = GNUNET_CONTAINER_meta_data_create (); |
795 | GNUNET_CONTAINER_meta_data_iterate (meta, &preserve_meta_items, ctx); | 817 | GNUNET_CONTAINER_meta_data_iterate (meta, |
818 | &preserve_meta_items, | ||
819 | ctx); | ||
796 | 820 | ||
797 | GNUNET_CONTAINER_meta_data_clear (meta); | 821 | GNUNET_CONTAINER_meta_data_clear (meta); |
798 | if (TRUE == gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->meta_liststore), &iter)) | 822 | if (TRUE == gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->meta_liststore), &iter)) |
@@ -854,57 +878,41 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
854 | } | 878 | } |
855 | 879 | ||
856 | 880 | ||
857 | void | 881 | /** |
858 | GNUNET_GTK_edit_publication_cancel_button_clicked_cb (GtkButton * button, | 882 | * The user clicked the 'confirm' button. Push the edits back into the |
859 | struct EditPublicationDialogContext *ctx) | 883 | * FileInformation structure and given it and the options back to the |
860 | { | 884 | * callback. Then clean up the dialog. |
861 | int do_index; | 885 | * |
862 | 886 | * @param button the cancel button | |
863 | /* FIXME: why are we passing half of these values here? */ | 887 | * @param user_data the 'struct EditPublicationDialogContext' |
864 | do_index = gtk_toggle_button_get_active (ctx->index_checkbutton); | 888 | */ |
865 | ctx->cb (ctx->cb_cls, do_index, ctx->short_fn, | ||
866 | &ctx->bo, NULL, GTK_RESPONSE_CANCEL); | ||
867 | free_edit_dialog_context (ctx); | ||
868 | } | ||
869 | |||
870 | |||
871 | |||
872 | void | 889 | void |
873 | GNUNET_GTK_edit_publication_confirm_button_clicked_cb (GtkButton * button, | 890 | GNUNET_GTK_edit_publication_confirm_button_clicked_cb (GtkButton * button, |
874 | struct EditPublicationDialogContext *ctx) | 891 | gpointer user_data) |
875 | { | 892 | { |
893 | struct EditPublicationDialogContext *ctx = user_data; | ||
894 | struct GNUNET_FS_BlockOptions bo; | ||
876 | gint year; | 895 | gint year; |
877 | const char *root; | ||
878 | int do_index; | ||
879 | 896 | ||
880 | GNUNET_FS_file_information_inspect (ctx->fip, &file_information_update, ctx); | 897 | GNUNET_FS_file_information_inspect (ctx->fip, |
881 | if (!GNUNET_GTK_get_selected_anonymity_combo_level (ctx->anonymity_combo, | 898 | &file_information_update, |
882 | &ctx->bo.anonymity_level)) | 899 | ctx); |
883 | ctx->bo.content_priority = gtk_spin_button_get_value (ctx->priority_spin); | 900 | GNUNET_break (GNUNET_GTK_get_selected_anonymity_combo_level (ctx->anonymity_combo, |
884 | ctx->bo.replication_level = gtk_spin_button_get_value (ctx->replication_spin); | 901 | &bo.anonymity_level)); |
885 | 902 | bo.content_priority = gtk_spin_button_get_value (ctx->priority_spin); | |
886 | do_index = gtk_toggle_button_get_active (ctx->index_checkbutton); | 903 | bo.replication_level = gtk_spin_button_get_value (ctx->replication_spin); |
887 | year = gtk_spin_button_get_value (ctx->expiration_year_spin); | 904 | year = gtk_spin_button_get_value (ctx->expiration_year_spin); |
888 | ctx->bo.expiration_time = GNUNET_FS_year_to_time (year); | 905 | bo.expiration_time = GNUNET_FS_year_to_time (year); |
889 | root = gtk_entry_get_text (ctx->root_entry); | 906 | ctx->cb (ctx->cb_cls, |
890 | ctx->cb (ctx->cb_cls, do_index, ctx->short_fn, | 907 | gtk_toggle_button_get_active (ctx->index_checkbutton), |
891 | &ctx->bo, root, GTK_RESPONSE_OK); | 908 | ctx->short_fn, |
909 | &bo, | ||
910 | gtk_entry_get_text (ctx->root_entry), | ||
911 | GTK_RESPONSE_OK); | ||
892 | free_edit_dialog_context (ctx); | 912 | free_edit_dialog_context (ctx); |
893 | } | 913 | } |
894 | 914 | ||
895 | 915 | ||
896 | gboolean | ||
897 | GNUNET_GTK_edit_publication_window_delete_event_cb (GtkWidget * widget, | ||
898 | GdkEvent * event, | ||
899 | struct EditPublicationDialogContext *ctx) | ||
900 | { | ||
901 | GNUNET_GTK_edit_publication_cancel_button_clicked_cb (GTK_BUTTON (gtk_builder_get_object | ||
902 | (ctx->builder, "GNUNET_GTK_edit_publication_cancel_button")), | ||
903 | ctx); | ||
904 | return TRUE; | ||
905 | } | ||
906 | |||
907 | |||
908 | /* ****************** code for initialization of the dialog ******************** */ | 916 | /* ****************** code for initialization of the dialog ******************** */ |
909 | 917 | ||
910 | 918 | ||
@@ -967,12 +975,12 @@ file_information_extract (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
967 | gtk_image_set_from_pixbuf (ctx->preview_image, pixbuf); | 975 | gtk_image_set_from_pixbuf (ctx->preview_image, pixbuf); |
968 | } | 976 | } |
969 | } | 977 | } |
970 | year = (int) GNUNET_FS_time_to_year (ctx->bo.expiration_time); | 978 | year = (int) GNUNET_FS_time_to_year (bo->expiration_time); |
971 | gtk_spin_button_set_value (ctx->expiration_year_spin, year); | 979 | gtk_spin_button_set_value (ctx->expiration_year_spin, year); |
972 | GNUNET_GTK_select_anonymity_combo_level (ctx->anonymity_combo, | 980 | GNUNET_GTK_select_anonymity_combo_level (ctx->anonymity_combo, |
973 | ctx->bo.anonymity_level); | 981 | bo->anonymity_level); |
974 | gtk_spin_button_set_value (ctx->priority_spin, ctx->bo.content_priority); | 982 | gtk_spin_button_set_value (ctx->priority_spin, bo->content_priority); |
975 | gtk_spin_button_set_value (ctx->replication_spin, ctx->bo.replication_level); | 983 | gtk_spin_button_set_value (ctx->replication_spin, bo->replication_level); |
976 | gtk_toggle_button_set_active (ctx->index_checkbutton, *do_index); | 984 | gtk_toggle_button_set_active (ctx->index_checkbutton, *do_index); |
977 | return GNUNET_SYSERR; /* only visit top-level item */ | 985 | return GNUNET_SYSERR; /* only visit top-level item */ |
978 | } | 986 | } |
@@ -1001,9 +1009,7 @@ GNUNET_GTK_edit_publication_window_realize_cb (GtkWidget *widget, struct EditPub | |||
1001 | */ | 1009 | */ |
1002 | void | 1010 | void |
1003 | GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | 1011 | GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, |
1004 | int do_index /* FIXME: not needed? */, | ||
1005 | const char *short_fn, | 1012 | const char *short_fn, |
1006 | const struct GNUNET_FS_BlockOptions bo, | ||
1007 | struct GNUNET_FS_FileInformation *fip, | 1013 | struct GNUNET_FS_FileInformation *fip, |
1008 | gboolean allow_no_keywords, | 1014 | gboolean allow_no_keywords, |
1009 | GtkListStore *anon_liststore, | 1015 | GtkListStore *anon_liststore, |
@@ -1117,7 +1123,6 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
1117 | 1123 | ||
1118 | if (NULL != short_fn) | 1124 | if (NULL != short_fn) |
1119 | ctx->short_fn = GNUNET_strdup (short_fn); | 1125 | ctx->short_fn = GNUNET_strdup (short_fn); |
1120 | ctx->bo = bo; | ||
1121 | ctx->fip = fip; | 1126 | ctx->fip = fip; |
1122 | ctx->preview_changed = GNUNET_NO; | 1127 | ctx->preview_changed = GNUNET_NO; |
1123 | ctx->allow_no_keywords = allow_no_keywords; | 1128 | ctx->allow_no_keywords = allow_no_keywords; |