[gnome-control-center] network: Remove net_object_get/set_title
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Remove net_object_get/set_title
- Date: Tue, 5 Nov 2019 23:07:39 +0000 (UTC)
commit a39ebd5bda16bbb713cf39a7cacb0b53dfa3d274
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Oct 24 13:42:25 2019 +1300
network: Remove net_object_get/set_title
panels/network/cc-network-panel.c | 34 +++---------
panels/network/cc-wifi-panel.c | 4 +-
panels/network/net-device-bluetooth.c | 10 ++--
panels/network/net-device-bluetooth.h | 3 ++
panels/network/net-device-ethernet.c | 16 +++---
panels/network/net-device-ethernet.h | 7 ++-
panels/network/net-device-mobile.c | 10 ++--
panels/network/net-device-mobile.h | 9 ++--
panels/network/net-device-wifi.c | 9 +++-
panels/network/net-device-wifi.h | 3 ++
panels/network/net-object.c | 98 +----------------------------------
panels/network/net-object.h | 3 --
panels/network/net-vpn.c | 1 -
13 files changed, 56 insertions(+), 151 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index 818199337..e4861b038 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -271,16 +271,12 @@ panel_refresh_device_titles (CcNetworkPanel *self)
titles = nm_device_disambiguate_names (nm_devices, num_devices);
for (i = 0; i < num_devices; i++) {
- const gchar *bt_name = NULL;
-
if (NM_IS_DEVICE_BT (nm_devices[i]))
- bt_name = nm_device_bt_get_name (NM_DEVICE_BT (nm_devices[i]));
-
- /* For bluetooth devices, use their device name. */
- if (bt_name)
- net_object_set_title (devices[i], bt_name);
- else
- net_object_set_title (devices[i], titles[i]);
+ net_device_bluetooth_set_title (NET_DEVICE_BLUETOOTH (devices[i]),
nm_device_bt_get_name (NM_DEVICE_BT (nm_devices[i])));
+ else if (NET_IS_DEVICE_ETHERNET (devices[i]))
+ net_device_ethernet_set_title (NET_DEVICE_ETHERNET (devices[i]), titles[i]);
+ else if (NET_IS_DEVICE_MOBILE (devices[i]))
+ net_device_mobile_set_title (NET_DEVICE_MOBILE (devices[i]), titles[i]);
}
}
@@ -500,20 +496,6 @@ panel_remove_device (CcNetworkPanel *self, NMDevice *device)
update_bluetooth_section (self);
}
-static void
-panel_add_proxy_device (CcNetworkPanel *self)
-{
- NetProxy *proxy;
-
- proxy = net_proxy_new ();
-
- /* add proxy to stack */
- add_object (self, NET_OBJECT (proxy), GTK_CONTAINER (self->box_proxy));
-
- /* add proxy to device list */
- net_object_set_title (NET_OBJECT (proxy), _("Network proxy"));
-}
-
static void
connection_state_changed (CcNetworkPanel *self)
{
@@ -614,8 +596,6 @@ panel_add_vpn_device (CcNetworkPanel *self, NMConnection *connection)
/* add as a panel */
add_object (self, NET_OBJECT (net_vpn), GTK_CONTAINER (self->box_vpn));
- net_object_set_title (NET_OBJECT (net_vpn), nm_connection_get_id (connection));
-
/* store in the devices array */
g_ptr_array_add (self->vpns, net_vpn);
@@ -755,6 +735,7 @@ cc_network_panel_class_init (CcNetworkPanelClass *klass)
static void
cc_network_panel_init (CcNetworkPanel *self)
{
+ NetProxy *proxy;
g_autoptr(GError) error = NULL;
GtkWidget *toplevel;
g_autoptr(GDBusConnection) system_bus = NULL;
@@ -773,7 +754,8 @@ cc_network_panel_init (CcNetworkPanel *self)
self->nm_device_to_device = g_hash_table_new (g_direct_hash, g_direct_equal);
/* add the virtual proxy device */
- panel_add_proxy_device (self);
+ proxy = net_proxy_new ();
+ add_object (self, NET_OBJECT (proxy), GTK_CONTAINER (self->box_proxy));
/* Create and store a NMClient instance if it doesn't exist yet */
if (!cc_object_storage_has_object (CC_OBJECT_NMCLIENT)) {
diff --git a/panels/network/cc-wifi-panel.c b/panels/network/cc-wifi-panel.c
index 880bcc065..d104f53df 100644
--- a/panels/network/cc-wifi-panel.c
+++ b/panels/network/cc-wifi-panel.c
@@ -276,7 +276,7 @@ update_devices_names (CcWifiPanel *self)
gtk_stack_add_named (self->center_stack, title_widget, "single");
gtk_stack_set_visible_child_name (self->center_stack, "single");
- net_object_set_title (NET_OBJECT (net_device), _("Wi-Fi"));
+ net_device_wifi_set_title (net_device, _("Wi-Fi"));
}
else
{
@@ -291,7 +291,7 @@ update_devices_names (CcWifiPanel *self)
net_device = g_ptr_array_index (self->devices, i);
device = net_device_wifi_get_device (net_device);
- net_object_set_title (NET_OBJECT (net_device), nm_device_get_description (device));
+ net_device_wifi_set_title (net_device, nm_device_get_description (device));
}
/* Remove the widget at the "single" page */
diff --git a/panels/network/net-device-bluetooth.c b/panels/network/net-device-bluetooth.c
index c0a6ae067..6f1274ef9 100644
--- a/panels/network/net-device-bluetooth.c
+++ b/panels/network/net-device-bluetooth.c
@@ -92,9 +92,6 @@ nm_device_bluetooth_refresh_ui (NetDeviceBluetooth *self)
{
NMDeviceState state;
- /* set device kind */
- g_object_bind_property (self, "title", self->device_label, "label", 0);
-
/* set up the device on/off switch */
state = nm_device_get_state (self->device);
gtk_widget_set_visible (GTK_WIDGET (self->device_off_switch),
@@ -238,3 +235,10 @@ net_device_bluetooth_get_device (NetDeviceBluetooth *self)
g_return_val_if_fail (NET_IS_DEVICE_BLUETOOTH (self), NULL);
return self->device;
}
+
+void
+net_device_bluetooth_set_title (NetDeviceBluetooth *self, const gchar *title)
+{
+ g_return_if_fail (NET_IS_DEVICE_BLUETOOTH (self));
+ gtk_label_set_label (self->device_label, title);
+}
diff --git a/panels/network/net-device-bluetooth.h b/panels/network/net-device-bluetooth.h
index 9b461389b..125cbbf3a 100644
--- a/panels/network/net-device-bluetooth.h
+++ b/panels/network/net-device-bluetooth.h
@@ -36,6 +36,9 @@ NetDeviceBluetooth *net_device_bluetooth_new (NMClient
NMDevice *net_device_bluetooth_get_device (NetDeviceBluetooth *device);
+void net_device_bluetooth_set_title (NetDeviceBluetooth *device,
+ const gchar *title);
+
void net_device_bluetooth_set_show_separator (NetDeviceBluetooth *device,
gboolean show_separator);
diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c
index b83b26038..e5ca3ce3d 100644
--- a/panels/network/net-device-ethernet.c
+++ b/panels/network/net-device-ethernet.c
@@ -199,8 +199,6 @@ device_ethernet_refresh_ui (NetDeviceEthernet *self)
g_autofree gchar *speed_text = NULL;
g_autofree gchar *status = NULL;
- gtk_label_set_label (self->device_label, net_object_get_title (NET_OBJECT (self)));
-
state = nm_device_get_state (self->device);
gtk_widget_set_sensitive (GTK_WIDGET (self->device_off_switch),
state != NM_DEVICE_STATE_UNAVAILABLE
@@ -463,12 +461,6 @@ device_off_toggled (NetDeviceEthernet *self)
}
}
-static void
-device_title_changed (NetDeviceEthernet *self)
-{
- device_ethernet_refresh_ui (self);
-}
-
static void
connection_activated (NetDeviceEthernet *self, GtkListBoxRow *row)
{
@@ -568,7 +560,6 @@ net_device_ethernet_new (NMClient *client, NMDevice *device)
g_signal_connect_object (device, "state-changed", G_CALLBACK (device_state_changed_cb), self,
G_CONNECT_SWAPPED);
- g_signal_connect (self, "notify::title", G_CALLBACK (device_title_changed), NULL);
device_ethernet_refresh_ui (self);
return self;
@@ -580,3 +571,10 @@ net_device_ethernet_get_device (NetDeviceEthernet *self)
g_return_val_if_fail (NET_IS_DEVICE_ETHERNET (self), NULL);
return self->device;
}
+
+void
+net_device_ethernet_set_title (NetDeviceEthernet *self, const gchar *title)
+{
+ g_return_if_fail (NET_IS_DEVICE_ETHERNET (self));
+ gtk_label_set_label (self->device_label, title);
+}
diff --git a/panels/network/net-device-ethernet.h b/panels/network/net-device-ethernet.h
index 21e136739..44ac8b9a6 100644
--- a/panels/network/net-device-ethernet.h
+++ b/panels/network/net-device-ethernet.h
@@ -30,9 +30,12 @@ G_BEGIN_DECLS
#define NET_TYPE_DEVICE_ETHERNET (net_device_ethernet_get_type ())
G_DECLARE_FINAL_TYPE (NetDeviceEthernet, net_device_ethernet, NET, DEVICE_ETHERNET, NetObject)
-NetDeviceEthernet *net_device_ethernet_new (NMClient *client,
- NMDevice *device);
+NetDeviceEthernet *net_device_ethernet_new (NMClient *client,
+ NMDevice *device);
NMDevice *net_device_ethernet_get_device (NetDeviceEthernet *device);
+void net_device_ethernet_set_title (NetDeviceEthernet *device,
+ const gchar *title);
+
G_END_DECLS
diff --git a/panels/network/net-device-mobile.c b/panels/network/net-device-mobile.c
index caa4e349f..7e637ed63 100644
--- a/panels/network/net-device-mobile.c
+++ b/panels/network/net-device-mobile.c
@@ -366,9 +366,6 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *self)
NMIPConfig *ipv4_config = NULL, *ipv6_config = NULL;
gboolean have_ipv4_address = FALSE, have_ipv6_address = FALSE;
- /* set device kind */
- g_object_bind_property (self, "title", self->device_label, "label", 0);
-
/* set up the device on/off switch */
gtk_widget_show (GTK_WIDGET (self->device_off_switch));
mobilebb_enabled_toggled (self);
@@ -915,3 +912,10 @@ net_device_mobile_get_device (NetDeviceMobile *self)
g_return_val_if_fail (NET_IS_DEVICE_MOBILE (self), NULL);
return self->device;
}
+
+void
+net_device_mobile_set_title (NetDeviceMobile *self, const gchar *title)
+{
+ g_return_if_fail (NET_IS_DEVICE_MOBILE (self));
+ gtk_label_set_label (self->device_label, title);
+}
diff --git a/panels/network/net-device-mobile.h b/panels/network/net-device-mobile.h
index 6ac3220ef..85c4e53c8 100644
--- a/panels/network/net-device-mobile.h
+++ b/panels/network/net-device-mobile.h
@@ -31,10 +31,13 @@ G_BEGIN_DECLS
#define NET_TYPE_DEVICE_MOBILE (net_device_mobile_get_type ())
G_DECLARE_FINAL_TYPE (NetDeviceMobile, net_device_mobile, NET, DEVICE_MOBILE, NetObject)
-NetDeviceMobile *net_device_mobile_new (NMClient *client,
- NMDevice *device,
- GDBusObject *modem);
+NetDeviceMobile *net_device_mobile_new (NMClient *client,
+ NMDevice *device,
+ GDBusObject *modem);
NMDevice *net_device_mobile_get_device (NetDeviceMobile *device);
+void net_device_mobile_set_title (NetDeviceMobile *device,
+ const gchar *title);
+
G_END_DECLS
diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c
index 075935081..3f48b404b 100644
--- a/panels/network/net-device-wifi.c
+++ b/panels/network/net-device-wifi.c
@@ -1317,8 +1317,6 @@ net_device_wifi_new (CcPanel *panel, NMClient *client, NMDevice *device)
} else
gtk_widget_set_sensitive (GTK_WIDGET (self->start_hotspot_button), TRUE);
- g_object_bind_property (self, "title", self->title_label, "label", 0);
-
nm_device_wifi_refresh_ui (self);
return self;
@@ -1331,6 +1329,13 @@ net_device_wifi_get_device (NetDeviceWifi *self)
return self->device;
}
+void
+net_device_wifi_set_title (NetDeviceWifi *self, const gchar *title)
+{
+ g_return_if_fail (NET_IS_DEVICE_WIFI (self));
+ gtk_label_set_label (self->title_label, title);
+}
+
GtkWidget *
net_device_wifi_get_header_widget (NetDeviceWifi *self)
{
diff --git a/panels/network/net-device-wifi.h b/panels/network/net-device-wifi.h
index 063245c4c..1e0d8700b 100644
--- a/panels/network/net-device-wifi.h
+++ b/panels/network/net-device-wifi.h
@@ -36,6 +36,9 @@ NetDeviceWifi *net_device_wifi_new (CcPanel *panel,
NMDevice *net_device_wifi_get_device (NetDeviceWifi *device);
+void net_device_wifi_set_title (NetDeviceWifi *device,
+ const gchar *title);
+
GtkWidget *net_device_wifi_get_header_widget (NetDeviceWifi *device);
GtkWidget *net_device_wifi_get_title_widget (NetDeviceWifi *device);
diff --git a/panels/network/net-object.c b/panels/network/net-object.c
index d717bdb01..8b1a8ac87 100644
--- a/panels/network/net-object.c
+++ b/panels/network/net-object.c
@@ -26,24 +26,13 @@
#include "net-object.h"
-typedef struct
-{
- gchar *title;
-} NetObjectPrivate;
-
-enum {
- PROP_0,
- PROP_TITLE,
- PROP_LAST
-};
-
enum {
SIGNAL_CHANGED,
SIGNAL_LAST
};
static guint signals[SIGNAL_LAST] = { 0 };
-G_DEFINE_TYPE_WITH_PRIVATE (NetObject, net_object, G_TYPE_OBJECT)
+G_DEFINE_TYPE (NetObject, net_object, G_TYPE_OBJECT)
void
net_object_emit_changed (NetObject *self)
@@ -52,26 +41,6 @@ net_object_emit_changed (NetObject *self)
g_signal_emit (self, signals[SIGNAL_CHANGED], 0);
}
-const gchar *
-net_object_get_title (NetObject *self)
-{
- NetObjectPrivate *priv = net_object_get_instance_private (self);
-
- g_return_val_if_fail (NET_IS_OBJECT (self), NULL);
- return priv->title;
-}
-
-void
-net_object_set_title (NetObject *self, const gchar *title)
-{
- NetObjectPrivate *priv = net_object_get_instance_private (self);
-
- g_return_if_fail (NET_IS_OBJECT (self));
- g_clear_pointer (&priv->title, g_free);
- priv->title = g_strdup (title);
- g_object_notify (G_OBJECT (self), "title");
-}
-
GtkWidget *
net_object_get_widget (NetObject *self,
GtkSizeGroup *heading_size_group)
@@ -81,75 +50,10 @@ net_object_get_widget (NetObject *self,
return klass->get_widget (self, heading_size_group);
}
-/**
- * net_object_get_property:
- **/
-static void
-net_object_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NetObject *self = NET_OBJECT (object);
- NetObjectPrivate *priv = net_object_get_instance_private (self);
-
- switch (prop_id) {
- case PROP_TITLE:
- g_value_set_string (value, priv->title);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/**
- * net_object_set_property:
- **/
-static void
-net_object_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- NetObject *self = NET_OBJECT (object);
- NetObjectPrivate *priv = net_object_get_instance_private (self);
-
- switch (prop_id) {
- case PROP_TITLE:
- g_free (priv->title);
- priv->title = g_strdup (g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-net_object_finalize (GObject *object)
-{
- NetObject *self = NET_OBJECT (object);
- NetObjectPrivate *priv = net_object_get_instance_private (self);
-
- g_clear_pointer (&priv->title, g_free);
-
- G_OBJECT_CLASS (net_object_parent_class)->finalize (object);
-}
-
static void
net_object_class_init (NetObjectClass *klass)
{
- GParamSpec *pspec;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = net_object_finalize;
- object_class->get_property = net_object_get_property;
- object_class->set_property = net_object_set_property;
-
- pspec = g_param_spec_string ("title", NULL, NULL,
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
- g_object_class_install_property (object_class, PROP_TITLE, pspec);
signals[SIGNAL_CHANGED] =
g_signal_new ("changed",
diff --git a/panels/network/net-object.h b/panels/network/net-object.h
index 69078824e..dbd9170aa 100644
--- a/panels/network/net-object.h
+++ b/panels/network/net-object.h
@@ -42,9 +42,6 @@ struct _NetObjectClass
GtkSizeGroup *heading_size_group);
};
-const gchar *net_object_get_title (NetObject *object);
-void net_object_set_title (NetObject *object,
- const gchar *title);
void net_object_emit_changed (NetObject *object);
GtkWidget *net_object_get_widget (NetObject *object,
GtkSizeGroup *heading_size_group);
diff --git a/panels/network/net-vpn.c b/panels/network/net-vpn.c
index 1fcb1b62c..ac58f6190 100644
--- a/panels/network/net-vpn.c
+++ b/panels/network/net-vpn.c
@@ -84,7 +84,6 @@ nm_device_refresh_vpn_ui (NetVpn *self)
* vpn connections in the device list.
*/
title = g_strdup_printf (_("%s VPN"), nm_connection_get_id (self->connection));
- net_object_set_title (NET_OBJECT (self), title);
gtk_label_set_label (self->device_label, title);
if (self->active_connection) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]