aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk_event-handler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk_event-handler.c')
-rw-r--r--src/fs/gnunet-fs-gtk_event-handler.c96
1 files changed, 63 insertions, 33 deletions
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c
index 43ff0844..ab1fea71 100644
--- a/src/fs/gnunet-fs-gtk_event-handler.c
+++ b/src/fs/gnunet-fs-gtk_event-handler.c
@@ -206,13 +206,17 @@ get_suggested_filename_anonymity (GtkTreeModel *tm,
206 gtk_tree_model_get (tm, iter, 0, &meta, 206 gtk_tree_model_get (tm, iter, 0, &meta,
207 15, &local_filename, 207 15, &local_filename,
208 16, &downloaded_anonymity, 208 16, &downloaded_anonymity,
209 -1); 209 -1);
210 if ( (NULL != local_filename) && (GNUNET_YES == top) ) 210 if (GNUNET_NO == top)
211 *local_parents = GNUNET_YES; 211 {
212 if ( (NULL == local_filename) && (GNUNET_NO == top) ) 212 if (NULL != local_filename)
213 *local_parents = GNUNET_NO; 213 *local_parents = GNUNET_YES;
214 if ( (downloaded_anonymity != -1) && (*anonymity == -1) && (GNUNET_NO == top) ) 214 else
215 *anonymity = downloaded_anonymity; 215 *local_parents = GNUNET_NO;
216 if ( (downloaded_anonymity != -1) &&
217 (*anonymity == -1) )
218 *anonymity = downloaded_anonymity;
219 }
216 if (gtk_tree_model_iter_parent (tm, &parent, iter)) 220 if (gtk_tree_model_iter_parent (tm, &parent, iter))
217 { 221 {
218 have_a_parent = GNUNET_YES; 222 have_a_parent = GNUNET_YES;
@@ -224,8 +228,6 @@ get_suggested_filename_anonymity (GtkTreeModel *tm,
224 { 228 {
225 have_a_parent = GNUNET_NO; 229 have_a_parent = GNUNET_NO;
226 dirname = NULL; 230 dirname = NULL;
227 if (GNUNET_NO == top)
228 *local_parents = GNUNET_NO;
229 } 231 }
230 if (local_filename == NULL) 232 if (local_filename == NULL)
231 { 233 {
@@ -242,7 +244,7 @@ get_suggested_filename_anonymity (GtkTreeModel *tm,
242 */ 244 */
243 if ( (NULL == dirname) && (GNUNET_NO == have_a_parent)) 245 if ( (NULL == dirname) && (GNUNET_NO == have_a_parent))
244 { 246 {
245 /* This is the ealderlest parent directory. Use absolute path. */ 247 /* This is the root. Use absolute path. */
246 basename = (const char *) local_filename; 248 basename = (const char *) local_filename;
247 *filename_is_absolute = GNUNET_YES; 249 *filename_is_absolute = GNUNET_YES;
248 } 250 }
@@ -284,12 +286,14 @@ get_suggested_filename_anonymity (GtkTreeModel *tm,
284 * @param path path selecting which entry we want to download 286 * @param path path selecting which entry we want to download
285 * @param tab the search tab where the user triggered the download request 287 * @param tab the search tab where the user triggered the download request
286 * @param is_recursive was the request for a recursive download? 288 * @param is_recursive was the request for a recursive download?
289 * @param save_as force opening the 'save as' dialog?
287 */ 290 */
288static void 291static void
289start_download (GtkTreeView *tree_view, 292start_download (GtkTreeView *tree_view,
290 GtkTreePath *path, 293 GtkTreePath *path,
291 struct SearchTab *tab, 294 struct SearchTab *tab,
292 int is_recursive) 295 int is_recursive,
296 int save_as)
293{ 297{
294 GtkTreeModel *tm; 298 GtkTreeModel *tm;
295 GtkTreeIter iter; 299 GtkTreeIter iter;
@@ -396,10 +400,13 @@ start_download (GtkTreeView *tree_view,
396 de->anonymity = anonymity; 400 de->anonymity = anonymity;
397 de->is_recursive = is_recursive; 401 de->is_recursive = is_recursive;
398 de->is_directory = GNUNET_FS_meta_data_test_for_directory (meta); 402 de->is_directory = GNUNET_FS_meta_data_test_for_directory (meta);
403 if (save_as)
404 have_a_suggestion = GNUNET_NO;
399 fprintf (stderr, 405 fprintf (stderr,
400 "lp %d, have-sug: %d\n", 406 "lp %d, have-sug: %d\n",
401 local_parents, 407 local_parents,
402 have_a_suggestion); 408 have_a_suggestion);
409
403 if ( (GNUNET_YES == local_parents) && 410 if ( (GNUNET_YES == local_parents) &&
404 (GNUNET_YES == have_a_suggestion) ) 411 (GNUNET_YES == have_a_suggestion) )
405 /* Skip the dialog, call directly */ 412 /* Skip the dialog, call directly */
@@ -444,18 +451,19 @@ GNUNET_FS_GTK_search_treeview_row_activated (GtkTreeView * tree_view,
444{ 451{
445 struct SearchTab *tab = user_data; 452 struct SearchTab *tab = user_data;
446 453
447 start_download (tree_view, path, tab, GNUNET_NO); 454 start_download (tree_view, path, tab, GNUNET_NO, GNUNET_NO);
448} 455}
449 456
450 457
451/** 458/**
452 * "Download" was selected in the current search context menu. 459 * "Download" was selected in the current search context menu.
453 * 460 *
454 * @param item the 'download' menu item 461 * @param is_recursive was this the 'recursive' option?
455 * @parma user_data the 'struct DownloadEntry' to download. 462 * @parma save_as was this the 'save as' option?
456 */ 463 */
457static void 464static void
458start_download_ctx_menu (GtkMenuItem *item, gpointer user_data) 465start_download_ctx_menu_helper (int is_recursive,
466 int save_as)
459{ 467{
460 GtkTreePath *path; 468 GtkTreePath *path;
461 GtkTreeView *tv; 469 GtkTreeView *tv;
@@ -471,38 +479,50 @@ start_download_ctx_menu (GtkMenuItem *item, gpointer user_data)
471 tv = GTK_TREE_VIEW (gtk_builder_get_object 479 tv = GTK_TREE_VIEW (gtk_builder_get_object
472 (current_context_search_tab->builder, 480 (current_context_search_tab->builder,
473 "_search_result_frame")); 481 "_search_result_frame"));
474 start_download (tv, path, current_context_search_tab, GNUNET_NO); 482 start_download (tv, path, current_context_search_tab,
483 is_recursive,
484 save_as);
475 gtk_tree_path_free (path); 485 gtk_tree_path_free (path);
476 current_context_search_tab = NULL; 486 current_context_search_tab = NULL;
477} 487}
478 488
479 489
480/** 490/**
491 * "Download" was selected in the current search context menu.
492 *
493 * @param item the 'download' menu item
494 * @parma user_data FIXME
495 */
496static void
497start_download_ctx_menu (GtkMenuItem *item, gpointer user_data)
498{
499 start_download_ctx_menu_helper (GNUNET_NO, GNUNET_NO);
500}
501
502
503/**
481 * "Download recursively" was selected in the current search context menu. 504 * "Download recursively" was selected in the current search context menu.
482 * 505 *
483 * @param item the 'download recursively' menu item 506 * @param item the 'download recursively' menu item
484 * @parma user_data the 'struct DownloadEntry' to download. 507 * @parma user_data FIXME
485 */ 508 */
486static void 509static void
487start_download_recursively_ctx_menu (GtkMenuItem *item, gpointer user_data) 510start_download_recursively_ctx_menu (GtkMenuItem *item, gpointer user_data)
488{ 511{
489 GtkTreePath *path; 512 start_download_ctx_menu_helper (GNUNET_YES, GNUNET_NO);
490 GtkTreeView *tv; 513}
491 514
492 if (current_context_row_reference == NULL) 515
493 { 516/**
494 GNUNET_break (0); 517 * "Download as..." was selected in the current search context menu.
495 return; 518 *
496 } 519 * @param item the 'download as...' menu item
497 path = gtk_tree_row_reference_get_path (current_context_row_reference); 520 * @parma user_data FIXME
498 gtk_tree_row_reference_free (current_context_row_reference); 521 */
499 current_context_row_reference = NULL; 522static void
500 tv = GTK_TREE_VIEW (gtk_builder_get_object 523start_download_as_ctx_menu (GtkMenuItem *item, gpointer user_data)
501 (current_context_search_tab->builder, 524{
502 "_search_result_frame")); 525 start_download_ctx_menu_helper (GNUNET_NO, GNUNET_YES);
503 start_download (tv, path, current_context_search_tab, GNUNET_YES);
504 gtk_tree_path_free (path);
505 current_context_search_tab = NULL;
506} 526}
507 527
508 528
@@ -643,6 +663,16 @@ search_list_popup (GtkTreeModel *tm,
643 TRUE); 663 TRUE);
644 gtk_widget_show (child); 664 gtk_widget_show (child);
645 gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); 665 gtk_menu_shell_append (GTK_MENU_SHELL (menu), child);
666
667
668 child = gtk_menu_item_new_with_label (_("Download _as..."));
669 g_signal_connect (child, "activate",
670 G_CALLBACK (start_download_as_ctx_menu), NULL);
671 gtk_label_set_use_underline (GTK_LABEL
672 (gtk_bin_get_child (GTK_BIN (child))),
673 TRUE);
674 gtk_widget_show (child);
675 gtk_menu_shell_append (GTK_MENU_SHELL (menu), child);
646 } 676 }
647 if ( (NULL != sr->download) && 677 if ( (NULL != sr->download) &&
648 (GNUNET_YES != sr->download->is_done) ) 678 (GNUNET_YES != sr->download->is_done) )