network: Factor out most of NetDeviceWired, create NetDeviceEthernet
Rename NetDeviceWired to NetDeviceEthernet, but split out most of the code into a new NetDeviceSimple superclass that can later be used for other device types that we provide only minimal UI/support for. https://bugzilla.gnome.org/show_bug.cgi?id=677143
This commit is contained in:
parent
9e5a8eb5c8
commit
71c0325f28
8 changed files with 281 additions and 130 deletions
|
@ -22,8 +22,10 @@ libnetwork_la_SOURCES = \
|
|||
net-device.h \
|
||||
net-device-wifi.c \
|
||||
net-device-wifi.h \
|
||||
net-device-wired.c \
|
||||
net-device-wired.h \
|
||||
net-device-simple.c \
|
||||
net-device-simple.h \
|
||||
net-device-ethernet.c \
|
||||
net-device-ethernet.h \
|
||||
net-device-mobile.c \
|
||||
net-device-mobile.h \
|
||||
net-vpn.c \
|
||||
|
@ -55,7 +57,7 @@ dist_ui_DATA = \
|
|||
network-proxy.ui \
|
||||
network-vpn.ui \
|
||||
network-wifi.ui \
|
||||
network-wired.ui \
|
||||
network-simple.ui \
|
||||
network-mobile.ui \
|
||||
network.ui
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "net-device.h"
|
||||
#include "net-device-mobile.h"
|
||||
#include "net-device-wifi.h"
|
||||
#include "net-device-wired.h"
|
||||
#include "net-device-ethernet.h"
|
||||
#include "net-object.h"
|
||||
#include "net-proxy.h"
|
||||
#include "net-vpn.h"
|
||||
|
@ -493,7 +493,7 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
|
|||
/* map the NMDeviceType to the GType */
|
||||
switch (type) {
|
||||
case NM_DEVICE_TYPE_ETHERNET:
|
||||
device_g_type = NET_TYPE_DEVICE_WIRED;
|
||||
device_g_type = NET_TYPE_DEVICE_ETHERNET;
|
||||
break;
|
||||
case NM_DEVICE_TYPE_MODEM:
|
||||
device_g_type = NET_TYPE_DEVICE_MOBILE;
|
||||
|
|
65
panels/network/net-device-ethernet.c
Normal file
65
panels/network/net-device-ethernet.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||
*
|
||||
* Copyright (C) 2011-2012 Richard Hughes <richard@hughsie.com>
|
||||
*
|
||||
* Licensed under the GNU General Public License Version 2
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include <nm-client.h>
|
||||
#include <nm-device.h>
|
||||
#include <nm-device-ethernet.h>
|
||||
#include <nm-remote-connection.h>
|
||||
|
||||
#include "panel-common.h"
|
||||
|
||||
#include "net-device-ethernet.h"
|
||||
|
||||
G_DEFINE_TYPE (NetDeviceEthernet, net_device_ethernet, NET_TYPE_DEVICE_SIMPLE)
|
||||
|
||||
static char *
|
||||
device_ethernet_get_speed (NetDeviceSimple *device_simple)
|
||||
{
|
||||
NMDevice *nm_device;
|
||||
guint speed;
|
||||
|
||||
nm_device = net_device_get_nm_device (NET_DEVICE (device_simple));
|
||||
|
||||
speed = nm_device_ethernet_get_speed (NM_DEVICE_ETHERNET (nm_device));
|
||||
if (speed > 0) {
|
||||
/* Translators: network device speed */
|
||||
return g_strdup_printf (_("%d Mb/s"), speed);
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
net_device_ethernet_class_init (NetDeviceEthernetClass *klass)
|
||||
{
|
||||
NetDeviceSimpleClass *simple_class = NET_DEVICE_SIMPLE_CLASS (klass);
|
||||
|
||||
simple_class->get_speed = device_ethernet_get_speed;
|
||||
}
|
||||
|
||||
static void
|
||||
net_device_ethernet_init (NetDeviceEthernet *device_ethernet)
|
||||
{
|
||||
}
|
58
panels/network/net-device-ethernet.h
Normal file
58
panels/network/net-device-ethernet.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||
*
|
||||
* Copyright (C) 2012 Red Hat, Inc.
|
||||
*
|
||||
* Licensed under the GNU General Public License Version 2
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __NET_DEVICE_ETHERNET_H
|
||||
#define __NET_DEVICE_ETHERNET_H
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "net-device-simple.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NET_TYPE_DEVICE_ETHERNET (net_device_ethernet_get_type ())
|
||||
#define NET_DEVICE_ETHERNET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NET_TYPE_DEVICE_ETHERNET, NetDeviceEthernet))
|
||||
#define NET_DEVICE_ETHERNET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NET_TYPE_DEVICE_ETHERNET, NetDeviceEthernetClass))
|
||||
#define NET_IS_DEVICE_ETHERNET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NET_TYPE_DEVICE_ETHERNET))
|
||||
#define NET_IS_DEVICE_ETHERNET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NET_TYPE_DEVICE_ETHERNET))
|
||||
#define NET_DEVICE_ETHERNET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NET_TYPE_DEVICE_ETHERNET, NetDeviceEthernetClass))
|
||||
|
||||
typedef struct _NetDeviceEthernetPrivate NetDeviceEthernetPrivate;
|
||||
typedef struct _NetDeviceEthernet NetDeviceEthernet;
|
||||
typedef struct _NetDeviceEthernetClass NetDeviceEthernetClass;
|
||||
|
||||
struct _NetDeviceEthernet
|
||||
{
|
||||
NetDeviceSimple parent;
|
||||
NetDeviceEthernetPrivate *priv;
|
||||
};
|
||||
|
||||
struct _NetDeviceEthernetClass
|
||||
{
|
||||
NetDeviceSimpleClass parent_class;
|
||||
};
|
||||
|
||||
GType net_device_ethernet_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NET_DEVICE_ETHERNET_H */
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||
*
|
||||
* Copyright (C) 2011-2012 Richard Hughes <richard@hughsie.com>
|
||||
* Copyright (C) 2012 Red Hat, Inc.
|
||||
*
|
||||
* Licensed under the GNU General Public License Version 2
|
||||
*
|
||||
|
@ -26,41 +27,40 @@
|
|||
|
||||
#include <nm-client.h>
|
||||
#include <nm-device.h>
|
||||
#include <nm-device-ethernet.h>
|
||||
#include <nm-remote-connection.h>
|
||||
|
||||
#include "panel-common.h"
|
||||
|
||||
#include "net-device-wired.h"
|
||||
#include "net-device-simple.h"
|
||||
|
||||
#define NET_DEVICE_WIRED_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NET_TYPE_DEVICE_WIRED, NetDeviceWiredPrivate))
|
||||
#define NET_DEVICE_SIMPLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NET_TYPE_DEVICE_SIMPLE, NetDeviceSimplePrivate))
|
||||
|
||||
struct _NetDeviceWiredPrivate
|
||||
struct _NetDeviceSimplePrivate
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
gboolean updating_device;
|
||||
GtkBuilder *builder;
|
||||
gboolean updating_device;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (NetDeviceWired, net_device_wired, NET_TYPE_DEVICE)
|
||||
G_DEFINE_TYPE (NetDeviceSimple, net_device_simple, NET_TYPE_DEVICE)
|
||||
|
||||
static GtkWidget *
|
||||
device_wired_proxy_add_to_notebook (NetObject *object,
|
||||
GtkNotebook *notebook,
|
||||
GtkSizeGroup *heading_size_group)
|
||||
device_simple_proxy_add_to_notebook (NetObject *object,
|
||||
GtkNotebook *notebook,
|
||||
GtkSizeGroup *heading_size_group)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWindow *window;
|
||||
NetDeviceWired *device_wired = NET_DEVICE_WIRED (object);
|
||||
NetDeviceSimple *device_simple = NET_DEVICE_SIMPLE (object);
|
||||
|
||||
/* add widgets to size group */
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_wired->priv->builder,
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_simple->priv->builder,
|
||||
"heading_ipv4"));
|
||||
gtk_size_group_add_widget (heading_size_group, widget);
|
||||
|
||||
/* reparent */
|
||||
window = GTK_WINDOW (gtk_builder_get_object (device_wired->priv->builder,
|
||||
window = GTK_WINDOW (gtk_builder_get_object (device_simple->priv->builder,
|
||||
"window_tmp"));
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_wired->priv->builder,
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_simple->priv->builder,
|
||||
"vbox6"));
|
||||
g_object_ref (widget);
|
||||
gtk_container_remove (GTK_CONTAINER (window), widget);
|
||||
|
@ -72,9 +72,9 @@ device_wired_proxy_add_to_notebook (NetObject *object,
|
|||
static void
|
||||
update_off_switch_from_device_state (GtkSwitch *sw,
|
||||
NMDeviceState state,
|
||||
NetDeviceWired *device_wired)
|
||||
NetDeviceSimple *device_simple)
|
||||
{
|
||||
device_wired->priv->updating_device = TRUE;
|
||||
device_simple->priv->updating_device = TRUE;
|
||||
switch (state) {
|
||||
case NM_DEVICE_STATE_UNMANAGED:
|
||||
case NM_DEVICE_STATE_UNAVAILABLE:
|
||||
|
@ -87,25 +87,29 @@ update_off_switch_from_device_state (GtkSwitch *sw,
|
|||
gtk_switch_set_active (sw, TRUE);
|
||||
break;
|
||||
}
|
||||
device_wired->priv->updating_device = FALSE;
|
||||
device_simple->priv->updating_device = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_device_wired_refresh_ui (NetDeviceWired *device_wired)
|
||||
nm_device_simple_refresh_ui (NetDeviceSimple *device_simple)
|
||||
{
|
||||
const char *str;
|
||||
char *hwaddr;
|
||||
GString *status;
|
||||
GtkWidget *widget;
|
||||
guint speed = 0;
|
||||
char *speed = NULL;
|
||||
NMDevice *nm_device;
|
||||
NMDeviceState state;
|
||||
NetDeviceWiredPrivate *priv = device_wired->priv;
|
||||
NetDeviceSimplePrivate *priv = device_simple->priv;
|
||||
|
||||
/* set device kind */
|
||||
nm_device = net_device_get_nm_device (NET_DEVICE (device_wired));
|
||||
nm_device = net_device_get_nm_device (NET_DEVICE (device_simple));
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_device"));
|
||||
gtk_label_set_label (GTK_LABEL (widget),
|
||||
panel_device_to_localized_string (nm_device));
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "image_device"));
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (widget),
|
||||
panel_device_to_icon_name (nm_device),
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
|
||||
/* set up the device on/off switch */
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "device_off_switch"));
|
||||
|
@ -113,42 +117,42 @@ nm_device_wired_refresh_ui (NetDeviceWired *device_wired)
|
|||
gtk_widget_set_visible (widget,
|
||||
state != NM_DEVICE_STATE_UNAVAILABLE
|
||||
&& state != NM_DEVICE_STATE_UNMANAGED);
|
||||
update_off_switch_from_device_state (GTK_SWITCH (widget), state, device_wired);
|
||||
update_off_switch_from_device_state (GTK_SWITCH (widget), state, device_simple);
|
||||
|
||||
/* set device state, with status and optionally speed */
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_status"));
|
||||
status = g_string_new (panel_device_state_to_localized_string (nm_device));
|
||||
if (state != NM_DEVICE_STATE_UNAVAILABLE)
|
||||
speed = nm_device_ethernet_get_speed (NM_DEVICE_ETHERNET (nm_device));
|
||||
if (speed > 0) {
|
||||
g_string_append (status, " - ");
|
||||
/* Translators: network device speed */
|
||||
g_string_append_printf (status, _("%d Mb/s"), speed);
|
||||
}
|
||||
speed = net_device_simple_get_speed (device_simple);
|
||||
if (speed)
|
||||
g_string_append_printf (status, " - %s", speed);
|
||||
gtk_label_set_label (GTK_LABEL (widget), status->str);
|
||||
g_string_free (status, TRUE);
|
||||
gtk_widget_set_tooltip_text (widget,
|
||||
panel_device_state_reason_to_localized_string (nm_device));
|
||||
|
||||
/* device MAC */
|
||||
str = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (nm_device));
|
||||
panel_set_device_widget_details (priv->builder, "mac", str);
|
||||
g_object_get (G_OBJECT (nm_device),
|
||||
"hw-address", &hwaddr,
|
||||
NULL);
|
||||
panel_set_device_widget_details (priv->builder, "mac", hwaddr);
|
||||
g_free (hwaddr);
|
||||
|
||||
/* set IP entries */
|
||||
panel_set_device_widgets (priv->builder, nm_device);
|
||||
}
|
||||
|
||||
static void
|
||||
device_wired_refresh (NetObject *object)
|
||||
device_simple_refresh (NetObject *object)
|
||||
{
|
||||
NetDeviceWired *device_wired = NET_DEVICE_WIRED (object);
|
||||
nm_device_wired_refresh_ui (device_wired);
|
||||
NetDeviceSimple *device_simple = NET_DEVICE_SIMPLE (object);
|
||||
nm_device_simple_refresh_ui (device_simple);
|
||||
}
|
||||
|
||||
static void
|
||||
device_off_toggled (GtkSwitch *sw,
|
||||
GParamSpec *pspec,
|
||||
NetDeviceWired *device_wired)
|
||||
NetDeviceSimple *device_simple)
|
||||
{
|
||||
const gchar *path;
|
||||
const GPtrArray *acs;
|
||||
|
@ -158,25 +162,25 @@ device_off_toggled (GtkSwitch *sw,
|
|||
NMConnection *connection;
|
||||
NMClient *client;
|
||||
|
||||
if (device_wired->priv->updating_device)
|
||||
if (device_simple->priv->updating_device)
|
||||
return;
|
||||
|
||||
active = gtk_switch_get_active (sw);
|
||||
if (active) {
|
||||
client = net_object_get_client (NET_OBJECT (device_wired));
|
||||
connection = net_device_get_find_connection (NET_DEVICE (device_wired));
|
||||
client = net_object_get_client (NET_OBJECT (device_simple));
|
||||
connection = net_device_get_find_connection (NET_DEVICE (device_simple));
|
||||
if (connection == NULL)
|
||||
return;
|
||||
nm_client_activate_connection (client,
|
||||
connection,
|
||||
net_device_get_nm_device (NET_DEVICE (device_wired)),
|
||||
net_device_get_nm_device (NET_DEVICE (device_simple)),
|
||||
NULL, NULL, NULL);
|
||||
} else {
|
||||
connection = net_device_get_find_connection (NET_DEVICE (device_wired));
|
||||
connection = net_device_get_find_connection (NET_DEVICE (device_simple));
|
||||
if (connection == NULL)
|
||||
return;
|
||||
path = nm_connection_get_path (connection);
|
||||
client = net_object_get_client (NET_OBJECT (device_wired));
|
||||
client = net_object_get_client (NET_OBJECT (device_simple));
|
||||
acs = nm_client_get_active_connections (client);
|
||||
for (i = 0; i < acs->len; i++) {
|
||||
a = (NMActiveConnection*)acs->pdata[i];
|
||||
|
@ -189,56 +193,65 @@ device_off_toggled (GtkSwitch *sw,
|
|||
}
|
||||
|
||||
static void
|
||||
edit_connection (GtkButton *button, NetDeviceWired *device_wired)
|
||||
edit_connection (GtkButton *button, NetDeviceSimple *device_simple)
|
||||
{
|
||||
net_object_edit (NET_OBJECT (device_wired));
|
||||
net_object_edit (NET_OBJECT (device_simple));
|
||||
}
|
||||
|
||||
static void
|
||||
net_device_wired_constructed (GObject *object)
|
||||
net_device_simple_constructed (GObject *object)
|
||||
{
|
||||
NetDeviceWired *device_wired = NET_DEVICE_WIRED (object);
|
||||
NetDeviceSimple *device_simple = NET_DEVICE_SIMPLE (object);
|
||||
|
||||
G_OBJECT_CLASS (net_device_wired_parent_class)->constructed (object);
|
||||
G_OBJECT_CLASS (net_device_simple_parent_class)->constructed (object);
|
||||
|
||||
nm_device_wired_refresh_ui (device_wired);
|
||||
nm_device_simple_refresh_ui (device_simple);
|
||||
}
|
||||
|
||||
static void
|
||||
net_device_wired_finalize (GObject *object)
|
||||
net_device_simple_finalize (GObject *object)
|
||||
{
|
||||
NetDeviceWired *device_wired = NET_DEVICE_WIRED (object);
|
||||
NetDeviceWiredPrivate *priv = device_wired->priv;
|
||||
NetDeviceSimple *device_simple = NET_DEVICE_SIMPLE (object);
|
||||
NetDeviceSimplePrivate *priv = device_simple->priv;
|
||||
|
||||
g_object_unref (priv->builder);
|
||||
|
||||
G_OBJECT_CLASS (net_device_wired_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (net_device_simple_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static char *
|
||||
device_simple_get_speed (NetDeviceSimple *simple)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
net_device_wired_class_init (NetDeviceWiredClass *klass)
|
||||
net_device_simple_class_init (NetDeviceSimpleClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
NetObjectClass *parent_class = NET_OBJECT_CLASS (klass);
|
||||
NetDeviceSimpleClass *simple_class = NET_DEVICE_SIMPLE_CLASS (klass);
|
||||
|
||||
object_class->finalize = net_device_wired_finalize;
|
||||
object_class->constructed = net_device_wired_constructed;
|
||||
parent_class->add_to_notebook = device_wired_proxy_add_to_notebook;
|
||||
parent_class->refresh = device_wired_refresh;
|
||||
g_type_class_add_private (klass, sizeof (NetDeviceWiredPrivate));
|
||||
object_class->finalize = net_device_simple_finalize;
|
||||
object_class->constructed = net_device_simple_constructed;
|
||||
parent_class->add_to_notebook = device_simple_proxy_add_to_notebook;
|
||||
parent_class->refresh = device_simple_refresh;
|
||||
simple_class->get_speed = device_simple_get_speed;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (NetDeviceSimplePrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
net_device_wired_init (NetDeviceWired *device_wired)
|
||||
net_device_simple_init (NetDeviceSimple *device_simple)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GtkWidget *widget;
|
||||
|
||||
device_wired->priv = NET_DEVICE_WIRED_GET_PRIVATE (device_wired);
|
||||
device_simple->priv = NET_DEVICE_SIMPLE_GET_PRIVATE (device_simple);
|
||||
|
||||
device_wired->priv->builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_file (device_wired->priv->builder,
|
||||
GNOMECC_UI_DIR "/network-wired.ui",
|
||||
device_simple->priv->builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_file (device_simple->priv->builder,
|
||||
GNOMECC_UI_DIR "/network-simple.ui",
|
||||
&error);
|
||||
if (error != NULL) {
|
||||
g_warning ("Could not load interface file: %s", error->message);
|
||||
|
@ -246,14 +259,22 @@ net_device_wired_init (NetDeviceWired *device_wired)
|
|||
return;
|
||||
}
|
||||
|
||||
/* setup wired combobox model */
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_wired->priv->builder,
|
||||
/* setup simple combobox model */
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_simple->priv->builder,
|
||||
"device_off_switch"));
|
||||
g_signal_connect (widget, "notify::active",
|
||||
G_CALLBACK (device_off_toggled), device_wired);
|
||||
G_CALLBACK (device_off_toggled), device_simple);
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_wired->priv->builder,
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_simple->priv->builder,
|
||||
"button_options"));
|
||||
g_signal_connect (widget, "clicked",
|
||||
G_CALLBACK (edit_connection), device_wired);
|
||||
G_CALLBACK (edit_connection), device_simple);
|
||||
}
|
||||
|
||||
char *
|
||||
net_device_simple_get_speed (NetDeviceSimple *device_simple)
|
||||
{
|
||||
NetDeviceSimpleClass *klass = NET_DEVICE_SIMPLE_GET_CLASS (device_simple);
|
||||
|
||||
return klass->get_speed (device_simple);
|
||||
}
|
63
panels/network/net-device-simple.h
Normal file
63
panels/network/net-device-simple.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||
*
|
||||
* Copyright (C) 2011-2012 Richard Hughes <richard@hughsie.com>
|
||||
* Copyright (C) 2012 Red Hat, Inc.
|
||||
*
|
||||
* Licensed under the GNU General Public License Version 2
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __NET_DEVICE_SIMPLE_H
|
||||
#define __NET_DEVICE_SIMPLE_H
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "net-device.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NET_TYPE_DEVICE_SIMPLE (net_device_simple_get_type ())
|
||||
#define NET_DEVICE_SIMPLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NET_TYPE_DEVICE_SIMPLE, NetDeviceSimple))
|
||||
#define NET_DEVICE_SIMPLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NET_TYPE_DEVICE_SIMPLE, NetDeviceSimpleClass))
|
||||
#define NET_IS_DEVICE_SIMPLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NET_TYPE_DEVICE_SIMPLE))
|
||||
#define NET_IS_DEVICE_SIMPLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NET_TYPE_DEVICE_SIMPLE))
|
||||
#define NET_DEVICE_SIMPLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NET_TYPE_DEVICE_SIMPLE, NetDeviceSimpleClass))
|
||||
|
||||
typedef struct _NetDeviceSimplePrivate NetDeviceSimplePrivate;
|
||||
typedef struct _NetDeviceSimple NetDeviceSimple;
|
||||
typedef struct _NetDeviceSimpleClass NetDeviceSimpleClass;
|
||||
|
||||
struct _NetDeviceSimple
|
||||
{
|
||||
NetDevice parent;
|
||||
NetDeviceSimplePrivate *priv;
|
||||
};
|
||||
|
||||
struct _NetDeviceSimpleClass
|
||||
{
|
||||
NetDeviceClass parent_class;
|
||||
|
||||
char *(*get_speed) (NetDeviceSimple *device_simple);
|
||||
};
|
||||
|
||||
GType net_device_simple_get_type (void);
|
||||
|
||||
char *net_device_simple_get_speed (NetDeviceSimple *device_simple);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NET_DEVICE_SIMPLE_H */
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||
*
|
||||
* Copyright (C) 2011-2012 Richard Hughes <richard@hughsie.com>
|
||||
*
|
||||
* Licensed under the GNU General Public License Version 2
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __NET_DEVICE_WIRED_H
|
||||
#define __NET_DEVICE_WIRED_H
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "net-device.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NET_TYPE_DEVICE_WIRED (net_device_wired_get_type ())
|
||||
#define NET_DEVICE_WIRED(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NET_TYPE_DEVICE_WIRED, NetDeviceWired))
|
||||
#define NET_DEVICE_WIRED_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NET_TYPE_DEVICE_WIRED, NetDeviceWiredClass))
|
||||
#define NET_IS_DEVICE_WIRED(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NET_TYPE_DEVICE_WIRED))
|
||||
#define NET_IS_DEVICE_WIRED_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NET_TYPE_DEVICE_WIRED))
|
||||
#define NET_DEVICE_WIRED_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NET_TYPE_DEVICE_WIRED, NetDeviceWiredClass))
|
||||
|
||||
typedef struct _NetDeviceWiredPrivate NetDeviceWiredPrivate;
|
||||
typedef struct _NetDeviceWired NetDeviceWired;
|
||||
typedef struct _NetDeviceWiredClass NetDeviceWiredClass;
|
||||
|
||||
struct _NetDeviceWired
|
||||
{
|
||||
NetDevice parent;
|
||||
NetDeviceWiredPrivate *priv;
|
||||
};
|
||||
|
||||
struct _NetDeviceWiredClass
|
||||
{
|
||||
NetDeviceClass parent_class;
|
||||
};
|
||||
|
||||
GType net_device_wired_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NET_DEVICE_WIRED_H */
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue