From 19c5d9d4fc62557b15ea681ce4918d7736d5b872 Mon Sep 17 00:00:00 2001 From: Alessandro Bono Date: Sun, 5 Feb 2023 14:49:18 +0100 Subject: [PATCH] thunderbolt: Decouple active and state properties usage The ability to tweak the state property was mainly introduced in order to implement delayed state change via the state-set signal. Since GTK 4.9.3[1] the active and state properties are no more interchangeable. [1] https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5442 --- panels/thunderbolt/cc-bolt-panel.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/panels/thunderbolt/cc-bolt-panel.c b/panels/thunderbolt/cc-bolt-panel.c index e6c68aa3d..10c20e097 100644 --- a/panels/thunderbolt/cc-bolt-panel.c +++ b/panels/thunderbolt/cc-bolt-panel.c @@ -481,7 +481,7 @@ cc_bolt_panel_authmode_sync (CcBoltPanel *panel) g_signal_handlers_block_by_func (panel->authmode_switch, on_authmode_state_set_cb, panel); - gtk_switch_set_state (panel->authmode_switch, enabled); + gtk_switch_set_active (panel->authmode_switch, enabled); g_signal_handlers_unblock_by_func (panel->authmode_switch, on_authmode_state_set_cb, panel); @@ -666,11 +666,22 @@ on_authmode_ready (GObject *source_object, gpointer user_data) { g_autoptr(GError) error = NULL; + BoltClient *client = BOLT_CLIENT (source_object); CcBoltPanel *panel; gboolean ok; - ok = bolt_client_set_authmode_finish (BOLT_CLIENT (source_object), res, &error); - if (!ok) + ok = bolt_client_set_authmode_finish (client, res, &error); + if (ok) + { + BoltAuthMode mode; + gboolean enabled; + + panel = CC_BOLT_PANEL (user_data); + mode = bolt_client_get_authmode (client); + enabled = (mode & BOLT_AUTH_ENABLED) != 0; + gtk_switch_set_state (panel->authmode_switch, enabled); + } + else { g_autofree char *text = NULL; @@ -688,7 +699,6 @@ on_authmode_ready (GObject *source_object, cc_bolt_panel_authmode_sync (panel); } - panel = CC_BOLT_PANEL (user_data); gtk_spinner_stop (panel->authmode_spinner); gtk_widget_set_sensitive (GTK_WIDGET (panel->authmode_switch), TRUE); }