diff options
Diffstat (limited to 'src/namestore/plugin_gtk_namestore_gns2dns.c')
-rw-r--r-- | src/namestore/plugin_gtk_namestore_gns2dns.c | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/src/namestore/plugin_gtk_namestore_gns2dns.c b/src/namestore/plugin_gtk_namestore_gns2dns.c index 76879194..88d41ba9 100644 --- a/src/namestore/plugin_gtk_namestore_gns2dns.c +++ b/src/namestore/plugin_gtk_namestore_gns2dns.c | |||
@@ -27,12 +27,30 @@ | |||
27 | #include "gnunet_gtk_namestore_plugin.h" | 27 | #include "gnunet_gtk_namestore_plugin.h" |
28 | 28 | ||
29 | 29 | ||
30 | |||
31 | /** | ||
32 | * The user has edited the GNS2DNS record value. Enable/disable 'save' | ||
33 | * button depending on the validity of the value. | ||
34 | * | ||
35 | * @param entry editing widget | ||
36 | * @param user_data the plugin environment | ||
37 | */ | ||
38 | void | ||
39 | GNS_edit_dialog_gns2dns_entry_changed_cb (GtkEditable *entry, | ||
40 | gpointer user_data) | ||
41 | { | ||
42 | struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = user_data; | ||
43 | |||
44 | env->check_validity (env->cls); | ||
45 | } | ||
46 | |||
47 | |||
30 | /** | 48 | /** |
31 | * Function that will be called to initialize the builder's | 49 | * Function that will be called to initialize the builder's |
32 | * widgets from the existing record (if there is one). | 50 | * widgets from the existing record (if there is one). |
33 | * The `n_value` is the existing value of the record as a string. | 51 | * The `n_value` is the existing value of the record as a string. |
34 | * | 52 | * |
35 | * @param cls the `struct GNUNET_GTK_NAMESTORE_PluginEnvirionment *` | 53 | * @param cls the `struct GNUNET_GTK_NAMESTORE_PluginEnvironment *` |
36 | * @param n_value the record as a string | 54 | * @param n_value the record as a string |
37 | * @param builder the edit dialog's builder | 55 | * @param builder the edit dialog's builder |
38 | */ | 56 | */ |
@@ -41,7 +59,9 @@ gns2dns_load (void *cls, | |||
41 | gchar *n_value, | 59 | gchar *n_value, |
42 | GtkBuilder *builder) | 60 | GtkBuilder *builder) |
43 | { | 61 | { |
44 | GNUNET_break (0); | 62 | gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, |
63 | "edit_dialog_gns2dns_entry")), | ||
64 | n_value); | ||
45 | } | 65 | } |
46 | 66 | ||
47 | 67 | ||
@@ -49,7 +69,7 @@ gns2dns_load (void *cls, | |||
49 | * Function that will be called to retrieve the final value of the | 69 | * Function that will be called to retrieve the final value of the |
50 | * record (in string format) once the dialog is being closed. | 70 | * record (in string format) once the dialog is being closed. |
51 | * | 71 | * |
52 | * @param cls the `struct GNUNET_GTK_NAMESTORE_PluginEnvirionment *` | 72 | * @param cls the `struct GNUNET_GTK_NAMESTORE_PluginEnvironment *` |
53 | * @param builder the edit dialog's builder | 73 | * @param builder the edit dialog's builder |
54 | * @return record value as a string, as specified in the dialog | 74 | * @return record value as a string, as specified in the dialog |
55 | */ | 75 | */ |
@@ -57,8 +77,13 @@ static gchar * | |||
57 | gns2dns_store (void *cls, | 77 | gns2dns_store (void *cls, |
58 | GtkBuilder *builder) | 78 | GtkBuilder *builder) |
59 | { | 79 | { |
60 | GNUNET_break (0); | 80 | GtkEntry *entry; |
61 | return NULL; | 81 | const gchar *value; |
82 | |||
83 | entry = GTK_ENTRY (gtk_builder_get_object (builder, | ||
84 | "edit_dialog_gns2dns_entry")); | ||
85 | value = gtk_entry_get_text (entry); | ||
86 | return g_strdup (value); | ||
62 | } | 87 | } |
63 | 88 | ||
64 | 89 | ||
@@ -69,7 +94,7 @@ gns2dns_store (void *cls, | |||
69 | * function should highlight fields with invalid inputs for the | 94 | * function should highlight fields with invalid inputs for the |
70 | * user. | 95 | * user. |
71 | * | 96 | * |
72 | * @param cls the `struct GNUNET_GTK_NAMESTORE_PluginEnvirionment *` | 97 | * @param cls the `struct GNUNET_GTK_NAMESTORE_PluginEnvironment *` |
73 | * @param builder the edit dialog's builder | 98 | * @param builder the edit dialog's builder |
74 | * @return #GNUNET_OK if there is a valid record value in the dialog | 99 | * @return #GNUNET_OK if there is a valid record value in the dialog |
75 | */ | 100 | */ |
@@ -77,7 +102,15 @@ static int | |||
77 | gns2dns_validate (void *cls, | 102 | gns2dns_validate (void *cls, |
78 | GtkBuilder *builder) | 103 | GtkBuilder *builder) |
79 | { | 104 | { |
80 | GNUNET_break (0); | 105 | GtkEditable *entry; |
106 | const gchar *preedit; | ||
107 | |||
108 | entry = GTK_EDITABLE (gtk_builder_get_object (builder, | ||
109 | "edit_dialog_gns2dns_entry")), | ||
110 | preedit = gtk_editable_get_chars (entry, 0, -1); | ||
111 | if ( (NULL == preedit) || | ||
112 | (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) ) | ||
113 | return GNUNET_SYSERR; | ||
81 | return GNUNET_OK; | 114 | return GNUNET_OK; |
82 | } | 115 | } |
83 | 116 | ||
@@ -91,7 +124,7 @@ gns2dns_validate (void *cls, | |||
91 | void * | 124 | void * |
92 | libgnunet_plugin_gtk_namestore_gns2dns_init (void *cls) | 125 | libgnunet_plugin_gtk_namestore_gns2dns_init (void *cls) |
93 | { | 126 | { |
94 | struct GNUNET_GTK_NAMESTORE_PluginEnvirionment *env = cls; | 127 | struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls; |
95 | struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin; | 128 | struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin; |
96 | 129 | ||
97 | plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions); | 130 | plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions); |