diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-01 20:00:19 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-01 20:00:19 +0000 |
commit | d4958e4bf956c66dcc43e680b6b28f7fdc0cc003 (patch) | |
tree | 183b60e3c7d7a2a01cf8f79d65c465abc0d44031 | |
parent | e6a86d7a1bdb8b8772552431e4f078706704ef5c (diff) | |
download | gnunet-gtk-d4958e4bf956c66dcc43e680b6b28f7fdc0cc003.tar.gz gnunet-gtk-d4958e4bf956c66dcc43e680b6b28f7fdc0cc003.zip |
-LRN: Add download+recursive/abort context menu items
-rw-r--r-- | src/fs/gnunet-fs-gtk-download.c | 2 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk-event_handler.c | 44 |
2 files changed, 42 insertions, 4 deletions
diff --git a/src/fs/gnunet-fs-gtk-download.c b/src/fs/gnunet-fs-gtk-download.c index 05a5ae95..45dee718 100644 --- a/src/fs/gnunet-fs-gtk-download.c +++ b/src/fs/gnunet-fs-gtk-download.c | |||
@@ -175,6 +175,8 @@ GNUNET_FS_GTK_open_download_as_dialog (struct DownloadContext *dc) | |||
175 | (builder, "GNUNET_GTK_save_as_recursive_check_button")); | 175 | (builder, "GNUNET_GTK_save_as_recursive_check_button")); |
176 | if (GNUNET_FS_meta_data_test_for_directory (dc->meta)) | 176 | if (GNUNET_FS_meta_data_test_for_directory (dc->meta)) |
177 | gtk_widget_set_sensitive (cb, TRUE); | 177 | gtk_widget_set_sensitive (cb, TRUE); |
178 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), dc->is_recursive); | ||
179 | |||
178 | ad = GTK_WIDGET (gtk_builder_get_object | 180 | ad = GTK_WIDGET (gtk_builder_get_object |
179 | (builder, "GNUNET_GTK_save_as_dialog")); | 181 | (builder, "GNUNET_GTK_save_as_dialog")); |
180 | if (dc->filename != NULL) | 182 | if (dc->filename != NULL) |
diff --git a/src/fs/gnunet-fs-gtk-event_handler.c b/src/fs/gnunet-fs-gtk-event_handler.c index 83bfcb50..b20fb8a2 100644 --- a/src/fs/gnunet-fs-gtk-event_handler.c +++ b/src/fs/gnunet-fs-gtk-event_handler.c | |||
@@ -617,7 +617,7 @@ setup_download (struct DownloadEntry *de, struct DownloadEntry *pde, | |||
617 | */ | 617 | */ |
618 | static void | 618 | static void |
619 | start_download (GtkTreeView * tree_view, GtkTreePath * path, | 619 | start_download (GtkTreeView * tree_view, GtkTreePath * path, |
620 | GtkTreeViewColumn * column, gpointer user_data) | 620 | GtkTreeViewColumn * column, gboolean recursive, gpointer user_data) |
621 | { | 621 | { |
622 | struct SearchTab *tab = user_data; | 622 | struct SearchTab *tab = user_data; |
623 | GtkTreeModel *tm; | 623 | GtkTreeModel *tm; |
@@ -697,6 +697,7 @@ start_download (GtkTreeView * tree_view, GtkTreePath * path, | |||
697 | dlc->rr = gtk_tree_row_reference_new (tm, path); | 697 | dlc->rr = gtk_tree_row_reference_new (tm, path); |
698 | dlc->sr = sr->result; | 698 | dlc->sr = sr->result; |
699 | dlc->anonymity = -1; | 699 | dlc->anonymity = -1; |
700 | dlc->is_recursive = recursive; | ||
700 | GNUNET_FS_GTK_open_download_as_dialog (dlc); | 701 | GNUNET_FS_GTK_open_download_as_dialog (dlc); |
701 | g_free (mime); | 702 | g_free (mime); |
702 | } | 703 | } |
@@ -714,7 +715,7 @@ static GtkTreeRowReference *current_context_row_reference; | |||
714 | static struct SearchTab *current_context_search_tab; | 715 | static struct SearchTab *current_context_search_tab; |
715 | 716 | ||
716 | /** | 717 | /** |
717 | * Download was selected in the current search context menu. | 718 | * "Download" was selected in the current search context menu. |
718 | */ | 719 | */ |
719 | static void | 720 | static void |
720 | start_download_ctx_menu (gpointer user_data, guint unused, GtkWidget * widget) | 721 | start_download_ctx_menu (gpointer user_data, guint unused, GtkWidget * widget) |
@@ -733,7 +734,32 @@ start_download_ctx_menu (gpointer user_data, guint unused, GtkWidget * widget) | |||
733 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 734 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
734 | (current_context_search_tab->builder, | 735 | (current_context_search_tab->builder, |
735 | "_search_result_frame")); | 736 | "_search_result_frame")); |
736 | start_download (tv, path, NULL, current_context_search_tab); | 737 | start_download (tv, path, NULL, FALSE, current_context_search_tab); |
738 | gtk_tree_path_free (path); | ||
739 | current_context_search_tab = NULL; | ||
740 | } | ||
741 | |||
742 | /** | ||
743 | * "Download recursively" was selected in the current search context menu. | ||
744 | */ | ||
745 | static void | ||
746 | start_download_recursively_ctx_menu (gpointer user_data, guint unused, GtkWidget * widget) | ||
747 | { | ||
748 | GtkTreePath *path; | ||
749 | GtkTreeView *tv; | ||
750 | |||
751 | if (current_context_row_reference == NULL) | ||
752 | { | ||
753 | GNUNET_break (0); | ||
754 | return; | ||
755 | } | ||
756 | path = gtk_tree_row_reference_get_path (current_context_row_reference); | ||
757 | gtk_tree_row_reference_free (current_context_row_reference); | ||
758 | current_context_row_reference = NULL; | ||
759 | tv = GTK_TREE_VIEW (gtk_builder_get_object | ||
760 | (current_context_search_tab->builder, | ||
761 | "_search_result_frame")); | ||
762 | start_download (tv, path, NULL, TRUE, current_context_search_tab); | ||
737 | gtk_tree_path_free (path); | 763 | gtk_tree_path_free (path); |
738 | current_context_search_tab = NULL; | 764 | current_context_search_tab = NULL; |
739 | } | 765 | } |
@@ -869,6 +895,16 @@ search_list_on_menu (GtkWidget * widget, GdkEvent * event, gpointer user_data) | |||
869 | (gtk_bin_get_child (GTK_BIN (child))), | 895 | (gtk_bin_get_child (GTK_BIN (child))), |
870 | TRUE); | 896 | TRUE); |
871 | gtk_widget_show (child); | 897 | gtk_widget_show (child); |
898 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | ||
899 | |||
900 | child = gtk_menu_item_new_with_label (_("Download _recursively")); | ||
901 | g_signal_connect (child, "activate", | ||
902 | G_CALLBACK (start_download_recursively_ctx_menu), NULL); | ||
903 | gtk_label_set_use_underline (GTK_LABEL | ||
904 | (gtk_bin_get_child (GTK_BIN (child))), | ||
905 | TRUE); | ||
906 | gtk_widget_show (child); | ||
907 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | ||
872 | } | 908 | } |
873 | else | 909 | else |
874 | { | 910 | { |
@@ -879,7 +915,7 @@ search_list_on_menu (GtkWidget * widget, GdkEvent * event, gpointer user_data) | |||
879 | (gtk_bin_get_child (GTK_BIN (child))), | 915 | (gtk_bin_get_child (GTK_BIN (child))), |
880 | TRUE); | 916 | TRUE); |
881 | gtk_widget_show (child); | 917 | gtk_widget_show (child); |
882 | 918 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | |
883 | } | 919 | } |
884 | 920 | ||
885 | child = gtk_menu_item_new_with_label (_("_Copy URI to Clipboard")); | 921 | child = gtk_menu_item_new_with_label (_("_Copy URI to Clipboard")); |