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 | 516 |
1 files changed, 324 insertions, 192 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 c4ad5117..72915041 100644 --- a/src/fs/gnunet-fs-gtk-main_window_file_publish.c +++ b/src/fs/gnunet-fs-gtk-main_window_file_publish.c | |||
@@ -26,16 +26,11 @@ | |||
26 | #include "gnunet-fs-gtk.h" | 26 | #include "gnunet-fs-gtk.h" |
27 | #include "gnunet-fs-gtk-edit_publish_dialog.h" | 27 | #include "gnunet-fs-gtk-edit_publish_dialog.h" |
28 | #include <gnunet/gnunet_util_lib.h> | 28 | #include <gnunet/gnunet_util_lib.h> |
29 | #include <gnunet/gnunet_fs_service.h> | ||
29 | 30 | ||
30 | #define MARKER_DIR_FILE_SIZE "-" | 31 | #define MARKER_DIR_FILE_SIZE "-" |
31 | 32 | ||
32 | /** | 33 | /** |
33 | * Builder used for the master publish dialog. | ||
34 | */ | ||
35 | static GtkBuilder *master_builder; | ||
36 | |||
37 | |||
38 | /** | ||
39 | * Check if two GtkTreeIters refer to the same element. | 34 | * Check if two GtkTreeIters refer to the same element. |
40 | * | 35 | * |
41 | * @param tm tree model of the iterators | 36 | * @param tm tree model of the iterators |
@@ -63,7 +58,7 @@ gtk_tree_iter_equals (GtkTreeModel * tm, GtkTreeIter * i1, GtkTreeIter * i2) | |||
63 | * Update selectivity in the master dialog. | 58 | * Update selectivity in the master dialog. |
64 | */ | 59 | */ |
65 | static void | 60 | static void |
66 | update_selectivity () | 61 | update_selectivity (gpointer data) |
67 | { | 62 | { |
68 | GtkTreeView *tv; | 63 | GtkTreeView *tv; |
69 | GtkTreeModel *tm; | 64 | GtkTreeModel *tm; |
@@ -83,12 +78,15 @@ update_selectivity () | |||
83 | struct GNUNET_FS_FileInformation *fip; | 78 | struct GNUNET_FS_FileInformation *fip; |
84 | int ns_ok; | 79 | int ns_ok; |
85 | gchar *namespace_id; | 80 | gchar *namespace_id; |
81 | GtkBuilder *builder; | ||
82 | |||
83 | builder = GTK_BUILDER (data); | ||
86 | 84 | ||
87 | tm = GTK_TREE_MODEL (gtk_builder_get_object | 85 | tm = GTK_TREE_MODEL (gtk_builder_get_object |
88 | (master_builder, | 86 | (builder, |
89 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | 87 | "GNUNET_GTK_file_sharing_publishing_tree_store")); |
90 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 88 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
91 | (master_builder, | 89 | (builder, |
92 | "GNUNET_GTK_master_publish_dialog_pseudonym_tree_view")); | 90 | "GNUNET_GTK_master_publish_dialog_pseudonym_tree_view")); |
93 | sel = gtk_tree_view_get_selection (tv); | 91 | sel = gtk_tree_view_get_selection (tv); |
94 | ns_ok = GNUNET_YES; | 92 | ns_ok = GNUNET_YES; |
@@ -102,34 +100,34 @@ update_selectivity () | |||
102 | } | 100 | } |
103 | up_button = | 101 | up_button = |
104 | GTK_WIDGET (gtk_builder_get_object | 102 | GTK_WIDGET (gtk_builder_get_object |
105 | (master_builder, | 103 | (builder, |
106 | "GNUNET_GTK_master_publish_dialog_up_button")); | 104 | "GNUNET_GTK_master_publish_dialog_up_button")); |
107 | down_button = | 105 | down_button = |
108 | GTK_WIDGET (gtk_builder_get_object | 106 | GTK_WIDGET (gtk_builder_get_object |
109 | (master_builder, | 107 | (builder, |
110 | "GNUNET_GTK_master_publish_dialog_down_button")); | 108 | "GNUNET_GTK_master_publish_dialog_down_button")); |
111 | left_button = | 109 | left_button = |
112 | GTK_WIDGET (gtk_builder_get_object | 110 | GTK_WIDGET (gtk_builder_get_object |
113 | (master_builder, | 111 | (builder, |
114 | "GNUNET_GTK_master_publish_dialog_left_button")); | 112 | "GNUNET_GTK_master_publish_dialog_left_button")); |
115 | right_button = | 113 | right_button = |
116 | GTK_WIDGET (gtk_builder_get_object | 114 | GTK_WIDGET (gtk_builder_get_object |
117 | (master_builder, | 115 | (builder, |
118 | "GNUNET_GTK_master_publish_dialog_right_button")); | 116 | "GNUNET_GTK_master_publish_dialog_right_button")); |
119 | delete_button = | 117 | delete_button = |
120 | GTK_WIDGET (gtk_builder_get_object | 118 | GTK_WIDGET (gtk_builder_get_object |
121 | (master_builder, | 119 | (builder, |
122 | "GNUNET_GTK_master_publish_dialog_delete_button")); | 120 | "GNUNET_GTK_master_publish_dialog_delete_button")); |
123 | edit_button = | 121 | edit_button = |
124 | GTK_WIDGET (gtk_builder_get_object | 122 | GTK_WIDGET (gtk_builder_get_object |
125 | (master_builder, | 123 | (builder, |
126 | "GNUNET_GTK_master_publish_dialog_edit_button")); | 124 | "GNUNET_GTK_master_publish_dialog_edit_button")); |
127 | execute_button = | 125 | execute_button = |
128 | GTK_WIDGET (gtk_builder_get_object | 126 | GTK_WIDGET (gtk_builder_get_object |
129 | (master_builder, | 127 | (builder, |
130 | "GNUNET_GTK_master_publish_dialog_execute_button")); | 128 | "GNUNET_GTK_master_publish_dialog_execute_button")); |
131 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 129 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
132 | (master_builder, | 130 | (builder, |
133 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 131 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
134 | sel = gtk_tree_view_get_selection (tv); | 132 | sel = gtk_tree_view_get_selection (tv); |
135 | tm = gtk_tree_view_get_model (tv); | 133 | tm = gtk_tree_view_get_model (tv); |
@@ -208,7 +206,7 @@ update_selectivity () | |||
208 | * @param iter parent entry, or NULL for top-level addition | 206 | * @param iter parent entry, or NULL for top-level addition |
209 | */ | 207 | */ |
210 | static void | 208 | static void |
211 | add_file_at_iter (const char *filename, const struct GNUNET_FS_BlockOptions *bo, | 209 | add_file_at_iter (gpointer data, const char *filename, const struct GNUNET_FS_BlockOptions *bo, |
212 | int do_index, GtkTreeIter * iter) | 210 | int do_index, GtkTreeIter * iter) |
213 | { | 211 | { |
214 | struct GNUNET_FS_FileInformation *fi; | 212 | struct GNUNET_FS_FileInformation *fi; |
@@ -223,6 +221,9 @@ add_file_at_iter (const char *filename, const struct GNUNET_FS_BlockOptions *bo, | |||
223 | char *file_size_fancy; | 221 | char *file_size_fancy; |
224 | const char *ss; | 222 | const char *ss; |
225 | struct stat sbuf; | 223 | struct stat sbuf; |
224 | GtkBuilder *builder; | ||
225 | |||
226 | builder = GTK_BUILDER (data); | ||
226 | 227 | ||
227 | if (0 != STAT (filename, &sbuf)) | 228 | if (0 != STAT (filename, &sbuf)) |
228 | return; | 229 | return; |
@@ -239,7 +240,7 @@ add_file_at_iter (const char *filename, const struct GNUNET_FS_BlockOptions *bo, | |||
239 | } | 240 | } |
240 | } | 241 | } |
241 | ts = GTK_TREE_STORE (gtk_builder_get_object | 242 | ts = GTK_TREE_STORE (gtk_builder_get_object |
242 | (master_builder, | 243 | (builder, |
243 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | 244 | "GNUNET_GTK_file_sharing_publishing_tree_store")); |
244 | 245 | ||
245 | meta = GNUNET_CONTAINER_meta_data_create (); | 246 | meta = GNUNET_CONTAINER_meta_data_create (); |
@@ -273,7 +274,7 @@ add_file_at_iter (const char *filename, const struct GNUNET_FS_BlockOptions *bo, | |||
273 | short_fn, 3, (guint) bo->anonymity_level, 4, | 274 | short_fn, 3, (guint) bo->anonymity_level, 4, |
274 | (guint) bo->content_priority, 5, fi, -1); | 275 | (guint) bo->content_priority, 5, fi, -1); |
275 | GNUNET_free (file_size_fancy); | 276 | GNUNET_free (file_size_fancy); |
276 | update_selectivity (); | 277 | update_selectivity (data); |
277 | } | 278 | } |
278 | 279 | ||
279 | 280 | ||
@@ -287,7 +288,7 @@ add_file_at_iter (const char *filename, const struct GNUNET_FS_BlockOptions *bo, | |||
287 | * @param pos iterator to set to the location of the new element | 288 | * @param pos iterator to set to the location of the new element |
288 | */ | 289 | */ |
289 | static void | 290 | static void |
290 | create_dir_at_iter (const char *name, const struct GNUNET_FS_BlockOptions *bo, | 291 | create_dir_at_iter (gpointer data, const char *name, const struct GNUNET_FS_BlockOptions *bo, |
291 | GtkTreeIter * iter, GtkTreeIter * pos) | 292 | GtkTreeIter * iter, GtkTreeIter * pos) |
292 | { | 293 | { |
293 | struct GNUNET_FS_FileInformation *fi; | 294 | struct GNUNET_FS_FileInformation *fi; |
@@ -295,9 +296,12 @@ create_dir_at_iter (const char *name, const struct GNUNET_FS_BlockOptions *bo, | |||
295 | GtkTreePath *path; | 296 | GtkTreePath *path; |
296 | struct GNUNET_CONTAINER_MetaData *meta; | 297 | struct GNUNET_CONTAINER_MetaData *meta; |
297 | GtkTreeStore *ts; | 298 | GtkTreeStore *ts; |
299 | GtkBuilder *builder; | ||
300 | |||
301 | builder = GTK_BUILDER (data); | ||
298 | 302 | ||
299 | ts = GTK_TREE_STORE (gtk_builder_get_object | 303 | ts = GTK_TREE_STORE (gtk_builder_get_object |
300 | (master_builder, | 304 | (builder, |
301 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | 305 | "GNUNET_GTK_file_sharing_publishing_tree_store")); |
302 | meta = GNUNET_CONTAINER_meta_data_create (); | 306 | meta = GNUNET_CONTAINER_meta_data_create (); |
303 | GNUNET_FS_meta_data_make_directory (meta); | 307 | GNUNET_FS_meta_data_make_directory (meta); |
@@ -315,7 +319,7 @@ create_dir_at_iter (const char *name, const struct GNUNET_FS_BlockOptions *bo, | |||
315 | gtk_tree_store_set (ts, pos, 0, MARKER_DIR_FILE_SIZE, 1, (gboolean) GNUNET_NO, | 319 | gtk_tree_store_set (ts, pos, 0, MARKER_DIR_FILE_SIZE, 1, (gboolean) GNUNET_NO, |
316 | 2, name, 3, (guint) bo->anonymity_level, 4, | 320 | 2, name, 3, (guint) bo->anonymity_level, 4, |
317 | (guint) bo->content_priority, 5, fi, -1); | 321 | (guint) bo->content_priority, 5, fi, -1); |
318 | update_selectivity (); | 322 | update_selectivity (data); |
319 | } | 323 | } |
320 | 324 | ||
321 | 325 | ||
@@ -797,11 +801,14 @@ scan_directory (void *cls, const char *filename) | |||
797 | * @param do_index should we index? | 801 | * @param do_index should we index? |
798 | */ | 802 | */ |
799 | static void | 803 | static void |
800 | add_dir (const char *filename, const struct GNUNET_FS_BlockOptions *bo, | 804 | add_dir (gpointer data, const char *filename, const struct GNUNET_FS_BlockOptions *bo, |
801 | int do_index) | 805 | int do_index) |
802 | { | 806 | { |
803 | struct stat sbuf; | 807 | struct stat sbuf; |
804 | struct AddDirContext scan_ctx; | 808 | struct AddDirContext scan_ctx; |
809 | GtkBuilder *builder; | ||
810 | |||
811 | builder = GTK_BUILDER (data); | ||
805 | 812 | ||
806 | if (0 != STAT (filename, &sbuf)) | 813 | if (0 != STAT (filename, &sbuf)) |
807 | return; | 814 | return; |
@@ -815,7 +822,7 @@ add_dir (const char *filename, const struct GNUNET_FS_BlockOptions *bo, | |||
815 | scan_ctx.do_index = do_index; | 822 | scan_ctx.do_index = do_index; |
816 | scan_ctx.ts = | 823 | scan_ctx.ts = |
817 | GTK_TREE_STORE (gtk_builder_get_object | 824 | GTK_TREE_STORE (gtk_builder_get_object |
818 | (master_builder, | 825 | (builder, |
819 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | 826 | "GNUNET_GTK_file_sharing_publishing_tree_store")); |
820 | scan_directory (&scan_ctx, filename); | 827 | scan_directory (&scan_ctx, filename); |
821 | } | 828 | } |
@@ -827,7 +834,7 @@ add_dir (const char *filename, const struct GNUNET_FS_BlockOptions *bo, | |||
827 | static void | 834 | static void |
828 | selection_changed_cb (GtkTreeSelection * ts, gpointer user_data) | 835 | selection_changed_cb (GtkTreeSelection * ts, gpointer user_data) |
829 | { | 836 | { |
830 | update_selectivity (); | 837 | update_selectivity (user_data); |
831 | } | 838 | } |
832 | 839 | ||
833 | 840 | ||
@@ -847,7 +854,7 @@ remove_old_entry (GtkTreeStore * ts, GtkTreeIter * root) | |||
847 | * Move an entry in the tree. | 854 | * Move an entry in the tree. |
848 | */ | 855 | */ |
849 | static void | 856 | static void |
850 | move_entry (GtkTreeModel * tm, GtkTreeIter * old, GtkTreeIter * newpos, | 857 | move_entry (gpointer data, GtkTreeModel * tm, GtkTreeIter * old, GtkTreeIter * newpos, |
851 | int dsel) | 858 | int dsel) |
852 | { | 859 | { |
853 | struct GNUNET_FS_FileInformation *fip; | 860 | struct GNUNET_FS_FileInformation *fip; |
@@ -863,6 +870,9 @@ move_entry (GtkTreeModel * tm, GtkTreeIter * old, GtkTreeIter * newpos, | |||
863 | GtkTreeIter cnewpos; | 870 | GtkTreeIter cnewpos; |
864 | GtkTreeRowReference *rr; | 871 | GtkTreeRowReference *rr; |
865 | GtkTreeRowReference *rr2; | 872 | GtkTreeRowReference *rr2; |
873 | GtkBuilder *builder; | ||
874 | |||
875 | builder = GTK_BUILDER (data); | ||
866 | 876 | ||
867 | gtk_tree_model_get (tm, old, 0, &fsf, 1, &do_index, 2, &short_fn, 3, | 877 | gtk_tree_model_get (tm, old, 0, &fsf, 1, &do_index, 2, &short_fn, 3, |
868 | &anonymity_level, 4, &priority, 5, &fip, -1); | 878 | &anonymity_level, 4, &priority, 5, &fip, -1); |
@@ -874,7 +884,7 @@ move_entry (GtkTreeModel * tm, GtkTreeIter * old, GtkTreeIter * newpos, | |||
874 | if (dsel == GNUNET_YES) | 884 | if (dsel == GNUNET_YES) |
875 | { | 885 | { |
876 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 886 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
877 | (master_builder, | 887 | (builder, |
878 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 888 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
879 | sel = gtk_tree_view_get_selection (tv); | 889 | sel = gtk_tree_view_get_selection (tv); |
880 | path = gtk_tree_model_get_path (tm, newpos); | 890 | path = gtk_tree_model_get_path (tm, newpos); |
@@ -894,7 +904,7 @@ move_entry (GtkTreeModel * tm, GtkTreeIter * old, GtkTreeIter * newpos, | |||
894 | gtk_tree_path_free (path); | 904 | gtk_tree_path_free (path); |
895 | gtk_tree_store_insert_before (GTK_TREE_STORE (tm), &cnewpos, newpos, | 905 | gtk_tree_store_insert_before (GTK_TREE_STORE (tm), &cnewpos, newpos, |
896 | NULL); | 906 | NULL); |
897 | move_entry (tm, &child, &cnewpos, GNUNET_NO); | 907 | move_entry (data, tm, &child, &cnewpos, GNUNET_NO); |
898 | path = gtk_tree_row_reference_get_path (rr2); | 908 | path = gtk_tree_row_reference_get_path (rr2); |
899 | gtk_tree_row_reference_free (rr2); | 909 | gtk_tree_row_reference_free (rr2); |
900 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &child, path)); | 910 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &child, path)); |
@@ -913,7 +923,7 @@ move_entry (GtkTreeModel * tm, GtkTreeIter * old, GtkTreeIter * newpos, | |||
913 | gtk_tree_path_free (path); | 923 | gtk_tree_path_free (path); |
914 | gtk_tree_selection_select_iter (sel, newpos); | 924 | gtk_tree_selection_select_iter (sel, newpos); |
915 | } | 925 | } |
916 | update_selectivity (); | 926 | update_selectivity (data); |
917 | } | 927 | } |
918 | 928 | ||
919 | /** | 929 | /** |
@@ -926,9 +936,12 @@ void GNUNET_GTK_master_publish_dialog_pseudonym_updates_renderer_edited_cb | |||
926 | { | 936 | { |
927 | GtkTreeIter iter; | 937 | GtkTreeIter iter; |
928 | GtkTreeStore *ts; | 938 | GtkTreeStore *ts; |
939 | GtkBuilder *builder; | ||
940 | |||
941 | builder = GTK_BUILDER (user_data); | ||
929 | 942 | ||
930 | ts = GTK_TREE_STORE (gtk_builder_get_object | 943 | ts = GTK_TREE_STORE (gtk_builder_get_object |
931 | (master_builder, "GNUNET_GTK_pseudonym_tree_store")); | 944 | (builder, "GNUNET_GTK_pseudonym_tree_store")); |
932 | 945 | ||
933 | if (TRUE != | 946 | if (TRUE != |
934 | gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ts), &iter, cpath)) | 947 | gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ts), &iter, cpath)) |
@@ -937,7 +950,7 @@ void GNUNET_GTK_master_publish_dialog_pseudonym_updates_renderer_edited_cb | |||
937 | return; | 950 | return; |
938 | } | 951 | } |
939 | gtk_tree_store_set (ts, &iter, 5, new_text, -1); | 952 | gtk_tree_store_set (ts, &iter, 5, new_text, -1); |
940 | update_selectivity (); | 953 | update_selectivity (user_data); |
941 | } | 954 | } |
942 | 955 | ||
943 | 956 | ||
@@ -951,9 +964,12 @@ void GNUNET_GTK_master_publish_dialog_pseudonym_identifier_renderer_edited_cb | |||
951 | { | 964 | { |
952 | GtkTreeIter iter; | 965 | GtkTreeIter iter; |
953 | GtkTreeStore *ts; | 966 | GtkTreeStore *ts; |
967 | GtkBuilder *builder; | ||
968 | |||
969 | builder = GTK_BUILDER (user_data); | ||
954 | 970 | ||
955 | ts = GTK_TREE_STORE (gtk_builder_get_object | 971 | ts = GTK_TREE_STORE (gtk_builder_get_object |
956 | (master_builder, "GNUNET_GTK_pseudonym_tree_store")); | 972 | (builder, "GNUNET_GTK_pseudonym_tree_store")); |
957 | 973 | ||
958 | if (TRUE != | 974 | if (TRUE != |
959 | gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ts), &iter, cpath)) | 975 | gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ts), &iter, cpath)) |
@@ -962,7 +978,7 @@ void GNUNET_GTK_master_publish_dialog_pseudonym_identifier_renderer_edited_cb | |||
962 | return; | 978 | return; |
963 | } | 979 | } |
964 | gtk_tree_store_set (ts, &iter, 2, new_text, -1); | 980 | gtk_tree_store_set (ts, &iter, 2, new_text, -1); |
965 | update_selectivity (); | 981 | update_selectivity (user_data); |
966 | } | 982 | } |
967 | 983 | ||
968 | 984 | ||
@@ -978,9 +994,12 @@ GNUNET_GTK_master_publish_dialog_right_button_clicked_cb (GtkWidget * dummy, | |||
978 | GtkTreeIter pred; | 994 | GtkTreeIter pred; |
979 | GtkTreeIter prev; | 995 | GtkTreeIter prev; |
980 | GtkTreeIter pos; | 996 | GtkTreeIter pos; |
997 | GtkBuilder *builder; | ||
998 | |||
999 | builder = GTK_BUILDER (data); | ||
981 | 1000 | ||
982 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 1001 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
983 | (master_builder, | 1002 | (builder, |
984 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1003 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
985 | sel = gtk_tree_view_get_selection (tv); | 1004 | sel = gtk_tree_view_get_selection (tv); |
986 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) | 1005 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
@@ -1010,7 +1029,7 @@ GNUNET_GTK_master_publish_dialog_right_button_clicked_cb (GtkWidget * dummy, | |||
1010 | GNUNET_break (0); | 1029 | GNUNET_break (0); |
1011 | return; | 1030 | return; |
1012 | } | 1031 | } |
1013 | move_entry (tm, &iter, &pos, GNUNET_YES); | 1032 | move_entry (data, tm, &iter, &pos, GNUNET_YES); |
1014 | remove_old_entry (GTK_TREE_STORE (tm), &iter); | 1033 | remove_old_entry (GTK_TREE_STORE (tm), &iter); |
1015 | } | 1034 | } |
1016 | 1035 | ||
@@ -1025,9 +1044,12 @@ GNUNET_GTK_master_publish_dialog_left_button_clicked_cb (GtkWidget * dummy, | |||
1025 | GtkTreeIter iter; | 1044 | GtkTreeIter iter; |
1026 | GtkTreeIter parent; | 1045 | GtkTreeIter parent; |
1027 | GtkTreeIter pos; | 1046 | GtkTreeIter pos; |
1047 | GtkBuilder *builder; | ||
1048 | |||
1049 | builder = GTK_BUILDER (data); | ||
1028 | 1050 | ||
1029 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 1051 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1030 | (master_builder, | 1052 | (builder, |
1031 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1053 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
1032 | sel = gtk_tree_view_get_selection (tv); | 1054 | sel = gtk_tree_view_get_selection (tv); |
1033 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) | 1055 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
@@ -1046,7 +1068,7 @@ GNUNET_GTK_master_publish_dialog_left_button_clicked_cb (GtkWidget * dummy, | |||
1046 | GNUNET_break (0); | 1068 | GNUNET_break (0); |
1047 | return; | 1069 | return; |
1048 | } | 1070 | } |
1049 | move_entry (tm, &iter, &pos, GNUNET_YES); | 1071 | move_entry (data, tm, &iter, &pos, GNUNET_YES); |
1050 | remove_old_entry (GTK_TREE_STORE (tm), &iter); | 1072 | remove_old_entry (GTK_TREE_STORE (tm), &iter); |
1051 | } | 1073 | } |
1052 | 1074 | ||
@@ -1064,9 +1086,12 @@ GNUNET_GTK_master_publish_dialog_up_button_clicked_cb (GtkWidget * dummy, | |||
1064 | GtkTreeIter prev; | 1086 | GtkTreeIter prev; |
1065 | GtkTreeIter *pprev; | 1087 | GtkTreeIter *pprev; |
1066 | GtkTreeIter pos; | 1088 | GtkTreeIter pos; |
1089 | GtkBuilder *builder; | ||
1090 | |||
1091 | builder = GTK_BUILDER (data); | ||
1067 | 1092 | ||
1068 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 1093 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1069 | (master_builder, | 1094 | (builder, |
1070 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1095 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
1071 | sel = gtk_tree_view_get_selection (tv); | 1096 | sel = gtk_tree_view_get_selection (tv); |
1072 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) | 1097 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
@@ -1101,7 +1126,7 @@ GNUNET_GTK_master_publish_dialog_up_button_clicked_cb (GtkWidget * dummy, | |||
1101 | GNUNET_break (0); | 1126 | GNUNET_break (0); |
1102 | return; | 1127 | return; |
1103 | } | 1128 | } |
1104 | move_entry (tm, &iter, &pos, GNUNET_YES); | 1129 | move_entry (data, tm, &iter, &pos, GNUNET_YES); |
1105 | remove_old_entry (GTK_TREE_STORE (tm), &iter); | 1130 | remove_old_entry (GTK_TREE_STORE (tm), &iter); |
1106 | } | 1131 | } |
1107 | 1132 | ||
@@ -1116,9 +1141,12 @@ GNUNET_GTK_master_publish_dialog_down_button_clicked_cb (GtkWidget * dummy, | |||
1116 | GtkTreeIter iter; | 1141 | GtkTreeIter iter; |
1117 | GtkTreeIter next; | 1142 | GtkTreeIter next; |
1118 | GtkTreeIter pos; | 1143 | GtkTreeIter pos; |
1144 | GtkBuilder *builder; | ||
1145 | |||
1146 | builder = GTK_BUILDER (data); | ||
1119 | 1147 | ||
1120 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 1148 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1121 | (master_builder, | 1149 | (builder, |
1122 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1150 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
1123 | sel = gtk_tree_view_get_selection (tv); | 1151 | sel = gtk_tree_view_get_selection (tv); |
1124 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) | 1152 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
@@ -1138,7 +1166,7 @@ GNUNET_GTK_master_publish_dialog_down_button_clicked_cb (GtkWidget * dummy, | |||
1138 | GNUNET_break (0); | 1166 | GNUNET_break (0); |
1139 | return; | 1167 | return; |
1140 | } | 1168 | } |
1141 | move_entry (tm, &iter, &pos, GNUNET_YES); | 1169 | move_entry (data, tm, &iter, &pos, GNUNET_YES); |
1142 | remove_old_entry (GTK_TREE_STORE (tm), &iter); | 1170 | remove_old_entry (GTK_TREE_STORE (tm), &iter); |
1143 | } | 1171 | } |
1144 | 1172 | ||
@@ -1152,9 +1180,12 @@ GNUNET_GTK_master_publish_dialog_new_button_clicked_cb (GtkWidget * dummy, | |||
1152 | GtkTreeIter iter; | 1180 | GtkTreeIter iter; |
1153 | GtkTreeIter pos; | 1181 | GtkTreeIter pos; |
1154 | struct GNUNET_FS_BlockOptions bo; | 1182 | struct GNUNET_FS_BlockOptions bo; |
1183 | GtkBuilder *builder; | ||
1184 | |||
1185 | builder = GTK_BUILDER (data); | ||
1155 | 1186 | ||
1156 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 1187 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1157 | (master_builder, | 1188 | (builder, |
1158 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1189 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
1159 | sel = gtk_tree_view_get_selection (tv); | 1190 | sel = gtk_tree_view_get_selection (tv); |
1160 | /* FIXME: consider opening a dialog to get | 1191 | /* FIXME: consider opening a dialog to get |
@@ -1169,10 +1200,10 @@ GNUNET_GTK_master_publish_dialog_new_button_clicked_cb (GtkWidget * dummy, | |||
1169 | bo.replication_level = 1; | 1200 | bo.replication_level = 1; |
1170 | if (TRUE != gtk_tree_selection_get_selected (sel, NULL, &iter)) | 1201 | if (TRUE != gtk_tree_selection_get_selected (sel, NULL, &iter)) |
1171 | { | 1202 | { |
1172 | create_dir_at_iter ("unnamed/", &bo, NULL, &pos); | 1203 | create_dir_at_iter (data, "unnamed/", &bo, NULL, &pos); |
1173 | return; | 1204 | return; |
1174 | } | 1205 | } |
1175 | create_dir_at_iter ("unnamed/", &bo, &iter, &pos); | 1206 | create_dir_at_iter (data, "unnamed/", &bo, &iter, &pos); |
1176 | } | 1207 | } |
1177 | 1208 | ||
1178 | 1209 | ||
@@ -1182,55 +1213,49 @@ GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy, | |||
1182 | { | 1213 | { |
1183 | GtkWidget *ad; | 1214 | GtkWidget *ad; |
1184 | GtkBuilder *builder; | 1215 | GtkBuilder *builder; |
1185 | char *filename; | 1216 | GtkWindow *master_pubdialog; |
1186 | struct GNUNET_FS_BlockOptions bo; | 1217 | |
1187 | int do_index; | 1218 | builder = GTK_BUILDER (data); |
1188 | GtkSpinButton *sb; | ||
1189 | 1219 | ||
1190 | builder = | ||
1191 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_file_dialog.glade"); | ||
1192 | if (builder == NULL) | ||
1193 | { | ||
1194 | GNUNET_break (0); | ||
1195 | return; | ||
1196 | } | ||
1197 | ad = GTK_WIDGET (gtk_builder_get_object | 1220 | ad = GTK_WIDGET (gtk_builder_get_object |
1198 | (builder, "GNUNET_GTK_publish_file_dialog")); | 1221 | (builder, "GNUNET_GTK_publish_file_dialog")); |
1199 | GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); | 1222 | GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); |
1200 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | 1223 | |
1201 | { | 1224 | master_pubdialog = GTK_WINDOW (gtk_builder_get_object (builder, |
1202 | gtk_widget_destroy (ad); | 1225 | "GNUNET_GTK_master_publish_dialog")); |
1203 | g_object_unref (G_OBJECT (builder)); | 1226 | gtk_window_set_transient_for (GTK_WINDOW (ad), master_pubdialog); |
1204 | return; | 1227 | |
1205 | } | 1228 | gtk_window_present (GTK_WINDOW (ad)); |
1206 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad)); | ||
1207 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object | ||
1208 | (builder, | ||
1209 | "GNUNET_GTK_publish_file_dialog_expiration_year_spin_button")); | ||
1210 | bo.anonymity_level = | ||
1211 | gtk_spin_button_get_value (GTK_SPIN_BUTTON | ||
1212 | (gtk_builder_get_object | ||
1213 | (builder, | ||
1214 | "GNUNET_GTK_publish_file_dialog_anonymity_spin_button"))); | ||
1215 | bo.content_priority = | ||
1216 | gtk_spin_button_get_value (GTK_SPIN_BUTTON | ||
1217 | (gtk_builder_get_object | ||
1218 | (builder, | ||
1219 | "GNUNET_GTK_publish_file_dialog_priority_spin_button"))); | ||
1220 | bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); | ||
1221 | bo.replication_level = 1; /* FIXME... */ | ||
1222 | do_index = | ||
1223 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON | ||
1224 | (gtk_builder_get_object | ||
1225 | (builder, | ||
1226 | "GNUNET_GTK_publish_file_dialog_do_index_checkbutton"))); | ||
1227 | add_file_at_iter (filename, &bo, do_index, NULL); | ||
1228 | gtk_widget_destroy (ad); | ||
1229 | g_object_unref (G_OBJECT (builder)); | ||
1230 | g_free (filename); | ||
1231 | update_selectivity (); | ||
1232 | } | 1229 | } |
1233 | 1230 | ||
1231 | struct edit_pub_cb_args | ||
1232 | { | ||
1233 | GtkTreeModel *tm; | ||
1234 | GtkTreeIter iter; | ||
1235 | /* FIXME: this indirection madness is not really required any longer. | ||
1236 | * we only need to pass over *tm and iter, everything else can be | ||
1237 | * copied. | ||
1238 | */ | ||
1239 | gchar *short_fn; | ||
1240 | struct GNUNET_FS_FileInformation *fip; | ||
1241 | int do_index; | ||
1242 | guint anonymity_level; | ||
1243 | guint priority; | ||
1244 | }; | ||
1245 | |||
1246 | void | ||
1247 | master_publish_edit_publish_dialog_cb (gpointer cls, int *do_index, char **short_fn, | ||
1248 | guint * anonymity_level, guint * priority, gchar *root, | ||
1249 | struct GNUNET_FS_FileInformation *fip, gint ret) | ||
1250 | { | ||
1251 | struct edit_pub_cb_args *cbargs = (struct edit_pub_cb_args *) cls; | ||
1252 | if (ret == GTK_RESPONSE_OK) | ||
1253 | gtk_tree_store_set (GTK_TREE_STORE (cbargs->tm), &cbargs->iter, | ||
1254 | 1, *do_index, 2, *short_fn, 3, *anonymity_level, 4, *priority, -1); | ||
1255 | g_free (root); | ||
1256 | g_free (short_fn); | ||
1257 | g_free (cbargs); | ||
1258 | } | ||
1234 | 1259 | ||
1235 | void | 1260 | void |
1236 | GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, | 1261 | GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, |
@@ -1239,29 +1264,36 @@ GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, | |||
1239 | GtkTreeView *tv; | 1264 | GtkTreeView *tv; |
1240 | GtkTreeModel *tm; | 1265 | GtkTreeModel *tm; |
1241 | GtkTreeSelection *sel; | 1266 | GtkTreeSelection *sel; |
1242 | GtkTreeIter iter; | 1267 | struct edit_pub_cb_args *cbargs; |
1243 | int do_index; | 1268 | GtkBuilder *builder; |
1244 | guint anonymity_level; | 1269 | GtkWindow *master_pubdialog; |
1245 | guint priority; | 1270 | |
1246 | gchar *short_fn; | 1271 | builder = GTK_BUILDER (data); |
1247 | struct GNUNET_FS_FileInformation *fip; | ||
1248 | 1272 | ||
1249 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 1273 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1250 | (master_builder, | 1274 | (builder, |
1251 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1275 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
1276 | |||
1277 | cbargs = g_new0 (struct edit_pub_cb_args, 1); | ||
1278 | cbargs->tm = gtk_tree_view_get_model (tv); | ||
1279 | |||
1280 | master_pubdialog = GTK_WINDOW (gtk_builder_get_object (builder, | ||
1281 | "GNUNET_GTK_master_publish_dialog")); | ||
1252 | sel = gtk_tree_view_get_selection (tv); | 1282 | sel = gtk_tree_view_get_selection (tv); |
1253 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) | 1283 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &cbargs->iter)) |
1254 | { | 1284 | { |
1255 | GNUNET_break (0); | 1285 | GNUNET_break (0); |
1286 | g_free (cbargs); | ||
1256 | return; | 1287 | return; |
1257 | } | 1288 | } |
1258 | gtk_tree_model_get (tm, &iter, 1, &do_index, 2, &short_fn, 3, | 1289 | |
1259 | &anonymity_level, 4, &priority, 5, &fip, -1); | 1290 | gtk_tree_model_get (tm, &cbargs->iter, 1, &cbargs->do_index, 2, |
1260 | GNUNET_FS_GTK_edit_publish_dialog (&do_index, &short_fn, &anonymity_level, | 1291 | &cbargs->short_fn, 3, &cbargs->anonymity_level, 4, &cbargs->priority, |
1261 | &priority, fip); | 1292 | 5, &cbargs->fip, -1); |
1262 | gtk_tree_store_set (GTK_TREE_STORE (tm), &iter, 1, do_index, 2, short_fn, 3, | 1293 | |
1263 | anonymity_level, 4, priority, -1); | 1294 | GNUNET_FS_GTK_edit_publish_dialog (builder, master_pubdialog, &cbargs->do_index, |
1264 | g_free (short_fn); | 1295 | &cbargs->short_fn, &cbargs->anonymity_level, &cbargs->priority, |
1296 | cbargs->fip, TRUE, &master_publish_edit_publish_dialog_cb, cbargs); | ||
1265 | } | 1297 | } |
1266 | 1298 | ||
1267 | 1299 | ||
@@ -1298,9 +1330,12 @@ GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy, | |||
1298 | GtkTreeSelection *sel; | 1330 | GtkTreeSelection *sel; |
1299 | GtkTreeIter iter; | 1331 | GtkTreeIter iter; |
1300 | struct GNUNET_FS_FileInformation *fip; | 1332 | struct GNUNET_FS_FileInformation *fip; |
1333 | GtkBuilder *builder; | ||
1334 | |||
1335 | builder = GTK_BUILDER (data); | ||
1301 | 1336 | ||
1302 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 1337 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1303 | (master_builder, | 1338 | (builder, |
1304 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1339 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
1305 | sel = gtk_tree_view_get_selection (tv); | 1340 | sel = gtk_tree_view_get_selection (tv); |
1306 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) | 1341 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &iter)) |
@@ -1311,65 +1346,69 @@ GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy, | |||
1311 | gtk_tree_model_get (tm, &iter, 5, &fip, -1); | 1346 | gtk_tree_model_get (tm, &iter, 5, &fip, -1); |
1312 | GNUNET_FS_file_information_destroy (fip, &free_fi_row_reference, NULL); | 1347 | GNUNET_FS_file_information_destroy (fip, &free_fi_row_reference, NULL); |
1313 | gtk_tree_store_remove (GTK_TREE_STORE (tm), &iter); | 1348 | gtk_tree_store_remove (GTK_TREE_STORE (tm), &iter); |
1314 | update_selectivity (); | 1349 | update_selectivity (data); |
1315 | } | 1350 | } |
1316 | 1351 | ||
1317 | |||
1318 | void | 1352 | void |
1319 | GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy, | 1353 | GNUNET_GTK_publish_directory_dialog_response_cb (GtkDialog *dialog, |
1320 | gpointer data) | 1354 | gint response_id, gpointer user_data) |
1321 | { | 1355 | { |
1322 | GtkWidget *ad; | ||
1323 | GtkBuilder *builder; | ||
1324 | char *filename; | 1356 | char *filename; |
1325 | int do_index; | 1357 | int do_index; |
1326 | GtkSpinButton *sb; | 1358 | GtkSpinButton *sb; |
1327 | struct GNUNET_FS_BlockOptions bo; | 1359 | struct GNUNET_FS_BlockOptions bo; |
1360 | GtkWidget *ad; | ||
1361 | GtkBuilder *builder; | ||
1362 | |||
1363 | builder = GTK_BUILDER (user_data); | ||
1328 | 1364 | ||
1329 | builder = | 1365 | ad = GTK_WIDGET (gtk_builder_get_object (builder, |
1330 | GNUNET_GTK_get_new_builder | 1366 | "GNUNET_GTK_publish_directory_dialog")); |
1331 | ("gnunet_fs_gtk_publish_directory_dialog.glade"); | 1367 | |
1332 | if (builder == NULL) | 1368 | if (response_id == -5) |
1333 | { | 1369 | { |
1334 | GNUNET_break (0); | 1370 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad)); |
1335 | return; | 1371 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, |
1372 | "GNUNET_GTK_publish_directory_dialog_expiration_year_spin_button")); | ||
1373 | if (!GNUNET_GTK_get_selected_anonymity_level (builder, | ||
1374 | "GNUNET_GTK_publish_directory_dialog_anonymity_combobox", | ||
1375 | &bo.anonymity_level)) | ||
1376 | bo.anonymity_level = 1; | ||
1377 | bo.content_priority = gtk_spin_button_get_value (GTK_SPIN_BUTTON ( | ||
1378 | gtk_builder_get_object (builder, | ||
1379 | "GNUNET_GTK_publish_directory_dialog_priority_spin_button"))); | ||
1380 | bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); | ||
1381 | do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ( | ||
1382 | gtk_builder_get_object (builder, | ||
1383 | "GNUNET_GTK_publish_directory_dialog_do_index_checkbutton"))); | ||
1384 | |||
1385 | /* FIXME: open progress dialog here... */ | ||
1386 | add_dir (user_data, filename, &bo, do_index); | ||
1387 | g_free (filename); | ||
1388 | update_selectivity (user_data); | ||
1336 | } | 1389 | } |
1390 | gtk_widget_hide (ad); | ||
1391 | } | ||
1392 | |||
1393 | |||
1394 | void | ||
1395 | GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy, | ||
1396 | gpointer data) | ||
1397 | { | ||
1398 | GtkWidget *ad; | ||
1399 | GtkBuilder *builder; | ||
1400 | GtkWindow *master_pubdialog; | ||
1401 | |||
1402 | builder = GTK_BUILDER (data); | ||
1337 | GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); | 1403 | GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); |
1338 | ad = GTK_WIDGET (gtk_builder_get_object | 1404 | ad = GTK_WIDGET (gtk_builder_get_object |
1339 | (builder, "GNUNET_GTK_publish_directory_dialog")); | 1405 | (builder, "GNUNET_GTK_publish_directory_dialog")); |
1340 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | 1406 | |
1341 | { | 1407 | master_pubdialog = GTK_WINDOW (gtk_builder_get_object (builder, |
1342 | gtk_widget_destroy (ad); | 1408 | "GNUNET_GTK_master_publish_dialog")); |
1343 | g_object_unref (G_OBJECT (builder)); | 1409 | gtk_window_set_transient_for (GTK_WINDOW (ad), master_pubdialog); |
1344 | return; | 1410 | |
1345 | } | 1411 | gtk_window_present (GTK_WINDOW (ad)); |
1346 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad)); | ||
1347 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object | ||
1348 | (builder, | ||
1349 | "GNUNET_GTK_publish_directory_dialog_expiration_year_spin_button")); | ||
1350 | bo.anonymity_level = | ||
1351 | gtk_spin_button_get_value (GTK_SPIN_BUTTON | ||
1352 | (gtk_builder_get_object | ||
1353 | (builder, | ||
1354 | "GNUNET_GTK_publish_directory_dialog_anonymity_spin_button"))); | ||
1355 | bo.content_priority = | ||
1356 | gtk_spin_button_get_value (GTK_SPIN_BUTTON | ||
1357 | (gtk_builder_get_object | ||
1358 | (builder, | ||
1359 | "GNUNET_GTK_publish_directory_dialog_priority_spin_button"))); | ||
1360 | bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); | ||
1361 | do_index = | ||
1362 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON | ||
1363 | (gtk_builder_get_object | ||
1364 | (builder, | ||
1365 | "GNUNET_GTK_publish_directory_dialog_do_index_checkbutton"))); | ||
1366 | |||
1367 | gtk_widget_destroy (ad); | ||
1368 | g_object_unref (G_OBJECT (builder)); | ||
1369 | /* FIXME: open progress dialog here... */ | ||
1370 | add_dir (filename, &bo, do_index); | ||
1371 | g_free (filename); | ||
1372 | update_selectivity (); | ||
1373 | } | 1412 | } |
1374 | 1413 | ||
1375 | 1414 | ||
@@ -1598,52 +1637,58 @@ free_file_information_tree_store (GtkTreeModel * tm, GtkTreeIter * iter) | |||
1598 | } | 1637 | } |
1599 | } | 1638 | } |
1600 | 1639 | ||
1601 | |||
1602 | /** | ||
1603 | */ | ||
1604 | void | 1640 | void |
1605 | GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, gpointer data) | 1641 | GNUNET_GTK_master_publish_dialog_realize_cb (GtkWidget *widget, |
1642 | gpointer user_data) | ||
1606 | { | 1643 | { |
1607 | GtkWidget *ad; | ||
1608 | GtkTreeStore *ts; | ||
1609 | gint ret; | ||
1610 | GtkTreeView *tv; | 1644 | GtkTreeView *tv; |
1611 | GtkTreeSelection *sel; | 1645 | GtkTreeSelection *sel; |
1612 | GtkTreeIter iter; | 1646 | GtkBuilder *builder; |
1613 | struct GNUNET_FS_FileInformation *fi; | 1647 | |
1614 | GtkTreeModel *tm; | 1648 | builder = GTK_BUILDER (user_data); |
1615 | GtkTreeModel *ptm; | ||
1616 | struct GNUNET_FS_Namespace *namespace; | ||
1617 | gchar *namespace_id; | ||
1618 | gchar *namespace_uid; | ||
1619 | 1649 | ||
1620 | GNUNET_assert (master_builder == NULL); | ||
1621 | master_builder = | ||
1622 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_dialog.glade"); | ||
1623 | if (master_builder == NULL) | ||
1624 | return; | ||
1625 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 1650 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1626 | (master_builder, | 1651 | (builder, |
1627 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1652 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
1628 | sel = gtk_tree_view_get_selection (tv); | 1653 | sel = gtk_tree_view_get_selection (tv); |
1629 | g_signal_connect (G_OBJECT (sel), "changed", | 1654 | g_signal_connect (G_OBJECT (sel), "changed", |
1630 | G_CALLBACK (selection_changed_cb), NULL); | 1655 | G_CALLBACK (selection_changed_cb), user_data); |
1631 | ad = GTK_WIDGET (gtk_builder_get_object | ||
1632 | (master_builder, "GNUNET_GTK_master_publish_dialog")); | ||
1633 | ts = GTK_TREE_STORE (gtk_builder_get_object | ||
1634 | (master_builder, "GNUNET_GTK_pseudonym_tree_store")); | ||
1635 | GNUNET_FS_namespace_list (GNUNET_FS_GTK_get_fs_handle (), | ||
1636 | &add_namespace_to_ts, ts); | ||
1637 | tm = GTK_TREE_MODEL (gtk_builder_get_object | ||
1638 | (master_builder, | ||
1639 | "GNUNET_GTK_file_sharing_publishing_tree_store")); | ||
1640 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 1656 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1641 | (master_builder, | 1657 | (builder, |
1642 | "GNUNET_GTK_master_publish_dialog_pseudonym_tree_view")); | 1658 | "GNUNET_GTK_master_publish_dialog_pseudonym_tree_view")); |
1643 | sel = gtk_tree_view_get_selection (tv); | 1659 | sel = gtk_tree_view_get_selection (tv); |
1644 | g_signal_connect (G_OBJECT (sel), "changed", | 1660 | g_signal_connect (G_OBJECT (sel), "changed", |
1645 | G_CALLBACK (selection_changed_cb), NULL); | 1661 | G_CALLBACK (selection_changed_cb), user_data); |
1646 | ret = gtk_dialog_run (GTK_DIALOG (ad)); | 1662 | } |
1663 | |||
1664 | void | ||
1665 | hide_master_publish_dialog (gpointer user_data, gint ret) | ||
1666 | { | ||
1667 | GtkTreeView *tv, *ptv; | ||
1668 | GtkTreeSelection *sel; | ||
1669 | GtkTreeModel *tm, *ptm; | ||
1670 | GtkTreeIter iter; | ||
1671 | gpointer namespace; | ||
1672 | gchar *namespace_id; | ||
1673 | gchar *namespace_uid; | ||
1674 | struct GNUNET_FS_FileInformation *fi; | ||
1675 | GtkWidget *ad; | ||
1676 | GtkBuilder *builder = GTK_BUILDER (user_data); | ||
1677 | |||
1678 | ad = GTK_WIDGET (gtk_builder_get_object | ||
1679 | (builder, "GNUNET_GTK_master_publish_dialog")); | ||
1680 | |||
1681 | ptv = GTK_TREE_VIEW (gtk_builder_get_object | ||
1682 | (builder, | ||
1683 | "GNUNET_GTK_master_publish_dialog_pseudonym_tree_view")); | ||
1684 | sel = gtk_tree_view_get_selection (ptv); | ||
1685 | ptm = gtk_tree_view_get_model (ptv); | ||
1686 | |||
1687 | tv = GTK_TREE_VIEW (gtk_builder_get_object | ||
1688 | (builder, | ||
1689 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | ||
1690 | tm = gtk_tree_view_get_model (tv); | ||
1691 | |||
1647 | if (ret == GTK_RESPONSE_OK) | 1692 | if (ret == GTK_RESPONSE_OK) |
1648 | { | 1693 | { |
1649 | if (TRUE == gtk_tree_selection_get_selected (sel, &ptm, &iter)) | 1694 | if (TRUE == gtk_tree_selection_get_selected (sel, &ptm, &iter)) |
@@ -1666,14 +1711,10 @@ GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, gpointer data) | |||
1666 | GNUNET_FS_PUBLISH_OPTION_NONE); | 1711 | GNUNET_FS_PUBLISH_OPTION_NONE); |
1667 | } | 1712 | } |
1668 | while (gtk_tree_model_iter_next (tm, &iter)); | 1713 | while (gtk_tree_model_iter_next (tm, &iter)); |
1669 | if (namespace_id != NULL) | 1714 | g_free (namespace_id); |
1670 | g_free (namespace_id); | 1715 | g_free (namespace_uid); |
1671 | if (namespace_uid != NULL) | ||
1672 | g_free (namespace_uid); | ||
1673 | } | 1716 | } |
1674 | ptm = | 1717 | |
1675 | GTK_TREE_MODEL (gtk_builder_get_object | ||
1676 | (master_builder, "GNUNET_GTK_pseudonym_tree_store")); | ||
1677 | /* free state from 'ptm' */ | 1718 | /* free state from 'ptm' */ |
1678 | if (TRUE == gtk_tree_model_get_iter_first (ptm, &iter)) | 1719 | if (TRUE == gtk_tree_model_get_iter_first (ptm, &iter)) |
1679 | do | 1720 | do |
@@ -1681,6 +1722,7 @@ GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, gpointer data) | |||
1681 | free_pseudonym_tree_store (ptm, &iter); | 1722 | free_pseudonym_tree_store (ptm, &iter); |
1682 | } | 1723 | } |
1683 | while (TRUE == gtk_tree_model_iter_next (ptm, &iter)); | 1724 | while (TRUE == gtk_tree_model_iter_next (ptm, &iter)); |
1725 | gtk_tree_store_clear (GTK_TREE_STORE (ptm)); | ||
1684 | 1726 | ||
1685 | /* free state from 'tm' */ | 1727 | /* free state from 'tm' */ |
1686 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) | 1728 | if (TRUE == gtk_tree_model_get_iter_first (tm, &iter)) |
@@ -1689,10 +1731,100 @@ GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, gpointer data) | |||
1689 | free_file_information_tree_store (tm, &iter); | 1731 | free_file_information_tree_store (tm, &iter); |
1690 | } | 1732 | } |
1691 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | 1733 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); |
1734 | gtk_tree_store_clear (GTK_TREE_STORE (tm)); | ||
1735 | |||
1736 | gtk_widget_hide (ad); | ||
1737 | } | ||
1738 | |||
1739 | void | ||
1740 | GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb (GtkButton *button, | ||
1741 | gpointer user_data) | ||
1742 | { | ||
1743 | hide_master_publish_dialog (user_data, GTK_RESPONSE_OK); | ||
1744 | } | ||
1745 | |||
1746 | void | ||
1747 | GNUNET_GTK_master_publish_dialog_cancel_button_clicked_cb (GtkButton *button, | ||
1748 | gpointer user_data) | ||
1749 | { | ||
1750 | hide_master_publish_dialog (user_data, GTK_RESPONSE_CANCEL); | ||
1751 | } | ||
1752 | |||
1753 | gboolean | ||
1754 | GNUNET_GTK_master_publish_dialog_delete_event_cb (GtkWidget *widget, | ||
1755 | GdkEvent *event, gpointer user_data) | ||
1756 | { | ||
1757 | hide_master_publish_dialog (user_data, GTK_RESPONSE_CANCEL); | ||
1758 | return TRUE; | ||
1759 | } | ||
1760 | |||
1761 | void | ||
1762 | GNUNET_GTK_publish_file_dialog_response_cb (GtkDialog *dialog, | ||
1763 | gint response_id, gpointer user_data) | ||
1764 | { | ||
1765 | char *filename; | ||
1766 | struct GNUNET_FS_BlockOptions bo; | ||
1767 | int do_index; | ||
1768 | GtkSpinButton *sb; | ||
1769 | GtkWidget *ad; | ||
1770 | |||
1771 | GtkBuilder *builder = GTK_BUILDER (user_data); | ||
1772 | |||
1773 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | ||
1774 | "GNUNET_GTK_publish_file_dialog")); | ||
1775 | |||
1776 | if (response_id == -5) | ||
1777 | { | ||
1778 | /* OK */ | ||
1779 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad)); | ||
1780 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | ||
1781 | "GNUNET_GTK_publish_file_dialog_expiration_year_spin_button")); | ||
1782 | |||
1783 | if (!GNUNET_GTK_get_selected_anonymity_level (builder, | ||
1784 | "GNUNET_GTK_publish_file_dialog_anonymity_combobox", &bo.anonymity_level)) | ||
1785 | bo.anonymity_level = 1; | ||
1786 | bo.content_priority = gtk_spin_button_get_value (GTK_SPIN_BUTTON ( | ||
1787 | gtk_builder_get_object (builder, | ||
1788 | "GNUNET_GTK_publish_file_dialog_priority_spin_button"))); | ||
1789 | bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (sb); | ||
1790 | bo.replication_level = 1; /* FIXME... */ | ||
1791 | do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ( | ||
1792 | gtk_builder_get_object (builder, | ||
1793 | "GNUNET_GTK_publish_file_dialog_do_index_checkbutton"))); | ||
1794 | add_file_at_iter (user_data, filename, &bo, do_index, NULL); | ||
1795 | g_free (filename); | ||
1796 | update_selectivity (user_data); | ||
1797 | } | ||
1798 | else | ||
1799 | { | ||
1800 | /* Cancel/Escape/close/etc */ | ||
1801 | } | ||
1802 | gtk_widget_hide (ad); | ||
1803 | } | ||
1804 | |||
1805 | /** | ||
1806 | */ | ||
1807 | void | ||
1808 | GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, gpointer data) | ||
1809 | { | ||
1810 | GtkWidget *ad; | ||
1811 | GtkTreeStore *ts; | ||
1812 | GtkBuilder *builder; | ||
1813 | |||
1814 | builder = GTK_BUILDER (data); | ||
1815 | |||
1816 | ad = GTK_WIDGET (gtk_builder_get_object | ||
1817 | (builder, "GNUNET_GTK_master_publish_dialog")); | ||
1818 | |||
1819 | if (!gtk_widget_get_visible (ad)) | ||
1820 | { | ||
1821 | ts = GTK_TREE_STORE (gtk_builder_get_object (builder, | ||
1822 | "GNUNET_GTK_pseudonym_tree_store")); | ||
1823 | GNUNET_FS_namespace_list (GNUNET_FS_GTK_get_fs_handle (), | ||
1824 | &add_namespace_to_ts, ts); | ||
1825 | } | ||
1692 | 1826 | ||
1693 | gtk_widget_destroy (ad); | 1827 | gtk_window_present (GTK_WINDOW (ad)); |
1694 | g_object_unref (G_OBJECT (master_builder)); | ||
1695 | master_builder = NULL; | ||
1696 | } | 1828 | } |
1697 | 1829 | ||
1698 | 1830 | ||