[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20321 - in gnunet-gtk: contrib src/gns
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20321 - in gnunet-gtk: contrib src/gns |
Date: |
Wed, 7 Mar 2012 00:45:40 +0100 |
Author: grothoff
Date: 2012-03-07 00:45:40 +0100 (Wed, 07 Mar 2012)
New Revision: 20321
Added:
gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c
Modified:
gnunet-gtk/contrib/gnunet_gns_gtk_main_window.glade
gnunet-gtk/src/gns/Makefile.am
gnunet-gtk/src/gns/gnunet-gns-gtk.c
Log:
-adding missing function prototypes to gnunet-gns-gtk
Modified: gnunet-gtk/contrib/gnunet_gns_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_gns_gtk_main_window.glade 2012-03-06 20:24:21 UTC
(rev 20320)
+++ gnunet-gtk/contrib/gnunet_gns_gtk_main_window.glade 2012-03-06 23:45:40 UTC
(rev 20321)
@@ -75,6 +75,7 @@
</data>
</object>
<object class="GtkWindow" id="GNUNET_GNS_GTK_main_window">
+ <signal name="delete_event"
handler="GNUNET_GNS_GTK_main_window_delete_event_cb"/>
<child>
<object class="GtkVBox" id="GNUNET_GNS_GTK_main_vbox">
<property name="visible">True</property>
@@ -258,6 +259,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">GNUNET_GNS_GTK_treestore</property>
+ <signal name="realize"
handler="GNUNET_GNS_GTK_main_treeview_realize_cb"/>
<signal name="popup_menu"
handler="GNUNET_GNS_GTK_main_treeview_popup_menu_cb"/>
<child>
<object class="GtkTreeViewColumn"
id="GNUNET_GNS_GTK_name_treeviewcolumn">
@@ -305,7 +307,6 @@
<child>
<object class="GtkCellRendererCombo"
id="GNUNET_GNS_GTK_type_cellrenderercombo">
<property name="editable">True</property>
- <property
name="model">GNUNET_GNS_GTK_type_liststore</property>
<signal name="changed"
handler="GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb"/>
</object>
<attributes>
Modified: gnunet-gtk/src/gns/Makefile.am
===================================================================
--- gnunet-gtk/src/gns/Makefile.am 2012-03-06 20:24:21 UTC (rev 20320)
+++ gnunet-gtk/src/gns/Makefile.am 2012-03-06 23:45:40 UTC (rev 20321)
@@ -11,12 +11,13 @@
gnunet_gns_gtk_SOURCES = \
gnunet-gns-gtk.c \
- gnunet-gns-gtk_about.c
+ gnunet-gns-gtk_about.c \
+ gnunet-gns-gtk_zone.c
gnunet_gns_gtk_LDADD = \
$(top_builddir)/src/lib/libgnunetgtk.la \
@GTK_LIBS@ \
@GLADE_LIBS@ @GNUNET_LIBS@ \
- -lgnunetutil \
+ -lgnunetutil -lgnunetnamestore \
$(INTLLIBS)
gnunet_gns_gtk_LDFLAGS = \
-export-dynamic
Modified: gnunet-gtk/src/gns/gnunet-gns-gtk.c
===================================================================
--- gnunet-gtk/src/gns/gnunet-gns-gtk.c 2012-03-06 20:24:21 UTC (rev 20320)
+++ gnunet-gtk/src/gns/gnunet-gns-gtk.c 2012-03-06 23:45:40 UTC (rev 20321)
@@ -24,6 +24,7 @@
* @author Christian Grothoff
*/
#include "gnunet_gtk.h"
+#include <gnunet/gnunet_namestore_service.h>
/**
* Handle to our main loop.
@@ -35,8 +36,38 @@
*/
static int tray_only;
+/**
+ * Hash of the public key of our zone.
+ */
+static GNUNET_HashCode zone;
/**
+ * Private key for the our zone.
+ */
+static struct GNUNET_CRYPTO_RsaPrivateKey *zone_pkey;
+
+/**
+ * Handle to the namestore.
+ */
+static struct GNUNET_NAMESTORE_Handle *ns;
+
+/**
+ * Name of our zone as a string.
+ */
+static char *zone_as_string;
+
+
+/**
+ * Get cfg.
+ */
+static const struct GNUNET_CONFIGURATION_Handle *
+get_configuration ()
+{
+ return GNUNET_GTK_main_loop_get_configuration (ml);
+}
+
+
+/**
* Get an object from the main window.
*
* @param name name of the object
@@ -50,6 +81,82 @@
/**
+ * The user edited the preferred name (PSEU) of this namespace.
+ * Push the update to the namestore.
+ *
+ * @param editable the edited widget
+ * @param user_data unused
+ */
+void
+GNUNET_GNS_GTK_pseu_entry_changed_cb (GtkEditable *editable,
+ gpointer user_data)
+{
+ GNUNET_break (0); // FIXME, not implemented
+}
+
+
+/**
+ * The user toggled the 'autoshort' option. Update the configuration.
+ *
+ * @param checkmenuitem the menu item
+ * @param user_data unused
+ */
+void
+GNUNET_GNS_GTK_autoshort_imagemenuitem_toggled_cb (GtkCheckMenuItem
*checkmenuitem,
+ gpointer user_data)
+{
+ GNUNET_break (0); // FIXME, not implemented
+}
+
+
+/**
+ * The user selected 'NEW' in the menu. Open a dialog to enter a filename
+ * to create a new zone (for editing).
+ *
+ * @param checkmenuitem the menu item
+ * @param user_data unused
+ */
+void
+GNUNET_GNS_GTK_new_imagemenuitem_activate_cb (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ GNUNET_break (0); // FIXME, not implemented
+}
+
+/**
+ * The user selected 'NEW' in the menu. Open a dialog to select
+ * a different zonefile (for editing).
+ *
+ * @param checkmenuitem the menu item
+ * @param user_data unused
+ */
+void
+GNUNET_GNS_GTK_open_imagemenuitem_activate_cb (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ GNUNET_break (0); // FIXME, not implemented
+}
+
+
+/**
+ * The user clicked on the 'copy' button. Copy the full string
+ * with the hash of our public key to the clipboard.
+ *
+ * @param button the button that was clicked
+ * @param user_data unused
+ */
+void
+GNUNET_GNS_GTK_public_key_copy_button_clicked_cb (GtkButton *button,
+ gpointer user_data)
+{
+ GtkClipboard *cb;
+
+ cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+ gtk_clipboard_set_text (cb, zone_as_string, -1);
+}
+
+
+/**
* Task run on shutdown.
*
* @param cls unused
@@ -58,14 +165,28 @@
static void
shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ if (NULL != ns)
+ {
+ GNUNET_NAMESTORE_disconnect (ns, GNUNET_NO);
+ ns = NULL;
+ }
+ if (NULL != zone_pkey)
+ {
+ GNUNET_CRYPTO_rsa_key_free (zone_pkey);
+ zone_pkey = NULL;
+ }
}
/**
- * Callback invoked if the application is supposed to exit.
+ * Callback invoked if the application is supposed to exit (via menu).
+ *
+ * @param menuitem the quit menu
+ * @param user_data unused
*/
void
-GNUNET_GNS_GTK_quit_cb (GObject * object, gpointer user_data)
+GNUNET_GNS_GTK_quit_imagemenuitem_activate_cb (GtkMenuItem *menuitem,
+ gpointer user_data)
{
GNUNET_GTK_tray_icon_destroy ();
GNUNET_GTK_main_loop_quit (ml);
@@ -74,18 +195,80 @@
/**
+ * Callback invoked if the application is supposed to exit (via window-close).
+ *
+ * @param widget the main window
+ * @param event deletion event
+ * @param user_data unused
+ */
+void
+GNUNET_GNS_GTK_main_window_delete_event_cb (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ GNUNET_GTK_tray_icon_destroy ();
+ GNUNET_GTK_main_loop_quit (ml);
+ GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+}
+
+
+/**
* Actual main function run right after GNUnet's scheduler
* is initialized. Initializes up GTK and Glade.
+ *
+ * @param cls the 'struct GNUNET_GTK_MainLoop'
+ * @param tc scheduler context
*/
static void
run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
GtkWidget *main_window;
+ char *keyfile;
+ char *label;
ml = cls;
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (get_configuration
(),
+ "gns",
+ "ZONEKEY",
+ &keyfile))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Option `%s' missing in section `%s'\n"),
+ "ZONEKEY", "gns");
+ return;
+ }
+ zone_pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+ GNUNET_free (keyfile);
+ keyfile = NULL;
+ if (NULL == zone_pkey)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to read or create private zone key\n"));
+ return;
+ }
+ GNUNET_CRYPTO_rsa_key_get_public (zone_pkey,
+ &pub);
+ GNUNET_CRYPTO_hash (&pub, sizeof (pub), &zone);
+ ns = GNUNET_NAMESTORE_connect (get_configuration ());
+ if (NULL == ns)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to connect to namestore\n"));
+ GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+ return;
+ }
+ zone_as_string = GNUNET_strdup (GNUNET_h2s_full (&zone));
+ GNUNET_asprintf (&label,
+ "<b>%s</b>",
+ zone_as_string);
+ gtk_label_set_text (GTK_LABEL (get_object ("GNUNET_GNS_GTK_zone_label")),
+ label);
+ GNUNET_free (label);
if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, NULL))
{
+ GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
return;
}
Added: gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c
===================================================================
--- gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c (rev 0)
+++ gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c 2012-03-06 23:45:40 UTC (rev
20321)
@@ -0,0 +1,158 @@
+/*
+ This file is part of GNUnet
+ (C) 2012 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/gns/gnunet-gns-gtk_zone.c
+ * @author Christian Grothoff
+ * @brief everything releated to the zone tree view
+ */
+#include "gnunet_gtk.h"
+
+
+
+
+/**
+ * The user has selected a new record type. Update the
+ * model, possibly invalidating (marking 'red') the existing
+ * value.
+ *
+ * @param renderer updated renderer
+ * @param path the path identifying the edited cell
+ * @param new_iter selected cell in the combo's model (with the record type)
+ * @param user_data unused
+ */
+void
+GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo,
+ gchar *path_string,
+ GtkTreeIter *new_iter,
+ gpointer user_data)
+{
+ GNUNET_break (0); // FIXME, not implemented
+}
+
+
+/**
+ * The user has toggled the 'public' checkmark of a cell. Update the
+ * model.
+ *
+ * @param renderer updated renderer
+ * @param path the path identifying the edited cell
+ * @param user_data unused
+ */
+void
+GNUNET_GNS_GTK_ispublic_cellrenderertoggle_toggled_cb (GtkCellRendererToggle
*cell_renderer,
+ gchar *path,
+ gpointer user_data)
+{
+ GNUNET_break (0); // FIXME, not implemented
+}
+
+
+/**
+ * The user has edited a 'expiration' cell. Update the model.
+ *
+ * @param renderer updated renderer
+ * @param path the path identifying the edited cell
+ * @param new_text the new expiration time
+ * @param user_data unused
+ */
+void
+GNUNET_GNS_GTK_expiration_cellrenderertext_edited_cb (GtkCellRendererText
*renderer,
+ gchar *path,
+ gchar *new_text,
+ gpointer user_data)
+{
+ GNUNET_break (0); // FIXME, not implemented
+}
+
+
+/**
+ * The user has edited a 'value' cell. Update the model,
+ * including the status on the consistency of the value with
+ * the type.
+ *
+ * @param renderer updated renderer
+ * @param path the path identifying the edited cell
+ * @param new_text the new value
+ * @param user_data unused
+ */
+void
+GNUNET_GNS_GTK_value_cellrenderertext_edited_cb (GtkCellRendererText *renderer,
+ gchar *path,
+ gchar *new_text,
+ gpointer user_data)
+{
+ GNUNET_break (0); // FIXME, not implemented
+}
+
+
+/**
+ * The user has edited a 'name' cell. Update the model (and if needed
+ * create another fresh line for additional records).
+ *
+ * @param renderer updated renderer
+ * @param path the path identifying the edited cell
+ * @param new_text the new name
+ * @param user_data unused
+ */
+void
+GNUNET_GNS_GTK_name_cellrenderertext_edited_cb (GtkCellRendererText *renderer,
+ gchar *path,
+ gchar *new_text,
+ gpointer user_data)
+{
+ GNUNET_break (0); // FIXME, not implemented
+}
+
+
+/**
+ * The zone treeview pop up menu is supposed to be created.
+ * (Note: this is not the only method that might need to be
+ * written to handle events to create pop up menus; right-clicks
+ * might need to be managed separately).
+ *
+ * @param widget the widget
+ * @param user_data unused
+ * @return TRUE if a menu was activated
+ */
+gboolean
+GNUNET_GNS_GTK_main_treeview_popup_menu_cb (GtkWidget *widget,
+ gpointer user_data)
+{
+ GNUNET_break (0); // FIXME, not implemented
+ return FALSE;
+}
+
+
+/**
+ * The zone treeview was realized. Setup the model.
+ *
+ * @param widget the widget
+ * @param user_data unused
+ */
+void
+GNUNET_GNS_GTK_main_treeview_realize_cb (GtkWidget *widget,
+ gpointer user_data)
+{
+ GNUNET_break (0); // FIXME, not implemented
+}
+
+
+/* end of gnunet-gns-gtk_zone.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20321 - in gnunet-gtk: contrib src/gns,
gnunet <=