diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/gnunet-fs-gtk-common.c | 93 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk-common.h | 9 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk-download.c | 9 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk-edit_publish_dialog.c | 367 |
4 files changed, 309 insertions, 169 deletions
diff --git a/src/fs/gnunet-fs-gtk-common.c b/src/fs/gnunet-fs-gtk-common.c index c4058cd1..586c51fd 100644 --- a/src/fs/gnunet-fs-gtk-common.c +++ b/src/fs/gnunet-fs-gtk-common.c | |||
@@ -42,38 +42,38 @@ char * | |||
42 | GNUNET_FS_GTK_dubious_meta_to_utf8 (enum EXTRACTOR_MetaFormat format, | 42 | GNUNET_FS_GTK_dubious_meta_to_utf8 (enum EXTRACTOR_MetaFormat format, |
43 | const char *data, size_t data_len) | 43 | const char *data, size_t data_len) |
44 | { | 44 | { |
45 | gchar *result = NULL; | 45 | switch (format) |
46 | |||
47 | if (format == EXTRACTOR_METAFORMAT_UTF8) | ||
48 | { | 46 | { |
47 | case EXTRACTOR_METAFORMAT_UTF8: | ||
49 | /* data must not contain NULLs (hence the -1) */ | 48 | /* data must not contain NULLs (hence the -1) */ |
50 | if (g_utf8_validate (data, data_len - 1, NULL)) | 49 | if (g_utf8_validate (data, data_len - 1, NULL)) |
51 | result = GNUNET_strdup (data); | 50 | return GNUNET_strdup (data); |
52 | else | 51 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
53 | { | 52 | _("Failed to validate supposedly utf-8 string `%s' of length %u, assuming it to be a C string\n"), |
54 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 53 | data, |
55 | "Failed to validate supposedly utf-8 string `%s' of length %u, assuming it to be a C string\n", | 54 | (unsigned int) data_len); |
56 | data, data_len); | 55 | format = EXTRACTOR_METAFORMAT_C_STRING; |
57 | format = EXTRACTOR_METAFORMAT_C_STRING; | 56 | /* fall-through */ |
58 | } | 57 | case EXTRACTOR_METAFORMAT_C_STRING: |
59 | } | ||
60 | if (format == EXTRACTOR_METAFORMAT_C_STRING) | ||
61 | { | ||
62 | if (data_len > 0) | 58 | if (data_len > 0) |
63 | { /* There are no guarantees that data is NULL-terminated, AFAIU, | 59 | { |
64 | * so let's play it safe, shall we? | 60 | /* There are no guarantees that data is NULL-terminated, AFAIU, |
65 | */ | 61 | * so let's play it safe, shall we? |
66 | char *data_copy = GNUNET_malloc (data_len + 1); | 62 | */ |
63 | char data_copy[data_len + 1]; | ||
67 | 64 | ||
68 | memcpy (data_copy, data, data_len); | 65 | memcpy (data_copy, data, data_len); |
69 | data_copy[data_len] = '\0'; | 66 | data_copy[data_len] = '\0'; |
70 | result = GNUNET_GTK_from_loc_to_utf8 (data_copy); | 67 | return GNUNET_GTK_from_loc_to_utf8 (data_copy); |
71 | GNUNET_free (data_copy); | ||
72 | } | 68 | } |
69 | break; | ||
70 | default: | ||
71 | break; | ||
73 | } | 72 | } |
74 | return result; | 73 | return NULL; |
75 | } | 74 | } |
76 | 75 | ||
76 | |||
77 | /** | 77 | /** |
78 | * Add meta data to list store. | 78 | * Add meta data to list store. |
79 | * | 79 | * |
@@ -98,18 +98,15 @@ GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, const char *plugin_name, | |||
98 | const char *data, size_t data_len) | 98 | const char *data, size_t data_len) |
99 | { | 99 | { |
100 | GtkListStore *ls = GTK_LIST_STORE (cls); | 100 | GtkListStore *ls = GTK_LIST_STORE (cls); |
101 | gchar *data_to_insert = NULL; | 101 | char *data_to_insert; |
102 | 102 | ||
103 | data_to_insert = GNUNET_FS_GTK_dubious_meta_to_utf8 (format, data, data_len); | 103 | data_to_insert = GNUNET_FS_GTK_dubious_meta_to_utf8 (format, data, data_len); |
104 | 104 | if (NULL == data_to_insert) | |
105 | if (NULL != data_to_insert) | 105 | return 0; |
106 | { | 106 | gtk_list_store_insert_with_values (ls, NULL, G_MAXINT, 0, type, 1, format, |
107 | gtk_list_store_insert_with_values (ls, NULL, G_MAXINT, 0, type, 1, format, | 107 | 2, EXTRACTOR_metatype_to_string (type), |
108 | 2, EXTRACTOR_metatype_to_string (type), | 108 | 3, data_to_insert, -1); |
109 | 3, data_to_insert, -1); | 109 | GNUNET_free (data_to_insert); |
110 | g_free (data_to_insert); | ||
111 | } | ||
112 | |||
113 | return 0; | 110 | return 0; |
114 | } | 111 | } |
115 | 112 | ||
@@ -117,6 +114,9 @@ GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, const char *plugin_name, | |||
117 | /** | 114 | /** |
118 | * Convert the year from the spin button to an expiration | 115 | * Convert the year from the spin button to an expiration |
119 | * time (on midnight, January 1st of that year). | 116 | * time (on midnight, January 1st of that year). |
117 | * | ||
118 | * @param spin button with an expiration year | ||
119 | * @return expiration time in the usual GNUnet format | ||
120 | */ | 120 | */ |
121 | struct GNUNET_TIME_Absolute | 121 | struct GNUNET_TIME_Absolute |
122 | GNUNET_FS_GTK_get_expiration_time (GtkSpinButton * spin) | 122 | GNUNET_FS_GTK_get_expiration_time (GtkSpinButton * spin) |
@@ -132,6 +132,14 @@ GNUNET_FS_GTK_get_expiration_time (GtkSpinButton * spin) | |||
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | /** | ||
136 | * Initialize the 'expiration_year_adjustment' of the given | ||
137 | * builder to have a lower range of current-year+1 and a | ||
138 | * default of current-year+2. | ||
139 | * | ||
140 | * @param builder builder object for which we should manipulate | ||
141 | * the adjustment | ||
142 | */ | ||
135 | void | 143 | void |
136 | GNUNET_FS_GTK_setup_expiration_year_adjustment (GtkBuilder * builder) | 144 | GNUNET_FS_GTK_setup_expiration_year_adjustment (GtkBuilder * builder) |
137 | { | 145 | { |
@@ -146,6 +154,12 @@ GNUNET_FS_GTK_setup_expiration_year_adjustment (GtkBuilder * builder) | |||
146 | } | 154 | } |
147 | 155 | ||
148 | 156 | ||
157 | /** | ||
158 | * Obtain pixbuf from thumbnail data in meta data. | ||
159 | * | ||
160 | * @param meta input meta data | ||
161 | * @return NULL on error, otherwise the embedded thumbnail | ||
162 | */ | ||
149 | GdkPixbuf * | 163 | GdkPixbuf * |
150 | GNUNET_FS_GTK_get_thumbnail_from_meta_data (const struct | 164 | GNUNET_FS_GTK_get_thumbnail_from_meta_data (const struct |
151 | GNUNET_CONTAINER_MetaData *meta) | 165 | GNUNET_CONTAINER_MetaData *meta) |
@@ -157,13 +171,13 @@ GNUNET_FS_GTK_get_thumbnail_from_meta_data (const struct | |||
157 | 171 | ||
158 | thumb = NULL; | 172 | thumb = NULL; |
159 | ts = GNUNET_CONTAINER_meta_data_get_thumbnail (meta, &thumb); | 173 | ts = GNUNET_CONTAINER_meta_data_get_thumbnail (meta, &thumb); |
160 | if (ts == 0) | 174 | if (0 == ts) |
161 | return NULL; | 175 | return NULL; |
162 | loader = gdk_pixbuf_loader_new (); | 176 | loader = gdk_pixbuf_loader_new (); |
163 | gdk_pixbuf_loader_write (loader, (const guchar *) thumb, ts, NULL); | 177 | gdk_pixbuf_loader_write (loader, (const guchar *) thumb, ts, NULL); |
164 | pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); | 178 | pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); |
165 | gdk_pixbuf_loader_close (loader, NULL); | 179 | gdk_pixbuf_loader_close (loader, NULL); |
166 | if (pixbuf != NULL) | 180 | if (NULL != pixbuf) |
167 | g_object_ref (pixbuf); | 181 | g_object_ref (pixbuf); |
168 | g_object_unref (loader); | 182 | g_object_unref (loader); |
169 | GNUNET_free (thumb); | 183 | GNUNET_free (thumb); |
@@ -174,6 +188,10 @@ GNUNET_FS_GTK_get_thumbnail_from_meta_data (const struct | |||
174 | /** | 188 | /** |
175 | * mmap the given file and run the GNUNET_FS_directory_list_contents | 189 | * mmap the given file and run the GNUNET_FS_directory_list_contents |
176 | * function on it. | 190 | * function on it. |
191 | * | ||
192 | * @param filename name with the directory | ||
193 | * @param dep function to call on each entry | ||
194 | * @param dep_cls closure for 'dep' | ||
177 | */ | 195 | */ |
178 | void | 196 | void |
179 | GNUNET_FS_GTK_mmap_and_scan (const char *filename, | 197 | GNUNET_FS_GTK_mmap_and_scan (const char *filename, |
@@ -190,16 +208,13 @@ GNUNET_FS_GTK_mmap_and_scan (const char *filename, | |||
190 | GNUNET_break (0); | 208 | GNUNET_break (0); |
191 | return; | 209 | return; |
192 | } | 210 | } |
193 | fh = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, | 211 | if (NULL == (fh = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, |
194 | GNUNET_DISK_PERM_NONE); | 212 | GNUNET_DISK_PERM_NONE))) |
195 | if (fh == NULL) | ||
196 | { | 213 | { |
197 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename); | 214 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename); |
198 | return; | 215 | return; |
199 | } | 216 | } |
200 | ddata = | 217 | if (NULL == (ddata = GNUNET_DISK_file_map (fh, &mh, GNUNET_DISK_MAP_TYPE_READ, (size_t) fsize))) |
201 | GNUNET_DISK_file_map (fh, &mh, GNUNET_DISK_MAP_TYPE_READ, (size_t) fsize); | ||
202 | if (ddata == NULL) | ||
203 | { | 218 | { |
204 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mmap", filename); | 219 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mmap", filename); |
205 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh)); | 220 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh)); |
diff --git a/src/fs/gnunet-fs-gtk-common.h b/src/fs/gnunet-fs-gtk-common.h index f7ad5ab2..1c9b0392 100644 --- a/src/fs/gnunet-fs-gtk-common.h +++ b/src/fs/gnunet-fs-gtk-common.h | |||
@@ -42,12 +42,15 @@ GNUNET_FS_GTK_get_thumbnail_from_meta_data (const struct | |||
42 | GNUNET_CONTAINER_MetaData *meta); | 42 | GNUNET_CONTAINER_MetaData *meta); |
43 | 43 | ||
44 | 44 | ||
45 | |||
45 | /** | 46 | /** |
47 | * Initialize the 'expiration_year_adjustment' of the given | ||
48 | * builder to have a lower range of current-year+1 and a | ||
49 | * default of current-year+2. | ||
46 | * FIXME: odd API... | 50 | * FIXME: odd API... |
47 | * Setup the expiration year adjustment to start with the | ||
48 | * next year and default to next year plus one. | ||
49 | * | 51 | * |
50 | * @param builder | 52 | * @param builder builder object for which we should manipulate |
53 | * the adjustment | ||
51 | */ | 54 | */ |
52 | void | 55 | void |
53 | GNUNET_FS_GTK_setup_expiration_year_adjustment (GtkBuilder * builder); | 56 | GNUNET_FS_GTK_setup_expiration_year_adjustment (GtkBuilder * builder); |
diff --git a/src/fs/gnunet-fs-gtk-download.c b/src/fs/gnunet-fs-gtk-download.c index cba115ab..36ad03e0 100644 --- a/src/fs/gnunet-fs-gtk-download.c +++ b/src/fs/gnunet-fs-gtk-download.c | |||
@@ -145,7 +145,7 @@ GNUNET_GTK_save_as_dialog_response_cb (GtkDialog * dialog, | |||
145 | call the handler manually */ | 145 | call the handler manually */ |
146 | GNUNET_GTK_save_as_dialog_delete_event_cb (GTK_WIDGET (dialog), NULL, | 146 | GNUNET_GTK_save_as_dialog_delete_event_cb (GTK_WIDGET (dialog), NULL, |
147 | user_data); | 147 | user_data); |
148 | /* FIXME: isn't the dialog going to be destroyed with the builder? | 148 | /* FIXME-BUG-MAYBE: isn't the dialog going to be destroyed with the builder? |
149 | Is this legal and/or required? */ | 149 | Is this legal and/or required? */ |
150 | gtk_widget_destroy (GTK_WIDGET (dialog)); | 150 | gtk_widget_destroy (GTK_WIDGET (dialog)); |
151 | } | 151 | } |
@@ -189,7 +189,7 @@ GNUNET_FS_GTK_open_download_as_dialog (struct DownloadContext *dc) | |||
189 | dc->is_recursive); | 189 | dc->is_recursive); |
190 | 190 | ||
191 | /* initialize filename based on filename from 'dc' */ | 191 | /* initialize filename based on filename from 'dc' */ |
192 | if (dc->filename != NULL) | 192 | if (NULL != dc->filename) |
193 | { | 193 | { |
194 | char *dirname; | 194 | char *dirname; |
195 | char *basename; | 195 | char *basename; |
@@ -200,6 +200,7 @@ GNUNET_FS_GTK_open_download_as_dialog (struct DownloadContext *dc) | |||
200 | if (basename > dirname) | 200 | if (basename > dirname) |
201 | basename[-1] = '\0'; | 201 | basename[-1] = '\0'; |
202 | 202 | ||
203 | /* FIXME: remove following lines after testing... */ | ||
203 | fprintf (stderr, | 204 | fprintf (stderr, |
204 | "Splitting `%s' into `%s' + `%s' for file chooser dialog.\n", | 205 | "Splitting `%s' into `%s' + `%s' for file chooser dialog.\n", |
205 | dc->filename, | 206 | dc->filename, |
@@ -237,7 +238,7 @@ GNUNET_FS_GTK_download_context_start_download (struct DownloadContext *dc) | |||
237 | dc->uri = NULL; | 238 | dc->uri = NULL; |
238 | de->meta = dc->meta; | 239 | de->meta = dc->meta; |
239 | dc->meta = NULL; | 240 | dc->meta = NULL; |
240 | if (dc->rr != NULL) | 241 | if (NULL != dc->rr) |
241 | { | 242 | { |
242 | de->rr = gtk_tree_row_reference_copy (dc->rr); | 243 | de->rr = gtk_tree_row_reference_copy (dc->rr); |
243 | de->ts = GTK_TREE_STORE (gtk_tree_row_reference_get_model (dc->rr)); | 244 | de->ts = GTK_TREE_STORE (gtk_tree_row_reference_get_model (dc->rr)); |
@@ -268,7 +269,7 @@ GNUNET_FS_GTK_download_context_start_download (struct DownloadContext *dc) | |||
268 | if (dc->is_recursive) | 269 | if (dc->is_recursive) |
269 | opt |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE; | 270 | opt |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE; |
270 | len = GNUNET_FS_uri_chk_get_file_size (dc->uri); | 271 | len = GNUNET_FS_uri_chk_get_file_size (dc->uri); |
271 | if (dc->sr != NULL) | 272 | if (NULL != dc->sr) |
272 | { | 273 | { |
273 | GNUNET_break (NULL != | 274 | GNUNET_break (NULL != |
274 | GNUNET_FS_download_start_from_search (fs, dc->sr, | 275 | GNUNET_FS_download_start_from_search (fs, dc->sr, |
diff --git a/src/fs/gnunet-fs-gtk-edit_publish_dialog.c b/src/fs/gnunet-fs-gtk-edit_publish_dialog.c index d787bff8..f125788b 100644 --- a/src/fs/gnunet-fs-gtk-edit_publish_dialog.c +++ b/src/fs/gnunet-fs-gtk-edit_publish_dialog.c | |||
@@ -29,66 +29,179 @@ | |||
29 | 29 | ||
30 | #include "metatypes.c" | 30 | #include "metatypes.c" |
31 | 31 | ||
32 | |||
33 | /** | ||
34 | * Internal state kept for each "edit" dialog where the user can edit | ||
35 | * publishing information for a file. | ||
36 | */ | ||
32 | struct EditPublicationDialogContext | 37 | struct EditPublicationDialogContext |
33 | { | 38 | { |
39 | /** | ||
40 | * Builder for the dialog. | ||
41 | */ | ||
34 | GtkBuilder *builder; | 42 | GtkBuilder *builder; |
35 | 43 | ||
36 | GtkListStore *metatypes_liststore; | 44 | /** |
45 | * The 'window' object for the dialog. | ||
46 | */ | ||
47 | GtkWindow *edit_publication_window; | ||
37 | 48 | ||
38 | GtkListStore *meta_liststore; | 49 | /** |
50 | * The confirmation button which closes the dialog (only sensitive | ||
51 | * if the values entered are valid). | ||
52 | */ | ||
53 | GtkWidget *confirm_button; | ||
54 | |||
55 | /** | ||
56 | * Tree view showing the meta data for the file. | ||
57 | */ | ||
39 | GtkTreeView *meta_treeview; | 58 | GtkTreeView *meta_treeview; |
40 | GtkTreeSelection *meta_selection; | ||
41 | GtkButton *meta_add_button; | ||
42 | GtkWidget *meta_del_button; | ||
43 | 59 | ||
44 | GtkCellRendererCombo *meta_combo; | 60 | /** |
61 | * Tree view showing the keywords for the file. | ||
62 | */ | ||
63 | GtkTreeView *keywords_treeview; | ||
64 | |||
65 | /** | ||
66 | * Image showing the preview image for the file. | ||
67 | */ | ||
68 | GtkImage *preview_image; | ||
69 | |||
70 | /** | ||
71 | * Combo box where the user can select the anonymity level. | ||
72 | */ | ||
73 | GtkComboBox *anonymity_combo; | ||
74 | |||
75 | /** | ||
76 | * Liststore of the 'anonymity_combo' with the anonymity levels. | ||
77 | */ | ||
78 | GtkListStore *anonymity_liststore; | ||
45 | 79 | ||
80 | /** | ||
81 | * Liststore of possible publication types. | ||
82 | */ | ||
46 | GtkListStore *pubtypes_liststore; | 83 | GtkListStore *pubtypes_liststore; |
47 | GtkComboBox *pubtypes_combo; | ||
48 | 84 | ||
85 | /** | ||
86 | * Liststore of all possible meta types the user can choose from. | ||
87 | * (updated to based on the selected publication type). | ||
88 | */ | ||
89 | GtkListStore *metatypes_liststore; | ||
90 | |||
91 | /** | ||
92 | * Liststore showing the meta data of the file (associated with | ||
93 | * the 'meta_treeview'. | ||
94 | */ | ||
95 | GtkListStore *meta_liststore; | ||
96 | |||
97 | /** | ||
98 | * Liststore with the keywords of the file (associated with the | ||
99 | * 'keywords_treeview'. | ||
100 | */ | ||
49 | GtkListStore *keywords_liststore; | 101 | GtkListStore *keywords_liststore; |
50 | GtkTreeView *keywords_treeview; | ||
51 | GtkTreeSelection *keywords_selection; | ||
52 | GtkWidget *keyword_add_button; | ||
53 | GtkWidget *keyword_del_button; | ||
54 | 102 | ||
55 | GtkEntry *keyword_entry; | 103 | /** |
104 | * Spin button to select content priority level for the file. | ||
105 | */ | ||
106 | GtkSpinButton *priority_spin; | ||
56 | 107 | ||
57 | GObject *pubwindow; | 108 | /** |
109 | * Spin button to select the expiration year. | ||
110 | */ | ||
111 | GtkSpinButton *expiration_year_spin; | ||
58 | 112 | ||
59 | GtkWidget *ok; | 113 | /** |
60 | GtkButton *cancel; | 114 | * Spin button to select the replication level. |
115 | */ | ||
116 | GtkSpinButton *replication_spin; | ||
61 | 117 | ||
62 | GtkImage *image; | 118 | /** |
119 | * Entry line for adding additional keywords. | ||
120 | */ | ||
121 | GtkEntry *keyword_entry; | ||
63 | 122 | ||
64 | GtkToggleButton *index_checkbutton; | 123 | /** |
65 | GtkLabel *index_label; | 124 | * Entry line for setting a namespace root (possibly invisible). |
125 | */ | ||
66 | GtkEntry *root_entry; | 126 | GtkEntry *root_entry; |
67 | GtkLabel *root_label; | ||
68 | 127 | ||
69 | GtkSpinButton *priority_spin; | 128 | /** |
70 | GtkSpinButton *year_spin; | 129 | * Entry line to check indexing vs. inserting (possibly invisible) |
71 | GtkSpinButton *replication_spin; | 130 | */ |
131 | GtkToggleButton *index_checkbutton; | ||
72 | 132 | ||
73 | GtkComboBox *anonymity_combo; | 133 | /** |
74 | GtkListStore *anonymity_liststore; | 134 | * ??? |
135 | */ | ||
136 | GtkTreeIter *meta_combo_selected_iter; | ||
75 | 137 | ||
76 | int do_index; | 138 | /** |
77 | char *short_fn; | 139 | * Continuation to call once the dialog has been closed |
78 | struct GNUNET_FS_BlockOptions bo; | 140 | */ |
79 | struct GNUNET_FS_FileInformation *fip; | ||
80 | gint preview_changed; | ||
81 | gboolean allow_no_keywords; | ||
82 | gboolean is_directory; | ||
83 | GNUNET_FS_GTK_EditPublishDialogCallback cb; | 141 | GNUNET_FS_GTK_EditPublishDialogCallback cb; |
84 | gchar *root; | ||
85 | gpointer cls; | ||
86 | 142 | ||
143 | /** | ||
144 | * Closure for 'cb'. | ||
145 | */ | ||
146 | void *cb_cls; | ||
147 | |||
148 | /** | ||
149 | * Short name of the file being published (or NULL). | ||
150 | */ | ||
151 | char *short_fn; | ||
152 | |||
153 | /** | ||
154 | * Briefly used temporary meta data set. | ||
155 | */ | ||
87 | struct GNUNET_CONTAINER_MetaData *md; | 156 | struct GNUNET_CONTAINER_MetaData *md; |
88 | 157 | ||
89 | GtkTreeIter *meta_combo_selected_iter; | 158 | /** |
159 | * Information about the file being published as seen by the FS-API. | ||
160 | * This is what we are primarily editing. | ||
161 | */ | ||
162 | struct GNUNET_FS_FileInformation *fip; | ||
163 | |||
164 | /** | ||
165 | * Overall options for the publish operation. This is also what | ||
166 | * we are primarily editing. | ||
167 | */ | ||
168 | struct GNUNET_FS_BlockOptions bo; | ||
169 | |||
170 | /** | ||
171 | * Flag to track if we changed the preview and thus should keep/discard | ||
172 | * certain metadata. (FIXME: yucky!) | ||
173 | */ | ||
174 | int preview_changed; | ||
175 | |||
176 | /** | ||
177 | * Is this operation for a directory? | ||
178 | */ | ||
179 | int is_directory; | ||
180 | |||
181 | /** | ||
182 | * Is it allowed for the user to supply keywords in this dialog? | ||
183 | * FIXME: why 'gboolean'? | ||
184 | */ | ||
185 | gboolean allow_no_keywords; | ||
186 | |||
90 | }; | 187 | }; |
91 | 188 | ||
189 | |||
190 | /** | ||
191 | * Free resources associated with the edit publication dialog. | ||
192 | * | ||
193 | * @param ctx the context of the dialog to release resources of | ||
194 | */ | ||
195 | static void | ||
196 | free_edit_dialog_context (struct EditPublicationDialogContext *ctx) | ||
197 | { | ||
198 | gtk_widget_destroy (GTK_WIDGET (ctx->edit_publication_window)); | ||
199 | GNUNET_free_non_null (ctx->short_fn); | ||
200 | // FIXME: destroy builder! | ||
201 | GNUNET_free (ctx); | ||
202 | } | ||
203 | |||
204 | |||
92 | static void | 205 | static void |
93 | change_metatypes (struct EditPublicationDialogContext *ctx, gint code) | 206 | change_metatypes (struct EditPublicationDialogContext *ctx, gint code) |
94 | { | 207 | { |
@@ -129,11 +242,9 @@ GNUNET_GTK_edit_publication_type_combo_changed_cb (GtkComboBox * widget, | |||
129 | GtkTreeIter iter; | 242 | GtkTreeIter iter; |
130 | gint code; | 243 | gint code; |
131 | 244 | ||
132 | if (!gtk_combo_box_get_active_iter (widget, &iter)) | 245 | if (! gtk_combo_box_get_active_iter (widget, &iter)) |
133 | return; | 246 | return; |
134 | |||
135 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->pubtypes_liststore), &iter, 0, &code, -1); | 247 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->pubtypes_liststore), &iter, 0, &code, -1); |
136 | |||
137 | change_metatypes (ctx, code); | 248 | change_metatypes (ctx, code); |
138 | } | 249 | } |
139 | 250 | ||
@@ -141,7 +252,8 @@ GNUNET_GTK_edit_publication_type_combo_changed_cb (GtkComboBox * widget, | |||
141 | static void | 252 | static void |
142 | metadata_selection_changed_cb (GtkTreeSelection *ts, struct EditPublicationDialogContext *ctx) | 253 | metadata_selection_changed_cb (GtkTreeSelection *ts, struct EditPublicationDialogContext *ctx) |
143 | { | 254 | { |
144 | gtk_widget_set_sensitive (ctx->meta_del_button, | 255 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object |
256 | (ctx->builder, "GNUNET_GTK_edit_publication_delete_button")), | ||
145 | gtk_tree_selection_get_selected (ts, NULL, NULL)); | 257 | gtk_tree_selection_get_selected (ts, NULL, NULL)); |
146 | } | 258 | } |
147 | 259 | ||
@@ -149,7 +261,9 @@ metadata_selection_changed_cb (GtkTreeSelection *ts, struct EditPublicationDialo | |||
149 | static void | 261 | static void |
150 | keywords_selection_changed_cb (GtkTreeSelection *ts, struct EditPublicationDialogContext *ctx) | 262 | keywords_selection_changed_cb (GtkTreeSelection *ts, struct EditPublicationDialogContext *ctx) |
151 | { | 263 | { |
152 | gtk_widget_set_sensitive (ctx->keyword_del_button, | 264 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object |
265 | (ctx->builder, | ||
266 | "GNUNET_GTK_edit_publication_keyword_list_del_button")), | ||
153 | gtk_tree_selection_get_selected (ts, NULL, NULL)); | 267 | gtk_tree_selection_get_selected (ts, NULL, NULL)); |
154 | } | 268 | } |
155 | 269 | ||
@@ -176,7 +290,10 @@ GNUNET_GTK_edit_publication_keyword_entry_key_press_event_cb (GtkWidget * | |||
176 | { | 290 | { |
177 | if (event->keyval == GDK_KEY_Return) | 291 | if (event->keyval == GDK_KEY_Return) |
178 | { | 292 | { |
179 | GNUNET_GTK_edit_publication_add_button_clicked_cb (GTK_BUTTON (ctx->keyword_add_button), ctx); | 293 | GNUNET_GTK_edit_publication_add_button_clicked_cb (GTK_BUTTON (gtk_builder_get_object (ctx->builder, |
294 | "GNUNET_GTK_edit_publication_keyword_list_add_button")), | ||
295 | |||
296 | ctx); | ||
180 | return TRUE; | 297 | return TRUE; |
181 | } | 298 | } |
182 | return FALSE; | 299 | return FALSE; |
@@ -198,7 +315,10 @@ void GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_edited_cb | |||
198 | 315 | ||
199 | if (!ctx->meta_combo_selected_iter) | 316 | if (!ctx->meta_combo_selected_iter) |
200 | return; | 317 | return; |
201 | g_object_get (ctx->meta_combo, "model", &combo_model, NULL); | 318 | g_object_get (GTK_CELL_RENDERER_COMBO (gtk_builder_get_object |
319 | (ctx->builder, | ||
320 | "GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer")), | ||
321 | "model", &combo_model, NULL); | ||
202 | gtk_tree_model_get (combo_model, ctx->meta_combo_selected_iter, 0, &type_id, 2, &description, -1); | 322 | gtk_tree_model_get (combo_model, ctx->meta_combo_selected_iter, 0, &type_id, 2, &description, -1); |
203 | g_object_unref (combo_model); | 323 | g_object_unref (combo_model); |
204 | g_free (ctx->meta_combo_selected_iter); | 324 | g_free (ctx->meta_combo_selected_iter); |
@@ -277,14 +397,16 @@ GNUNET_GTK_edit_publication_delete_button_clicked_cb (GtkButton * button, | |||
277 | struct EditPublicationDialogContext *ctx) | 397 | struct EditPublicationDialogContext *ctx) |
278 | { | 398 | { |
279 | GtkTreeIter iter; | 399 | GtkTreeIter iter; |
400 | GtkTreeSelection *meta_selection; | ||
280 | 401 | ||
281 | if (TRUE != gtk_tree_selection_get_selected (ctx->meta_selection, NULL, &iter)) | 402 | meta_selection = gtk_tree_view_get_selection (ctx->meta_treeview); |
403 | if (! gtk_tree_selection_get_selected (meta_selection, NULL, &iter)) | ||
282 | { | 404 | { |
283 | GNUNET_break (0); | 405 | GNUNET_break (0); |
284 | return; | 406 | return; |
285 | } | 407 | } |
286 | if (gtk_list_store_remove (ctx->meta_liststore, &iter)) | 408 | if (gtk_list_store_remove (ctx->meta_liststore, &iter)) |
287 | gtk_tree_selection_select_iter (ctx->meta_selection, &iter); | 409 | gtk_tree_selection_select_iter (meta_selection, &iter); |
288 | } | 410 | } |
289 | 411 | ||
290 | 412 | ||
@@ -301,7 +423,7 @@ GNUNET_GTK_edit_publication_keyword_list_add_button_clicked_cb (GtkButton * | |||
301 | { | 423 | { |
302 | gtk_list_store_insert_with_values (ctx->keywords_liststore, &iter, G_MAXINT, 0, keyword, 1, TRUE, | 424 | gtk_list_store_insert_with_values (ctx->keywords_liststore, &iter, G_MAXINT, 0, keyword, 1, TRUE, |
303 | -1); | 425 | -1); |
304 | gtk_widget_set_sensitive (ctx->ok, TRUE); | 426 | gtk_widget_set_sensitive (ctx->confirm_button, TRUE); |
305 | } | 427 | } |
306 | gtk_entry_set_text (ctx->keyword_entry, ""); | 428 | gtk_entry_set_text (ctx->keyword_entry, ""); |
307 | } | 429 | } |
@@ -335,7 +457,9 @@ GNUNET_GTK_edit_publication_keyword_entry_changed_cb (GtkEditable * editable, | |||
335 | const char *keyword; | 457 | const char *keyword; |
336 | 458 | ||
337 | keyword = gtk_entry_get_text (ctx->keyword_entry); | 459 | keyword = gtk_entry_get_text (ctx->keyword_entry); |
338 | gtk_widget_set_sensitive (ctx->keyword_add_button, (strlen (keyword) > 0) ? TRUE : FALSE); | 460 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (ctx->builder, |
461 | "GNUNET_GTK_edit_publication_keyword_list_add_button")), | ||
462 | (strlen (keyword) > 0) ? TRUE : FALSE); | ||
339 | } | 463 | } |
340 | 464 | ||
341 | 465 | ||
@@ -345,17 +469,20 @@ GNUNET_GTK_edit_publication_keyword_list_del_button_clicked_cb (GtkButton * | |||
345 | struct EditPublicationDialogContext *ctx) | 469 | struct EditPublicationDialogContext *ctx) |
346 | { | 470 | { |
347 | GtkTreeIter iter; | 471 | GtkTreeIter iter; |
472 | GtkTreeSelection *keywords_selection; | ||
473 | |||
474 | keywords_selection = gtk_tree_view_get_selection (ctx->keywords_treeview); | ||
348 | 475 | ||
349 | if (TRUE != gtk_tree_selection_get_selected (ctx->keywords_selection, NULL, &iter)) | 476 | if (TRUE != gtk_tree_selection_get_selected (keywords_selection, NULL, &iter)) |
350 | { | 477 | { |
351 | GNUNET_break (0); | 478 | GNUNET_break (0); |
352 | return; | 479 | return; |
353 | } | 480 | } |
354 | if (gtk_list_store_remove (GTK_LIST_STORE (ctx->keywords_liststore), &iter)) | 481 | if (gtk_list_store_remove (GTK_LIST_STORE (ctx->keywords_liststore), &iter)) |
355 | gtk_tree_selection_select_iter (ctx->keywords_selection, &iter); | 482 | gtk_tree_selection_select_iter (keywords_selection, &iter); |
356 | 483 | ||
357 | if (!ctx->allow_no_keywords && !gtk_tree_model_has_items (GTK_TREE_MODEL (ctx->keywords_liststore))) | 484 | if (!ctx->allow_no_keywords && !gtk_tree_model_has_items (GTK_TREE_MODEL (ctx->keywords_liststore))) |
358 | gtk_widget_set_sensitive (ctx->ok, FALSE); | 485 | gtk_widget_set_sensitive (ctx->confirm_button, FALSE); |
359 | } | 486 | } |
360 | 487 | ||
361 | 488 | ||
@@ -365,7 +492,7 @@ void GNUNET_GTK_edit_publication_metadata_preview_file_chooser_button_file_set_c | |||
365 | gchar *fn; | 492 | gchar *fn; |
366 | 493 | ||
367 | fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); | 494 | fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); |
368 | gtk_image_set_from_file (ctx->image, fn); | 495 | gtk_image_set_from_file (ctx->preview_image, fn); |
369 | g_free (fn); | 496 | g_free (fn); |
370 | ctx->preview_changed = GNUNET_YES; | 497 | ctx->preview_changed = GNUNET_YES; |
371 | } | 498 | } |
@@ -478,6 +605,7 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
478 | const char *mime; | 605 | const char *mime; |
479 | GFile *f; | 606 | GFile *f; |
480 | GFileInfo *finfo; | 607 | GFileInfo *finfo; |
608 | char *sfn; | ||
481 | 609 | ||
482 | if (!GNUNET_GTK_get_selected_anonymity_combo_level | 610 | if (!GNUNET_GTK_get_selected_anonymity_combo_level |
483 | (ctx->anonymity_combo, &ctx->bo.anonymity_level)) | 611 | (ctx->anonymity_combo, &ctx->bo.anonymity_level)) |
@@ -485,13 +613,8 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
485 | ctx->bo.content_priority = gtk_spin_button_get_value (ctx->priority_spin); | 613 | ctx->bo.content_priority = gtk_spin_button_get_value (ctx->priority_spin); |
486 | ctx->bo.replication_level = gtk_spin_button_get_value (ctx->replication_spin); | 614 | ctx->bo.replication_level = gtk_spin_button_get_value (ctx->replication_spin); |
487 | *do_index = gtk_toggle_button_get_active (ctx->index_checkbutton); | 615 | *do_index = gtk_toggle_button_get_active (ctx->index_checkbutton); |
488 | ctx->bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (ctx->year_spin); | 616 | ctx->bo.expiration_time = GNUNET_FS_GTK_get_expiration_time (ctx->expiration_year_spin); |
489 | 617 | ||
490 | if (!ctx->allow_no_keywords) | ||
491 | { | ||
492 | g_free (ctx->root); | ||
493 | ctx->root = g_strdup (gtk_entry_get_text (ctx->root_entry)); | ||
494 | } | ||
495 | /* update URI */ | 618 | /* update URI */ |
496 | if (NULL != (*uri)) | 619 | if (NULL != (*uri)) |
497 | GNUNET_FS_uri_destroy (*uri); | 620 | GNUNET_FS_uri_destroy (*uri); |
@@ -564,13 +687,17 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
564 | g_free (fn); | 687 | g_free (fn); |
565 | } | 688 | } |
566 | GNUNET_CONTAINER_meta_data_destroy (ctx->md); | 689 | GNUNET_CONTAINER_meta_data_destroy (ctx->md); |
690 | ctx->md = NULL; | ||
567 | 691 | ||
568 | /* update short_fn */ | 692 | /* update short_fn */ |
569 | GNUNET_free_non_null (ctx->short_fn); | 693 | sfn = GNUNET_CONTAINER_meta_data_get_first_by_types (meta, |
570 | ctx->short_fn = | 694 | EXTRACTOR_METATYPE_FILENAME, |
571 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | 695 | -1); |
572 | EXTRACTOR_METATYPE_FILENAME, | 696 | if (NULL != sfn) |
573 | -1); | 697 | { |
698 | GNUNET_free_non_null (ctx->short_fn); | ||
699 | ctx->short_fn = sfn; | ||
700 | } | ||
574 | return GNUNET_SYSERR; /* only visit top-level item */ | 701 | return GNUNET_SYSERR; /* only visit top-level item */ |
575 | } | 702 | } |
576 | 703 | ||
@@ -579,17 +706,24 @@ void | |||
579 | GNUNET_GTK_edit_publication_cancel_button_clicked_cb (GtkButton * button, | 706 | GNUNET_GTK_edit_publication_cancel_button_clicked_cb (GtkButton * button, |
580 | struct EditPublicationDialogContext *ctx) | 707 | struct EditPublicationDialogContext *ctx) |
581 | { | 708 | { |
582 | ctx->cb (ctx->cls, ctx->do_index, ctx->short_fn, | 709 | int do_index; |
583 | &ctx->bo, NULL, GTK_RESPONSE_CANCEL); | 710 | |
584 | gtk_widget_destroy (GTK_WIDGET (ctx->pubwindow)); | 711 | /* FIXME: why are we passing half of these values here? */ |
712 | do_index = gtk_toggle_button_get_active (ctx->index_checkbutton); | ||
713 | ctx->cb (ctx->cb_cls, do_index, ctx->short_fn, | ||
714 | &ctx->bo, NULL, GTK_RESPONSE_CANCEL); | ||
715 | free_edit_dialog_context (ctx); | ||
585 | } | 716 | } |
586 | 717 | ||
587 | 718 | ||
719 | |||
588 | void | 720 | void |
589 | GNUNET_GTK_edit_publication_confirm_button_clicked_cb (GtkButton * button, | 721 | GNUNET_GTK_edit_publication_confirm_button_clicked_cb (GtkButton * button, |
590 | struct EditPublicationDialogContext *ctx) | 722 | struct EditPublicationDialogContext *ctx) |
591 | { | 723 | { |
592 | gint year; | 724 | gint year; |
725 | const char *root; | ||
726 | int do_index; | ||
593 | 727 | ||
594 | GNUNET_FS_file_information_inspect (ctx->fip, &file_information_update, ctx); | 728 | GNUNET_FS_file_information_inspect (ctx->fip, &file_information_update, ctx); |
595 | if (!GNUNET_GTK_get_selected_anonymity_combo_level (ctx->anonymity_combo, | 729 | if (!GNUNET_GTK_get_selected_anonymity_combo_level (ctx->anonymity_combo, |
@@ -597,13 +731,13 @@ GNUNET_GTK_edit_publication_confirm_button_clicked_cb (GtkButton * button, | |||
597 | ctx->bo.content_priority = gtk_spin_button_get_value (ctx->priority_spin); | 731 | ctx->bo.content_priority = gtk_spin_button_get_value (ctx->priority_spin); |
598 | ctx->bo.replication_level = gtk_spin_button_get_value (ctx->replication_spin); | 732 | ctx->bo.replication_level = gtk_spin_button_get_value (ctx->replication_spin); |
599 | 733 | ||
600 | ctx->do_index = gtk_toggle_button_get_active (ctx->index_checkbutton); | 734 | do_index = gtk_toggle_button_get_active (ctx->index_checkbutton); |
601 | year = gtk_spin_button_get_value (ctx->year_spin); | 735 | year = gtk_spin_button_get_value (ctx->expiration_year_spin); |
602 | ctx->bo.expiration_time = GNUNET_FS_year_to_time (year); | 736 | ctx->bo.expiration_time = GNUNET_FS_year_to_time (year); |
603 | ctx->cb (ctx->cls, ctx->do_index, ctx->short_fn, | 737 | root = gtk_entry_get_text (ctx->root_entry); |
604 | &ctx->bo, ctx->root, GTK_RESPONSE_OK); | 738 | ctx->cb (ctx->cb_cls, do_index, ctx->short_fn, |
605 | GNUNET_free_non_null (ctx->short_fn); | 739 | &ctx->bo, root, GTK_RESPONSE_OK); |
606 | gtk_widget_destroy (GTK_WIDGET (ctx->pubwindow)); | 740 | free_edit_dialog_context (ctx); |
607 | } | 741 | } |
608 | 742 | ||
609 | 743 | ||
@@ -612,7 +746,9 @@ GNUNET_GTK_edit_publication_window_delete_event_cb (GtkWidget * widget, | |||
612 | GdkEvent * event, | 746 | GdkEvent * event, |
613 | struct EditPublicationDialogContext *ctx) | 747 | struct EditPublicationDialogContext *ctx) |
614 | { | 748 | { |
615 | GNUNET_GTK_edit_publication_cancel_button_clicked_cb (ctx->cancel, ctx); | 749 | GNUNET_GTK_edit_publication_cancel_button_clicked_cb (GTK_BUTTON (gtk_builder_get_object |
750 | (ctx->builder, "GNUNET_GTK_edit_publication_cancel_button")), | ||
751 | ctx); | ||
616 | return TRUE; | 752 | return TRUE; |
617 | } | 753 | } |
618 | 754 | ||
@@ -672,11 +808,11 @@ file_information_extract (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
672 | pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); | 808 | pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); |
673 | if (pixbuf != NULL) | 809 | if (pixbuf != NULL) |
674 | { | 810 | { |
675 | gtk_image_set_from_pixbuf (ctx->image, pixbuf); | 811 | gtk_image_set_from_pixbuf (ctx->preview_image, pixbuf); |
676 | } | 812 | } |
677 | } | 813 | } |
678 | year = (int) GNUNET_FS_time_to_year (ctx->bo.expiration_time); | 814 | year = (int) GNUNET_FS_time_to_year (ctx->bo.expiration_time); |
679 | gtk_spin_button_set_value (ctx->year_spin, year); | 815 | gtk_spin_button_set_value (ctx->expiration_year_spin, year); |
680 | GNUNET_GTK_select_anonymity_combo_level (ctx->anonymity_combo, | 816 | GNUNET_GTK_select_anonymity_combo_level (ctx->anonymity_combo, |
681 | ctx->bo.anonymity_level); | 817 | ctx->bo.anonymity_level); |
682 | gtk_spin_button_set_value (ctx->priority_spin, ctx->bo.content_priority); | 818 | gtk_spin_button_set_value (ctx->priority_spin, ctx->bo.content_priority); |
@@ -689,13 +825,17 @@ file_information_extract (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
689 | void | 825 | void |
690 | GNUNET_GTK_edit_publication_window_realize_cb (GtkWidget *widget, struct EditPublicationDialogContext *ctx) | 826 | GNUNET_GTK_edit_publication_window_realize_cb (GtkWidget *widget, struct EditPublicationDialogContext *ctx) |
691 | { | 827 | { |
692 | ctx->keywords_selection = gtk_tree_view_get_selection (ctx->keywords_treeview); | 828 | GtkTreeSelection *meta_selection; |
693 | ctx->meta_selection = gtk_tree_view_get_selection (ctx->meta_treeview); | 829 | GtkTreeSelection *keywords_selection; |
830 | |||
831 | /* FIXME: these can be set by (modern) versions of Glade */ | ||
832 | keywords_selection = gtk_tree_view_get_selection (ctx->keywords_treeview); | ||
833 | meta_selection = gtk_tree_view_get_selection (ctx->meta_treeview); | ||
694 | 834 | ||
695 | g_signal_connect (G_OBJECT (ctx->keywords_selection), "changed", | 835 | g_signal_connect (G_OBJECT (keywords_selection), "changed", |
696 | G_CALLBACK (keywords_selection_changed_cb), ctx); | 836 | G_CALLBACK (keywords_selection_changed_cb), ctx); |
697 | 837 | ||
698 | g_signal_connect (G_OBJECT (ctx->meta_selection), "changed", | 838 | g_signal_connect (G_OBJECT (meta_selection), "changed", |
699 | G_CALLBACK (metadata_selection_changed_cb), ctx); | 839 | G_CALLBACK (metadata_selection_changed_cb), ctx); |
700 | } | 840 | } |
701 | 841 | ||
@@ -705,17 +845,20 @@ GNUNET_GTK_edit_publication_window_realize_cb (GtkWidget *widget, struct EditPub | |||
705 | */ | 845 | */ |
706 | void | 846 | void |
707 | GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | 847 | GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, |
708 | int do_index, const char *short_fn, | 848 | int do_index /* FIXME: not needed? */, |
849 | const char *short_fn, | ||
709 | const struct GNUNET_FS_BlockOptions bo, | 850 | const struct GNUNET_FS_BlockOptions bo, |
710 | struct GNUNET_FS_FileInformation *fip, | 851 | struct GNUNET_FS_FileInformation *fip, |
711 | gboolean allow_no_keywords, | 852 | gboolean allow_no_keywords, |
712 | GtkListStore *anon_liststore, | 853 | GtkListStore *anon_liststore, |
713 | GNUNET_FS_GTK_EditPublishDialogCallback cb, | 854 | GNUNET_FS_GTK_EditPublishDialogCallback cb, |
714 | gpointer cls) | 855 | gpointer cb_cls) |
715 | { | 856 | { |
716 | GtkTreeIter iter; | 857 | GtkTreeIter iter; |
717 | gint code; | 858 | gint code; |
718 | 859 | GtkComboBox *pubtypes_combo; | |
860 | GtkLabel *index_label; | ||
861 | GtkLabel *root_label; | ||
719 | struct EditPublicationDialogContext *ctx; | 862 | struct EditPublicationDialogContext *ctx; |
720 | 863 | ||
721 | ctx = GNUNET_malloc (sizeof (struct EditPublicationDialogContext)); | 864 | ctx = GNUNET_malloc (sizeof (struct EditPublicationDialogContext)); |
@@ -737,59 +880,31 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
737 | ctx->meta_treeview = GTK_TREE_VIEW (gtk_builder_get_object | 880 | ctx->meta_treeview = GTK_TREE_VIEW (gtk_builder_get_object |
738 | (ctx->builder, | 881 | (ctx->builder, |
739 | "GNUNET_GTK_edit_publication_metadata_tree_view")); | 882 | "GNUNET_GTK_edit_publication_metadata_tree_view")); |
740 | ctx->meta_del_button = | ||
741 | GTK_WIDGET (gtk_builder_get_object | ||
742 | (ctx->builder, "GNUNET_GTK_edit_publication_delete_button")); | ||
743 | ctx->keywords_treeview = GTK_TREE_VIEW (gtk_builder_get_object | 883 | ctx->keywords_treeview = GTK_TREE_VIEW (gtk_builder_get_object |
744 | (ctx->builder, | 884 | (ctx->builder, |
745 | "GNUNET_GTK_edit_publication_keyword_list_tree_view")); | 885 | "GNUNET_GTK_edit_publication_keyword_list_tree_view")); |
746 | ctx->keyword_del_button = | 886 | ctx->edit_publication_window = |
747 | GTK_WIDGET (gtk_builder_get_object | 887 | GTK_WINDOW (gtk_builder_get_object (ctx->builder, "GNUNET_GTK_edit_publication_window")); |
748 | (ctx->builder, | ||
749 | "GNUNET_GTK_edit_publication_keyword_list_del_button")); | ||
750 | ctx->meta_add_button = | ||
751 | GTK_BUTTON (gtk_builder_get_object | ||
752 | (ctx->builder, "GNUNET_GTK_edit_publication_add_button")); | ||
753 | ctx->meta_combo = | ||
754 | GTK_CELL_RENDERER_COMBO (gtk_builder_get_object | ||
755 | (ctx->builder, | ||
756 | "GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer")); | ||
757 | ctx->pubwindow = | ||
758 | gtk_builder_get_object (ctx->builder, "GNUNET_GTK_edit_publication_window"); | ||
759 | ctx->keywords_liststore = GTK_LIST_STORE (gtk_builder_get_object | 888 | ctx->keywords_liststore = GTK_LIST_STORE (gtk_builder_get_object |
760 | (ctx->builder, "GNUNET_GTK_publication_keywords_liststore")); | 889 | (ctx->builder, "GNUNET_GTK_publication_keywords_liststore")); |
761 | ctx->keyword_entry = | 890 | ctx->keyword_entry = |
762 | GTK_ENTRY (gtk_builder_get_object | 891 | GTK_ENTRY (gtk_builder_get_object |
763 | (ctx->builder, "GNUNET_GTK_edit_publication_keyword_entry")); | 892 | (ctx->builder, "GNUNET_GTK_edit_publication_keyword_entry")); |
764 | ctx->ok = GTK_WIDGET (gtk_builder_get_object | 893 | ctx->confirm_button = GTK_WIDGET (gtk_builder_get_object |
765 | (ctx->builder, "GNUNET_GTK_edit_publication_confirm_button")); | 894 | (ctx->builder, "GNUNET_GTK_edit_publication_confirm_button")); |
766 | ctx->keyword_add_button = | 895 | ctx->preview_image = |
767 | GTK_WIDGET (gtk_builder_get_object | ||
768 | (ctx->builder, | ||
769 | "GNUNET_GTK_edit_publication_keyword_list_add_button")); | ||
770 | ctx->image = | ||
771 | GTK_IMAGE (gtk_builder_get_object | 896 | GTK_IMAGE (gtk_builder_get_object |
772 | (ctx->builder, | 897 | (ctx->builder, |
773 | "GNUNET_GTK_edit_publication_metadata_preview_image")); | 898 | "GNUNET_GTK_edit_publication_metadata_preview_image")); |
774 | ctx->meta_liststore = GTK_LIST_STORE (gtk_builder_get_object | 899 | ctx->meta_liststore = GTK_LIST_STORE (gtk_builder_get_object |
775 | (ctx->builder, | 900 | (ctx->builder, |
776 | "GNUNET_GTK_publication_metadata_liststore")); | 901 | "GNUNET_GTK_publication_metadata_liststore")); |
777 | ctx->cancel = | ||
778 | GTK_BUTTON (gtk_builder_get_object | ||
779 | (ctx->builder, "GNUNET_GTK_edit_publication_cancel_button")); | ||
780 | 902 | ||
781 | ctx->index_label = GTK_LABEL (gtk_builder_get_object | ||
782 | (ctx->builder, "GNUNET_GTK_edit_publication_index_label")); | ||
783 | ctx->root_entry = GTK_ENTRY (gtk_builder_get_object | 903 | ctx->root_entry = GTK_ENTRY (gtk_builder_get_object |
784 | (ctx->builder, "GNUNET_GTK_edit_publication_root_entry")); | 904 | (ctx->builder, "GNUNET_GTK_edit_publication_root_entry")); |
785 | ctx->root_label = GTK_LABEL (gtk_builder_get_object | ||
786 | (ctx->builder, "GNUNET_GTK_edit_publication_root_label")); | ||
787 | 905 | ||
788 | ctx->pubtypes_combo = | ||
789 | GTK_COMBO_BOX (gtk_builder_get_object | ||
790 | (ctx->builder, "GNUNET_GTK_edit_publication_type_combo")); | ||
791 | 906 | ||
792 | ctx->year_spin = GTK_SPIN_BUTTON | 907 | ctx->expiration_year_spin = GTK_SPIN_BUTTON |
793 | (gtk_builder_get_object | 908 | (gtk_builder_get_object |
794 | (ctx->builder, | 909 | (ctx->builder, |
795 | "GNUNET_GTK_edit_publication_expiration_year_spin_button")); | 910 | "GNUNET_GTK_edit_publication_expiration_year_spin_button")); |
@@ -814,30 +929,36 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
814 | /* indexing does not apply to directories */ | 929 | /* indexing does not apply to directories */ |
815 | gtk_widget_set_visible (GTK_WIDGET (ctx->index_checkbutton), | 930 | gtk_widget_set_visible (GTK_WIDGET (ctx->index_checkbutton), |
816 | !GNUNET_FS_file_information_is_directory (fip)); | 931 | !GNUNET_FS_file_information_is_directory (fip)); |
817 | gtk_widget_set_visible (GTK_WIDGET (ctx->index_label), | 932 | index_label = GTK_LABEL (gtk_builder_get_object |
933 | (ctx->builder, "GNUNET_GTK_edit_publication_index_label")); | ||
934 | gtk_widget_set_visible (GTK_WIDGET (index_label), | ||
818 | !GNUNET_FS_file_information_is_directory (fip)); | 935 | !GNUNET_FS_file_information_is_directory (fip)); |
819 | gtk_widget_set_visible (GTK_WIDGET (ctx->root_entry), | 936 | gtk_widget_set_visible (GTK_WIDGET (ctx->root_entry), |
820 | !allow_no_keywords); | 937 | !allow_no_keywords); |
821 | gtk_widget_set_visible (GTK_WIDGET (ctx->root_label), | 938 | root_label = GTK_LABEL (gtk_builder_get_object |
939 | (ctx->builder, "GNUNET_GTK_edit_publication_root_label")); | ||
940 | gtk_widget_set_visible (GTK_WIDGET (root_label), | ||
822 | !allow_no_keywords); | 941 | !allow_no_keywords); |
823 | 942 | ||
824 | gtk_list_store_clear (ctx->keywords_liststore); | 943 | gtk_list_store_clear (ctx->keywords_liststore); |
825 | gtk_list_store_clear (ctx->meta_liststore); | 944 | gtk_list_store_clear (ctx->meta_liststore); |
826 | 945 | ||
827 | if (NULL != short_fn) | 946 | if (NULL != short_fn) |
828 | gtk_window_set_title (GTK_WINDOW (ctx->pubwindow), short_fn); | 947 | gtk_window_set_title (ctx->edit_publication_window, short_fn); |
829 | else | 948 | else |
830 | gtk_window_set_title (GTK_WINDOW (ctx->pubwindow), _("<unnamed>")); | 949 | gtk_window_set_title (ctx->edit_publication_window, _("<unnamed>")); |
831 | 950 | ||
832 | if (gtk_combo_box_get_active_iter (ctx->pubtypes_combo, &iter)) | 951 | pubtypes_combo = |
952 | GTK_COMBO_BOX (gtk_builder_get_object | ||
953 | (ctx->builder, "GNUNET_GTK_edit_publication_type_combo")); | ||
954 | if (gtk_combo_box_get_active_iter (pubtypes_combo, &iter)) | ||
833 | { | 955 | { |
834 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->pubtypes_liststore), &iter, 0, &code, -1); | 956 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->pubtypes_liststore), &iter, 0, &code, -1); |
835 | change_metatypes (ctx, 0); | 957 | change_metatypes (ctx, 0); |
836 | } | 958 | } |
837 | else | 959 | else |
838 | gtk_combo_box_set_active (ctx->pubtypes_combo, 0); | 960 | gtk_combo_box_set_active (pubtypes_combo, 0); |
839 | 961 | ||
840 | ctx->do_index = do_index; | ||
841 | if (NULL != short_fn) | 962 | if (NULL != short_fn) |
842 | ctx->short_fn = GNUNET_strdup (short_fn); | 963 | ctx->short_fn = GNUNET_strdup (short_fn); |
843 | ctx->bo = bo; | 964 | ctx->bo = bo; |
@@ -846,14 +967,14 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
846 | ctx->allow_no_keywords = allow_no_keywords; | 967 | ctx->allow_no_keywords = allow_no_keywords; |
847 | ctx->is_directory = GNUNET_FS_file_information_is_directory (fip); | 968 | ctx->is_directory = GNUNET_FS_file_information_is_directory (fip); |
848 | ctx->cb = cb; | 969 | ctx->cb = cb; |
849 | ctx->cls = cls; | 970 | ctx->cb_cls = cb_cls; |
850 | 971 | ||
851 | GNUNET_FS_file_information_inspect (fip, &file_information_extract, ctx); | 972 | GNUNET_FS_file_information_inspect (fip, &file_information_extract, ctx); |
852 | 973 | ||
853 | gtk_entry_set_text (ctx->keyword_entry, ""); | 974 | gtk_entry_set_text (ctx->keyword_entry, ""); |
854 | gtk_widget_set_sensitive (ctx->ok, allow_no_keywords ? TRUE : FALSE); | 975 | gtk_widget_set_sensitive (ctx->confirm_button, allow_no_keywords ? TRUE : FALSE); |
855 | gtk_window_set_transient_for (GTK_WINDOW (ctx->pubwindow), parent); | 976 | gtk_window_set_transient_for (ctx->edit_publication_window, parent); |
856 | gtk_window_present (GTK_WINDOW (ctx->pubwindow)); | 977 | gtk_window_present (ctx->edit_publication_window); |
857 | } | 978 | } |
858 | 979 | ||
859 | 980 | ||