[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25197 - in gnunet-gtk: contrib src/setup
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25197 - in gnunet-gtk: contrib src/setup |
Date: |
Mon, 3 Dec 2012 17:08:27 +0100 |
Author: grothoff
Date: 2012-12-03 17:08:26 +0100 (Mon, 03 Dec 2012)
New Revision: 25197
Modified:
gnunet-gtk/contrib/gnunet_setup_gns_edit_a.glade
gnunet-gtk/src/setup/gnunet-setup-gns-edit.c
gnunet-gtk/src/setup/gnunet-setup-gns-edit.h
gnunet-gtk/src/setup/gnunet-setup-gns.c
Log:
-towards A dialog
Modified: gnunet-gtk/contrib/gnunet_setup_gns_edit_a.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_setup_gns_edit_a.glade 2012-12-03 15:43:55 UTC
(rev 25196)
+++ gnunet-gtk/contrib/gnunet_setup_gns_edit_a.glade 2012-12-03 16:08:26 UTC
(rev 25197)
@@ -20,7 +20,11 @@
<object class="GtkDialog" id="edit_a_dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
+ <property name="modal">True</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
+ <signal name="response" handler="GNS_edit_a_dialog_response_cb"
swapped="no"/>
<child internal-child="vbox">
<object class="GtkVBox" id="edit_dialog_vbox">
<property name="visible">True</property>
@@ -67,6 +71,8 @@
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Store the
updated record in the database. If the record is public, GNUnet will begin to
publish the record to the world, limiting your ability to change it later
(based on the selected expiration values).</property>
<property name="use_stock">True</property>
@@ -185,6 +191,7 @@
<object class="GtkEntry" id="edit_dialog_a_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_focus">True</property>
<property name="tooltip_text" translatable="yes">Enter
the IPv4 address for the A record here. The format is the usual dotted-decimal
format (i.e. 127.0.0.1).</property>
<property name="max_length">15</property>
<property name="invisible_char">●</property>
@@ -192,6 +199,7 @@
<property
name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property
name="secondary_icon_sensitive">True</property>
+ <signal name="changed"
handler="GNS_edit_dialog_a_entry_changed_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
Modified: gnunet-gtk/src/setup/gnunet-setup-gns-edit.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns-edit.c 2012-12-03 15:43:55 UTC
(rev 25196)
+++ gnunet-gtk/src/setup/gnunet-setup-gns-edit.c 2012-12-03 16:08:26 UTC
(rev 25197)
@@ -26,6 +26,57 @@
/**
+ * Editing dialog was closed, get the data and call the
+ * continuation.
+ *
+ * @param dialog editing dialog
+ * @param user_data the 'struct EditDialogContext'
+ */
+void
+GNS_edit_a_dialog_response_cb (GtkDialog *dialog,
+ gint response_id,
+ gpointer user_data)
+{
+ struct EditDialogContext *edc = user_data;
+
+ fprintf (stderr, "response CB %d!\n", response_id);
+ /* FIXME: resync dialog elements back into 'edc'! */
+ gtk_widget_destroy (GTK_WIDGET (edc->dialog));
+ g_object_unref (edc->builder);
+ edc->builder = NULL;
+ edc->cont (edc, response_id);
+}
+
+
+/**
+ * Disable 'save' button, dialog state is not acceptable.
+ *
+ * @param edc dialog to modify
+ */
+static void
+edit_dialog_disable_save (struct EditDialogContext *edc)
+{
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (edc->builder,
+
"edit_dialog_save_button")),
+ FALSE);
+}
+
+
+/**
+ * Enable 'save' button, dialog state is acceptable.
+ *
+ * @param edc dialog to modify
+ */
+static void
+edit_dialog_enable_save (struct EditDialogContext *edc)
+{
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (edc->builder,
+
"edit_dialog_save_button")),
+ TRUE);
+}
+
+
+/**
* Initialize widgets of the edit dialog that are the same regardless of
* the type of the record.
*
@@ -39,9 +90,7 @@
{
gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
"edit_dialog_delete_button")));
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (edc->builder,
-
"edit_dialog_save_button")),
- FALSE);
+ edit_dialog_disable_save (edc);
}
gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
"edit_dialog_name_entry")),
@@ -54,6 +103,7 @@
edc->n_is_shadow);
if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value == edc->n_exp_time)
{
+ fprintf (stderr, "forever\n");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object
(edc->builder,
"edit_dialog_expiration_never_radiobutton")),
TRUE);
@@ -70,16 +120,22 @@
{
struct GNUNET_TIME_Relative rt;
+ fprintf (stderr, "relative\n");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object
(edc->builder,
"edit_dialog_expiration_relative_radiobutton")),
TRUE);
gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
-
"edit_dialog_expiration_relative_combobox")));
+
"edit_dialog_expiration_absolute_calendar")));
+ gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
+
"edit_dialog_expiration_absolute_hbox")));
rt.rel_value = edc->n_exp_time;
- gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
-
"edit_dialog_expiration_relative_combobox")),
- GNUNET_STRINGS_relative_time_to_string (rt,
GNUNET_NO));
-
+#if 0
+ /* FIXME: gtk_combo_box_set_text does not exist, we need to
+ update the model and then select the respective element... */
+ gtk_combo_box_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
+
"edit_dialog_expiration_relative_combobox")),
+ GNUNET_STRINGS_relative_time_to_string (rt,
GNUNET_NO));
+#endif
}
else
{
@@ -88,13 +144,13 @@
struct tm *ymd;
GtkCalendar *cal;
+ fprintf (stderr, "absolute\n");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object
(edc->builder,
"edit_dialog_expiration_absolute_radiobutton")),
TRUE);
+
gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
-
"edit_dialog_expiration_absolute_calendar")));
- gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
-
"edit_dialog_expiration_absolute_hbox")));
+
"edit_dialog_expiration_relative_combobox")));
at.abs_value = edc->n_exp_time;
tp = (time_t) (at.abs_value / 1000LL); /* convert to seconds */
ymd = gmtime (&tp);
@@ -120,6 +176,51 @@
/**
+ * Run the edit dialog. Performs all of the common initialization
+ * steps to run an edit dialog for records.
+ *
+ * @param edc editing context
+ */
+static void
+run_edit_dialog (struct EditDialogContext *edc)
+{
+ edit_dialog_setup_common_elements (edc);
+ edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
+ "edit_a_dialog"));
+ gtk_dialog_set_default_response (edc->dialog,
+ GTK_RESPONSE_OK);
+ gtk_window_present (GTK_WINDOW (edc->dialog));
+}
+
+
+/* ************************ A records *********************** */
+
+/**
+ * The user has edited the A record value. Enable/disable 'save'
+ * button depending on the validity of the value.
+ *
+ * @param entry editing widget
+ * @param preedit new value
+ * @param user_data the 'struct EditDialogContext' of the dialog
+ */
+void
+GNS_edit_dialog_a_entry_changed_cb (GtkEditable *entry,
+ gpointer user_data)
+{
+ struct EditDialogContext *edc = user_data;
+ const gchar *preedit;
+ struct in_addr v4;
+
+ preedit = gtk_editable_get_chars (entry, 0, -1);
+ if ( (NULL != preedit) &&
+ (1 == inet_pton (AF_INET, preedit, &v4)) )
+ edit_dialog_enable_save (edc);
+ else
+ edit_dialog_disable_save (edc);
+}
+
+
+/**
* Run an GNS Edit dialog for an 'A' Record.
*
* @param cont continuation to call when done
@@ -128,8 +229,6 @@
void
GNS_edit_dialog_a (struct EditDialogContext *edc)
{
- GtkDialog *dialog;
-
edc->builder = GNUNET_GTK_get_new_builder ("gnunet_setup_gns_edit_a.glade",
edc);
if (NULL == edc->builder)
@@ -138,15 +237,15 @@
edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
return;
}
- edit_dialog_setup_common_elements (edc);
- dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
- "edit_a_dialog"));
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_OK);
- gtk_window_present (GTK_WINDOW (dialog));
-
- GNUNET_break (0); /* not implemented */
- edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
+ if (GNUNET_YES ==
+ edc->old_record_in_namestore)
+ {
+ /* set A record */
+ gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
+
"edit_dialog_a_entry")),
+ edc->n_value);
+ }
+ run_edit_dialog (edc);
}
Modified: gnunet-gtk/src/setup/gnunet-setup-gns-edit.h
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns-edit.h 2012-12-03 15:43:55 UTC
(rev 25196)
+++ gnunet-gtk/src/setup/gnunet-setup-gns-edit.h 2012-12-03 16:08:26 UTC
(rev 25197)
@@ -77,6 +77,11 @@
GtkBuilder *builder;
/**
+ * Main dialog window.
+ */
+ GtkDialog *dialog;
+
+ /**
* Old name of the record (for deletion).
*/
gchar *n_name;
Modified: gnunet-gtk/src/setup/gnunet-setup-gns.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns.c 2012-12-03 15:43:55 UTC (rev
25196)
+++ gnunet-gtk/src/setup/gnunet-setup-gns.c 2012-12-03 16:08:26 UTC (rev
25197)
@@ -1074,6 +1074,7 @@
(void**)&rd.data, &rd.data_size);
rc = GNUNET_malloc (sizeof (struct RemoveContext));
+ GNUNET_CONTAINER_DLL_insert (rc_head, rc_tail, rc);
rc->path = strdup (path);
rc->qe = GNUNET_NAMESTORE_record_remove (namestore, pkey, name, &rd,
&update_treemodel_after_remove,
rc);
@@ -1085,6 +1086,7 @@
{
/* Removing the whole name record */
rc = GNUNET_malloc(sizeof (struct RemoveContext));
+ GNUNET_CONTAINER_DLL_insert (rc_head, rc_tail, rc);
rc->path = strdup (path);
rc->qe = GNUNET_NAMESTORE_record_remove (namestore, pkey, name, NULL,
&update_treemodel_after_remove,
rc);
@@ -1256,6 +1258,8 @@
guint type;
char *name_str;
+ if (0 == strcmp (new_text, _(NEW_RECORD_STR)))
+ return; /* no record type was selected */
type = GNUNET_NAMESTORE_typename_to_number (new_text);
if (UINT32_MAX == type)
{
@@ -1395,8 +1399,9 @@
path, new_text);
if ((0 == strcmp (new_text, NEW_NAME_STR)) || (0 == strcmp (new_text, "")))
return;
- if (GNUNET_OK !=
- GNUNET_DNSPARSER_check_label (new_text))
+ if ( (GNUNET_OK !=
+ GNUNET_DNSPARSER_check_label (new_text)) &&
+ (0 != strcmp (new_text, ROOT_STR)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Name `%s' invalid for GADS/DNS (too long for a DNS
label?)\n"),
@@ -1473,6 +1478,7 @@
GtkTreeIter it;
GtkMenu *popup;
GtkTreeSelection *sel;
+ gboolean name_vis;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Considering creating popup menu...\n");
@@ -1483,7 +1489,16 @@
"No row selected\n");
return FALSE;
}
- popup = GTK_MENU (GNUNET_SETUP_get_object
("GNUNET_setup_gns_delete_popup_menu"));
+ gtk_tree_model_get (tm, &it,
+ GNS_TREESTORE_COL_NAME_IS_VISIBLE, &name_vis,
+ -1);
+ if (name_vis)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Selected row is not a record row\n");
+ return FALSE;
+ }
+ popup = GTK_MENU (GNUNET_SETUP_get_object
("GNUNET_setup_gns_edit_popup_menu"));
gtk_widget_show_all (GTK_WIDGET (popup));
gtk_menu_popup (popup, NULL, NULL, NULL, NULL, 0, 0);
return TRUE;
@@ -1928,9 +1943,13 @@
gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_zone_selection_hbuttonbox")));
return;
}
- if (GNUNET_SYSERR == GNUNET_DNSPARSER_check_label (name))
+ if ( (GNUNET_SYSERR == GNUNET_DNSPARSER_check_label (name)) &&
+ (0 != strcmp (name, ROOT_STR)) )
{
GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Got invalid record name `%s' from namestore\n"),
+ name);
GNUNET_NAMESTORE_zone_iterator_next (zc_ctx->it);
return;
}
@@ -1946,6 +1965,7 @@
GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, _(NEW_RECORD_STR),
GNS_TREESTORE_COL_IS_RECORD_ROW, TRUE,
GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE,
+ GNS_TREESTORE_COL_TYPE_IS_EDITABLE, TRUE,
-1);
/* Append elements for records */
@@ -2069,6 +2089,7 @@
GNS_TREESTORE_COL_RECORD_TYPE,
GNUNET_DNSPARSER_TYPE_A,
GNS_TREESTORE_COL_IS_RECORD_ROW, FALSE,
GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE,
+ GNS_TREESTORE_COL_TYPE_IS_EDITABLE, TRUE,
-1);
/* Load zone from namestore! */
zc_ctx->zone = zone;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25197 - in gnunet-gtk: contrib src/setup,
gnunet <=