diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-13 09:00:23 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-13 09:00:23 +0000 |
commit | d0c61090b1c1d3a0ef6ba1cb6a91e2a879929f30 (patch) | |
tree | 9cc9390ded2c9da7f75781bf81456475a2adc7c6 | |
parent | 3e7867781a077b5ed972ef3c38f2a76f1b395a3a (diff) | |
download | gnunet-gtk-d0c61090b1c1d3a0ef6ba1cb6a91e2a879929f30.tar.gz gnunet-gtk-d0c61090b1c1d3a0ef6ba1cb6a91e2a879929f30.zip |
-fixing zone open dialog skeleton
-rw-r--r-- | contrib/Makefile.am | 1 | ||||
-rw-r--r-- | contrib/gnunet_gns_gtk_zone_open.glade | 75 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk_open-directory.c | 2 | ||||
-rw-r--r-- | src/gns/gnunet-gns-gtk.c | 86 |
4 files changed, 125 insertions, 39 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am index f862f77c..8b81fe54 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am | |||
@@ -31,6 +31,7 @@ pkgdata_DATA = \ | |||
31 | gnunet_fs_gtk_progress_dialog.glade \ | 31 | gnunet_fs_gtk_progress_dialog.glade \ |
32 | gnunet_gns_gtk_about_window.glade \ | 32 | gnunet_gns_gtk_about_window.glade \ |
33 | gnunet_gns_gtk_main_window.glade \ | 33 | gnunet_gns_gtk_main_window.glade \ |
34 | gnunet_gns_gtk_zone_open.glade \ | ||
34 | gnunet_gtk_status_bar_menu.glade \ | 35 | gnunet_gtk_status_bar_menu.glade \ |
35 | gnunet_peerinfo_gtk_about_window.glade \ | 36 | gnunet_peerinfo_gtk_about_window.glade \ |
36 | gnunet_peerinfo_gtk_main_window.glade \ | 37 | gnunet_peerinfo_gtk_main_window.glade \ |
diff --git a/contrib/gnunet_gns_gtk_zone_open.glade b/contrib/gnunet_gns_gtk_zone_open.glade new file mode 100644 index 00000000..392f2738 --- /dev/null +++ b/contrib/gnunet_gns_gtk_zone_open.glade | |||
@@ -0,0 +1,75 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <interface> | ||
3 | <!-- interface-requires gtk+ 3.0 --> | ||
4 | <object class="GtkFileFilter" id="GNUNET_GNS_GTK_zone_open_filefilter"> | ||
5 | <patterns> | ||
6 | <pattern>*.zkey</pattern> | ||
7 | </patterns> | ||
8 | </object> | ||
9 | <object class="GtkFileChooserDialog" id="GNUNET_GNS_GTK_zone_open_filechooserdialog"> | ||
10 | <property name="can_focus">False</property> | ||
11 | <property name="border_width">5</property> | ||
12 | <property name="title" translatable="yes">Open zone file...</property> | ||
13 | <property name="type_hint">dialog</property> | ||
14 | <property name="filter">GNUNET_GNS_GTK_zone_open_filefilter</property> | ||
15 | <signal name="response" handler="GNUNET_GNS_GTK_zone_open_dialog_response_cb" swapped="no"/> | ||
16 | <child internal-child="vbox"> | ||
17 | <object class="GtkBox" id="GNUNET_GNS_GTK_zone_open_filechooserdialog-vbox"> | ||
18 | <property name="can_focus">False</property> | ||
19 | <property name="orientation">vertical</property> | ||
20 | <property name="spacing">2</property> | ||
21 | <child internal-child="action_area"> | ||
22 | <object class="GtkButtonBox" id="GNUNET_GNS_GTK_zone_open_filechooserdialog-action_area"> | ||
23 | <property name="can_focus">False</property> | ||
24 | <property name="layout_style">end</property> | ||
25 | <child> | ||
26 | <object class="GtkButton" id="GNUNET_GNS_GTK_zone_open_cancel_button"> | ||
27 | <property name="label">gtk-cancel</property> | ||
28 | <property name="use_action_appearance">False</property> | ||
29 | <property name="visible">True</property> | ||
30 | <property name="can_focus">True</property> | ||
31 | <property name="receives_default">True</property> | ||
32 | <property name="use_action_appearance">False</property> | ||
33 | <property name="use_stock">True</property> | ||
34 | </object> | ||
35 | <packing> | ||
36 | <property name="expand">False</property> | ||
37 | <property name="fill">True</property> | ||
38 | <property name="position">0</property> | ||
39 | </packing> | ||
40 | </child> | ||
41 | <child> | ||
42 | <object class="GtkButton" id="GNUNET_GNS_GTK_zone_open_ok_button"> | ||
43 | <property name="label">gtk-ok</property> | ||
44 | <property name="use_action_appearance">False</property> | ||
45 | <property name="visible">True</property> | ||
46 | <property name="can_focus">True</property> | ||
47 | <property name="receives_default">True</property> | ||
48 | <property name="use_action_appearance">False</property> | ||
49 | <property name="use_stock">True</property> | ||
50 | </object> | ||
51 | <packing> | ||
52 | <property name="expand">False</property> | ||
53 | <property name="fill">True</property> | ||
54 | <property name="position">1</property> | ||
55 | </packing> | ||
56 | </child> | ||
57 | </object> | ||
58 | <packing> | ||
59 | <property name="expand">False</property> | ||
60 | <property name="fill">True</property> | ||
61 | <property name="pack_type">end</property> | ||
62 | <property name="position">0</property> | ||
63 | </packing> | ||
64 | </child> | ||
65 | <child> | ||
66 | <placeholder/> | ||
67 | </child> | ||
68 | </object> | ||
69 | </child> | ||
70 | <action-widgets> | ||
71 | <action-widget response="-6">GNUNET_GNS_GTK_zone_open_cancel_button</action-widget> | ||
72 | <action-widget response="-5">GNUNET_GNS_GTK_zone_open_ok_button</action-widget> | ||
73 | </action-widgets> | ||
74 | </object> | ||
75 | </interface> | ||
diff --git a/src/fs/gnunet-fs-gtk_open-directory.c b/src/fs/gnunet-fs-gtk_open-directory.c index fec36b7c..9cc2640a 100644 --- a/src/fs/gnunet-fs-gtk_open-directory.c +++ b/src/fs/gnunet-fs-gtk_open-directory.c | |||
@@ -123,7 +123,7 @@ GNUNET_GTK_open_directory_dialog_response_cb (GtkDialog * dialog, | |||
123 | acc.filename = filename; | 123 | acc.filename = filename; |
124 | acc.sr = NULL; | 124 | acc.sr = NULL; |
125 | GNUNET_FS_GTK_mmap_and_scan (filename, &add_child, &acc); | 125 | GNUNET_FS_GTK_mmap_and_scan (filename, &add_child, &acc); |
126 | g_free (filename); | 126 | GNUNET_free (filename); |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
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 | */ |
62 | static char *zonefile_directory; | 62 | static char *zonefile_directory; |
63 | 63 | ||
64 | GtkWidget *main_window; | 64 | static 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 | */ | ||
140 | void | ||
141 | GNUNET_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 | |||
140 | GNUNET_GNS_GTK_open_imagemenuitem_activate_cb (GtkMenuItem *menuitem, | 172 | GNUNET_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 | ||