diff options
author | Dan Williams <dcbw@redhat.com> | 2013-10-10 11:16:23 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-02-19 20:00:24 -0600 |
commit | 55e34f334f6400d9a03d39d52ddccc27c85d408d (patch) | |
tree | 744fadcb272650af907171e2de9f084315bf1637 | |
parent | 0a3ec428cdf1c614f5c41573e1e284d84cb2f642 (diff) | |
download | network-manager-applet-55e34f334f6400d9a03d39d52ddccc27c85d408d.tar.gz |
editor: generalize ce_spin_output_with_default()
We may want to use this for default value strings other than
"automatic" in the future, so change the name to "automatic" and
pass the string to the generic helper that does the actual work.
Also, the return value for the "output" signal for the spinbutton
should be 'gboolean' not 'gint'.
-rw-r--r-- | src/connection-editor/ce-page.c | 17 | ||||
-rw-r--r-- | src/connection-editor/ce-page.h | 2 | ||||
-rw-r--r-- | src/connection-editor/page-ethernet.c | 2 | ||||
-rw-r--r-- | src/connection-editor/page-infiniband.c | 2 | ||||
-rw-r--r-- | src/connection-editor/page-vlan.c | 2 | ||||
-rw-r--r-- | src/connection-editor/page-wifi.c | 6 |
6 files changed, 20 insertions, 11 deletions
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c index 866d2cc0..0e01023e 100644 --- a/src/connection-editor/ce-page.c +++ b/src/connection-editor/ce-page.c @@ -55,16 +55,17 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -gint -ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data) +static gboolean +spin_output_with_default_string (GtkSpinButton *spin, + int defvalue, + const char *defstring) { - int defvalue = GPOINTER_TO_INT (user_data); int val; gchar *buf = NULL; val = gtk_spin_button_get_value_as_int (spin); if (val == defvalue) - buf = g_strdup (_("automatic")); + buf = g_strdup (defstring); else buf = g_strdup_printf ("%d", val); @@ -75,6 +76,14 @@ ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data) return TRUE; } +gboolean +ce_spin_output_with_automatic (GtkSpinButton *spin, gpointer user_data) +{ + return spin_output_with_default_string (spin, + GPOINTER_TO_INT (user_data), + _("automatic")); +} + 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 f5e96d60..794d20db 100644 --- a/src/connection-editor/ce-page.h +++ b/src/connection-editor/ce-page.h @@ -118,7 +118,7 @@ void ce_page_mac_to_entry (const GByteArray *mac, int type, GtkEntry *entry); GByteArray *ce_page_entry_to_mac (GtkEntry *entry, int type, gboolean *invalid); -gint ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data); +gboolean ce_spin_output_with_automatic (GtkSpinButton *spin, gpointer user_data); int ce_get_property_default (NMSetting *setting, const char *property_name); diff --git a/src/connection-editor/page-ethernet.c b/src/connection-editor/page-ethernet.c index 5c695726..d24a10f3 100644 --- a/src/connection-editor/page-ethernet.c +++ b/src/connection-editor/page-ethernet.c @@ -180,7 +180,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_default), + G_CALLBACK (ce_spin_output_with_automatic), GINT_TO_POINTER (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 bcd01a42..937da397 100644 --- a/src/connection-editor/page-infiniband.c +++ b/src/connection-editor/page-infiniband.c @@ -118,7 +118,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_default), + G_CALLBACK (ce_spin_output_with_automatic), GINT_TO_POINTER (mtu_def)); gtk_spin_button_set_value (priv->mtu, (gdouble) nm_setting_infiniband_get_mtu (setting)); diff --git a/src/connection-editor/page-vlan.c b/src/connection-editor/page-vlan.c index ff133872..c6aeccef 100644 --- a/src/connection-editor/page-vlan.c +++ b/src/connection-editor/page-vlan.c @@ -443,7 +443,7 @@ populate_ui (CEPageVlan *self) mtu_def = mtu_val = 1500; } g_signal_connect (priv->mtu, "output", - G_CALLBACK (ce_spin_output_with_default), + G_CALLBACK (ce_spin_output_with_automatic), GINT_TO_POINTER (mtu_def)); gtk_spin_button_set_value (priv->mtu, (gdouble) mtu_val); diff --git a/src/connection-editor/page-wifi.c b/src/connection-editor/page-wifi.c index bf6c47d0..d0a56173 100644 --- a/src/connection-editor/page-wifi.c +++ b/src/connection-editor/page-wifi.c @@ -315,19 +315,19 @@ populate_ui (CEPageWifi *self) 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_default), + 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); 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_default), + G_CALLBACK (ce_spin_output_with_automatic), GINT_TO_POINTER (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_default), + G_CALLBACK (ce_spin_output_with_automatic), GINT_TO_POINTER (mtu_def)); g_signal_connect_swapped (priv->mtu, "value-changed", G_CALLBACK (ce_page_changed), self); |