aboutsummaryrefslogtreecommitdiff
path: root/src/main_window_open_directory.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main_window_open_directory.c')
-rw-r--r--src/main_window_open_directory.c147
1 files changed, 0 insertions, 147 deletions
diff --git a/src/main_window_open_directory.c b/src/main_window_open_directory.c
deleted file mode 100644
index d9d90cff..00000000
--- a/src/main_window_open_directory.c
+++ /dev/null
@@ -1,147 +0,0 @@
1/*
2 This file is part of GNUnet
3 (C) 2005, 2006, 2010 Christian Grothoff (and other contributing authors)
4
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
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/main_window_open_directory.c
23 * @author Christian Grothoff
24 */
25#include "common.h"
26#include "fs_event_handler.h"
27
28struct AddChildContext
29{
30 const char *filename;
31 GtkTreeStore *ts;
32 struct SearchTab *tab;
33 struct SearchResult *par;
34 GtkTreeRowReference *prr;
35 GtkTreeIter iter;
36};
37
38
39/**
40 * Function used to process entries in a directory.
41 *
42 * @param cls closure, our 'struct AddChildContext*'
43 * @param filename name of the file in the directory
44 * @param uri URI of the file
45 * @param metadata metadata for the file; metadata for
46 * the directory if everything else is NULL/zero
47 * @param length length of the available data for the file
48 * (of type size_t since data must certainly fit
49 * into memory; if files are larger than size_t
50 * permits, then they will certainly not be
51 * embedded with the directory itself).
52 * @param data data available for the file (length bytes)
53 */
54static void
55add_child (void *cls,
56 const char *filename,
57 const struct GNUNET_FS_Uri *uri,
58 const struct GNUNET_CONTAINER_MetaData *meta,
59 size_t length,
60 const void *data)
61{
62 struct AddChildContext *acc = cls;
63 struct GNUNET_CONTAINER_MetaData *dmeta;
64 GtkTreePath *tp;
65 GtkTreeIter iter;
66
67 if (uri == NULL)
68 {
69 /* directory meta data itself */
70 dmeta = GNUNET_CONTAINER_meta_data_duplicate (meta);
71 GNUNET_CONTAINER_meta_data_insert (dmeta,
72 "<user>",
73 EXTRACTOR_METATYPE_FILENAME,
74 EXTRACTOR_METAFORMAT_C_STRING,
75 "text/plain",
76 acc->filename,
77 strlen (acc->filename) + 1);
78 acc->tab = GNUNET_GTK_add_to_uri_tab (&acc->iter,
79 &acc->par,
80 dmeta,
81 NULL);
82 tp = gtk_tree_model_get_path (GTK_TREE_MODEL (acc->tab->ts),
83 &acc->iter);
84 acc->prr = gtk_tree_row_reference_new (GTK_TREE_MODEL (acc->tab->ts),
85 tp);
86 gtk_tree_path_free (tp);
87 acc->ts = acc->tab->ts;
88 GNUNET_CONTAINER_meta_data_destroy (dmeta);
89 return;
90 }
91 if (acc->ts == NULL)
92 return;
93 GNUNET_assert (NULL !=
94 GNUNET_GTK_add_search_result (acc->tab,
95 &iter,
96 acc->prr,
97 uri,
98 meta,
99 NULL,
100 0));
101}
102
103
104/**
105 * User selected "Open directory" in menu. Display dialog, open
106 * file and then display a new tab with its contents.
107 */
108void
109GNUNET_GTK_main_menu_file_open_gnunet_directory_activate_cb (GtkWidget * dummy,
110 gpointer data)
111{
112 struct AddChildContext acc;
113 GtkWidget *ad;
114 GtkBuilder *builder;
115 char *filename;
116 GtkFileFilter *ff;
117
118 builder = GNUNET_GTK_get_new_builder ("open_directory_dialog.glade");
119 if (builder == NULL)
120 {
121 GNUNET_break (0);
122 return;
123 }
124 ad = GTK_WIDGET (gtk_builder_get_object (builder,
125 "GNUNET_GTK_open_directory_dialog"));
126 ff = GTK_FILE_FILTER (gtk_builder_get_object (builder,
127 "gnunet_directory_filter"));
128 /* FIXME: some day, write a custom file filter for gnunet-directories... */
129 gtk_file_filter_add_pattern (ff, "*" GNUNET_FS_DIRECTORY_EXT);
130 if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad)))
131 {
132 gtk_widget_destroy (ad);
133 g_object_unref (G_OBJECT (builder));
134 return;
135 }
136 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad));
137 gtk_widget_destroy (ad);
138 g_object_unref (G_OBJECT (builder));
139 acc.filename = filename;
140 acc.ts = NULL;
141 GNUNET_GTK_mmap_and_scan (filename,
142 &add_child,
143 &acc);
144 g_free (filename);
145}
146
147/* end of main_window_open_directory.c */