[gnome-control-center] network: Remove net_object_get_cancellable
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Remove net_object_get_cancellable
- Date: Tue, 5 Nov 2019 23:06:14 +0000 (UTC)
commit 966cb97d452ebaee657138a64cc87ff4abac9cf4
Author: Robert Ancell <robert ancell canonical com>
Date: Wed Oct 23 13:51:47 2019 +1300
network: Remove net_object_get_cancellable
Only a few objects need it
panels/network/cc-network-panel.c | 17 +++--------------
panels/network/cc-wifi-panel.c | 1 -
panels/network/net-device-bluetooth.c | 5 +----
panels/network/net-device-bluetooth.h | 3 +--
panels/network/net-device-ethernet.c | 5 +----
panels/network/net-device-ethernet.h | 5 ++---
panels/network/net-device-mobile.c | 20 +++++++++++---------
panels/network/net-device-mobile.h | 5 ++---
panels/network/net-device-wifi.c | 32 ++++++++------------------------
panels/network/net-device-wifi.h | 1 -
panels/network/net-object.c | 24 ------------------------
panels/network/net-object.h | 1 -
12 files changed, 29 insertions(+), 90 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index b7a22ee7f..1c3b46212 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -56,7 +56,6 @@ struct _CcNetworkPanel
{
CcPanel parent;
- GCancellable *cancellable;
GHashTable *device_to_widget;
GPtrArray *devices;
NMClient *client;
@@ -208,9 +207,6 @@ cc_network_panel_dispose (GObject *object)
{
CcNetworkPanel *self = CC_NETWORK_PANEL (object);
- g_cancellable_cancel (self->cancellable);
-
- g_clear_object (&self->cancellable);
g_clear_object (&self->client);
g_clear_object (&self->modem_manager);
@@ -464,21 +460,15 @@ 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 (self->cancellable,
- self->client,
- device));
+ net_device = NET_DEVICE (net_device_ethernet_new (self->client, 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 (self->cancellable,
- self->client,
- device));
+ net_device = NET_DEVICE (net_device_mobile_new (self->client, 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 (self->cancellable,
- self->client,
- device));
+ net_device = NET_DEVICE (net_device_bluetooth_new (self->client, device));
add_object (self, NET_OBJECT (net_device), GTK_CONTAINER (self->box_bluetooth));
break;
@@ -819,7 +809,6 @@ cc_network_panel_init (CcNetworkPanel *self)
gtk_widget_init_template (GTK_WIDGET (self));
- self->cancellable = g_cancellable_new ();
self->devices = g_ptr_array_new_with_free_func (g_object_unref);
self->device_to_widget = g_hash_table_new (g_direct_hash, g_direct_equal);
diff --git a/panels/network/cc-wifi-panel.c b/panels/network/cc-wifi-panel.c
index d013c404e..6434783b6 100644
--- a/panels/network/cc-wifi-panel.c
+++ b/panels/network/cc-wifi-panel.c
@@ -158,7 +158,6 @@ add_wifi_device (CcWifiPanel *self,
/* Create the NetDevice */
net_device = net_device_wifi_new (CC_PANEL (self),
- self->cancellable,
self->client,
device);
diff --git a/panels/network/net-device-bluetooth.c b/panels/network/net-device-bluetooth.c
index f2de0295e..2be157d34 100644
--- a/panels/network/net-device-bluetooth.c
+++ b/panels/network/net-device-bluetooth.c
@@ -233,12 +233,9 @@ net_device_bluetooth_init (NetDeviceBluetooth *self)
}
NetDeviceBluetooth *
-net_device_bluetooth_new (GCancellable *cancellable,
- NMClient *client,
- NMDevice *device)
+net_device_bluetooth_new (NMClient *client, NMDevice *device)
{
return g_object_new (NET_TYPE_DEVICE_BLUETOOTH,
- "cancellable", cancellable,
"client", client,
"nm-device", device,
NULL);
diff --git a/panels/network/net-device-bluetooth.h b/panels/network/net-device-bluetooth.h
index f42aeef14..89eefe00e 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 (GCancellable *cancellable,
- NMClient *client,
+NetDeviceBluetooth *net_device_bluetooth_new (NMClient *client,
NMDevice *device);
void net_device_bluetooth_set_show_separator (NetDeviceBluetooth *device_bluetooth,
diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c
index b2865708f..6343d1235 100644
--- a/panels/network/net-device-ethernet.c
+++ b/panels/network/net-device-ethernet.c
@@ -592,12 +592,9 @@ net_device_ethernet_init (NetDeviceEthernet *self)
}
NetDeviceEthernet *
-net_device_ethernet_new (GCancellable *cancellable,
- NMClient *client,
- NMDevice *device)
+net_device_ethernet_new (NMClient *client, NMDevice *device)
{
return g_object_new (NET_TYPE_DEVICE_ETHERNET,
- "cancellable", cancellable,
"client", client,
"nm-device", device,
NULL);
diff --git a/panels/network/net-device-ethernet.h b/panels/network/net-device-ethernet.h
index d74648dcd..3bf152512 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 (GCancellable *cancellable,
- NMClient *client,
- NMDevice *device);
+NetDeviceEthernet *net_device_ethernet_new (NMClient *client,
+ NMDevice *device);
G_END_DECLS
diff --git a/panels/network/net-device-mobile.c b/panels/network/net-device-mobile.c
index 066987483..461869297 100644
--- a/panels/network/net-device-mobile.c
+++ b/panels/network/net-device-mobile.c
@@ -61,6 +61,8 @@ struct _NetDeviceMobile
GtkLabel *route_label;
GtkLabel *status_label;
+ GCancellable *cancellable;
+
gboolean updating_device;
/* Old MM < 0.7 support */
@@ -752,7 +754,6 @@ device_mobile_device_got_modem_manager_cdma_cb (GObject *source_object,
static void
net_device_mobile_constructed (GObject *object)
{
- GCancellable *cancellable;
NetDeviceMobile *self = NET_DEVICE_MOBILE (object);
NMClient *client;
NMDevice *device;
@@ -761,7 +762,6 @@ net_device_mobile_constructed (GObject *object)
G_OBJECT_CLASS (net_device_mobile_parent_class)->constructed (object);
device = net_device_get_nm_device (NET_DEVICE (self));
- cancellable = net_object_get_cancellable (NET_OBJECT (self));
caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
@@ -776,7 +776,7 @@ net_device_mobile_constructed (GObject *object)
"org.freedesktop.ModemManager",
nm_device_get_udi (device),
"org.freedesktop.ModemManager.Modem",
- cancellable,
+ self->cancellable,
device_mobile_device_got_modem_manager_cb,
self);
@@ -788,7 +788,7 @@ net_device_mobile_constructed (GObject *object)
"org.freedesktop.ModemManager",
nm_device_get_udi (device),
"org.freedesktop.ModemManager.Modem.Gsm.Network",
- cancellable,
+ self->cancellable,
device_mobile_device_got_modem_manager_gsm_cb,
self);
}
@@ -800,7 +800,7 @@ net_device_mobile_constructed (GObject *object)
"org.freedesktop.ModemManager",
nm_device_get_udi (device),
"org.freedesktop.ModemManager.Modem.Cdma",
- cancellable,
+ self->cancellable,
device_mobile_device_got_modem_manager_cdma_cb,
self);
}
@@ -885,7 +885,10 @@ net_device_mobile_dispose (GObject *object)
{
NetDeviceMobile *self = NET_DEVICE_MOBILE (object);
+ g_cancellable_cancel (self->cancellable);
+
g_clear_object (&self->builder);
+ g_clear_object (&self->cancellable);
g_clear_object (&self->gsm_proxy);
g_clear_object (&self->cdma_proxy);
@@ -958,6 +961,8 @@ net_device_mobile_init (NetDeviceMobile *self)
self->route_label = GTK_LABEL (gtk_builder_get_object (self->builder, "route_label"));
self->status_label = GTK_LABEL (gtk_builder_get_object (self->builder, "status_label"));
+ self->cancellable = g_cancellable_new ();
+
/* setup mobile combobox model */
g_signal_connect_swapped (self->network_combo, "changed",
G_CALLBACK (mobile_connection_changed_cb),
@@ -979,12 +984,9 @@ net_device_mobile_init (NetDeviceMobile *self)
}
NetDeviceMobile *
-net_device_mobile_new (GCancellable *cancellable,
- NMClient *client,
- NMDevice *device)
+net_device_mobile_new (NMClient *client, NMDevice *device)
{
return g_object_new (NET_TYPE_DEVICE_MOBILE,
- "cancellable", cancellable,
"client", client,
"nm-device", device,
NULL);
diff --git a/panels/network/net-device-mobile.h b/panels/network/net-device-mobile.h
index 220806547..2022222bd 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 (GCancellable *cancellable,
- NMClient *client,
- NMDevice *device);
+NetDeviceMobile *net_device_mobile_new (NMClient *client,
+ NMDevice *device);
G_END_DECLS
diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c
index ed8a7f6a6..d235c3d84 100644
--- a/panels/network/net-device-wifi.c
+++ b/panels/network/net-device-wifi.c
@@ -101,13 +101,9 @@ enum {
G_DEFINE_TYPE (NetDeviceWifi, net_device_wifi, NET_TYPE_DEVICE)
NetDeviceWifi *
-net_device_wifi_new (CcPanel *panel,
- GCancellable *cancellable,
- NMClient *client,
- NMDevice *device)
+net_device_wifi_new (CcPanel *panel, NMClient *client, NMDevice *device)
{
NetDeviceWifi *self = g_object_new (NET_TYPE_DEVICE_WIFI,
- "cancellable", cancellable,
"client", client,
"nm-device", device,
NULL);
@@ -300,10 +296,9 @@ device_get_hotspot_security_details (NetDeviceWifi *self,
* We'll refresh the UI when secrets arrive.
*/
if (tmp_secret == NULL) {
- GCancellable *cancellable = net_object_get_cancellable (NET_OBJECT (self));
nm_remote_connection_get_secrets_async ((NMRemoteConnection*)c,
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
- cancellable,
+ self->cancellable,
get_secrets_cb,
self);
return;
@@ -549,7 +544,6 @@ wireless_try_to_connect (NetDeviceWifi *self,
const gchar *ssid_target;
NMDevice *device;
NMClient *client;
- GCancellable *cancellable;
if (self->updating_device)
return;
@@ -567,7 +561,6 @@ wireless_try_to_connect (NetDeviceWifi *self,
/* activate the connection */
client = net_object_get_client (NET_OBJECT (self));
- cancellable = net_object_get_cancellable (NET_OBJECT (self));
if (!is_8021x (device, ap_object_path)) {
g_autoptr(GPermission) permission = NULL;
@@ -593,7 +586,7 @@ wireless_try_to_connect (NetDeviceWifi *self,
partial,
device,
ap_object_path,
- cancellable,
+ self->cancellable,
connection_add_activate_cb,
self);
} else {
@@ -757,7 +750,6 @@ overwrite_ssid_cb (GObject *source_object,
NMDevice *device;
NMConnection *c;
NetDeviceWifi *self;
- GCancellable *cancellable;
connection = NM_REMOTE_CONNECTION (source_object);
@@ -771,7 +763,6 @@ overwrite_ssid_cb (GObject *source_object,
self = user_data;
device = net_device_get_nm_device (NET_DEVICE (self));
client = net_object_get_client (NET_OBJECT (self));
- cancellable = net_object_get_cancellable (NET_OBJECT (self));
c = net_device_wifi_get_hotspot_connection (self);
g_debug ("activate existing hotspot connection\n");
@@ -779,7 +770,7 @@ overwrite_ssid_cb (GObject *source_object,
c,
device,
NULL,
- cancellable,
+ self->cancellable,
activate_cb,
self);
}
@@ -815,15 +806,12 @@ start_hotspot (NetDeviceWifi *self)
if (response == GTK_RESPONSE_APPLY) {
NMConnection *connection;
- GCancellable *cancellable;
-
- cancellable = net_object_get_cancellable (NET_OBJECT (self));
connection = cc_wifi_hotspot_dialog_get_connection (self->hotspot_dialog);
if (NM_IS_REMOTE_CONNECTION (connection))
nm_remote_connection_commit_changes_async (NM_REMOTE_CONNECTION (connection),
TRUE,
- cancellable,
+ self->cancellable,
overwrite_ssid_cb,
self);
else
@@ -831,7 +819,7 @@ start_hotspot (NetDeviceWifi *self)
connection,
device,
NULL,
- cancellable,
+ self->cancellable,
activate_new_cb,
self);
}
@@ -1048,7 +1036,6 @@ really_forget (GtkDialog *dialog, gint response, gpointer data)
GList *r;
NMRemoteConnection *connection;
NetDeviceWifi *self;
- GCancellable *cancellable;
gtk_widget_destroy (GTK_WIDGET (dialog));
@@ -1056,12 +1043,11 @@ really_forget (GtkDialog *dialog, gint response, gpointer data)
return;
self = NET_DEVICE_WIFI (g_object_get_data (G_OBJECT (forget), "net"));
- cancellable = net_object_get_cancellable (NET_OBJECT (self));
rows = g_object_steal_data (G_OBJECT (forget), "rows");
for (r = rows; r; r = r->next) {
row = r->data;
connection = NM_REMOTE_CONNECTION (cc_wifi_connection_row_get_connection (row));
- nm_remote_connection_delete_async (connection, cancellable, really_forgotten, g_object_ref
(data));
+ nm_remote_connection_delete_async (connection, self->cancellable, really_forgotten,
g_object_ref (data));
gtk_widget_hide (GTK_WIDGET (row));
}
g_list_free (rows);
@@ -1338,7 +1324,6 @@ ap_activated (NetDeviceWifi *self, GtkListBoxRow *row)
NMAccessPoint *ap;
NMClient *client;
NMDevice *nm_device;
- GCancellable *cancellable;
/* The mockups want a row to connecto hidden networks; this could
* be handeled here. */
@@ -1354,10 +1339,9 @@ ap_activated (NetDeviceWifi *self, GtkListBoxRow *row)
if (connection != NULL) {
client = net_object_get_client (NET_OBJECT (self));
nm_device = net_device_get_nm_device (NET_DEVICE (self));
- cancellable = net_object_get_cancellable (NET_OBJECT (self));
nm_client_activate_connection_async (client,
connection,
- nm_device, NULL, cancellable,
+ nm_device, NULL, self->cancellable,
connection_activate_cb, self);
} else {
GBytes *ssid;
diff --git a/panels/network/net-device-wifi.h b/panels/network/net-device-wifi.h
index 0b4b29977..582bab8a7 100644
--- a/panels/network/net-device-wifi.h
+++ b/panels/network/net-device-wifi.h
@@ -31,7 +31,6 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (NetDeviceWifi, net_device_wifi, NET, DEVICE_WIFI, NetDevice)
NetDeviceWifi *net_device_wifi_new (CcPanel *panel,
- GCancellable *cancellable,
NMClient *client,
NMDevice *device);
diff --git a/panels/network/net-object.c b/panels/network/net-object.c
index 45ad38df6..f24f188f7 100644
--- a/panels/network/net-object.c
+++ b/panels/network/net-object.c
@@ -29,7 +29,6 @@
typedef struct
{
gchar *title;
- GCancellable *cancellable;
NMClient *client;
} NetObjectPrivate;
@@ -37,7 +36,6 @@ enum {
PROP_0,
PROP_TITLE,
PROP_CLIENT,
- PROP_CANCELLABLE,
PROP_LAST
};
@@ -93,15 +91,6 @@ net_object_get_client (NetObject *self)
return priv->client;
}
-GCancellable *
-net_object_get_cancellable (NetObject *self)
-{
- NetObjectPrivate *priv = net_object_get_instance_private (self);
-
- g_return_val_if_fail (NET_IS_OBJECT (self), NULL);
- return priv->cancellable;
-}
-
GtkWidget *
net_object_get_widget (NetObject *self,
GtkSizeGroup *heading_size_group)
@@ -138,9 +127,6 @@ net_object_get_property (GObject *object,
case PROP_CLIENT:
g_value_set_pointer (value, priv->client);
break;
- case PROP_CANCELLABLE:
- g_value_set_object (value, priv->cancellable);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -169,10 +155,6 @@ net_object_set_property (GObject *object,
if (priv->client)
g_object_add_weak_pointer (G_OBJECT (priv->client), (gpointer *) (&priv->client));
break;
- case PROP_CANCELLABLE:
- g_assert (!priv->cancellable);
- priv->cancellable = g_value_dup_object (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -186,7 +168,6 @@ net_object_finalize (GObject *object)
NetObjectPrivate *priv = net_object_get_instance_private (self);
g_clear_pointer (&priv->title, g_free);
- g_clear_object (&priv->cancellable);
if (priv->client)
g_object_remove_weak_pointer (G_OBJECT (priv->client), (gpointer *) (&priv->client));
@@ -212,11 +193,6 @@ net_object_class_init (NetObjectClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (object_class, PROP_CLIENT, pspec);
- pspec = g_param_spec_object ("cancellable", NULL, NULL,
- G_TYPE_CANCELLABLE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
- g_object_class_install_property (object_class, PROP_CANCELLABLE, 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 63c3d3085..ad23c0045 100644
--- a/panels/network/net-object.h
+++ b/panels/network/net-object.h
@@ -47,7 +47,6 @@ const gchar *net_object_get_title (NetObject *object)
void net_object_set_title (NetObject *object,
const gchar *title);
NMClient *net_object_get_client (NetObject *object);
-GCancellable *net_object_get_cancellable (NetObject *object);
void net_object_emit_changed (NetObject *object);
void net_object_emit_removed (NetObject *object);
void net_object_refresh (NetObject *object);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]