diff options
author | velsinki <112010-velsinki@users.noreply.gitlab.gnome.org> | 2023-04-25 01:35:13 +0200 |
---|---|---|
committer | Felipe Borges <felipeborges@gnome.org> | 2023-05-05 09:35:01 +0000 |
commit | efc595cccd4a4c25a78a4466d9894d0ae4c13d43 (patch) | |
tree | 3017a908af039f41f7d5daa5d2129f9b21f7a4e2 | |
parent | a0ee96c8ff480bf963568616ffa464e72dfdd8c0 (diff) | |
download | gnome-control-center-efc595cccd4a4c25a78a4466d9894d0ae4c13d43.tar.gz |
sharing: Fix visual bug for active indicators
The switch for the current network was only updated to TRUE after a
network change. However, if a new network was not enabled, the switch
should be set to FALSE. This is now properly handled.
Furthermore, the Off/Enabled/Active indicator was also inconsistent
after network changes due to the is_visible check failing sometimes,
even after changing to an already enabled network. Because the actual
current network state is now better tracked, we can just check the state
of the switch instead.
-rw-r--r-- | panels/sharing/cc-sharing-networks.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/panels/sharing/cc-sharing-networks.c b/panels/sharing/cc-sharing-networks.c index 7b977f585..2ef502b42 100644 --- a/panels/sharing/cc-sharing-networks.c +++ b/panels/sharing/cc-sharing-networks.c @@ -85,8 +85,7 @@ cc_sharing_networks_update_status (CcSharingNetworks *self) if (self->networks == NULL) status = CC_SHARING_STATUS_OFF; - else if (gtk_widget_is_visible (self->current_switch) && - gtk_switch_get_active (GTK_SWITCH (self->current_switch))) + else if (gtk_switch_get_active (GTK_SWITCH (self->current_switch))) status = CC_SHARING_STATUS_ACTIVE; else status = CC_SHARING_STATUS_ENABLED; @@ -280,7 +279,7 @@ static void cc_sharing_update_networks_box (CcSharingNetworks *self) { GtkWidget *child; - gboolean current_visible; + gboolean current_visible, current_network_enabled = FALSE; const char *current_network; GList *l; @@ -334,11 +333,7 @@ cc_sharing_update_networks_box (CcSharingNetworks *self) GtkWidget *row; if (g_strcmp0 (net->uuid, current_network) == 0) { - g_signal_handlers_block_by_func (self->current_switch, - cc_sharing_networks_enable_network, self); - gtk_switch_set_active (GTK_SWITCH (self->current_switch), TRUE); - g_signal_handlers_unblock_by_func (self->current_switch, - cc_sharing_networks_enable_network, self); + current_network_enabled = TRUE; continue; } @@ -350,6 +345,12 @@ cc_sharing_update_networks_box (CcSharingNetworks *self) gtk_list_box_insert (GTK_LIST_BOX (self->listbox), row, -1); } + g_signal_handlers_block_by_func (self->current_switch, + cc_sharing_networks_enable_network, self); + gtk_switch_set_active (GTK_SWITCH (self->current_switch), current_network_enabled); + g_signal_handlers_unblock_by_func (self->current_switch, + cc_sharing_networks_enable_network, self); + if (self->networks == NULL && !current_visible) { gtk_widget_set_visible (self->no_network_row, TRUE); |