[gnome-control-center] network: Remove net_object_get_panel



commit 0b3ce1e15d4ec2b6260457e9a2d3b22d5798ea66
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Oct 23 12:08:54 2019 +1300

    network: Remove net_object_get_panel
    
    It was only being used for WiFi devices

 panels/network/cc-network-panel.c     | 12 ++++--------
 panels/network/net-device-bluetooth.c |  4 +---
 panels/network/net-device-bluetooth.h |  3 +--
 panels/network/net-device-ethernet.c  |  4 +---
 panels/network/net-device-ethernet.h  |  3 +--
 panels/network/net-device-mobile.c    |  8 ++------
 panels/network/net-device-mobile.h    |  3 +--
 panels/network/net-device-wifi.c      | 32 +++++++++++++-------------------
 panels/network/net-object.c           | 26 --------------------------
 panels/network/net-object.h           |  1 -
 panels/network/net-vpn.c              |  4 +---
 panels/network/net-vpn.h              |  3 +--
 12 files changed, 26 insertions(+), 77 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index 8288e8144..48ad02d03 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -465,24 +465,21 @@ panel_add_device (CcNetworkPanel *self, NMDevice *device)
         switch (type) {
         case NM_DEVICE_TYPE_ETHERNET:
         case NM_DEVICE_TYPE_INFINIBAND:
-                net_device = NET_DEVICE (net_device_ethernet_new (CC_PANEL (self),
-                                                                  self->cancellable,
+                net_device = NET_DEVICE (net_device_ethernet_new (self->cancellable,
                                                                   self->client,
                                                                   device,
                                                                   nm_device_get_udi (device)));
                 add_object (self, NET_OBJECT (net_device), GTK_CONTAINER (self->box_wired));
                 break;
         case NM_DEVICE_TYPE_MODEM:
-                net_device = NET_DEVICE (net_device_mobile_new (CC_PANEL (self),
-                                                                self->cancellable,
+                net_device = NET_DEVICE (net_device_mobile_new (self->cancellable,
                                                                 self->client,
                                                                 device,
                                                                 nm_device_get_udi (device)));
                 add_object (self, NET_OBJECT (net_device), GTK_CONTAINER (self->box_wired));
                 break;
         case NM_DEVICE_TYPE_BT:
-                net_device = NET_DEVICE (net_device_bluetooth_new (CC_PANEL (self),
-                                                                   self->cancellable,
+                net_device = NET_DEVICE (net_device_bluetooth_new (self->cancellable,
                                                                    self->client,
                                                                    device,
                                                                    nm_device_get_udi (device)));
@@ -686,8 +683,7 @@ panel_add_vpn_device (CcNetworkPanel *self, NMConnection *connection)
                 return;
 
         /* add as a VPN object */
-        net_vpn = net_vpn_new (CC_PANEL (self),
-                               id,
+        net_vpn = net_vpn_new (id,
                                connection,
                                self->client);
         g_signal_connect_object (net_vpn, "removed",
diff --git a/panels/network/net-device-bluetooth.c b/panels/network/net-device-bluetooth.c
index 3276e1265..1543009d5 100644
--- a/panels/network/net-device-bluetooth.c
+++ b/panels/network/net-device-bluetooth.c
@@ -233,14 +233,12 @@ net_device_bluetooth_init (NetDeviceBluetooth *self)
 }
 
 NetDeviceBluetooth *
-net_device_bluetooth_new (CcPanel      *panel,
-                          GCancellable *cancellable,
+net_device_bluetooth_new (GCancellable *cancellable,
                           NMClient     *client,
                           NMDevice     *device,
                           const gchar  *id)
 {
         return g_object_new (NET_TYPE_DEVICE_BLUETOOTH,
-                             "panel", panel,
                              "cancellable", cancellable,
                              "client", client,
                              "nm-device", device,
diff --git a/panels/network/net-device-bluetooth.h b/panels/network/net-device-bluetooth.h
index 91d61c920..9da291c10 100644
--- a/panels/network/net-device-bluetooth.h
+++ b/panels/network/net-device-bluetooth.h
@@ -31,8 +31,7 @@ G_BEGIN_DECLS
 #define NET_TYPE_DEVICE_BLUETOOTH (net_device_bluetooth_get_type ())
 G_DECLARE_FINAL_TYPE (NetDeviceBluetooth, net_device_bluetooth, NET, DEVICE_BLUETOOTH, NetDevice)
 
-NetDeviceBluetooth *net_device_bluetooth_new                (CcPanel            *panel,
-                                                             GCancellable       *cancellable,
+NetDeviceBluetooth *net_device_bluetooth_new                (GCancellable       *cancellable,
                                                              NMClient           *client,
                                                              NMDevice           *device,
                                                              const gchar        *id);
diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c
index 4142ee1ff..a4cb76519 100644
--- a/panels/network/net-device-ethernet.c
+++ b/panels/network/net-device-ethernet.c
@@ -592,14 +592,12 @@ net_device_ethernet_init (NetDeviceEthernet *self)
 }
 
 NetDeviceEthernet *
-net_device_ethernet_new (CcPanel      *panel,
-                         GCancellable *cancellable,
+net_device_ethernet_new (GCancellable *cancellable,
                          NMClient     *client,
                          NMDevice     *device,
                          const gchar  *id)
 {
         return g_object_new (NET_TYPE_DEVICE_ETHERNET,
-                             "panel", panel,
                              "cancellable", cancellable,
                              "client", client,
                              "nm-device", device,
diff --git a/panels/network/net-device-ethernet.h b/panels/network/net-device-ethernet.h
index 3190dc9ad..ba865e224 100644
--- a/panels/network/net-device-ethernet.h
+++ b/panels/network/net-device-ethernet.h
@@ -30,8 +30,7 @@ G_BEGIN_DECLS
 #define NET_TYPE_DEVICE_ETHERNET          (net_device_ethernet_get_type ())
 G_DECLARE_FINAL_TYPE (NetDeviceEthernet, net_device_ethernet, NET, DEVICE_ETHERNET, NetDevice)
 
-NetDeviceEthernet *net_device_ethernet_new (CcPanel      *panel,
-                                            GCancellable *cancellable,
+NetDeviceEthernet *net_device_ethernet_new (GCancellable *cancellable,
                                             NMClient     *client,
                                             NMDevice     *device,
                                             const gchar  *id);
diff --git a/panels/network/net-device-mobile.c b/panels/network/net-device-mobile.c
index 519490063..3a5242352 100644
--- a/panels/network/net-device-mobile.c
+++ b/panels/network/net-device-mobile.c
@@ -124,7 +124,6 @@ mobile_connection_changed_cb (NetDeviceMobile *self)
         NMConnection *connection;
         NMDevice *device;
         NMClient *client;
-        CcNetworkPanel *panel;
         GtkWidget *toplevel;
 
         if (self->updating_device)
@@ -145,8 +144,7 @@ mobile_connection_changed_cb (NetDeviceMobile *self)
                             COLUMN_ID, &object_path,
                             -1);
         if (g_strcmp0 (object_path, NULL) == 0) {
-                panel = net_object_get_panel (NET_OBJECT (self));
-                toplevel = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel)));
+                toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self->box));
                 cc_network_panel_connect_to_3g_network (toplevel,
                                                         client,
                                                         device);
@@ -981,14 +979,12 @@ net_device_mobile_init (NetDeviceMobile *self)
 }
 
 NetDeviceMobile *
-net_device_mobile_new (CcPanel      *panel,
-                       GCancellable *cancellable,
+net_device_mobile_new (GCancellable *cancellable,
                        NMClient     *client,
                        NMDevice     *device,
                        const gchar  *id)
 {
         return g_object_new (NET_TYPE_DEVICE_MOBILE,
-                             "panel", panel,
                              "cancellable", cancellable,
                              "client", client,
                              "nm-device", device,
diff --git a/panels/network/net-device-mobile.h b/panels/network/net-device-mobile.h
index 673d4309d..664b17550 100644
--- a/panels/network/net-device-mobile.h
+++ b/panels/network/net-device-mobile.h
@@ -31,8 +31,7 @@ G_BEGIN_DECLS
 #define NET_TYPE_DEVICE_MOBILE (net_device_mobile_get_type ())
 G_DECLARE_FINAL_TYPE (NetDeviceMobile, net_device_mobile, NET, DEVICE_MOBILE, NetDevice)
 
-NetDeviceMobile *net_device_mobile_new (CcPanel      *panel,
-                                        GCancellable *cancellable,
+NetDeviceMobile *net_device_mobile_new (GCancellable *cancellable,
                                         NMClient     *client,
                                         NMDevice     *device,
                                         const gchar  *id);
diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c
index 62bb071bd..aafcdc2e3 100644
--- a/panels/network/net-device-wifi.c
+++ b/panels/network/net-device-wifi.c
@@ -77,6 +77,7 @@ struct _NetDeviceWifi
         GtkLabel                *status_label;
         GtkLabel                *title_label;
 
+        CcPanel                 *panel;
         gboolean                 updating_device;
         gchar                   *selected_ssid_title;
         gchar                   *selected_connection_id;
@@ -106,13 +107,14 @@ net_device_wifi_new (CcPanel      *panel,
                      NMDevice     *device,
                      const gchar  *id)
 {
-        return g_object_new (NET_TYPE_DEVICE_WIFI,
-                             "panel", panel,
-                             "cancellable", cancellable,
-                             "client", client,
-                             "nm-device", device,
-                             "id", id,
-                             NULL);
+        NetDeviceWifi *self = g_object_new (NET_TYPE_DEVICE_WIFI,
+                                            "cancellable", cancellable,
+                                            "client", client,
+                                            "nm-device", device,
+                                            "id", id,
+                                            NULL);
+        self->panel = panel;
+        return self;
 }
 
 GtkWidget *
@@ -472,12 +474,10 @@ static void
 connect_to_hidden_network (NetDeviceWifi *self)
 {
         NMClient *client;
-        CcNetworkPanel *panel;
         GtkWidget *toplevel;
 
         client = net_object_get_client (NET_OBJECT (self));
-        panel = net_object_get_panel (NET_OBJECT (self));
-        toplevel = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel)));
+        toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self->notebook));
         cc_network_panel_connect_to_hidden_network (toplevel, client);
 }
 
@@ -599,7 +599,6 @@ wireless_try_to_connect (NetDeviceWifi *self,
                                                              connection_add_activate_cb,
                                                              self);
         } else {
-                CcNetworkPanel *panel;
                 g_autoptr(GVariantBuilder) builder = NULL;
                 GVariant *parameters;
 
@@ -610,8 +609,7 @@ wireless_try_to_connect (NetDeviceWifi *self,
                 g_variant_builder_add (builder, "v", g_variant_new_string (ap_object_path));
                 parameters = g_variant_new ("av", builder);
 
-                panel = net_object_get_panel (NET_OBJECT (self));
-                g_object_set (G_OBJECT (panel), "parameters", parameters, NULL);
+                g_object_set (self->panel, "parameters", parameters, NULL);
         }
 }
 
@@ -897,13 +895,11 @@ switch_hotspot_changed_cb (NetDeviceWifi *self)
 {
         GtkWidget *dialog;
         GtkWidget *window;
-        CcNetworkPanel *panel;
 
         if (self->updating_device)
                 return;
 
-        panel = net_object_get_panel (NET_OBJECT (self));
-        window = gtk_widget_get_toplevel (GTK_WIDGET (panel));
+        window = gtk_widget_get_toplevel (GTK_WIDGET (self->notebook));
         dialog = gtk_message_dialog_new (GTK_WINDOW (window),
                                          GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                          GTK_MESSAGE_OTHER,
@@ -1239,7 +1235,6 @@ open_history (NetDeviceWifi *self)
 {
         GtkWidget *dialog;
         GtkWidget *window;
-        CcNetworkPanel *panel;
         GtkWidget *forget;
         GtkWidget *header;
         GtkWidget *swin;
@@ -1250,8 +1245,7 @@ open_history (NetDeviceWifi *self)
         GList *list_rows;
 
         dialog = g_object_new (HDY_TYPE_DIALOG, "use-header-bar", 1, NULL);
-        panel = net_object_get_panel (NET_OBJECT (self));
-        window = gtk_widget_get_toplevel (GTK_WIDGET (panel));
+        window = gtk_widget_get_toplevel (GTK_WIDGET (self->notebook));
         gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
         gtk_window_set_title (GTK_WINDOW (dialog), _("Known Wi-Fi Networks"));
         gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
diff --git a/panels/network/net-object.c b/panels/network/net-object.c
index 905dc70c6..23aa2dc25 100644
--- a/panels/network/net-object.c
+++ b/panels/network/net-object.c
@@ -32,7 +32,6 @@ typedef struct
         gchar                           *title;
         GCancellable                    *cancellable;
         NMClient                        *client;
-        CcNetworkPanel                  *panel;
 } NetObjectPrivate;
 
 enum {
@@ -41,7 +40,6 @@ enum {
         PROP_TITLE,
         PROP_CLIENT,
         PROP_CANCELLABLE,
-        PROP_PANEL,
         PROP_LAST
 };
 
@@ -132,15 +130,6 @@ net_object_get_cancellable (NetObject *self)
         return priv->cancellable;
 }
 
-CcNetworkPanel *
-net_object_get_panel (NetObject *self)
-{
-        NetObjectPrivate *priv = net_object_get_instance_private (self);
-
-        g_return_val_if_fail (NET_IS_OBJECT (self), NULL);
-        return priv->panel;
-}
-
 GtkWidget *
 net_object_get_widget (NetObject    *self,
                        GtkSizeGroup *heading_size_group)
@@ -191,9 +180,6 @@ net_object_get_property (GObject *object,
         case PROP_CANCELLABLE:
                 g_value_set_object (value, priv->cancellable);
                 break;
-        case PROP_PANEL:
-                g_value_set_pointer (value, priv->panel);
-                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                 break;
@@ -230,12 +216,6 @@ net_object_set_property (GObject *object,
                 g_assert (!priv->cancellable);
                 priv->cancellable = g_value_dup_object (value);
                 break;
-        case PROP_PANEL:
-                g_assert (!priv->panel);
-                priv->panel = g_value_get_pointer (value);
-                if (priv->panel)
-                        g_object_add_weak_pointer (G_OBJECT (priv->panel), (gpointer *) (&priv->panel));
-                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                 break;
@@ -254,8 +234,6 @@ net_object_finalize (GObject *object)
 
         if (priv->client)
                 g_object_remove_weak_pointer (G_OBJECT (priv->client), (gpointer *) (&priv->client));
-        if (priv->panel)
-                g_object_remove_weak_pointer (G_OBJECT (priv->panel), (gpointer *) (&priv->panel));
 
         G_OBJECT_CLASS (net_object_parent_class)->finalize (object);
 }
@@ -288,10 +266,6 @@ net_object_class_init (NetObjectClass *klass)
                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
         g_object_class_install_property (object_class, PROP_CANCELLABLE, pspec);
 
-        pspec = g_param_spec_pointer ("panel", NULL, NULL,
-                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-        g_object_class_install_property (object_class, PROP_PANEL, pspec);
-
         signals[SIGNAL_CHANGED] =
                 g_signal_new ("changed",
                               G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/panels/network/net-object.h b/panels/network/net-object.h
index 636f9ba82..bd5f2ebdc 100644
--- a/panels/network/net-object.h
+++ b/panels/network/net-object.h
@@ -51,7 +51,6 @@ void             net_object_set_title                   (NetObject      *object,
                                                          const gchar    *title);
 NMClient        *net_object_get_client                  (NetObject      *object);
 GCancellable    *net_object_get_cancellable             (NetObject      *object);
-CcNetworkPanel  *net_object_get_panel                   (NetObject      *object);
 void             net_object_emit_changed                (NetObject      *object);
 void             net_object_emit_removed                (NetObject      *object);
 void             net_object_refresh                     (NetObject      *object);
diff --git a/panels/network/net-vpn.c b/panels/network/net-vpn.c
index 512d90ded..5897027ca 100644
--- a/panels/network/net-vpn.c
+++ b/panels/network/net-vpn.c
@@ -61,13 +61,11 @@ G_DEFINE_TYPE (NetVpn, net_vpn, NET_TYPE_OBJECT)
 static void nm_device_refresh_vpn_ui (NetVpn *self);
 
 NetVpn *
-net_vpn_new (CcPanel      *panel,
-             const gchar  *id,
+net_vpn_new (const gchar  *id,
              NMConnection *connection,
              NMClient     *client)
 {
         return g_object_new (NET_TYPE_VPN,
-                             "panel", panel,
                              "id", id,
                              "connection", connection,
                              "client", client,
diff --git a/panels/network/net-vpn.h b/panels/network/net-vpn.h
index 7c3e975af..cb17eb3c8 100644
--- a/panels/network/net-vpn.h
+++ b/panels/network/net-vpn.h
@@ -31,8 +31,7 @@ G_BEGIN_DECLS
 #define NET_TYPE_VPN (net_vpn_get_type ())
 G_DECLARE_FINAL_TYPE (NetVpn, net_vpn, NET, VPN, NetObject)
 
-NetVpn *net_vpn_new                (CcPanel      *panel,
-                                    const gchar  *id,
+NetVpn *net_vpn_new                (const gchar  *id,
                                     NMConnection *connection,
                                     NMClient     *client);
 


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