diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk-event_handler.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk-event_handler.c | 60 |
1 files changed, 55 insertions, 5 deletions
diff --git a/src/fs/gnunet-fs-gtk-event_handler.c b/src/fs/gnunet-fs-gtk-event_handler.c index 272c9b1d..83bfcb50 100644 --- a/src/fs/gnunet-fs-gtk-event_handler.c +++ b/src/fs/gnunet-fs-gtk-event_handler.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2010 Christian Grothoff (and other contributing authors) | 3 | (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -627,6 +627,11 @@ start_download (GtkTreeView * tree_view, GtkTreePath * path, | |||
627 | struct SearchResult *sr; | 627 | struct SearchResult *sr; |
628 | gchar *mime; | 628 | gchar *mime; |
629 | struct DownloadContext *dlc; | 629 | struct DownloadContext *dlc; |
630 | char *buf; | ||
631 | char *tmp; | ||
632 | size_t tmplen; | ||
633 | char cwd[FILENAME_MAX]; | ||
634 | char *filename; | ||
630 | 635 | ||
631 | GNUNET_assert (tab != NULL); | 636 | GNUNET_assert (tab != NULL); |
632 | tm = gtk_tree_view_get_model (tree_view); | 637 | tm = gtk_tree_view_get_model (tree_view); |
@@ -642,10 +647,52 @@ start_download (GtkTreeView * tree_view, GtkTreePath * path, | |||
642 | g_free (mime); | 647 | g_free (mime); |
643 | return; | 648 | return; |
644 | } | 649 | } |
650 | |||
651 | |||
652 | /* FIXME: we should check if this download is a file in some directory | ||
653 | (gtk_tree_model_iter_get_parent) and if so obtain the name under which | ||
654 | the directory was stored! */ | ||
655 | /* Calculate suggested filename; first, pre-pend current working directory */ | ||
656 | filename = GNUNET_FS_meta_data_suggest_filename (meta); | ||
657 | if (NULL != getcwd (cwd, sizeof (cwd))) | ||
658 | { | ||
659 | if (NULL == filename) | ||
660 | { | ||
661 | buf = GNUNET_strdup (cwd); | ||
662 | } | ||
663 | else | ||
664 | { | ||
665 | GNUNET_asprintf (&tmp, "%s%s%s", | ||
666 | cwd, | ||
667 | DIR_SEPARATOR_STR, | ||
668 | filename); | ||
669 | tmplen = strlen (tmp); | ||
670 | /* now, if we have a directory, replace trailing '/' with ".gnd" */ | ||
671 | if (GNUNET_YES == | ||
672 | GNUNET_FS_meta_data_test_for_directory (meta)) | ||
673 | { | ||
674 | if ( (tmp[tmplen-1] == '/') || | ||
675 | (tmp[tmplen-1] == '\\') ) | ||
676 | tmp[tmplen-1] = '\0'; | ||
677 | GNUNET_asprintf (&buf, | ||
678 | "%s%s", | ||
679 | tmp, | ||
680 | GNUNET_FS_DIRECTORY_EXT); | ||
681 | GNUNET_free (tmp); | ||
682 | } | ||
683 | else | ||
684 | { | ||
685 | buf = tmp; | ||
686 | } | ||
687 | } | ||
688 | } | ||
689 | GNUNET_free_non_null (filename); | ||
690 | |||
691 | /* now setup everything for the save-as dialog */ | ||
645 | dlc = GNUNET_malloc (sizeof (struct DownloadContext)); | 692 | dlc = GNUNET_malloc (sizeof (struct DownloadContext)); |
646 | dlc->uri = GNUNET_FS_uri_dup (uri); | 693 | dlc->uri = GNUNET_FS_uri_dup (uri); |
647 | dlc->mime = (NULL != mime) ? GNUNET_strdup (mime) : NULL; | 694 | dlc->mime = (NULL != mime) ? GNUNET_strdup (mime) : NULL; |
648 | dlc->filename = GNUNET_FS_meta_data_suggest_filename (meta); | 695 | dlc->filename = buf; |
649 | dlc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); | 696 | dlc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); |
650 | dlc->rr = gtk_tree_row_reference_new (tm, path); | 697 | dlc->rr = gtk_tree_row_reference_new (tm, path); |
651 | dlc->sr = sr->result; | 698 | dlc->sr = sr->result; |
@@ -1129,7 +1176,8 @@ setup_search (struct GNUNET_FS_SearchContext *sc, | |||
1129 | else | 1176 | else |
1130 | tab->query_txt = GNUNET_FS_uri_to_string (query); | 1177 | tab->query_txt = GNUNET_FS_uri_to_string (query); |
1131 | } | 1178 | } |
1132 | tab->builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_search_tab.glade"); | 1179 | tab->builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_search_tab.glade", |
1180 | tab); | ||
1133 | tab->ts = | 1181 | tab->ts = |
1134 | GTK_TREE_STORE (gtk_builder_get_object | 1182 | GTK_TREE_STORE (gtk_builder_get_object |
1135 | (tab->builder, | 1183 | (tab->builder, |
@@ -1154,7 +1202,7 @@ setup_search (struct GNUNET_FS_SearchContext *sc, | |||
1154 | tab->label = | 1202 | tab->label = |
1155 | GTK_LABEL (gtk_builder_get_object | 1203 | GTK_LABEL (gtk_builder_get_object |
1156 | (tab->builder, "_search_result_label_window_label")); | 1204 | (tab->builder, "_search_result_label_window_label")); |
1157 | 1205 | /* FIXME: connect these signals using glade!!! */ | |
1158 | tab->close_button = | 1206 | tab->close_button = |
1159 | GTK_WIDGET (gtk_builder_get_object | 1207 | GTK_WIDGET (gtk_builder_get_object |
1160 | (tab->builder, "_search_result_label_close_button")); | 1208 | (tab->builder, "_search_result_label_close_button")); |
@@ -1660,7 +1708,8 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | |||
1660 | /* create new tab */ | 1708 | /* create new tab */ |
1661 | publish_tab = GNUNET_malloc (sizeof (struct PublishTab)); | 1709 | publish_tab = GNUNET_malloc (sizeof (struct PublishTab)); |
1662 | publish_tab->builder = | 1710 | publish_tab->builder = |
1663 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_tab.glade"); | 1711 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_tab.glade", |
1712 | publish_tab); | ||
1664 | df = GTK_WINDOW (gtk_builder_get_object | 1713 | df = GTK_WINDOW (gtk_builder_get_object |
1665 | (publish_tab->builder, "_publish_frame_window")); | 1714 | (publish_tab->builder, "_publish_frame_window")); |
1666 | publish_tab->frame = gtk_bin_get_child (GTK_BIN (df)); | 1715 | publish_tab->frame = gtk_bin_get_child (GTK_BIN (df)); |
@@ -1676,6 +1725,7 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | |||
1676 | gtk_container_remove (GTK_CONTAINER (df), tab_label); | 1725 | gtk_container_remove (GTK_CONTAINER (df), tab_label); |
1677 | gtk_widget_destroy (GTK_WIDGET (df)); | 1726 | gtk_widget_destroy (GTK_WIDGET (df)); |
1678 | 1727 | ||
1728 | /* FIXME: connect these signals using GLADE!!! */ | ||
1679 | /* get refs to widgets */ | 1729 | /* get refs to widgets */ |
1680 | close_button = | 1730 | close_button = |
1681 | GTK_WIDGET (gtk_builder_get_object | 1731 | GTK_WIDGET (gtk_builder_get_object |