[network-manager-applet/lr/team: 4/6] editor: set input and output default value handlers at the same time



commit ce7d90b8cf1d684d171acc62a4e297c8bea2970a
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Thu Jul 14 16:45:58 2016 +0200

    editor: set input and output default value handlers at the same time
    
    They should always be used together (otherwise things break for a
    non-zero default values).

 src/connection-editor/ce-page.c         |   30 ++++++++++++++++++++++++++----
 src/connection-editor/ce-page.h         |    9 ++-------
 src/connection-editor/page-bond.c       |    4 +---
 src/connection-editor/page-ethernet.c   |    4 +---
 src/connection-editor/page-infiniband.c |    4 +---
 src/connection-editor/page-team.c       |    4 +---
 src/connection-editor/page-vlan.c       |    4 +---
 src/connection-editor/page-wifi.c       |   13 +++----------
 8 files changed, 36 insertions(+), 36 deletions(-)
---
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index a0c0ac7..4b17fde 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -70,7 +70,7 @@ spin_output_with_default_string (GtkSpinButton *spin,
        return TRUE;
 }
 
-gboolean
+static gboolean
 ce_spin_output_with_automatic (GtkSpinButton *spin, gpointer user_data)
 {
        return spin_output_with_default_string (spin,
@@ -78,7 +78,7 @@ ce_spin_output_with_automatic (GtkSpinButton *spin, gpointer user_data)
                                                _("automatic"));
 }
 
-gboolean
+static gboolean
 ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data)
 {
        return spin_output_with_default_string (spin,
@@ -103,7 +103,7 @@ spin_input_with_default_string (GtkSpinButton *spin,
        return FALSE;
 }
 
-gint
+static gint
 ce_spin_input_with_automatic (GtkSpinButton *spin, gdouble *new_val, gpointer user_data)
 {
        return spin_input_with_default_string (spin,
@@ -112,7 +112,7 @@ ce_spin_input_with_automatic (GtkSpinButton *spin, gdouble *new_val, gpointer us
                                               _("automatic"));
 }
 
-gint
+static gint
 ce_spin_input_with_default (GtkSpinButton *spin, gdouble *new_val, gpointer user_data)
 {
        return spin_input_with_default_string (spin,
@@ -121,6 +121,28 @@ ce_spin_input_with_default (GtkSpinButton *spin, gdouble *new_val, gpointer user
                                               _("default"));
 }
 
+void
+ce_spin_automatic_val (GtkSpinButton *spin, int defvalue)
+{
+       g_signal_connect (spin, "output",
+                         G_CALLBACK (ce_spin_output_with_automatic),
+                         GINT_TO_POINTER (defvalue));
+       g_signal_connect (spin, "input",
+                         G_CALLBACK (ce_spin_input_with_automatic),
+                         GINT_TO_POINTER (defvalue));
+}
+
+void
+ce_spin_default_val (GtkSpinButton *spin, int defvalue)
+{
+       g_signal_connect (spin, "output",
+                         G_CALLBACK (ce_spin_output_with_default),
+                         GINT_TO_POINTER (defvalue));
+       g_signal_connect (spin, "input",
+                         G_CALLBACK (ce_spin_input_with_default),
+                         GINT_TO_POINTER (defvalue));
+}
+
 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 b479393..6fdb33c 100644
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -131,13 +131,8 @@ gboolean ce_page_device_entry_get (GtkEntry *entry, int type,
 
 void ce_page_changed (CEPage *self);
 
-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);
+void ce_spin_automatic_val (GtkSpinButton *spin, int defvalue);
+void ce_spin_default_val (GtkSpinButton *spin, int defvalue);
 
 int ce_get_property_default (NMSetting *setting, const char *property_name);
 
diff --git a/src/connection-editor/page-bond.c b/src/connection-editor/page-bond.c
index 7e5e025..e43940c 100644
--- a/src/connection-editor/page-bond.c
+++ b/src/connection-editor/page-bond.c
@@ -356,9 +356,7 @@ populate_ui (CEPageBond *self)
        } else {
                mtu_def = mtu_val = 0;
        }
-       g_signal_connect (priv->mtu, "output",
-                         G_CALLBACK (ce_spin_output_with_automatic),
-                         GINT_TO_POINTER (mtu_def));
+       ce_spin_automatic_val (priv->mtu, mtu_def);
        gtk_spin_button_set_value (priv->mtu, (gdouble) mtu_val);
 }
 
diff --git a/src/connection-editor/page-ethernet.c b/src/connection-editor/page-ethernet.c
index d72b7dd..9cc5c6d 100644
--- a/src/connection-editor/page-ethernet.c
+++ b/src/connection-editor/page-ethernet.c
@@ -224,9 +224,7 @@ populate_ui (CEPageEthernet *self)
 
        /* MTU */
        mtu_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRED_MTU);
-       g_signal_connect (priv->mtu, "output",
-                         G_CALLBACK (ce_spin_output_with_automatic),
-                         GINT_TO_POINTER (mtu_def));
+       ce_spin_automatic_val (priv->mtu, mtu_def);
 
        gtk_spin_button_set_value (priv->mtu, (gdouble) nm_setting_wired_get_mtu (setting));
 
diff --git a/src/connection-editor/page-infiniband.c b/src/connection-editor/page-infiniband.c
index e328f70..3cf7cd6 100644
--- a/src/connection-editor/page-infiniband.c
+++ b/src/connection-editor/page-infiniband.c
@@ -108,9 +108,7 @@ populate_ui (CEPageInfiniband *self)
 
        /* MTU */
        mtu_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_INFINIBAND_MTU);
-       g_signal_connect (priv->mtu, "output",
-                         G_CALLBACK (ce_spin_output_with_automatic),
-                         GINT_TO_POINTER (mtu_def));
+       ce_spin_automatic_val (priv->mtu, mtu_def);
 
        gtk_spin_button_set_value (priv->mtu, (gdouble) nm_setting_infiniband_get_mtu (setting));
 }
diff --git a/src/connection-editor/page-team.c b/src/connection-editor/page-team.c
index bb197d8..b4900a9 100644
--- a/src/connection-editor/page-team.c
+++ b/src/connection-editor/page-team.c
@@ -152,9 +152,7 @@ populate_ui (CEPageTeam *self)
        } else {
                mtu_def = mtu_val = 0;
        }
-       g_signal_connect (priv->mtu, "output",
-                         G_CALLBACK (ce_spin_output_with_automatic),
-                         GINT_TO_POINTER (mtu_def));
+       ce_spin_automatic_val (priv->mtu, mtu_def);
        gtk_spin_button_set_value (priv->mtu, (gdouble) mtu_val);
 }
 
diff --git a/src/connection-editor/page-vlan.c b/src/connection-editor/page-vlan.c
index 0f555fb..e021143 100644
--- a/src/connection-editor/page-vlan.c
+++ b/src/connection-editor/page-vlan.c
@@ -543,9 +543,7 @@ populate_ui (CEPageVlan *self)
        } else {
                mtu_def = mtu_val = 1500;
        }
-       g_signal_connect (priv->mtu, "output",
-                         G_CALLBACK (ce_spin_output_with_automatic),
-                         GINT_TO_POINTER (mtu_def));
+       ce_spin_automatic_val (priv->mtu, mtu_def);
 
        gtk_spin_button_set_value (priv->mtu, (gdouble) mtu_val);
        g_signal_connect (priv->mtu, "value-changed", G_CALLBACK (stuff_changed), self);
diff --git a/src/connection-editor/page-wifi.c b/src/connection-editor/page-wifi.c
index 71c557a..7bf9987 100644
--- a/src/connection-editor/page-wifi.c
+++ b/src/connection-editor/page-wifi.c
@@ -304,21 +304,14 @@ populate_ui (CEPageWifi *self)
        guint32 idx;
 
        rate_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRELESS_RATE);
-       g_signal_connect (priv->rate, "output",
-                         G_CALLBACK (ce_spin_output_with_automatic),
-                         GINT_TO_POINTER (rate_def));
-       g_signal_connect_swapped (priv->rate, "value-changed", G_CALLBACK (ce_page_changed), self);
+       ce_spin_automatic_val (priv->mtu, rate_def);
 
        tx_power_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRELESS_TX_POWER);
-       g_signal_connect (priv->tx_power, "output",
-                         G_CALLBACK (ce_spin_output_with_automatic),
-                         GINT_TO_POINTER (tx_power_def));
+       ce_spin_automatic_val (priv->mtu, tx_power_def);
        g_signal_connect_swapped (priv->tx_power, "value-changed", G_CALLBACK (ce_page_changed), self);
 
        mtu_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRELESS_MTU);
-       g_signal_connect (priv->mtu, "output",
-                         G_CALLBACK (ce_spin_output_with_automatic),
-                         GINT_TO_POINTER (mtu_def));
+       ce_spin_automatic_val (priv->mtu, mtu_def);
        g_signal_connect_swapped (priv->mtu, "value-changed", G_CALLBACK (ce_page_changed), self);
 
        ssid = nm_setting_wireless_get_ssid (setting);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]