aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk-main_window_open_directory.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk-main_window_open_directory.c')
-rw-r--r--src/fs/gnunet-fs-gtk-main_window_open_directory.c50
1 files changed, 35 insertions, 15 deletions
diff --git a/src/fs/gnunet-fs-gtk-main_window_open_directory.c b/src/fs/gnunet-fs-gtk-main_window_open_directory.c
index ae3b7d0b..23e71fc6 100644
--- a/src/fs/gnunet-fs-gtk-main_window_open_directory.c
+++ b/src/fs/gnunet-fs-gtk-main_window_open_directory.c
@@ -85,6 +85,34 @@ add_child (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri,
85 meta, NULL, 0)); 85 meta, NULL, 0));
86} 86}
87 87
88void
89GNUNET_GTK_open_directory_dialog_response_cb (GtkDialog *dialog,
90 gint response_id, gpointer user_data)
91{
92 GtkBuilder *builder;
93 GtkWidget *ad;
94 char *filename;
95 struct AddChildContext acc;
96
97 builder = GTK_BUILDER (user_data);
98 ad = GTK_WIDGET (gtk_builder_get_object
99 (builder, "GNUNET_GTK_open_directory_dialog"));
100
101 if (response_id != -5)
102 {
103 gtk_widget_destroy (ad);
104 g_object_unref (G_OBJECT (builder));
105 return;
106 }
107
108 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad));
109 gtk_widget_destroy (ad);
110 g_object_unref (G_OBJECT (builder));
111 acc.filename = filename;
112 acc.ts = NULL;
113 GNUNET_FS_GTK_mmap_and_scan (filename, &add_child, &acc);
114 g_free (filename);
115}
88 116
89/** 117/**
90 * User selected "Open directory" in menu. Display dialog, open 118 * User selected "Open directory" in menu. Display dialog, open
@@ -94,12 +122,12 @@ void
94GNUNET_GTK_main_menu_file_open_gnunet_directory_activate_cb (GtkWidget * dummy, 122GNUNET_GTK_main_menu_file_open_gnunet_directory_activate_cb (GtkWidget * dummy,
95 gpointer data) 123 gpointer data)
96{ 124{
97 struct AddChildContext acc;
98 GtkWidget *ad; 125 GtkWidget *ad;
99 GtkBuilder *builder; 126 GtkBuilder *builder;
100 char *filename; 127 GtkWidget *toplevel;
101 GtkFileFilter *ff; 128 GtkFileFilter *ff;
102 129
130
103 builder = 131 builder =
104 GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_open_directory_dialog.glade"); 132 GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_open_directory_dialog.glade");
105 if (builder == NULL) 133 if (builder == NULL)
@@ -113,19 +141,11 @@ GNUNET_GTK_main_menu_file_open_gnunet_directory_activate_cb (GtkWidget * dummy,
113 (builder, "gnunet_directory_filter")); 141 (builder, "gnunet_directory_filter"));
114 /* FIXME: some day, write a custom file filter for gnunet-directories... */ 142 /* FIXME: some day, write a custom file filter for gnunet-directories... */
115 gtk_file_filter_add_pattern (ff, "*" GNUNET_FS_DIRECTORY_EXT); 143 gtk_file_filter_add_pattern (ff, "*" GNUNET_FS_DIRECTORY_EXT);
116 if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) 144
117 { 145 toplevel = gtk_widget_get_toplevel (dummy);
118 gtk_widget_destroy (ad); 146 if (GTK_IS_WINDOW (toplevel))
119 g_object_unref (G_OBJECT (builder)); 147 gtk_window_set_transient_for (GTK_WINDOW (ad), GTK_WINDOW (toplevel));
120 return; 148 gtk_window_present (GTK_WINDOW (ad));
121 }
122 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad));
123 gtk_widget_destroy (ad);
124 g_object_unref (G_OBJECT (builder));
125 acc.filename = filename;
126 acc.ts = NULL;
127 GNUNET_FS_GTK_mmap_and_scan (filename, &add_child, &acc);
128 g_free (filename);
129} 149}
130 150
131/* end of gnunet-fs-gtk-main_window_open_directory.c */ 151/* end of gnunet-fs-gtk-main_window_open_directory.c */