diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk-main_window_file_publish.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk-main_window_file_publish.c | 526 |
1 files changed, 264 insertions, 262 deletions
diff --git a/src/fs/gnunet-fs-gtk-main_window_file_publish.c b/src/fs/gnunet-fs-gtk-main_window_file_publish.c index db349c95..387736b6 100644 --- a/src/fs/gnunet-fs-gtk-main_window_file_publish.c +++ b/src/fs/gnunet-fs-gtk-main_window_file_publish.c | |||
@@ -94,10 +94,6 @@ struct AddDirClientContext | |||
94 | unsigned int total; | 94 | unsigned int total; |
95 | }; | 95 | }; |
96 | 96 | ||
97 | void | ||
98 | GNUNET_GTK_publish_file_dialog_response_cb (GtkDialog * dialog, | ||
99 | gint response_id, | ||
100 | struct MainPublishingDialogContext *ctx); | ||
101 | 97 | ||
102 | static void | 98 | static void |
103 | selection_changed_cb (GtkTreeSelection * ts, struct MainPublishingDialogContext *ctx); | 99 | selection_changed_cb (GtkTreeSelection * ts, struct MainPublishingDialogContext *ctx); |
@@ -613,173 +609,6 @@ GNUNET_GTK_master_publish_dialog_new_button_clicked_cb (GtkWidget * dummy, | |||
613 | } | 609 | } |
614 | 610 | ||
615 | 611 | ||
616 | void | ||
617 | GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy, | ||
618 | struct MainPublishingDialogContext *ctx) | ||
619 | { | ||
620 | GtkWidget *ad; | ||
621 | |||
622 | GtkComboBox *combo; | ||
623 | GtkTreeModel *anon_treemodel; | ||
624 | |||
625 | ctx->open_file_builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_file_dialog.glade", ctx); | ||
626 | GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->open_file_builder); | ||
627 | ad = GTK_WIDGET (gtk_builder_get_object | ||
628 | (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog")); | ||
629 | |||
630 | /* FIXME: Use some kind of adjustable defaults instead of 1000, 0 and TRUE */ | ||
631 | gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object ( | ||
632 | ctx->open_file_builder, | ||
633 | "GNUNET_GTK_publish_file_dialog_priority_spin_button")), 1000); | ||
634 | gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object ( | ||
635 | ctx->open_file_builder, | ||
636 | "GNUNET_GTK_publish_file_dialog_replication_spin_button")), 0); | ||
637 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object ( | ||
638 | ctx->open_file_builder, | ||
639 | "GNUNET_GTK_publish_file_dialog_do_index_checkbutton")), TRUE); | ||
640 | |||
641 | ctx->open_file_handler_id = g_signal_connect (G_OBJECT (ad), "response", G_CALLBACK (GNUNET_GTK_publish_file_dialog_response_cb), ctx); | ||
642 | |||
643 | anon_treemodel = GTK_TREE_MODEL (gtk_builder_get_object (ctx->main_window_builder, | ||
644 | "main_window_search_anonymity_liststore")); | ||
645 | combo = GTK_COMBO_BOX (gtk_builder_get_object (ctx->open_file_builder, | ||
646 | "GNUNET_GTK_publish_file_dialog_anonymity_combobox")); | ||
647 | gtk_combo_box_set_model (combo, anon_treemodel); | ||
648 | |||
649 | gtk_window_set_transient_for (GTK_WINDOW (ad), ctx->master_pubdialog); | ||
650 | |||
651 | gtk_window_present (GTK_WINDOW (ad)); | ||
652 | } | ||
653 | |||
654 | |||
655 | struct EditPublishContext | ||
656 | { | ||
657 | GtkTreeModel *tm; | ||
658 | GtkTreeIter iter; | ||
659 | }; | ||
660 | |||
661 | |||
662 | /** | ||
663 | * Function called when the edit publish dialog has been closed. | ||
664 | * | ||
665 | * @param cls closure | ||
666 | * @param do_index index flag set? | ||
667 | * @param short_fn short filename | ||
668 | * @param bo block options for publishing | ||
669 | * @param root always NULL here | ||
670 | * @param ret GTK_RESPONSE_OK if the dialog was closed with "OK" | ||
671 | */ | ||
672 | static void | ||
673 | master_publish_edit_publish_dialog_cb (gpointer cls, int do_index, | ||
674 | const char *short_fn, | ||
675 | const struct GNUNET_FS_BlockOptions *bo, | ||
676 | const char *root, | ||
677 | gint ret) | ||
678 | { | ||
679 | struct EditPublishContext *cbargs = cls; | ||
680 | struct GNUNET_FS_FileInformation *fi; | ||
681 | |||
682 | if (ret == GTK_RESPONSE_OK) | ||
683 | { | ||
684 | gtk_tree_store_set (GTK_TREE_STORE (cbargs->tm), &cbargs->iter, 1, do_index, | ||
685 | 2, short_fn, 3, (guint) bo->anonymity_level, 4, | ||
686 | (guint) bo->content_priority, | ||
687 | 6, (guint64) bo->expiration_time.abs_value, | ||
688 | 7, (guint) bo->replication_level, | ||
689 | -1); | ||
690 | gtk_tree_model_get (cbargs->tm, &cbargs->iter, 5, &fi, -1); | ||
691 | GNUNET_FS_file_information_set_filename (fi, short_fn); | ||
692 | } | ||
693 | GNUNET_free (cbargs); | ||
694 | } | ||
695 | |||
696 | |||
697 | void | ||
698 | GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, | ||
699 | struct MainPublishingDialogContext *ctx) | ||
700 | { | ||
701 | struct EditPublishContext *cbargs; | ||
702 | gint do_index; | ||
703 | char *short_fn; | ||
704 | guint anonymity_level; | ||
705 | guint priority; | ||
706 | struct GNUNET_FS_FileInformation *fip; | ||
707 | guint64 abs_etime; | ||
708 | guint replication_level; | ||
709 | struct GNUNET_FS_BlockOptions bo; | ||
710 | GtkListStore *anon_liststore; | ||
711 | |||
712 | anon_liststore = GTK_LIST_STORE (gtk_builder_get_object (ctx->main_window_builder, "main_window_search_anonymity_liststore")); | ||
713 | |||
714 | cbargs = GNUNET_malloc (sizeof (struct EditPublishContext)); | ||
715 | cbargs->tm = ctx->file_info_treemodel; | ||
716 | if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &cbargs->iter)) | ||
717 | { | ||
718 | GNUNET_break (0); | ||
719 | GNUNET_free (cbargs); | ||
720 | return; | ||
721 | } | ||
722 | |||
723 | gtk_tree_model_get (ctx->file_info_treemodel, &cbargs->iter, 1, &do_index, 2, &short_fn, 3, | ||
724 | &anonymity_level, 4, &priority, 5, &fip, | ||
725 | 6, &abs_etime, | ||
726 | 7, &replication_level, | ||
727 | -1); | ||
728 | bo.anonymity_level = anonymity_level; | ||
729 | bo.content_priority = priority; | ||
730 | bo.expiration_time.abs_value = (uint64_t) abs_etime; | ||
731 | bo.replication_level = replication_level; | ||
732 | /* FIXME: can we just give our anon_liststore out like this? What about | ||
733 | (unintended) sharing of state? */ | ||
734 | GNUNET_FS_GTK_edit_publish_dialog (ctx->master_pubdialog, do_index, | ||
735 | short_fn, bo, fip, TRUE, anon_liststore, | ||
736 | &master_publish_edit_publish_dialog_cb, | ||
737 | cbargs); | ||
738 | } | ||
739 | |||
740 | |||
741 | /** | ||
742 | * Free row reference stored in the file information's | ||
743 | * client-info pointer. | ||
744 | */ | ||
745 | static int | ||
746 | free_fi_row_reference (void *cls, struct GNUNET_FS_FileInformation *fi, | ||
747 | uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, | ||
748 | struct GNUNET_FS_Uri **uri, | ||
749 | struct GNUNET_FS_BlockOptions *bo, int *do_index, | ||
750 | void **client_info) | ||
751 | { | ||
752 | GtkTreeRowReference *row = *client_info; | ||
753 | |||
754 | if (row == NULL) | ||
755 | { | ||
756 | GNUNET_break (0); | ||
757 | return GNUNET_OK; | ||
758 | } | ||
759 | gtk_tree_row_reference_free (row); | ||
760 | return GNUNET_OK; | ||
761 | } | ||
762 | |||
763 | |||
764 | void | ||
765 | GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy, | ||
766 | struct MainPublishingDialogContext *ctx) | ||
767 | { | ||
768 | GtkTreeIter iter; | ||
769 | struct GNUNET_FS_FileInformation *fip; | ||
770 | |||
771 | if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)) | ||
772 | { | ||
773 | GNUNET_break (0); | ||
774 | return; | ||
775 | } | ||
776 | gtk_tree_model_get (ctx->file_info_treemodel, &iter, 5, &fip, -1); | ||
777 | GNUNET_FS_file_information_destroy (fip, &free_fi_row_reference, NULL); | ||
778 | gtk_tree_store_remove (GTK_TREE_STORE (ctx->file_info_treemodel), &iter); | ||
779 | update_selectivity (ctx); | ||
780 | } | ||
781 | |||
782 | |||
783 | static void | 612 | static void |
784 | insert_progress_dialog_text (struct AddDirClientContext *adcc, | 613 | insert_progress_dialog_text (struct AddDirClientContext *adcc, |
785 | const char *text) | 614 | const char *text) |
@@ -899,32 +728,6 @@ close_scan (struct AddDirClientContext *adcc) | |||
899 | } | 728 | } |
900 | 729 | ||
901 | 730 | ||
902 | void | ||
903 | GNUNET_FS_GTK_progress_dialog_cancel_button_clicked_cb (GtkButton *button, | ||
904 | void *cls) | ||
905 | { | ||
906 | struct AddDirClientContext *adcc = cls; | ||
907 | |||
908 | if (adcc->ds != NULL) | ||
909 | { | ||
910 | /* Still scanning - signal the scanner to finish */ | ||
911 | GNUNET_FS_directory_scan_abort (adcc->ds); | ||
912 | adcc->ds = NULL; | ||
913 | } | ||
914 | close_scan (adcc); | ||
915 | } | ||
916 | |||
917 | |||
918 | gboolean | ||
919 | GNUNET_FS_GTK_progress_dialog_delete_event_cb (GtkWidget *widget, | ||
920 | GdkEvent * event, | ||
921 | void *cls) | ||
922 | { | ||
923 | /* Don't allow GTK to kill the window, until the scan is finished */ | ||
924 | return GNUNET_NO; | ||
925 | } | ||
926 | |||
927 | |||
928 | static void | 731 | static void |
929 | directory_scan_cb (void *cls, | 732 | directory_scan_cb (void *cls, |
930 | const char *filename, int is_directory, | 733 | const char *filename, int is_directory, |
@@ -1081,10 +884,10 @@ scan_file_or_directory (struct MainPublishingDialogContext *ctx, | |||
1081 | } | 884 | } |
1082 | 885 | ||
1083 | 886 | ||
1084 | void | 887 | static void |
1085 | GNUNET_GTK_publish_directory_dialog_response_cb (GtkDialog * dialog, | 888 | publish_directory_dialog_response_cb (GtkDialog * dialog, |
1086 | gint response_id, | 889 | gint response_id, |
1087 | struct MainPublishingDialogContext *ctx) | 890 | struct MainPublishingDialogContext *ctx) |
1088 | { | 891 | { |
1089 | char *filename; | 892 | char *filename; |
1090 | int do_index; | 893 | int do_index; |
@@ -1133,6 +936,265 @@ GNUNET_GTK_publish_directory_dialog_response_cb (GtkDialog * dialog, | |||
1133 | } | 936 | } |
1134 | 937 | ||
1135 | 938 | ||
939 | static void | ||
940 | publish_file_dialog_response_cb (GtkDialog * dialog, | ||
941 | gint response_id, | ||
942 | struct MainPublishingDialogContext *ctx) | ||
943 | { | ||
944 | char *filename; | ||
945 | struct GNUNET_FS_BlockOptions bo; | ||
946 | int do_index; | ||
947 | GtkSpinButton *sb; | ||
948 | GtkWidget *ad; | ||
949 | |||
950 | if (g_signal_handler_is_connected (G_OBJECT (dialog), ctx->open_file_handler_id)) | ||
951 | g_signal_handler_disconnect (G_OBJECT (dialog), ctx->open_file_handler_id); | ||
952 | ctx->open_file_handler_id = 0; | ||
953 | |||
954 | ad = GTK_WIDGET (gtk_builder_get_object | ||
955 | (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog")); | ||
956 | |||
957 | if (response_id == -5) | ||
958 | { | ||
959 | /* OK */ | ||
960 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object | ||
961 | (ctx->open_file_builder, | ||
962 | "GNUNET_GTK_publish_file_dialog_expiration_year_spin_button")); | ||
963 | |||
964 | if (!GNUNET_GTK_get_selected_anonymity_level | ||
965 | (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog_anonymity_combobox", | ||
966 | &bo.anonymity_level)) | ||
967 | bo.anonymity_level = 1; | ||
968 | bo.content_priority = | ||
969 | gtk_spin_button_get_value (GTK_SPIN_BUTTON | ||
970 | (gtk_builder_get_object | ||
971 | (ctx->open_file_builder, | ||
972 | "GNUNET_GTK_publish_file_dialog_priority_spin_button"))); | ||
973 | bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); | ||
974 | bo.replication_level = | ||
975 | gtk_spin_button_get_value (GTK_SPIN_BUTTON | ||
976 | (gtk_builder_get_object | ||
977 | (ctx->open_file_builder, | ||
978 | "GNUNET_GTK_publish_file_dialog_replication_spin_button"))); | ||
979 | do_index = | ||
980 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON | ||
981 | (gtk_builder_get_object | ||
982 | (ctx->open_file_builder, | ||
983 | "GNUNET_GTK_publish_file_dialog_do_index_checkbutton"))); | ||
984 | |||
985 | filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (ad)); | ||
986 | |||
987 | scan_file_or_directory (ctx, filename, &bo, do_index); | ||
988 | |||
989 | g_free (filename); | ||
990 | } | ||
991 | else | ||
992 | { | ||
993 | /* Cancel/Escape/close/etc */ | ||
994 | } | ||
995 | gtk_widget_destroy (ad); | ||
996 | } | ||
997 | |||
998 | |||
999 | void | ||
1000 | GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy, | ||
1001 | struct MainPublishingDialogContext *ctx) | ||
1002 | { | ||
1003 | GtkWidget *ad; | ||
1004 | |||
1005 | GtkComboBox *combo; | ||
1006 | GtkTreeModel *anon_treemodel; | ||
1007 | |||
1008 | ctx->open_file_builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_file_dialog.glade", ctx); | ||
1009 | GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->open_file_builder); | ||
1010 | ad = GTK_WIDGET (gtk_builder_get_object | ||
1011 | (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog")); | ||
1012 | |||
1013 | /* FIXME: Use some kind of adjustable defaults instead of 1000, 0 and TRUE */ | ||
1014 | gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object ( | ||
1015 | ctx->open_file_builder, | ||
1016 | "GNUNET_GTK_publish_file_dialog_priority_spin_button")), 1000); | ||
1017 | gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object ( | ||
1018 | ctx->open_file_builder, | ||
1019 | "GNUNET_GTK_publish_file_dialog_replication_spin_button")), 0); | ||
1020 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object ( | ||
1021 | ctx->open_file_builder, | ||
1022 | "GNUNET_GTK_publish_file_dialog_do_index_checkbutton")), TRUE); | ||
1023 | |||
1024 | ctx->open_file_handler_id = g_signal_connect (G_OBJECT (ad), "response", G_CALLBACK (publish_file_dialog_response_cb), ctx); | ||
1025 | |||
1026 | anon_treemodel = GTK_TREE_MODEL (gtk_builder_get_object (ctx->main_window_builder, | ||
1027 | "main_window_search_anonymity_liststore")); | ||
1028 | combo = GTK_COMBO_BOX (gtk_builder_get_object (ctx->open_file_builder, | ||
1029 | "GNUNET_GTK_publish_file_dialog_anonymity_combobox")); | ||
1030 | gtk_combo_box_set_model (combo, anon_treemodel); | ||
1031 | |||
1032 | gtk_window_set_transient_for (GTK_WINDOW (ad), ctx->master_pubdialog); | ||
1033 | |||
1034 | gtk_window_present (GTK_WINDOW (ad)); | ||
1035 | } | ||
1036 | |||
1037 | |||
1038 | struct EditPublishContext | ||
1039 | { | ||
1040 | GtkTreeModel *tm; | ||
1041 | GtkTreeIter iter; | ||
1042 | }; | ||
1043 | |||
1044 | |||
1045 | /** | ||
1046 | * Function called when the edit publish dialog has been closed. | ||
1047 | * | ||
1048 | * @param cls closure | ||
1049 | * @param do_index index flag set? | ||
1050 | * @param short_fn short filename | ||
1051 | * @param bo block options for publishing | ||
1052 | * @param root always NULL here | ||
1053 | * @param ret GTK_RESPONSE_OK if the dialog was closed with "OK" | ||
1054 | */ | ||
1055 | static void | ||
1056 | master_publish_edit_publish_dialog_cb (gpointer cls, int do_index, | ||
1057 | const char *short_fn, | ||
1058 | const struct GNUNET_FS_BlockOptions *bo, | ||
1059 | const char *root, | ||
1060 | gint ret) | ||
1061 | { | ||
1062 | struct EditPublishContext *cbargs = cls; | ||
1063 | struct GNUNET_FS_FileInformation *fi; | ||
1064 | |||
1065 | if (ret == GTK_RESPONSE_OK) | ||
1066 | { | ||
1067 | gtk_tree_store_set (GTK_TREE_STORE (cbargs->tm), &cbargs->iter, | ||
1068 | 1, do_index, | ||
1069 | 2, short_fn, | ||
1070 | 3, (guint) bo->anonymity_level, | ||
1071 | 4, (guint) bo->content_priority, | ||
1072 | 6, (guint64) bo->expiration_time.abs_value, | ||
1073 | 7, (guint) bo->replication_level, | ||
1074 | -1); | ||
1075 | gtk_tree_model_get (cbargs->tm, &cbargs->iter, 5, &fi, -1); | ||
1076 | GNUNET_FS_file_information_set_filename (fi, short_fn); | ||
1077 | } | ||
1078 | GNUNET_free (cbargs); | ||
1079 | } | ||
1080 | |||
1081 | |||
1082 | void | ||
1083 | GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, | ||
1084 | struct MainPublishingDialogContext *ctx) | ||
1085 | { | ||
1086 | struct EditPublishContext *cbargs; | ||
1087 | gint do_index; | ||
1088 | char *short_fn; | ||
1089 | guint anonymity_level; | ||
1090 | guint priority; | ||
1091 | struct GNUNET_FS_FileInformation *fip; | ||
1092 | guint64 abs_etime; | ||
1093 | guint replication_level; | ||
1094 | struct GNUNET_FS_BlockOptions bo; | ||
1095 | GtkListStore *anon_liststore; | ||
1096 | |||
1097 | anon_liststore = GTK_LIST_STORE (gtk_builder_get_object (ctx->main_window_builder, "main_window_search_anonymity_liststore")); | ||
1098 | |||
1099 | cbargs = GNUNET_malloc (sizeof (struct EditPublishContext)); | ||
1100 | cbargs->tm = ctx->file_info_treemodel; | ||
1101 | if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &cbargs->iter)) | ||
1102 | { | ||
1103 | GNUNET_break (0); | ||
1104 | GNUNET_free (cbargs); | ||
1105 | return; | ||
1106 | } | ||
1107 | |||
1108 | gtk_tree_model_get (ctx->file_info_treemodel, &cbargs->iter, | ||
1109 | 1, &do_index, | ||
1110 | 2, &short_fn, | ||
1111 | 3, &anonymity_level, | ||
1112 | 4, &priority, | ||
1113 | 5, &fip, | ||
1114 | 6, &abs_etime, | ||
1115 | 7, &replication_level, | ||
1116 | -1); | ||
1117 | bo.anonymity_level = anonymity_level; | ||
1118 | bo.content_priority = priority; | ||
1119 | bo.expiration_time.abs_value = (uint64_t) abs_etime; | ||
1120 | bo.replication_level = replication_level; | ||
1121 | /* FIXME: can we just give our anon_liststore out like this? What about | ||
1122 | (unintended) sharing of state? */ | ||
1123 | GNUNET_FS_GTK_edit_publish_dialog (ctx->master_pubdialog, | ||
1124 | short_fn, fip, TRUE, anon_liststore, | ||
1125 | &master_publish_edit_publish_dialog_cb, | ||
1126 | cbargs); | ||
1127 | } | ||
1128 | |||
1129 | |||
1130 | /** | ||
1131 | * Free row reference stored in the file information's | ||
1132 | * client-info pointer. | ||
1133 | */ | ||
1134 | static int | ||
1135 | free_fi_row_reference (void *cls, struct GNUNET_FS_FileInformation *fi, | ||
1136 | uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, | ||
1137 | struct GNUNET_FS_Uri **uri, | ||
1138 | struct GNUNET_FS_BlockOptions *bo, int *do_index, | ||
1139 | void **client_info) | ||
1140 | { | ||
1141 | GtkTreeRowReference *row = *client_info; | ||
1142 | |||
1143 | if (row == NULL) | ||
1144 | { | ||
1145 | GNUNET_break (0); | ||
1146 | return GNUNET_OK; | ||
1147 | } | ||
1148 | gtk_tree_row_reference_free (row); | ||
1149 | return GNUNET_OK; | ||
1150 | } | ||
1151 | |||
1152 | |||
1153 | void | ||
1154 | GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy, | ||
1155 | struct MainPublishingDialogContext *ctx) | ||
1156 | { | ||
1157 | GtkTreeIter iter; | ||
1158 | struct GNUNET_FS_FileInformation *fip; | ||
1159 | |||
1160 | if (TRUE != gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)) | ||
1161 | { | ||
1162 | GNUNET_break (0); | ||
1163 | return; | ||
1164 | } | ||
1165 | gtk_tree_model_get (ctx->file_info_treemodel, &iter, 5, &fip, -1); | ||
1166 | GNUNET_FS_file_information_destroy (fip, &free_fi_row_reference, NULL); | ||
1167 | gtk_tree_store_remove (GTK_TREE_STORE (ctx->file_info_treemodel), &iter); | ||
1168 | update_selectivity (ctx); | ||
1169 | } | ||
1170 | |||
1171 | |||
1172 | void | ||
1173 | GNUNET_FS_GTK_progress_dialog_cancel_button_clicked_cb (GtkButton *button, | ||
1174 | void *cls) | ||
1175 | { | ||
1176 | struct AddDirClientContext *adcc = cls; | ||
1177 | |||
1178 | if (adcc->ds != NULL) | ||
1179 | { | ||
1180 | /* Still scanning - signal the scanner to finish */ | ||
1181 | GNUNET_FS_directory_scan_abort (adcc->ds); | ||
1182 | adcc->ds = NULL; | ||
1183 | } | ||
1184 | close_scan (adcc); | ||
1185 | } | ||
1186 | |||
1187 | |||
1188 | gboolean | ||
1189 | GNUNET_FS_GTK_progress_dialog_delete_event_cb (GtkWidget *widget, | ||
1190 | GdkEvent * event, | ||
1191 | void *cls) | ||
1192 | { | ||
1193 | /* Don't allow GTK to kill the window, until the scan is finished */ | ||
1194 | return GNUNET_NO; | ||
1195 | } | ||
1196 | |||
1197 | |||
1136 | void | 1198 | void |
1137 | GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy, | 1199 | GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy, |
1138 | struct MainPublishingDialogContext *ctx) | 1200 | struct MainPublishingDialogContext *ctx) |
@@ -1159,7 +1221,7 @@ GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy, | |||
1159 | ad = GTK_WIDGET (gtk_builder_get_object | 1221 | ad = GTK_WIDGET (gtk_builder_get_object |
1160 | (ctx->open_directory_builder, "GNUNET_GTK_publish_directory_dialog")); | 1222 | (ctx->open_directory_builder, "GNUNET_GTK_publish_directory_dialog")); |
1161 | 1223 | ||
1162 | ctx->open_directory_handler_id = g_signal_connect (G_OBJECT (ad), "response", G_CALLBACK (GNUNET_GTK_publish_directory_dialog_response_cb), ctx); | 1224 | ctx->open_directory_handler_id = g_signal_connect (G_OBJECT (ad), "response", G_CALLBACK (publish_directory_dialog_response_cb), ctx); |
1163 | 1225 | ||
1164 | anon_treemodel = GTK_TREE_MODEL (gtk_builder_get_object (ctx->main_window_builder, | 1226 | anon_treemodel = GTK_TREE_MODEL (gtk_builder_get_object (ctx->main_window_builder, |
1165 | "main_window_search_anonymity_liststore")); | 1227 | "main_window_search_anonymity_liststore")); |
@@ -1502,66 +1564,6 @@ GNUNET_GTK_master_publish_dialog_delete_event_cb (GtkWidget * widget, | |||
1502 | } | 1564 | } |
1503 | 1565 | ||
1504 | 1566 | ||
1505 | void | ||
1506 | GNUNET_GTK_publish_file_dialog_response_cb (GtkDialog * dialog, | ||
1507 | gint response_id, | ||
1508 | struct MainPublishingDialogContext *ctx) | ||
1509 | { | ||
1510 | char *filename; | ||
1511 | struct GNUNET_FS_BlockOptions bo; | ||
1512 | int do_index; | ||
1513 | GtkSpinButton *sb; | ||
1514 | GtkWidget *ad; | ||
1515 | |||
1516 | if (g_signal_handler_is_connected (G_OBJECT (dialog), ctx->open_file_handler_id)) | ||
1517 | g_signal_handler_disconnect (G_OBJECT (dialog), ctx->open_file_handler_id); | ||
1518 | ctx->open_file_handler_id = 0; | ||
1519 | |||
1520 | ad = GTK_WIDGET (gtk_builder_get_object | ||
1521 | (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog")); | ||
1522 | |||
1523 | if (response_id == -5) | ||
1524 | { | ||
1525 | /* OK */ | ||
1526 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object | ||
1527 | (ctx->open_file_builder, | ||
1528 | "GNUNET_GTK_publish_file_dialog_expiration_year_spin_button")); | ||
1529 | |||
1530 | if (!GNUNET_GTK_get_selected_anonymity_level | ||
1531 | (ctx->open_file_builder, "GNUNET_GTK_publish_file_dialog_anonymity_combobox", | ||
1532 | &bo.anonymity_level)) | ||
1533 | bo.anonymity_level = 1; | ||
1534 | bo.content_priority = | ||
1535 | gtk_spin_button_get_value (GTK_SPIN_BUTTON | ||
1536 | (gtk_builder_get_object | ||
1537 | (ctx->open_file_builder, | ||
1538 | "GNUNET_GTK_publish_file_dialog_priority_spin_button"))); | ||
1539 | bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); | ||
1540 | bo.replication_level = | ||
1541 | gtk_spin_button_get_value (GTK_SPIN_BUTTON | ||
1542 | (gtk_builder_get_object | ||
1543 | (ctx->open_file_builder, | ||
1544 | "GNUNET_GTK_publish_file_dialog_replication_spin_button"))); | ||
1545 | do_index = | ||
1546 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON | ||
1547 | (gtk_builder_get_object | ||
1548 | (ctx->open_file_builder, | ||
1549 | "GNUNET_GTK_publish_file_dialog_do_index_checkbutton"))); | ||
1550 | |||
1551 | filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (ad)); | ||
1552 | |||
1553 | scan_file_or_directory (ctx, filename, &bo, do_index); | ||
1554 | |||
1555 | g_free (filename); | ||
1556 | } | ||
1557 | else | ||
1558 | { | ||
1559 | /* Cancel/Escape/close/etc */ | ||
1560 | } | ||
1561 | gtk_widget_destroy (ad); | ||
1562 | } | ||
1563 | |||
1564 | |||
1565 | /** | 1567 | /** |
1566 | */ | 1568 | */ |
1567 | void | 1569 | void |