1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2025-01-07 04:15:32 +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:
Evangelos Ribeiro Tzaras 2022-05-19 20:06:23 +02:00
parent 0605582fc7
commit 41479eea09
2 changed files with 20 additions and 6 deletions

View file

@ -74,7 +74,12 @@ on_account_state_changed (CallsAccountRow *self)
{
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_state (self->online_switch, state == CALLS_ACCOUNT_STATE_ONLINE);
}
static void
@ -88,15 +93,24 @@ on_edit_clicked (CallsAccountRow *self)
}
static void
on_online_switched (CallsAccountRow *self)
static gboolean
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);
return TRUE;
}

View file

@ -21,7 +21,7 @@
<property name="valign">center</property>
<property name="visible">True</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>
</child>