summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2016-07-14 16:24:44 +0200
committerLubomir Rintel <lkundrak@v3.sk>2016-07-25 13:39:00 +0200
commit4729d50f1a8f029a10a961500c50f84cec05e0c9 (patch)
tree13a6bc66038c7c926d1554e0c3180abb7a504223
parent32d2ac332400359c4e5c0ffd6197893336c90f07 (diff)
downloadnetwork-manager-applet-4729d50f1a8f029a10a961500c50f84cec05e0c9.tar.gz
editor: spins with default value need an input handler too
Otherwise the default value gets converted to a string on output, but to a zero on input (which is not correct when the default value is not 0).
-rw-r--r--src/connection-editor/ce-page.c35
-rw-r--r--src/connection-editor/ce-page.h4
2 files changed, 39 insertions, 0 deletions
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index 6b7678a3..a0c0ac7c 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -86,6 +86,41 @@ ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data)
_("default"));
}
+static gint
+spin_input_with_default_string (GtkSpinButton *spin,
+ int defvalue,
+ gdouble *new_val,
+ const char *defstring)
+{
+ const gchar *buf;
+
+ buf = gtk_entry_get_text (GTK_ENTRY (spin));
+ if (strcmp (buf, defstring) == 0) {
+ *new_val = defvalue;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gint
+ce_spin_input_with_automatic (GtkSpinButton *spin, gdouble *new_val, gpointer user_data)
+{
+ return spin_input_with_default_string (spin,
+ GPOINTER_TO_INT (user_data),
+ new_val,
+ _("automatic"));
+}
+
+gint
+ce_spin_input_with_default (GtkSpinButton *spin, gdouble *new_val, gpointer user_data)
+{
+ return spin_input_with_default_string (spin,
+ GPOINTER_TO_INT (user_data),
+ new_val,
+ _("default"));
+}
+
int
ce_get_property_default (NMSetting *setting, const char *property_name)
{
diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h
index 2e9e093a..b479393f 100644
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -135,6 +135,10 @@ gboolean ce_spin_output_with_automatic (GtkSpinButton *spin, gpointer user_data)
gboolean ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data);
+gboolean ce_spin_input_with_automatic (GtkSpinButton *spin, gdouble *new_val, gpointer user_data);
+
+gboolean ce_spin_input_with_default (GtkSpinButton *spin, gdouble *new_val, gpointer user_data);
+
int ce_get_property_default (NMSetting *setting, const char *property_name);
void ce_page_complete_init (CEPage *self,