[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r29954 - in gnunet-gtk: contrib src/namestore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r29954 - in gnunet-gtk: contrib src/namestore |
Date: |
Tue, 8 Oct 2013 10:13:40 +0200 |
Author: grothoff
Date: 2013-10-08 10:13:40 +0200 (Tue, 08 Oct 2013)
New Revision: 29954
Modified:
gnunet-gtk/contrib/gnunet_namestore_gtk_main_window.glade
gnunet-gtk/src/namestore/gnunet-namestore-gtk.c
gnunet-gtk/src/namestore/gnunet-namestore-gtk_edit.h
Log:
-enable selecting any ego for zone editing
Modified: gnunet-gtk/contrib/gnunet_namestore_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_namestore_gtk_main_window.glade 2013-10-08
07:25:15 UTC (rev 29953)
+++ gnunet-gtk/contrib/gnunet_namestore_gtk_main_window.glade 2013-10-08
08:13:40 UTC (rev 29954)
@@ -103,8 +103,8 @@
<signal name="changed"
handler="gnunet_namestore_gtk_pseu_entry_changed_cb" swapped="no"/>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="padding">5</property>
<property name="position">1</property>
</packing>
@@ -117,67 +117,18 @@
</packing>
</child>
<child>
- <object class="GtkHButtonBox"
id="gnunet_namestore_gtk_zone_selection_hbuttonbox">
+ <object class="GtkComboBox"
id="gnunet_namestore_gtk_zone_combobox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="layout_style">center</property>
+ <property name="model">zone_liststore</property>
+ <property name="tearoff_title">Ego</property>
+ <signal name="changed"
handler="gnunet_namestore_gtk_zone_combobox_changed_cb" swapped="no"/>
<child>
- <object class="GtkRadioButton"
id="gnunet_namestore_gtk_master_zone_selection_radiobutton">
- <property name="label" translatable="yes">_Master
Zone</property>
- <property
name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled"
handler="gnunet_namestore_gtk_master_zone_selection_radiobutton_toggled_cb"
swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">10</property>
- <property name="position">0</property>
- </packing>
+ <object class="GtkCellRendererText"
id="gnunet_namestore_gtk_zone_ego_name_cellrenderertext"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
</child>
- <child>
- <object class="GtkRadioButton"
id="gnunet_namestore_gtk_private_zone_selection_radiobutton">
- <property name="label" translatable="yes">_Private
Zone</property>
- <property
name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <property
name="group">gnunet_namestore_gtk_master_zone_selection_radiobutton</property>
- <signal name="toggled"
handler="gnunet_namestore_gtk_private_zone_selection_radiobutton_toggled_cb"
swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">10</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton"
id="gnunet_namestore_gtk_shorten_zone_selection_radiobutton">
- <property name="label" translatable="yes">_Shorten
Zone</property>
- <property
name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <property
name="group">gnunet_namestore_gtk_master_zone_selection_radiobutton</property>
- <signal name="toggled"
handler="gnunet_namestore_gtk_shorten_zone_selection_radiobutton_toggled_cb"
swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">10</property>
- <property name="position">2</property>
- </packing>
- </child>
</object>
<packing>
<property name="expand">False</property>
@@ -199,8 +150,9 @@
<property name="can_focus">False</property>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">10</property>
<property name="position">1</property>
</packing>
</child>
@@ -252,7 +204,7 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
@@ -556,4 +508,12 @@
</row>
</data>
</object>
+ <object class="GtkListStore" id="zone_liststore">
+ <columns>
+ <!-- column-name ego_name -->
+ <column type="gchararray"/>
+ <!-- column-name ego -->
+ <column type="gpointer"/>
+ </columns>
+ </object>
</interface>
Modified: gnunet-gtk/src/namestore/gnunet-namestore-gtk.c
===================================================================
--- gnunet-gtk/src/namestore/gnunet-namestore-gtk.c 2013-10-08 07:25:15 UTC
(rev 29953)
+++ gnunet-gtk/src/namestore/gnunet-namestore-gtk.c 2013-10-08 08:13:40 UTC
(rev 29954)
@@ -182,6 +182,25 @@
/**
+ * Columns in the zone list store.
+ */
+enum ZONE_COLUMNS
+{
+
+ /**
+ * A gchararray
+ */
+ ZONE_LS_NAME = 0,
+
+
+ /**
+ * A `struct GNUNET_IDENTITY_Ego`
+ */
+ ZONE_LS_EGO = 1
+};
+
+
+/**
* Closure for 'operation_done_cont'.
*/
struct OperationContext
@@ -356,17 +375,17 @@
* Pointer to name of the configuration option that gives the
* zone key for the zone we are editing right now.
*/
-static const char *current_zone_option;
+static char *current_zone_option;
/**
- * Connection to identity service.
+ * List of all known zones/egos.
*/
-static struct GNUNET_IDENTITY_Handle *identity;
+static GtkListStore *zone_liststore;
/**
- * Request for our ego.
+ * Connection to identity service.
*/
-static struct GNUNET_IDENTITY_Operation *id_op;
+static struct GNUNET_IDENTITY_Handle *identity;
/**
* Main loop handle.
@@ -725,10 +744,18 @@
static void
clear_zone_view ()
{
+ GtkEntry *pseu_entry;
+
+ pseu_entry = GTK_ENTRY((get_object ("gnunet_namestore_gtk_pseu_entry")));
+ gtk_entry_set_text (pseu_entry, "");
+ GNUNET_free_non_null (current_zone_option);
+ current_zone_option = NULL;
+ GNUNET_free_non_null (current_pseudonym);
+ current_pseudonym = NULL;
GNUNET_CONTAINER_multihashmap_iterate (n2r,
&release_ri,
NULL);
- gtk_widget_hide (GTK_WIDGET (get_object
("gnunet_namestore_gtk_zone_selection_hbuttonbox")));
+ gtk_widget_hide (GTK_WIDGET (get_object
("gnunet_namestore_gtk_zone_combobox")));
gtk_widget_show (GTK_WIDGET (get_object
("gnunet_namestore_gtk_status_label")));
gtk_widget_hide (GTK_WIDGET (get_object
("gnunet_namestore_gtk_scrolledwindow")));
gtk_widget_hide (GTK_WIDGET (get_object ("gnunet_namestore_gtk_qr_image")));
@@ -740,17 +767,6 @@
/**
- * Load a particular zone into the main tree view.
- *
- * @param zonename name of the option in the configuration file
- * with the name of the file with the private key of the
- * zone to load
- */
-static void
-load_zone (const char *zonename);
-
-
-/**
* Display an error message for the user.
*
* @param title title of the error message
@@ -1115,6 +1131,7 @@
edc->new_zone_option = g_strdup (current_zone_option);
edc->record_type = n_type;
edc->cont = &edit_dialog_continuation;
+ edc->zone_liststore = zone_liststore;
switch (n_type)
{
case GNUNET_DNSPARSER_TYPE_A:
@@ -1314,9 +1331,9 @@
*/
void
gnunet_namestore_gtk_name_cellrenderertext_edited_cb (GtkCellRendererText
*renderer,
- gchar *path,
- gchar *new_text,
- gpointer user_data)
+ gchar *path,
+ gchar *new_text,
+ gpointer user_data)
{
GtkTreeIter it;
gboolean not_dummy;
@@ -1606,7 +1623,7 @@
*/
void
gnunet_namestore_gtk_pseu_entry_changed_cb (GtkEditable *editable,
- gpointer user_data)
+ gpointer user_data)
{
const gchar *pseu;
struct RecordInfo *ri;
@@ -1727,8 +1744,7 @@
static void
zone_sync_proc (void *cls)
{
- if (0 == strcmp (current_zone_option, "ZONEKEY"))
- gtk_widget_show (GTK_WIDGET (get_object
("gnunet_namestore_gtk_pseu_hbox")));
+ gtk_widget_show (GTK_WIDGET (get_object ("gnunet_namestore_gtk_pseu_hbox")));
#if HAVE_QRENCODE_H
setup_qrcode ();
gtk_widget_show (GTK_WIDGET (get_object ("gnunet_namestore_gtk_qr_image")));
@@ -1741,7 +1757,7 @@
#endif
gtk_widget_hide (GTK_WIDGET (get_object
("gnunet_namestore_gtk_status_label")));
gtk_widget_show (GTK_WIDGET (get_object
("gnunet_namestore_gtk_scrolledwindow")));
- gtk_widget_show (GTK_WIDGET (get_object
("gnunet_namestore_gtk_zone_selection_hbuttonbox")));
+ gtk_widget_show (GTK_WIDGET (get_object
("gnunet_namestore_gtk_zone_combobox")));
}
@@ -1948,50 +1964,38 @@
/**
- * Method called to inform about the egos of this peer. Called
- * when we are doing a #load_zone operation and are getting the
- * private key of the new zone to edit.
+ * Method called to switch the model to a new zone.
*
- * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get,
- * this function is only called ONCE, and 'NULL' being passed in
- * @a ego does indicate an error (i.e. name is taken or no default
- * value is known). If @a ego is non-NULL and if '*ctx'
- * is set in those callbacks, the value WILL be passed to a subsequent
- * call to the identity callback of #GNUNET_IDENTITY_connect (if
- * that one was not NULL).
- *
- * @param cls closure with the 'const char *' zonename
+ * @param name name of the zone
* @param ego ego handle
- * @param ctx context for application to store data for this ego
- * (during the lifetime of this process, initially NULL)
- * @param name name assigned by the user for this ego,
- * NULL if the user just deleted the ego and it
- * must thus no longer be used
*/
static void
-identity_cb (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *name)
+load_zone (const char *name,
+ struct GNUNET_IDENTITY_Ego *ego)
{
- const char *zonename = cls;
char *emsg;
char *label;
GtkTreeIter toplevel;
- id_op = NULL;
/* setup crypto keys */
+ clear_zone_view ();
+ if (NULL != zmon)
+ {
+ GNUNET_NAMESTORE_zone_monitor_stop (zmon);
+ zmon = NULL;
+ }
if (NULL == ego)
{
GNUNET_asprintf (&emsg,
- _("Default zone for `%s' not set; did you run
gnunet-gns-import.sh?\n"),
- zonename);
+ _("Could not load zone `%s'; did you run
gnunet-gns-import.sh?\n"),
+ name);
show_error_message (_("Failed to load zone"),
emsg);
GNUNET_free (emsg);
- gtk_widget_show (GTK_WIDGET (get_object
("gnunet_namestore_gtk_zone_selection_hbuttonbox")));
+ gtk_widget_show (GTK_WIDGET (get_object
("gnunet_namestore_gtk_zone_combobox")));
return;
}
+ current_zone_option = GNUNET_strdup (name);
pkey = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
*pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
GNUNET_CRYPTO_ecc_key_get_public_for_signature (pkey, &pubkey);
@@ -2023,38 +2027,6 @@
/**
- * Load a particular zone into the main tree view.
- *
- * @param zonename name of the option in the configuration file
- * with the name of the file with the private key of the
- * zone to load
- */
-static void
-load_zone (const char *zonename)
-{
- /* clear previous zone */
- if (NULL != zmon)
- {
- GNUNET_NAMESTORE_zone_monitor_stop (zmon);
- zmon = NULL;
- }
- if (NULL != id_op)
- {
- GNUNET_IDENTITY_cancel (id_op);
- id_op = NULL;
- }
- clear_zone_view ();
- current_zone_option = zonename;
- GNUNET_free_non_null (pkey);
- pkey = NULL;
- id_op = GNUNET_IDENTITY_get (identity,
- zonename,
- &identity_cb,
- (void *) zonename);
-}
-
-
-/**
* A different zone was selected in the zone toggle bar. Load the
* appropriate zone.
*
@@ -2062,47 +2034,29 @@
* @param user_data builder, unused
*/
void
-gnunet_namestore_gtk_shorten_zone_selection_radiobutton_toggled_cb
(GtkToggleButton *togglebutton,
-
gpointer user_data)
+gnunet_namestore_gtk_zone_combobox_changed_cb (GtkComboBox *widget,
+ gpointer user_data)
{
- if (gtk_toggle_button_get_active (togglebutton))
- load_zone ("gns-short");
-}
+ GtkTreeIter iter;
+ struct GNUNET_IDENTITY_Ego *ego;
+ char *name;
-
-/**
- * A different zone was selected in the zone toggle bar. Load the
- * appropriate zone.
- *
- * @param togglebutton button that was toggled (could be to "on" or "off", we
only react to "on")
- * @param user_data builder, unused
- */
-void
-gnunet_namestore_gtk_private_zone_selection_radiobutton_toggled_cb
(GtkToggleButton *togglebutton,
-
gpointer user_data)
-{
- if (gtk_toggle_button_get_active (togglebutton))
- load_zone ("gns-private");
+ if (! gtk_combo_box_get_active_iter (widget,
+ &iter))
+ {
+ load_zone (NULL, NULL);
+ return;
+ }
+ gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore),
+ &iter,
+ ZONE_LS_NAME, &name,
+ ZONE_LS_EGO, &ego,
+ -1);
+ load_zone (name, ego);
}
/**
- * A different zone was selected in the zone toggle bar. Load the
- * appropriate zone.
- *
- * @param togglebutton button that was toggled (could be to "on" or "off", we
only react to "on")
- * @param user_data builder, unused
- */
-void
-gnunet_namestore_gtk_master_zone_selection_radiobutton_toggled_cb
(GtkToggleButton *togglebutton,
-
gpointer user_data)
-{
- if (gtk_toggle_button_get_active (togglebutton))
- load_zone ("gns-master");
-}
-
-
-/**
* Actual main to tear down the system.
*
* @param cls the main loop handle
@@ -2173,11 +2127,6 @@
GNUNET_free (current_pseudonym);
current_pseudonym = NULL;
}
- if (NULL != id_op)
- {
- GNUNET_IDENTITY_cancel (id_op);
- id_op = NULL;
- }
if (NULL != identity)
{
GNUNET_IDENTITY_disconnect (identity);
@@ -2198,6 +2147,99 @@
/**
+ * Method called to inform about the egos of this peer. Updates the
+ * `zone_liststore`.
+ *
+ * When used with #GNUNET_IDENTITY_connect, this function is
+ * initially called for all egos and then again whenever a
+ * ego's name changes or if it is deleted. At the end of
+ * the initial pass over all egos, the function is once called
+ * with 'NULL' for @a ego. That does NOT mean that the callback won't
+ * be invoked in the future or that there was an error.
+ *
+ * If @a ego is non-NULL and if '*ctx' is set in those callbacks, the
+ * value WILL be passed to a subsequent call to the identity callback
+ * of #GNUNET_IDENTITY_connect (if that one was not NULL).
+ *
+ * When an identity is renamed, this function is called with the
+ * (known) @a ego but the NEW @a name.
+ *
+ * When an identity is deleted, this function is called with the
+ * (known) ego and "NULL" for the @a name. In this case,
+ * the @a ego is henceforth invalid (and the @a ctx should also be
+ * cleaned up).
+ *
+ * @param cls closure
+ * @param ego ego handle
+ * @param ctx context for application to store data for this ego
+ * (during the lifetime of this process, initially NULL)
+ * @param name name assigned by the user for this ego,
+ * NULL if the user just deleted the ego and it
+ * must thus no longer be used
+ */
+static void
+identity_cb (void *cls,
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *name)
+{
+ GtkTreeRowReference *rr;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+
+ if ( (NULL == ego) &&
+ (NULL == name) &&
+ (NULL == ctx) )
+ {
+ /* end of initial iteration, trigger loading selected zone */
+ gnunet_namestore_gtk_zone_combobox_changed_cb
+ (GTK_COMBO_BOX (get_object ("gnunet_namestore_gtk_zone_combobox")),
+ ml);
+ return;
+ }
+ rr = *ctx;
+ if (NULL == rr)
+ {
+ /* new zone, add to list */
+ gtk_list_store_insert_with_values (zone_liststore,
+ &iter, -1,
+ ZONE_LS_NAME, name,
+ ZONE_LS_EGO, ego,
+ -1);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (zone_liststore),
+ &iter);
+ rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (zone_liststore),
+ path);
+ *ctx = rr;
+ gtk_tree_path_free (path);
+ if (0 == strcmp ("master-zone",
+ name))
+ gtk_combo_box_set_active_iter
+ (GTK_COMBO_BOX (get_object ("gnunet_namestore_gtk_zone_combobox")),
+ &iter);
+ return;
+ }
+ path = gtk_tree_row_reference_get_path (rr);
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (zone_liststore),
+ &iter,
+ path);
+ gtk_tree_path_free (path);
+ if (NULL == ego)
+ {
+ /* zone was removed, remove from list */
+ gtk_list_store_remove (zone_liststore,
+ &iter);
+ return;
+ }
+ /* zone was renamed, rename in model */
+ gtk_list_store_set (zone_liststore,
+ &iter,
+ ZONE_LS_NAME, name,
+ -1);
+}
+
+
+/**
* Actual main method that sets up the configuration window.
*
* @param cls the main loop handle
@@ -2229,12 +2271,14 @@
g_free (label);
return;
}
- identity = GNUNET_IDENTITY_connect (cfg, NULL, NULL);
ts = GTK_TREE_STORE (get_object ("gnunet_namestore_gtk_treestore"));
tv = GTK_TREE_VIEW (get_object ("gnunet_namestore_gtk_treeview"));
+ zone_liststore = GTK_LIST_STORE (get_object ("zone_liststore"));
tm = GTK_TREE_MODEL (ts);
n2r = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
- load_zone ("gns-master");
+ identity = GNUNET_IDENTITY_connect (cfg,
+ &identity_cb,
+ NULL);
gtk_widget_show (main_window);
gtk_window_present (GTK_WINDOW (main_window));
}
Modified: gnunet-gtk/src/namestore/gnunet-namestore-gtk_edit.h
===================================================================
--- gnunet-gtk/src/namestore/gnunet-namestore-gtk_edit.h 2013-10-08
07:25:15 UTC (rev 29953)
+++ gnunet-gtk/src/namestore/gnunet-namestore-gtk_edit.h 2013-10-08
08:13:40 UTC (rev 29954)
@@ -138,6 +138,11 @@
*/
gboolean n_is_shadow;
+ /**
+ * List of all zones.
+ */
+ GtkListStore *zone_liststore;
+
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r29954 - in gnunet-gtk: contrib src/namestore,
gnunet <=