Commit ca7cc39d authored by Lubomir Rintel's avatar Lubomir Rintel

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).
parent 4729d50f
......@@ -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)
{
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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));
......
......@@ -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));
}
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment