[gnome-control-center/gnome-42] wifi: Fix state of "Forget" button in "Known Wi-Fi Networks" dialog



commit aad990ed17cdeef654fc8b8b2c90cc2696801b2a
Author: Hendrik Müller <henne90gen gmail com>
Date:   Fri Jul 15 08:37:45 2022 +0200

    wifi: Fix state of "Forget" button in "Known Wi-Fi Networks" dialog
    
    The "Forget" button would only update it's sensitivity after the first
    select and deselect, when selecting and deselecting rows in the
    "Known Wi-Fi Networks" dialog.
    When selecting the first row, it would go from disabled to enabled.
    Then deselecting that row would cause the button to go from enabled to
    disabled.
    Selecting any rows after that would no longer update the sensitivity and
    make the dialog essentially useless.
    
    The issue was, that the signals "add" and "remove" where being
    expected to be emitted when the connection list updates its rows.
    However, neither CcWifiConnectionList nor GtkListBox emit these signals.
    The fix was, to emit these two signals at the appropriate locations.
    The signals have also been renamed to "add-row" and "remove-row" to
    make their purpose more clear.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1824
    Closes https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1993

 panels/network/cc-wifi-connection-list.c | 16 ++++++++++++++++
 panels/network/net-device-wifi.c         |  4 ++--
 2 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/panels/network/cc-wifi-connection-list.c b/panels/network/cc-wifi-connection-list.c
index 5de65ca2e..2312445bb 100644
--- a/panels/network/cc-wifi-connection-list.c
+++ b/panels/network/cc-wifi-connection-list.c
@@ -133,6 +133,8 @@ cc_wifi_connection_list_row_add (CcWifiConnectionList *self,
 
   g_signal_connect_object (res, "configure", G_CALLBACK (on_row_configured_cb), self, G_CONNECT_SWAPPED);
 
+  g_signal_emit_by_name (self, "add-row", res);
+
   return res;
 }
 
@@ -154,6 +156,7 @@ clear_widget (CcWifiConnectionList *self)
   while (g_hash_table_iter_next (&iter, NULL, (gpointer*) &row))
     {
       g_hash_table_iter_remove (&iter);
+      g_signal_emit_by_name (self, "remove-row", row);
       gtk_list_box_remove (self->listbox, GTK_WIDGET (row));
     }
 
@@ -165,6 +168,7 @@ clear_widget (CcWifiConnectionList *self)
 
       row = g_ptr_array_index (self->connections_row, i);
       g_ptr_array_index (self->connections_row, i) = NULL;
+      g_signal_emit_by_name (self, "remove-row", row);
       gtk_list_box_remove (self->listbox, GTK_WIDGET (row));
      }
 
@@ -404,6 +408,7 @@ on_device_ap_removed_cb (CcWifiConnectionList *self,
           if (self->hide_unavailable)
             {
               g_ptr_array_index (self->connections_row, i) = NULL;
+              g_signal_emit_by_name (self, "remove-row", row);
               gtk_list_box_remove (self->listbox, GTK_WIDGET (row));
             }
         }
@@ -425,6 +430,7 @@ on_device_ap_removed_cb (CcWifiConnectionList *self,
   if (cc_wifi_connection_row_remove_access_point (row, ap))
     {
       g_hash_table_remove (self->ssid_to_row, ssid);
+      g_signal_emit_by_name (self, "remove-row", row);
       gtk_list_box_remove (self->listbox, GTK_WIDGET (row));
     }
 }
@@ -699,6 +705,16 @@ cc_wifi_connection_list_class_init (CcWifiConnectionListClass *klass)
                 G_SIGNAL_RUN_LAST,
                 0, NULL, NULL, NULL,
                 G_TYPE_NONE, 1, CC_TYPE_WIFI_CONNECTION_ROW);
+  g_signal_new ("add-row",
+                CC_TYPE_WIFI_CONNECTION_LIST,
+                G_SIGNAL_RUN_LAST,
+                0, NULL, NULL, NULL,
+                G_TYPE_NONE, 1, CC_TYPE_WIFI_CONNECTION_ROW);
+  g_signal_new ("remove-row",
+                CC_TYPE_WIFI_CONNECTION_LIST,
+                G_SIGNAL_RUN_LAST,
+                0, NULL, NULL, NULL,
+                G_TYPE_NONE, 1, CC_TYPE_WIFI_CONNECTION_ROW);
 }
 
 static void
diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c
index 7f6fcc777..92299b10f 100644
--- a/panels/network/net-device-wifi.c
+++ b/panels/network/net-device-wifi.c
@@ -1085,11 +1085,11 @@ history_button_clicked_cb (NetDeviceWifi *self)
         g_object_set_data (G_OBJECT (list), "forget", forget);
         g_object_set_data (G_OBJECT (list), "net", self);
 
-        g_signal_connect_object (list, "add",
+        g_signal_connect_object (list, "add-row",
                                  G_CALLBACK (on_connection_list_row_added_cb),
                                  self,
                                  G_CONNECT_SWAPPED);
-        g_signal_connect_object (list, "remove",
+        g_signal_connect_object (list, "remove-row",
                                  G_CALLBACK (on_connection_list_row_removed_cb),
                                  self,
                                  G_CONNECT_SWAPPED);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]