aboutsummaryrefslogtreecommitdiff
path: root/src/gns/gnunet-gns-gtk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns/gnunet-gns-gtk.c')
-rw-r--r--src/gns/gnunet-gns-gtk.c86
1 files changed, 48 insertions, 38 deletions
diff --git a/src/gns/gnunet-gns-gtk.c b/src/gns/gnunet-gns-gtk.c
index a9c451f0..4751f24a 100644
--- a/src/gns/gnunet-gns-gtk.c
+++ b/src/gns/gnunet-gns-gtk.c
@@ -61,7 +61,7 @@ static char *zone_as_string;
61 */ 61 */
62static char *zonefile_directory; 62static char *zonefile_directory;
63 63
64GtkWidget *main_window; 64static GtkWidget *main_window;
65 65
66/** 66/**
67 * Get cfg. 67 * Get cfg.
@@ -129,6 +129,38 @@ GNUNET_GNS_GTK_new_imagemenuitem_activate_cb (GtkMenuItem *menuitem,
129 GNUNET_break (0); // FIXME, not implemented 129 GNUNET_break (0); // FIXME, not implemented
130} 130}
131 131
132
133/**
134 * Function called from the open-directory dialog upon completion.
135 *
136 * @param dialog the pseudonym selection dialog
137 * @param response_id response code from the dialog
138 * @param user_data the builder of the dialog
139 */
140void
141GNUNET_GNS_GTK_zone_open_dialog_response_cb (GtkDialog * dialog,
142 gint response_id,
143 gpointer user_data)
144{
145 GtkBuilder *builder = user_data;
146 char *filename;
147
148 if (GTK_RESPONSE_OK != response_id)
149 {
150 gtk_widget_destroy (GTK_WIDGET (dialog));
151 g_object_unref (G_OBJECT (builder));
152 return;
153 }
154 filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog));
155 gtk_widget_destroy (GTK_WIDGET (dialog));
156 g_object_unref (G_OBJECT (builder));
157
158 /* FIXME: move to new zone 'filename' */
159 fprintf (stderr, "Got zone `%s'\n", filename);
160 GNUNET_free (filename);
161}
162
163
132/** 164/**
133 * The user selected 'OPEN' in the menu. Open a dialog to select 165 * The user selected 'OPEN' in the menu. Open a dialog to select
134 * a different zonefile (for editing). 166 * a different zonefile (for editing).
@@ -140,45 +172,23 @@ void
140GNUNET_GNS_GTK_open_imagemenuitem_activate_cb (GtkMenuItem *menuitem, 172GNUNET_GNS_GTK_open_imagemenuitem_activate_cb (GtkMenuItem *menuitem,
141 gpointer user_data) 173 gpointer user_data)
142{ 174{
143 GtkWidget *dialog; 175 GtkWidget *ad;
144 dialog = gtk_file_chooser_dialog_new ("Open zone file...", 176 GtkBuilder *builder;
145 main_window, 177 GtkWidget *toplevel;
146 GTK_FILE_CHOOSER_ACTION_OPEN, 178
147 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 179 builder =
148 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, 180 GNUNET_GTK_get_new_builder ("gnunet_gns_gtk_zone_open.glade", NULL);
149 NULL); 181 if (NULL == builder)
150 if (NULL != zonefile_directory)
151 gtk_file_chooser_set_current_folder (dialog, zonefile_directory);
152 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
153 { 182 {
154 char *filename; 183 GNUNET_break (0);
155 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); 184 return;
156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
157 _("Opening `%s'\n"), filename);
158 if (NULL != zone_pkey)
159 {
160 GNUNET_CRYPTO_rsa_key_free(zone_pkey);
161 zone_pkey = GNUNET_CRYPTO_rsa_key_create_from_file(filename);
162 if (NULL == zone_pkey)
163 {
164 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
165 _("Not a valid zone file `%s'\n"), filename);
166
167 GtkWidget *err_dialog;
168 err_dialog = gtk_message_dialog_new (main_window,
169 GTK_DIALOG_DESTROY_WITH_PARENT,
170 GTK_MESSAGE_ERROR,
171 GTK_BUTTONS_CLOSE,
172 _("Error loading file '%s':\n not a valid zone file"),
173 filename);
174 gtk_dialog_run (GTK_DIALOG (err_dialog));
175 gtk_widget_destroy (err_dialog);
176 }
177 //if (zone_pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);)
178 }
179 g_free (filename);
180 } 185 }
181 gtk_widget_destroy (dialog); 186 ad = GTK_WIDGET (gtk_builder_get_object
187 (builder, "GNUNET_GNS_GTK_zone_open_filechooserdialog"));
188 toplevel = gtk_widget_get_toplevel (menuitem);
189 if (GTK_IS_WINDOW (toplevel))
190 gtk_window_set_transient_for (GTK_WINDOW (ad), GTK_WINDOW (toplevel));
191 gtk_window_present (GTK_WINDOW (ad));
182} 192}
183 193
184 194