[gnome-control-center/backport-edit-connection-details-in-known-connections-dialog: 3/3] wifi: Allow accessing settings of known wifi networks




commit f69926a95aa545c730893513c2e3ca45c8e8d981
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
    Closes https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1858

 panels/network/cc-wifi-connection-list.c | 12 +++++++-----
 panels/network/cc-wifi-connection-row.c  | 21 +++++++++++++++++++--
 panels/network/cc-wifi-connection-row.h  |  3 ++-
 3 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/panels/network/cc-wifi-connection-list.c b/panels/network/cc-wifi-connection-list.c
index 2312445bb..03a889394 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);
@@ -232,7 +234,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 */
@@ -350,7 +352,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;
     }
@@ -374,7 +376,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 fdae62056..ca59d6fb4 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
 };
 
@@ -253,7 +255,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)
     {
@@ -362,6 +364,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);
     }
@@ -408,6 +414,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);
     }
@@ -473,6 +483,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);
@@ -507,13 +522,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);


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