diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-06 23:45:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-06 23:45:40 +0000 |
commit | bb5311d405810df9c664efd7cb1b397026b6203e (patch) | |
tree | 2a184f68dd80b2483685a1bad34c47977e3d3328 | |
parent | 8266f7f126f64f1de2bf5087395dd0c68a38b58a (diff) | |
download | gnunet-gtk-bb5311d405810df9c664efd7cb1b397026b6203e.tar.gz gnunet-gtk-bb5311d405810df9c664efd7cb1b397026b6203e.zip |
-adding missing function prototypes to gnunet-gns-gtk
-rw-r--r-- | contrib/gnunet_gns_gtk_main_window.glade | 3 | ||||
-rw-r--r-- | src/gns/Makefile.am | 5 | ||||
-rw-r--r-- | src/gns/gnunet-gns-gtk.c | 187 | ||||
-rw-r--r-- | src/gns/gnunet-gns-gtk_zone.c | 158 |
4 files changed, 348 insertions, 5 deletions
diff --git a/contrib/gnunet_gns_gtk_main_window.glade b/contrib/gnunet_gns_gtk_main_window.glade index 2910a399..cafb17c2 100644 --- a/contrib/gnunet_gns_gtk_main_window.glade +++ b/contrib/gnunet_gns_gtk_main_window.glade | |||
@@ -75,6 +75,7 @@ | |||
75 | </data> | 75 | </data> |
76 | </object> | 76 | </object> |
77 | <object class="GtkWindow" id="GNUNET_GNS_GTK_main_window"> | 77 | <object class="GtkWindow" id="GNUNET_GNS_GTK_main_window"> |
78 | <signal name="delete_event" handler="GNUNET_GNS_GTK_main_window_delete_event_cb"/> | ||
78 | <child> | 79 | <child> |
79 | <object class="GtkVBox" id="GNUNET_GNS_GTK_main_vbox"> | 80 | <object class="GtkVBox" id="GNUNET_GNS_GTK_main_vbox"> |
80 | <property name="visible">True</property> | 81 | <property name="visible">True</property> |
@@ -258,6 +259,7 @@ | |||
258 | <property name="visible">True</property> | 259 | <property name="visible">True</property> |
259 | <property name="can_focus">True</property> | 260 | <property name="can_focus">True</property> |
260 | <property name="model">GNUNET_GNS_GTK_treestore</property> | 261 | <property name="model">GNUNET_GNS_GTK_treestore</property> |
262 | <signal name="realize" handler="GNUNET_GNS_GTK_main_treeview_realize_cb"/> | ||
261 | <signal name="popup_menu" handler="GNUNET_GNS_GTK_main_treeview_popup_menu_cb"/> | 263 | <signal name="popup_menu" handler="GNUNET_GNS_GTK_main_treeview_popup_menu_cb"/> |
262 | <child> | 264 | <child> |
263 | <object class="GtkTreeViewColumn" id="GNUNET_GNS_GTK_name_treeviewcolumn"> | 265 | <object class="GtkTreeViewColumn" id="GNUNET_GNS_GTK_name_treeviewcolumn"> |
@@ -305,7 +307,6 @@ | |||
305 | <child> | 307 | <child> |
306 | <object class="GtkCellRendererCombo" id="GNUNET_GNS_GTK_type_cellrenderercombo"> | 308 | <object class="GtkCellRendererCombo" id="GNUNET_GNS_GTK_type_cellrenderercombo"> |
307 | <property name="editable">True</property> | 309 | <property name="editable">True</property> |
308 | <property name="model">GNUNET_GNS_GTK_type_liststore</property> | ||
309 | <signal name="changed" handler="GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb"/> | 310 | <signal name="changed" handler="GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb"/> |
310 | </object> | 311 | </object> |
311 | <attributes> | 312 | <attributes> |
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am index 200677a2..2e02c683 100644 --- a/src/gns/Makefile.am +++ b/src/gns/Makefile.am | |||
@@ -11,12 +11,13 @@ bin_PROGRAMS = gnunet-gns-gtk | |||
11 | 11 | ||
12 | gnunet_gns_gtk_SOURCES = \ | 12 | gnunet_gns_gtk_SOURCES = \ |
13 | gnunet-gns-gtk.c \ | 13 | gnunet-gns-gtk.c \ |
14 | gnunet-gns-gtk_about.c | 14 | gnunet-gns-gtk_about.c \ |
15 | gnunet-gns-gtk_zone.c | ||
15 | gnunet_gns_gtk_LDADD = \ | 16 | gnunet_gns_gtk_LDADD = \ |
16 | $(top_builddir)/src/lib/libgnunetgtk.la \ | 17 | $(top_builddir)/src/lib/libgnunetgtk.la \ |
17 | @GTK_LIBS@ \ | 18 | @GTK_LIBS@ \ |
18 | @GLADE_LIBS@ @GNUNET_LIBS@ \ | 19 | @GLADE_LIBS@ @GNUNET_LIBS@ \ |
19 | -lgnunetutil \ | 20 | -lgnunetutil -lgnunetnamestore \ |
20 | $(INTLLIBS) | 21 | $(INTLLIBS) |
21 | gnunet_gns_gtk_LDFLAGS = \ | 22 | gnunet_gns_gtk_LDFLAGS = \ |
22 | -export-dynamic | 23 | -export-dynamic |
diff --git a/src/gns/gnunet-gns-gtk.c b/src/gns/gnunet-gns-gtk.c index 9a49bc6f..d40dbb1e 100644 --- a/src/gns/gnunet-gns-gtk.c +++ b/src/gns/gnunet-gns-gtk.c | |||
@@ -24,6 +24,7 @@ | |||
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | #include "gnunet_gtk.h" | 26 | #include "gnunet_gtk.h" |
27 | #include <gnunet/gnunet_namestore_service.h> | ||
27 | 28 | ||
28 | /** | 29 | /** |
29 | * Handle to our main loop. | 30 | * Handle to our main loop. |
@@ -35,6 +36,36 @@ static struct GNUNET_GTK_MainLoop *ml; | |||
35 | */ | 36 | */ |
36 | static int tray_only; | 37 | static int tray_only; |
37 | 38 | ||
39 | /** | ||
40 | * Hash of the public key of our zone. | ||
41 | */ | ||
42 | static GNUNET_HashCode zone; | ||
43 | |||
44 | /** | ||
45 | * Private key for the our zone. | ||
46 | */ | ||
47 | static struct GNUNET_CRYPTO_RsaPrivateKey *zone_pkey; | ||
48 | |||
49 | /** | ||
50 | * Handle to the namestore. | ||
51 | */ | ||
52 | static struct GNUNET_NAMESTORE_Handle *ns; | ||
53 | |||
54 | /** | ||
55 | * Name of our zone as a string. | ||
56 | */ | ||
57 | static char *zone_as_string; | ||
58 | |||
59 | |||
60 | /** | ||
61 | * Get cfg. | ||
62 | */ | ||
63 | static const struct GNUNET_CONFIGURATION_Handle * | ||
64 | get_configuration () | ||
65 | { | ||
66 | return GNUNET_GTK_main_loop_get_configuration (ml); | ||
67 | } | ||
68 | |||
38 | 69 | ||
39 | /** | 70 | /** |
40 | * Get an object from the main window. | 71 | * Get an object from the main window. |
@@ -50,6 +81,82 @@ get_object (const char *name) | |||
50 | 81 | ||
51 | 82 | ||
52 | /** | 83 | /** |
84 | * The user edited the preferred name (PSEU) of this namespace. | ||
85 | * Push the update to the namestore. | ||
86 | * | ||
87 | * @param editable the edited widget | ||
88 | * @param user_data unused | ||
89 | */ | ||
90 | void | ||
91 | GNUNET_GNS_GTK_pseu_entry_changed_cb (GtkEditable *editable, | ||
92 | gpointer user_data) | ||
93 | { | ||
94 | GNUNET_break (0); // FIXME, not implemented | ||
95 | } | ||
96 | |||
97 | |||
98 | /** | ||
99 | * The user toggled the 'autoshort' option. Update the configuration. | ||
100 | * | ||
101 | * @param checkmenuitem the menu item | ||
102 | * @param user_data unused | ||
103 | */ | ||
104 | void | ||
105 | GNUNET_GNS_GTK_autoshort_imagemenuitem_toggled_cb (GtkCheckMenuItem *checkmenuitem, | ||
106 | gpointer user_data) | ||
107 | { | ||
108 | GNUNET_break (0); // FIXME, not implemented | ||
109 | } | ||
110 | |||
111 | |||
112 | /** | ||
113 | * The user selected 'NEW' in the menu. Open a dialog to enter a filename | ||
114 | * to create a new zone (for editing). | ||
115 | * | ||
116 | * @param checkmenuitem the menu item | ||
117 | * @param user_data unused | ||
118 | */ | ||
119 | void | ||
120 | GNUNET_GNS_GTK_new_imagemenuitem_activate_cb (GtkMenuItem *menuitem, | ||
121 | gpointer user_data) | ||
122 | { | ||
123 | GNUNET_break (0); // FIXME, not implemented | ||
124 | } | ||
125 | |||
126 | /** | ||
127 | * The user selected 'NEW' in the menu. Open a dialog to select | ||
128 | * a different zonefile (for editing). | ||
129 | * | ||
130 | * @param checkmenuitem the menu item | ||
131 | * @param user_data unused | ||
132 | */ | ||
133 | void | ||
134 | GNUNET_GNS_GTK_open_imagemenuitem_activate_cb (GtkMenuItem *menuitem, | ||
135 | gpointer user_data) | ||
136 | { | ||
137 | GNUNET_break (0); // FIXME, not implemented | ||
138 | } | ||
139 | |||
140 | |||
141 | /** | ||
142 | * The user clicked on the 'copy' button. Copy the full string | ||
143 | * with the hash of our public key to the clipboard. | ||
144 | * | ||
145 | * @param button the button that was clicked | ||
146 | * @param user_data unused | ||
147 | */ | ||
148 | void | ||
149 | GNUNET_GNS_GTK_public_key_copy_button_clicked_cb (GtkButton *button, | ||
150 | gpointer user_data) | ||
151 | { | ||
152 | GtkClipboard *cb; | ||
153 | |||
154 | cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); | ||
155 | gtk_clipboard_set_text (cb, zone_as_string, -1); | ||
156 | } | ||
157 | |||
158 | |||
159 | /** | ||
53 | * Task run on shutdown. | 160 | * Task run on shutdown. |
54 | * | 161 | * |
55 | * @param cls unused | 162 | * @param cls unused |
@@ -58,14 +165,46 @@ get_object (const char *name) | |||
58 | static void | 165 | static void |
59 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 166 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
60 | { | 167 | { |
168 | if (NULL != ns) | ||
169 | { | ||
170 | GNUNET_NAMESTORE_disconnect (ns, GNUNET_NO); | ||
171 | ns = NULL; | ||
172 | } | ||
173 | if (NULL != zone_pkey) | ||
174 | { | ||
175 | GNUNET_CRYPTO_rsa_key_free (zone_pkey); | ||
176 | zone_pkey = NULL; | ||
177 | } | ||
178 | } | ||
179 | |||
180 | |||
181 | /** | ||
182 | * Callback invoked if the application is supposed to exit (via menu). | ||
183 | * | ||
184 | * @param menuitem the quit menu | ||
185 | * @param user_data unused | ||
186 | */ | ||
187 | void | ||
188 | GNUNET_GNS_GTK_quit_imagemenuitem_activate_cb (GtkMenuItem *menuitem, | ||
189 | gpointer user_data) | ||
190 | { | ||
191 | GNUNET_GTK_tray_icon_destroy (); | ||
192 | GNUNET_GTK_main_loop_quit (ml); | ||
193 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
61 | } | 194 | } |
62 | 195 | ||
63 | 196 | ||
64 | /** | 197 | /** |
65 | * Callback invoked if the application is supposed to exit. | 198 | * Callback invoked if the application is supposed to exit (via window-close). |
199 | * | ||
200 | * @param widget the main window | ||
201 | * @param event deletion event | ||
202 | * @param user_data unused | ||
66 | */ | 203 | */ |
67 | void | 204 | void |
68 | GNUNET_GNS_GTK_quit_cb (GObject * object, gpointer user_data) | 205 | GNUNET_GNS_GTK_main_window_delete_event_cb (GtkWidget *widget, |
206 | GdkEvent *event, | ||
207 | gpointer user_data) | ||
69 | { | 208 | { |
70 | GNUNET_GTK_tray_icon_destroy (); | 209 | GNUNET_GTK_tray_icon_destroy (); |
71 | GNUNET_GTK_main_loop_quit (ml); | 210 | GNUNET_GTK_main_loop_quit (ml); |
@@ -76,16 +215,60 @@ GNUNET_GNS_GTK_quit_cb (GObject * object, gpointer user_data) | |||
76 | /** | 215 | /** |
77 | * Actual main function run right after GNUnet's scheduler | 216 | * Actual main function run right after GNUnet's scheduler |
78 | * is initialized. Initializes up GTK and Glade. | 217 | * is initialized. Initializes up GTK and Glade. |
218 | * | ||
219 | * @param cls the 'struct GNUNET_GTK_MainLoop' | ||
220 | * @param tc scheduler context | ||
79 | */ | 221 | */ |
80 | static void | 222 | static void |
81 | run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 223 | run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
82 | { | 224 | { |
225 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub; | ||
83 | GtkWidget *main_window; | 226 | GtkWidget *main_window; |
227 | char *keyfile; | ||
228 | char *label; | ||
84 | 229 | ||
85 | ml = cls; | 230 | ml = cls; |
231 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (get_configuration (), | ||
232 | "gns", | ||
233 | "ZONEKEY", | ||
234 | &keyfile)) | ||
235 | { | ||
236 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
237 | _("Option `%s' missing in section `%s'\n"), | ||
238 | "ZONEKEY", "gns"); | ||
239 | return; | ||
240 | } | ||
241 | zone_pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | ||
242 | GNUNET_free (keyfile); | ||
243 | keyfile = NULL; | ||
244 | if (NULL == zone_pkey) | ||
245 | { | ||
246 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
247 | _("Failed to read or create private zone key\n")); | ||
248 | return; | ||
249 | } | ||
250 | GNUNET_CRYPTO_rsa_key_get_public (zone_pkey, | ||
251 | &pub); | ||
252 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &zone); | ||
86 | 253 | ||
254 | ns = GNUNET_NAMESTORE_connect (get_configuration ()); | ||
255 | if (NULL == ns) | ||
256 | { | ||
257 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
258 | _("Failed to connect to namestore\n")); | ||
259 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
260 | return; | ||
261 | } | ||
262 | zone_as_string = GNUNET_strdup (GNUNET_h2s_full (&zone)); | ||
263 | GNUNET_asprintf (&label, | ||
264 | "<b>%s</b>", | ||
265 | zone_as_string); | ||
266 | gtk_label_set_text (GTK_LABEL (get_object ("GNUNET_GNS_GTK_zone_label")), | ||
267 | label); | ||
268 | GNUNET_free (label); | ||
87 | if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, NULL)) | 269 | if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, NULL)) |
88 | { | 270 | { |
271 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
89 | return; | 272 | return; |
90 | } | 273 | } |
91 | 274 | ||
diff --git a/src/gns/gnunet-gns-gtk_zone.c b/src/gns/gnunet-gns-gtk_zone.c new file mode 100644 index 00000000..71160c1d --- /dev/null +++ b/src/gns/gnunet-gns-gtk_zone.c | |||
@@ -0,0 +1,158 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2012 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/gns/gnunet-gns-gtk_zone.c | ||
23 | * @author Christian Grothoff | ||
24 | * @brief everything releated to the zone tree view | ||
25 | */ | ||
26 | #include "gnunet_gtk.h" | ||
27 | |||
28 | |||
29 | |||
30 | |||
31 | /** | ||
32 | * The user has selected a new record type. Update the | ||
33 | * model, possibly invalidating (marking 'red') the existing | ||
34 | * value. | ||
35 | * | ||
36 | * @param renderer updated renderer | ||
37 | * @param path the path identifying the edited cell | ||
38 | * @param new_iter selected cell in the combo's model (with the record type) | ||
39 | * @param user_data unused | ||
40 | */ | ||
41 | void | ||
42 | GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, | ||
43 | gchar *path_string, | ||
44 | GtkTreeIter *new_iter, | ||
45 | gpointer user_data) | ||
46 | { | ||
47 | GNUNET_break (0); // FIXME, not implemented | ||
48 | } | ||
49 | |||
50 | |||
51 | /** | ||
52 | * The user has toggled the 'public' checkmark of a cell. Update the | ||
53 | * model. | ||
54 | * | ||
55 | * @param renderer updated renderer | ||
56 | * @param path the path identifying the edited cell | ||
57 | * @param user_data unused | ||
58 | */ | ||
59 | void | ||
60 | GNUNET_GNS_GTK_ispublic_cellrenderertoggle_toggled_cb (GtkCellRendererToggle *cell_renderer, | ||
61 | gchar *path, | ||
62 | gpointer user_data) | ||
63 | { | ||
64 | GNUNET_break (0); // FIXME, not implemented | ||
65 | } | ||
66 | |||
67 | |||
68 | /** | ||
69 | * The user has edited a 'expiration' cell. Update the model. | ||
70 | * | ||
71 | * @param renderer updated renderer | ||
72 | * @param path the path identifying the edited cell | ||
73 | * @param new_text the new expiration time | ||
74 | * @param user_data unused | ||
75 | */ | ||
76 | void | ||
77 | GNUNET_GNS_GTK_expiration_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | ||
78 | gchar *path, | ||
79 | gchar *new_text, | ||
80 | gpointer user_data) | ||
81 | { | ||
82 | GNUNET_break (0); // FIXME, not implemented | ||
83 | } | ||
84 | |||
85 | |||
86 | /** | ||
87 | * The user has edited a 'value' cell. Update the model, | ||
88 | * including the status on the consistency of the value with | ||
89 | * the type. | ||
90 | * | ||
91 | * @param renderer updated renderer | ||
92 | * @param path the path identifying the edited cell | ||
93 | * @param new_text the new value | ||
94 | * @param user_data unused | ||
95 | */ | ||
96 | void | ||
97 | GNUNET_GNS_GTK_value_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | ||
98 | gchar *path, | ||
99 | gchar *new_text, | ||
100 | gpointer user_data) | ||
101 | { | ||
102 | GNUNET_break (0); // FIXME, not implemented | ||
103 | } | ||
104 | |||
105 | |||
106 | /** | ||
107 | * The user has edited a 'name' cell. Update the model (and if needed | ||
108 | * create another fresh line for additional records). | ||
109 | * | ||
110 | * @param renderer updated renderer | ||
111 | * @param path the path identifying the edited cell | ||
112 | * @param new_text the new name | ||
113 | * @param user_data unused | ||
114 | */ | ||
115 | void | ||
116 | GNUNET_GNS_GTK_name_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | ||
117 | gchar *path, | ||
118 | gchar *new_text, | ||
119 | gpointer user_data) | ||
120 | { | ||
121 | GNUNET_break (0); // FIXME, not implemented | ||
122 | } | ||
123 | |||
124 | |||
125 | /** | ||
126 | * The zone treeview pop up menu is supposed to be created. | ||
127 | * (Note: this is not the only method that might need to be | ||
128 | * written to handle events to create pop up menus; right-clicks | ||
129 | * might need to be managed separately). | ||
130 | * | ||
131 | * @param widget the widget | ||
132 | * @param user_data unused | ||
133 | * @return TRUE if a menu was activated | ||
134 | */ | ||
135 | gboolean | ||
136 | GNUNET_GNS_GTK_main_treeview_popup_menu_cb (GtkWidget *widget, | ||
137 | gpointer user_data) | ||
138 | { | ||
139 | GNUNET_break (0); // FIXME, not implemented | ||
140 | return FALSE; | ||
141 | } | ||
142 | |||
143 | |||
144 | /** | ||
145 | * The zone treeview was realized. Setup the model. | ||
146 | * | ||
147 | * @param widget the widget | ||
148 | * @param user_data unused | ||
149 | */ | ||
150 | void | ||
151 | GNUNET_GNS_GTK_main_treeview_realize_cb (GtkWidget *widget, | ||
152 | gpointer user_data) | ||
153 | { | ||
154 | GNUNET_break (0); // FIXME, not implemented | ||
155 | } | ||
156 | |||
157 | |||
158 | /* end of gnunet-gns-gtk_zone.c */ | ||