[gnome-control-center] network: Add a NetObject->edit vfunc for the different devices to use
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Add a NetObject->edit vfunc for the different devices to use
- Date: Fri, 20 Jul 2012 08:33:26 +0000 (UTC)
commit 62b8a4c8bbca007eb6514771baa4e3eea94e93e7
Author: Richard Hughes <richard hughsie com>
Date: Fri Jul 20 09:08:53 2012 +0100
network: Add a NetObject->edit vfunc for the different devices to use
panels/network/net-device-wired.c | 15 +--------------
panels/network/net-device.c | 23 +++++++++++++++++++++++
panels/network/net-object.c | 8 ++++++++
panels/network/net-object.h | 2 ++
panels/network/net-vpn.c | 8 ++++++++
5 files changed, 42 insertions(+), 14 deletions(-)
---
diff --git a/panels/network/net-device-wired.c b/panels/network/net-device-wired.c
index f2bd65e..40e6c43 100644
--- a/panels/network/net-device-wired.c
+++ b/panels/network/net-device-wired.c
@@ -190,20 +190,7 @@ device_off_toggled (GtkSwitch *sw,
static void
edit_connection (GtkButton *button, NetDeviceWired *device_wired)
{
- const gchar *uuid;
- gchar *cmdline;
- GError *error = NULL;
- NMConnection *connection;
-
- connection = net_device_get_find_connection (NET_DEVICE (device_wired));
- uuid = nm_connection_get_uuid (connection);
- cmdline = g_strdup_printf ("nm-connection-editor --edit %s", uuid);
- g_debug ("Launching '%s'\n", cmdline);
- if (!g_spawn_command_line_async (cmdline, &error)) {
- g_warning ("Failed to launch nm-connection-editor: %s", error->message);
- g_error_free (error);
- }
- g_free (cmdline);
+ net_object_edit (NET_OBJECT (device_wired));
}
static void
diff --git a/panels/network/net-device.c b/panels/network/net-device.c
index fe9fcb3..5f01410 100644
--- a/panels/network/net-device.c
+++ b/panels/network/net-device.c
@@ -225,6 +225,26 @@ net_device_get_nm_device (NetDevice *device)
return device->priv->nm_device;
}
+static void
+net_device_edit (NetObject *object)
+{
+ const gchar *uuid;
+ gchar *cmdline;
+ GError *error = NULL;
+ NetDevice *device = NET_DEVICE (object);
+ NMConnection *connection;
+
+ connection = net_device_get_find_connection (device);
+ uuid = nm_connection_get_uuid (connection);
+ cmdline = g_strdup_printf ("nm-connection-editor --edit %s", uuid);
+ g_debug ("Launching '%s'\n", cmdline);
+ if (!g_spawn_command_line_async (cmdline, &error)) {
+ g_warning ("Failed to launch nm-connection-editor: %s", error->message);
+ g_error_free (error);
+ }
+ g_free (cmdline);
+}
+
/**
* net_device_get_property:
**/
@@ -290,9 +310,12 @@ net_device_class_init (NetDeviceClass *klass)
{
GParamSpec *pspec;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ NetObjectClass *parent_class = NET_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;
+ parent_class->edit = net_device_edit;
pspec = g_param_spec_object ("nm-device", NULL, NULL,
NM_TYPE_DEVICE,
diff --git a/panels/network/net-object.c b/panels/network/net-object.c
index fb2784f..d28f5d1 100644
--- a/panels/network/net-object.c
+++ b/panels/network/net-object.c
@@ -167,6 +167,14 @@ net_object_refresh (NetObject *object)
klass->refresh (object);
}
+void
+net_object_edit (NetObject *object)
+{
+ NetObjectClass *klass = NET_OBJECT_GET_CLASS (object);
+ if (klass->edit != NULL)
+ klass->edit (object);
+}
+
/**
* net_object_get_property:
**/
diff --git a/panels/network/net-object.h b/panels/network/net-object.h
index ce0b381..0b91e0c 100644
--- a/panels/network/net-object.h
+++ b/panels/network/net-object.h
@@ -56,6 +56,7 @@ struct _NetObjectClass
GtkSizeGroup *heading_size_group);
void (*delete) (NetObject *object);
void (*refresh) (NetObject *object);
+ void (*edit) (NetObject *object);
/* signal */
void (* changed) (NetObject *object);
@@ -76,6 +77,7 @@ void net_object_emit_changed (NetObject *object)
void net_object_emit_removed (NetObject *object);
void net_object_delete (NetObject *object);
void net_object_refresh (NetObject *object);
+void net_object_edit (NetObject *object);
GtkWidget *net_object_add_to_notebook (NetObject *object,
GtkNotebook *notebook,
GtkSizeGroup *heading_size_group);
diff --git a/panels/network/net-vpn.c b/panels/network/net-vpn.c
index ee2ebd1..828acab 100644
--- a/panels/network/net-vpn.c
+++ b/panels/network/net-vpn.c
@@ -378,9 +378,16 @@ device_off_toggled (GtkSwitch *sw,
static void
edit_connection (GtkButton *button, NetVpn *vpn)
{
+ net_object_edit (NET_OBJECT (vpn));
+}
+
+static void
+vpn_proxy_edit (NetObject *object)
+{
const gchar *uuid;
gchar *cmdline;
GError *error = NULL;
+ NetVpn *vpn = NET_VPN (object);
uuid = nm_connection_get_uuid (vpn->priv->connection);
cmdline = g_strdup_printf ("nm-connection-editor --edit %s", uuid);
@@ -471,6 +478,7 @@ net_vpn_class_init (NetVpnClass *klass)
parent_class->add_to_notebook = vpn_proxy_add_to_notebook;
parent_class->delete = vpn_proxy_delete;
parent_class->refresh = vpn_proxy_refresh;
+ parent_class->edit = vpn_proxy_edit;
pspec = g_param_spec_object ("connection", NULL, NULL,
NM_TYPE_CONNECTION,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]