[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25206 - gnunet-gtk/src/setup
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25206 - gnunet-gtk/src/setup |
Date: |
Mon, 3 Dec 2012 20:02:19 +0100 |
Author: grothoff
Date: 2012-12-03 20:02:19 +0100 (Mon, 03 Dec 2012)
New Revision: 25206
Modified:
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:
-implementing more of the A-dialog
Modified: gnunet-gtk/src/setup/gnunet-setup-gns-edit.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns-edit.c 2012-12-03 19:00:56 UTC
(rev 25205)
+++ gnunet-gtk/src/setup/gnunet-setup-gns-edit.c 2012-12-03 19:02:19 UTC
(rev 25206)
@@ -23,32 +23,9 @@
* @brief editing dialogs for GNS records
*/
#include "gnunet-setup-gns-edit.h"
+#include <gnunet/gnunet_gns_service.h>
-
/**
- * 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
@@ -77,6 +54,33 @@
/**
+ * Check that the common elements of the edit dialog are valid;
+ * if so, call 'edit_dialog_enable_save', otherwise 'edit_dialog_disable_save'.
+ *
+ * @param edc edit dialog to check
+ */
+static void
+edit_dialog_check_save (struct EditDialogContext *edc)
+{
+ GtkEditable *entry;
+ const gchar *name;
+
+ /* check name */
+ entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
+ "edit_dialog_name_entry"));
+ name = gtk_editable_get_chars (entry, 0, -1);
+ if ( (GNUNET_SYSERR == GNUNET_DNSPARSER_check_label (name)) &&
+ (0 != strcmp (name, GNUNET_GNS_MASTERZONE_STR)) )
+ {
+ edit_dialog_disable_save (edc);
+ return;
+ }
+ /* any other checks should go here */
+ edit_dialog_enable_save (edc);
+}
+
+
+/**
* The user has edited the A record value. Enable/disable 'save'
* button depending on the validity of the value.
*
@@ -89,19 +93,8 @@
gpointer user_data)
{
struct EditDialogContext *edc = user_data;
- const gchar *preedit;
- struct in_addr v4;
- preedit = gtk_editable_get_chars (entry, 0, -1);
-#if 0
- /* FIXME: need a way to check if _rest_ of the dialog is
- also consistent (like the _value_!) */
- if (1)
- edit_dialog_enable_save (edc);
- else
- edit_dialog_disable_save (edc);
-#endif
- GNUNET_break (0);
+ edc->validator (edc);
}
@@ -116,7 +109,7 @@
gpointer user_data)
{
struct EditDialogContext *edc = user_data;
-
+
/* not sure if we need to do anything here */
// FIXME
GNUNET_break (0);
@@ -153,8 +146,12 @@
{
struct EditDialogContext *edc = user_data;
- // FIXME
- GNUNET_break (0);
+ if (gtk_toggle_button_get_active (button))
+ gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (edc->builder,
+
"edit_dialog_expiration_relative_combobox")));
+ else
+ gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
+
"edit_dialog_expiration_relative_combobox")));
}
@@ -168,10 +165,7 @@
GNS_edit_dialog_expiration_forever_radiobutton_toggled_cb (GtkToggleButton
*button,
gpointer user_data)
{
- struct EditDialogContext *edc = user_data;
-
- // FIXME
- GNUNET_break (0);
+ /* nothing to do */
}
@@ -187,8 +181,20 @@
{
struct EditDialogContext *edc = user_data;
- // FIXME
- GNUNET_break (0);
+ if (gtk_toggle_button_get_active (button))
+ {
+ gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (edc->builder,
+
"edit_dialog_expiration_absolute_calendar")));
+ gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (edc->builder,
+
"edit_dialog_expiration_absolute_hbox")));
+ }
+ else
+ {
+ 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")));
+ }
}
@@ -312,6 +318,55 @@
/* ************************ A records *********************** */
/**
+ * Check validity of the value in the edit dialog for A-records.
+ * Then call the shared validity check if the result is OK.
+ *
+ * @param edc edit dialog context
+ */
+static void
+edit_dialog_a_validity_check (struct EditDialogContext *edc)
+{
+ GtkEditable *entry;
+ const gchar *preedit;
+ struct in_addr v4;
+
+ entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
+ "edit_dialog_a_entry")),
+ preedit = gtk_editable_get_chars (entry, 0, -1);
+ if ( (NULL == preedit) ||
+ (1 != inet_pton (AF_INET, preedit, &v4)) )
+ {
+ edit_dialog_disable_save (edc);
+ return;
+ }
+ edit_dialog_check_save (edc);
+}
+
+
+/**
+ * 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);
+}
+
+
+/**
* The user has edited the A record value. Enable/disable 'save'
* button depending on the validity of the value.
*
@@ -324,15 +379,8 @@
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);
+ edit_dialog_a_validity_check (edc);
}
@@ -361,6 +409,7 @@
"edit_dialog_a_entry")),
edc->n_value);
}
+ edc->validator = &edit_dialog_a_validity_check;
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 19:00:56 UTC
(rev 25205)
+++ gnunet-gtk/src/setup/gnunet-setup-gns-edit.h 2012-12-03 19:02:19 UTC
(rev 25206)
@@ -49,7 +49,14 @@
GtkResponseType ret);
+/**
+ * Signature of a dialog-specific validation function to validate the
+ * value. Should either call 'edit_dialog_disable_save' if the value
+ * is invalid, or 'edit_dialog_check_save' if the value is valid.
+ */
+typedef void (*GNS_EditValidator)(struct EditDialogContext *edc);
+
/**
* Context for edit operations.
*/
@@ -72,6 +79,12 @@
GNS_EditContinuation cont;
/**
+ * Function to call to validate the state of the dialog and
+ * ultimately update the 'save' button sensitivity.
+ */
+ GNS_EditValidator validator;
+
+ /**
* Builder for the dialog (internal to gnunet-setup-gns-edit.c).
*/
GtkBuilder *builder;
Modified: gnunet-gtk/src/setup/gnunet-setup-gns.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns.c 2012-12-03 19:00:56 UTC (rev
25205)
+++ gnunet-gtk/src/setup/gnunet-setup-gns.c 2012-12-03 19:02:19 UTC (rev
25206)
@@ -26,6 +26,7 @@
#include "gnunet_gtk.h"
#include "gnunet-setup-gns.h"
#include "gnunet-setup-gns-edit.h"
+#include <gnunet/gnunet_gns_service.h>
#include <gnunet/gnunet_namestore_service.h>
#include <gnunet/gnunet_dnsparser_lib.h>
@@ -42,11 +43,6 @@
#define NEW_RECORD_STR gettext_noop ("<new record>")
/**
- * Text we use for 'our own zone'. FIXME: define as constant in GNS?
- */
-#define ROOT_STR "+"
-
-/**
* Text we use for the expiration to mean 'never expires'.
*/
#define EXPIRE_NEVER_STRING gettext_noop ("never")
@@ -828,7 +824,7 @@
g_free (name);
return;
}
- if ( (0 == strcmp (name, ROOT_STR)) &&
+ if ( (0 == strcmp (name, GNUNET_GNS_MASTERZONE_STR)) &&
(0 == strcmp (current_zone_option, "ZONEKEY")) )
{
/* We have to append PSEU RECORD, this is the 'master' zone */
@@ -1082,7 +1078,7 @@
g_free (n_name);
g_free (n_value);
}
- else if (0 != strcmp (name, ROOT_STR))
+ else if (0 != strcmp (name, GNUNET_GNS_MASTERZONE_STR))
{
/* Removing the whole name record */
rc = GNUNET_malloc(sizeof (struct RemoveContext));
@@ -1401,7 +1397,7 @@
return;
if ( (GNUNET_OK !=
GNUNET_DNSPARSER_check_label (new_text)) &&
- (0 != strcmp (new_text, ROOT_STR)) )
+ (0 != strcmp (new_text, GNUNET_GNS_MASTERZONE_STR)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Name `%s' invalid for GADS/DNS (too long for a DNS
label?)\n"),
@@ -1944,7 +1940,7 @@
return;
}
if ( (GNUNET_SYSERR == GNUNET_DNSPARSER_check_label (name)) &&
- (0 != strcmp (name, ROOT_STR)) )
+ (0 != strcmp (name, GNUNET_GNS_MASTERZONE_STR)) )
{
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -2009,7 +2005,7 @@
else
GNUNET_asprintf (&type_str, "%s", EXPIRE_INVALID_STRING);
- if ( (0 == strcmp (name, ROOT_STR)) &&
+ if ( (0 == strcmp (name, GNUNET_GNS_MASTERZONE_STR)) &&
(GNUNET_NAMESTORE_TYPE_PSEU == rd[c].record_type) )
{
pseu_entry = GTK_ENTRY((GNUNET_SETUP_get_object
("GNUNET_setup_gns_pseu_entry")));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25206 - gnunet-gtk/src/setup,
gnunet <=