summaryrefslogtreecommitdiff
path: root/panels/network/net-device.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2012-07-16 17:22:56 +0100
committerRichard Hughes <richard@hughsie.com>2012-07-17 10:21:26 +0100
commit5d17320817bc26418d9e07745affba50ec680e11 (patch)
tree4ecaffa04817bbe97e7258a58bede6407af053fa /panels/network/net-device.c
parentf9e2828f77bb2a03b6bdc27e249f4fa7ed59c565 (diff)
downloadgnome-control-center-5d17320817bc26418d9e07745affba50ec680e11.tar.gz
network: Add a GObject nm-device property for NetDevice
Diffstat (limited to 'panels/network/net-device.c')
-rw-r--r--panels/network/net-device.c65
1 files changed, 64 insertions, 1 deletions
diff --git a/panels/network/net-device.c b/panels/network/net-device.c
index 7ab8f6ca2..6c4a8057c 100644
--- a/panels/network/net-device.c
+++ b/panels/network/net-device.c
@@ -33,6 +33,12 @@ struct _NetDevicePrivate
NMDevice *nm_device;
};
+enum {
+ PROP_0,
+ PROP_DEVICE,
+ PROP_LAST
+};
+
G_DEFINE_TYPE (NetDevice, net_device, NET_TYPE_OBJECT)
static void
@@ -62,6 +68,54 @@ net_device_get_nm_device (NetDevice *device)
return device->priv->nm_device;
}
+/**
+ * net_device_get_property:
+ **/
+static void
+net_device_get_property (GObject *device_,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ NetDevice *net_device = NET_DEVICE (device_);
+ NetDevicePrivate *priv = net_device->priv;
+
+ switch (prop_id) {
+ case PROP_DEVICE:
+ g_value_set_object (value, priv->nm_device);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (net_device, prop_id, pspec);
+ break;
+ }
+}
+
+/**
+ * net_device_set_property:
+ **/
+static void
+net_device_set_property (GObject *device_,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ NetDevice *net_device = NET_DEVICE (device_);
+ NetDevicePrivate *priv = net_device->priv;
+
+ switch (prop_id) {
+ case PROP_DEVICE:
+ priv->nm_device = g_value_dup_object (value);
+ g_signal_connect (priv->nm_device,
+ "state-changed",
+ G_CALLBACK (state_changed_cb),
+ net_device);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (net_device, prop_id, pspec);
+ break;
+ }
+}
+
static void
net_device_finalize (GObject *object)
{
@@ -77,8 +131,17 @@ net_device_finalize (GObject *object)
static void
net_device_class_init (NetDeviceClass *klass)
{
+ GParamSpec *pspec;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = net_device_finalize;
+ object_class->get_property = net_device_get_property;
+ object_class->set_property = net_device_set_property;
+
+ pspec = g_param_spec_object ("nm-device", NULL, NULL,
+ NM_TYPE_DEVICE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+ g_object_class_install_property (object_class, PROP_DEVICE, pspec);
+
g_type_class_add_private (klass, sizeof (NetDevicePrivate));
}
@@ -93,7 +156,7 @@ net_device_new (void)
{
NetDevice *device;
device = g_object_new (NET_TYPE_DEVICE,
- "removable", TRUE,
+ "removable", FALSE,
NULL);
return NET_DEVICE (device);
}