mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-08 04:45:31 +00:00
account-row: Use delayed state changes for GtkSwitch
When trying to go online/offline we're always waiting for confirmation from the stack (even if it's a timeout) so the delayed pattern is a good choice.
This commit is contained in:
parent
0605582fc7
commit
41479eea09
2 changed files with 20 additions and 6 deletions
|
@ -74,7 +74,12 @@ on_account_state_changed (CallsAccountRow *self)
|
||||||
{
|
{
|
||||||
CallsAccountState state = calls_account_get_state (self->account);
|
CallsAccountState state = calls_account_get_state (self->account);
|
||||||
|
|
||||||
|
g_debug ("Account (%s) state changed: %s",
|
||||||
|
calls_origin_get_name (CALLS_ORIGIN (self->account)),
|
||||||
|
calls_account_state_to_string (state));
|
||||||
|
|
||||||
gtk_switch_set_active (self->online_switch, state == CALLS_ACCOUNT_STATE_ONLINE);
|
gtk_switch_set_active (self->online_switch, state == CALLS_ACCOUNT_STATE_ONLINE);
|
||||||
|
gtk_switch_set_state (self->online_switch, state == CALLS_ACCOUNT_STATE_ONLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -88,15 +93,24 @@ on_edit_clicked (CallsAccountRow *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
on_online_switched (CallsAccountRow *self)
|
on_online_switched (GtkSwitch *widget,
|
||||||
|
gboolean online,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
gboolean online;
|
CallsAccountRow *self;
|
||||||
|
|
||||||
g_assert (CALLS_IS_ACCOUNT_ROW (self));
|
g_assert (CALLS_IS_ACCOUNT_ROW (user_data));
|
||||||
|
|
||||||
|
self = CALLS_ACCOUNT_ROW (user_data);
|
||||||
|
|
||||||
|
g_debug ("Trying to go %sline with account %s",
|
||||||
|
online ? "on" : "off",
|
||||||
|
calls_origin_get_name (CALLS_ORIGIN (self->account)));
|
||||||
|
|
||||||
online = gtk_switch_get_active (self->online_switch);
|
|
||||||
calls_account_go_online (self->account, online);
|
calls_account_go_online (self->account, online);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="active">False</property>
|
<property name="active">False</property>
|
||||||
<signal name="notify::active" handler="on_online_switched" swapped="yes"/>
|
<signal name="state-set" handler="on_online_switched" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue