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