[gnome-control-center] wifi: Allow accessing settings of known wifi networks



commit f0890ca1b6171a7e0bc126e197772966d63413c4
Author: Hendrik Müller <henne90gen gmail com>
Date:   Sun Jun 26 19:33:15 2022 +0200

    wifi: Allow accessing settings of known wifi networks
    
    Currently it is only possible to access the settings for the currently
    connected wifi network.
    Being able to configure a wifi network, even though it is not connected,
    would be useful for example to share the password for a network that is
    not in range.
    
    To achieve this, a new property was added to CcWifiConnectionRow.
    The new property "known_connection" signals whether this connection is
    known and thus whether the options button for configuring it should be
    displayed.
    
    The property "known_connections" will be set to TRUE in two cases:
    - when the list of connections is shown in the "Known Networks" dialog
    - when the connection is known, but not the active connection
    
    Closes https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1906

 panels/network/cc-wifi-connection-list.c | 12 +++++++-----
 panels/network/cc-wifi-connection-row.c  | 21 +++++++++++++++++++--
 panels/network/cc-wifi-connection-row.h  |  3 ++-
 panels/network/net-device-wifi.c         |  1 +
 4 files changed, 29 insertions(+), 8 deletions(-)
---
diff --git a/panels/network/cc-wifi-connection-list.c b/panels/network/cc-wifi-connection-list.c
index f21db9155..6ce08c6dd 100644
--- a/panels/network/cc-wifi-connection-list.c
+++ b/panels/network/cc-wifi-connection-list.c
@@ -114,7 +114,8 @@ connection_ignored (NMConnection *connection)
 static CcWifiConnectionRow*
 cc_wifi_connection_list_row_add (CcWifiConnectionList *self,
                                  NMConnection         *connection,
-                                 NMAccessPoint        *ap)
+                                 NMAccessPoint        *ap,
+                                 gboolean              known_connection)
 {
   CcWifiConnectionRow *res;
   g_autoptr(GPtrArray) aps = NULL;
@@ -128,7 +129,8 @@ cc_wifi_connection_list_row_add (CcWifiConnectionList *self,
   res = cc_wifi_connection_row_new (self->device,
                                     connection,
                                     aps,
-                                    self->checkable);
+                                    self->checkable,
+                                    known_connection);
   gtk_list_box_append (self->listbox, GTK_WIDGET (res));
 
   g_signal_connect_object (res, "configure", G_CALLBACK (on_row_configured_cb), self, G_CONNECT_SWAPPED);
@@ -228,7 +230,7 @@ update_connections (CcWifiConnectionList *self)
       else
         g_ptr_array_add (self->connections_row,
                          cc_wifi_connection_list_row_add (self, con,
-                         NULL));
+                         NULL, TRUE));
     }
 
   /* Coldplug all known APs again */
@@ -347,7 +349,7 @@ on_device_ap_added_cb (CcWifiConnectionList *self,
 
       row = g_ptr_array_index (self->connections_row, j);
       if (!row)
-        row = cc_wifi_connection_list_row_add (self, g_ptr_array_index (connections, i), NULL);
+        row = cc_wifi_connection_list_row_add (self, g_ptr_array_index (connections, i), NULL, TRUE);
       cc_wifi_connection_row_add_access_point (row, ap);
       g_ptr_array_index (self->connections_row, j) = row;
     }
@@ -378,7 +380,7 @@ on_device_ap_added_cb (CcWifiConnectionList *self,
   row = g_hash_table_lookup (self->ssid_to_row, ssid);
   if (!row)
     {
-      row = cc_wifi_connection_list_row_add (self, NULL, ap);
+      row = cc_wifi_connection_list_row_add (self, NULL, ap, FALSE);
 
       g_hash_table_insert (self->ssid_to_row, g_bytes_ref (ssid), row);
     }
diff --git a/panels/network/cc-wifi-connection-row.c b/panels/network/cc-wifi-connection-row.c
index ae1be3766..608dda6a8 100644
--- a/panels/network/cc-wifi-connection-row.c
+++ b/panels/network/cc-wifi-connection-row.c
@@ -31,6 +31,7 @@ struct _CcWifiConnectionRow
   NMDeviceWifi    *device;
   GPtrArray       *aps;
   NMConnection    *connection;
+  gboolean         known_connection;
 
   GtkLabel        *active_label;
   GtkCheckButton  *checkbutton;
@@ -48,6 +49,7 @@ enum
   PROP_DEVICE,
   PROP_APS,
   PROP_CONNECTION,
+  PROP_KNOWN_CONNECTION,
   PROP_LAST
 };
 
@@ -260,7 +262,7 @@ update_ui (CcWifiConnectionRow *self)
     }
 
   gtk_widget_set_visible (GTK_WIDGET (self->active_label), active);
-  gtk_widget_set_visible (GTK_WIDGET (self->options_button), active || connecting);
+  gtk_widget_set_visible (GTK_WIDGET (self->options_button), active || connecting || self->known_connection);
 
   if (security != NM_AP_SEC_UNKNOWN && security != NM_AP_SEC_NONE && security != NM_AP_SEC_OWE && security 
!= NM_AP_SEC_OWE_TM)
     {
@@ -369,6 +371,10 @@ cc_wifi_connection_row_get_property (GObject    *object,
       g_value_set_object (value, self->connection);
       break;
 
+    case PROP_KNOWN_CONNECTION:
+      g_value_set_boolean (value, self->known_connection);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -415,6 +421,10 @@ cc_wifi_connection_row_set_property (GObject      *object,
       self->connection = g_value_dup_object (value);
       break;
 
+    case PROP_KNOWN_CONNECTION:
+      self->known_connection = g_value_get_boolean (value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -480,6 +490,11 @@ cc_wifi_connection_row_class_init (CcWifiConnectionRowClass *klass)
                                                  NM_TYPE_CONNECTION,
                                                  G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | 
G_PARAM_STATIC_STRINGS);
 
+  props[PROP_KNOWN_CONNECTION] = g_param_spec_boolean ("known-connection", "Known Connection",
+                                                "Whether this row is a known connection or not",
+                                                FALSE,
+                                                G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | 
G_PARAM_STATIC_STRINGS);
+
   g_object_class_install_properties (object_class,
                                      PROP_LAST,
                                      props);
@@ -514,13 +529,15 @@ CcWifiConnectionRow *
 cc_wifi_connection_row_new (NMDeviceWifi  *device,
                             NMConnection  *connection,
                             GPtrArray     *aps,
-                            gboolean       checkable)
+                            gboolean       checkable,
+                            gboolean       known_connection)
 {
   return g_object_new (CC_TYPE_WIFI_CONNECTION_ROW,
                        "device", device,
                        "connection", connection,
                        "aps", aps,
                        "checkable", checkable,
+                       "known-connection", known_connection,
                        NULL);
 }
 
diff --git a/panels/network/cc-wifi-connection-row.h b/panels/network/cc-wifi-connection-row.h
index d632cbf20..4d6f7bae9 100644
--- a/panels/network/cc-wifi-connection-row.h
+++ b/panels/network/cc-wifi-connection-row.h
@@ -30,7 +30,8 @@ G_DECLARE_FINAL_TYPE (CcWifiConnectionRow, cc_wifi_connection_row, CC, WIFI_CONN
 CcWifiConnectionRow *cc_wifi_connection_row_new                 (NMDeviceWifi  *device,
                                                                  NMConnection  *connection,
                                                                  GPtrArray     *aps,
-                                                                 gboolean       checkable);
+                                                                 gboolean       checkable,
+                                                                 gboolean       known_connection);
 
 gboolean             cc_wifi_connection_row_get_checkable       (CcWifiConnectionRow   *row);
 gboolean             cc_wifi_connection_row_get_checked         (CcWifiConnectionRow   *row);
diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c
index 3a92f324e..0cefe5c93 100644
--- a/panels/network/net-device-wifi.c
+++ b/panels/network/net-device-wifi.c
@@ -1314,3 +1314,4 @@ net_device_wifi_turn_off_hotspot (NetDeviceWifi *self)
 
         stop_shared_connection (self);
 }
+


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