network: Convert NetDeviceEthernet, NetDeviceBluetooth and NetDeviceMobile to GtkTemplate
This means NetObject is now obsolete and can be removed. There was a GtkSizeGroup that the mobile settings used, but it isn't clear if this is still relevant. It should be added back later if found to be (this code is likely to be removed to make way for a dedicated mobile panel).
This commit is contained in:
parent
ff042560d6
commit
36449d60c7
14 changed files with 103 additions and 295 deletions
|
@ -34,7 +34,6 @@
|
|||
#include "net-device-ethernet.h"
|
||||
#include "net-device-mobile.h"
|
||||
#include "net-device-wifi.h"
|
||||
#include "net-object.h"
|
||||
#include "net-proxy.h"
|
||||
#include "net-vpn.h"
|
||||
|
||||
|
@ -59,12 +58,10 @@ struct _CcNetworkPanel
|
|||
GPtrArray *ethernet_devices;
|
||||
GPtrArray *mobile_devices;
|
||||
GPtrArray *vpns;
|
||||
GHashTable *device_to_widget;
|
||||
GHashTable *nm_device_to_device;
|
||||
|
||||
NMClient *client;
|
||||
MMManager *modem_manager;
|
||||
GtkSizeGroup *sizegroup;
|
||||
gboolean updating_device;
|
||||
|
||||
/* widgets */
|
||||
|
@ -212,7 +209,6 @@ cc_network_panel_dispose (GObject *object)
|
|||
g_clear_pointer (&self->ethernet_devices, g_ptr_array_unref);
|
||||
g_clear_pointer (&self->mobile_devices, g_ptr_array_unref);
|
||||
g_clear_pointer (&self->vpns, g_ptr_array_unref);
|
||||
g_clear_pointer (&self->device_to_widget, g_hash_table_destroy);
|
||||
g_clear_pointer (&self->nm_device_to_device, g_hash_table_destroy);
|
||||
|
||||
G_OBJECT_CLASS (cc_network_panel_parent_class)->dispose (object);
|
||||
|
@ -239,7 +235,7 @@ panel_refresh_device_titles (CcNetworkPanel *self)
|
|||
{
|
||||
g_autoptr(GPtrArray) ndarray = NULL;
|
||||
g_autoptr(GPtrArray) nmdarray = NULL;
|
||||
NetObject **devices;
|
||||
GtkWidget **devices;
|
||||
NMDevice **nm_devices;
|
||||
g_auto(GStrv) titles = NULL;
|
||||
guint i, num_devices;
|
||||
|
@ -265,7 +261,7 @@ panel_refresh_device_titles (CcNetworkPanel *self)
|
|||
if (ndarray->len == 0)
|
||||
return;
|
||||
|
||||
devices = (NetObject **)ndarray->pdata;
|
||||
devices = (GtkWidget **)ndarray->pdata;
|
||||
nm_devices = (NMDevice **)nmdarray->pdata;
|
||||
num_devices = ndarray->len;
|
||||
|
||||
|
@ -386,29 +382,20 @@ update_bluetooth_section (CcNetworkPanel *self)
|
|||
gtk_widget_set_visible (self->container_bluetooth, self->bluetooth_devices->len > 0);
|
||||
}
|
||||
|
||||
static void
|
||||
add_object (CcNetworkPanel *self, NetObject *object, GtkContainer *container)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = net_object_get_widget (object, self->sizegroup);
|
||||
g_hash_table_insert (self->device_to_widget, object, widget);
|
||||
gtk_container_add (container, widget);
|
||||
}
|
||||
|
||||
static void
|
||||
panel_add_device (CcNetworkPanel *self, NMDevice *device)
|
||||
{
|
||||
NMDeviceType type;
|
||||
NetObject *net_device;
|
||||
NetDeviceEthernet *device_ethernet;
|
||||
NetDeviceMobile *device_mobile;
|
||||
NetDeviceBluetooth *device_bluetooth;
|
||||
g_autoptr(GDBusObject) modem_object = NULL;
|
||||
|
||||
if (!nm_device_get_managed (device))
|
||||
return;
|
||||
|
||||
/* does already exist */
|
||||
net_device = g_hash_table_lookup (self->nm_device_to_device, device);
|
||||
if (net_device != NULL)
|
||||
if (g_hash_table_lookup (self->nm_device_to_device, device) != NULL)
|
||||
return;
|
||||
|
||||
type = nm_device_get_device_type (device);
|
||||
|
@ -420,9 +407,11 @@ panel_add_device (CcNetworkPanel *self, NMDevice *device)
|
|||
switch (type) {
|
||||
case NM_DEVICE_TYPE_ETHERNET:
|
||||
case NM_DEVICE_TYPE_INFINIBAND:
|
||||
net_device = NET_OBJECT (net_device_ethernet_new (self->client, device));
|
||||
add_object (self, net_device, GTK_CONTAINER (self->box_wired));
|
||||
g_ptr_array_add (self->ethernet_devices, net_device);
|
||||
device_ethernet = net_device_ethernet_new (self->client, device);
|
||||
gtk_widget_show (GTK_WIDGET (device_ethernet));
|
||||
gtk_container_add (GTK_CONTAINER (self->box_wired), GTK_WIDGET (device_ethernet));
|
||||
g_ptr_array_add (self->ethernet_devices, device_ethernet);
|
||||
g_hash_table_insert (self->nm_device_to_device, device, device_ethernet);
|
||||
break;
|
||||
case NM_DEVICE_TYPE_MODEM:
|
||||
if (g_str_has_prefix (nm_device_get_udi (device), "/org/freedesktop/ModemManager1/Modem/")) {
|
||||
|
@ -441,14 +430,23 @@ panel_add_device (CcNetworkPanel *self, NMDevice *device)
|
|||
}
|
||||
}
|
||||
|
||||
net_device = NET_OBJECT (net_device_mobile_new (self->client, device, modem_object));
|
||||
add_object (self, net_device, GTK_CONTAINER (self->box_wired));
|
||||
g_ptr_array_add (self->mobile_devices, net_device);
|
||||
device_mobile = net_device_mobile_new (self->client, device, modem_object);
|
||||
gtk_widget_show (GTK_WIDGET (device_mobile));
|
||||
gtk_container_add (GTK_CONTAINER (self->box_wired), GTK_WIDGET (device_mobile));
|
||||
g_ptr_array_add (self->mobile_devices, device_mobile);
|
||||
g_hash_table_insert (self->nm_device_to_device, device, device_mobile);
|
||||
break;
|
||||
case NM_DEVICE_TYPE_BT:
|
||||
net_device = NET_OBJECT (net_device_bluetooth_new (self->client, device));
|
||||
add_object (self, net_device, GTK_CONTAINER (self->box_bluetooth));
|
||||
g_ptr_array_add (self->bluetooth_devices, net_device);
|
||||
device_bluetooth = net_device_bluetooth_new (self->client, device);
|
||||
gtk_widget_show (GTK_WIDGET (device_bluetooth));
|
||||
gtk_container_add (GTK_CONTAINER (self->box_bluetooth), GTK_WIDGET (device_bluetooth));
|
||||
g_ptr_array_add (self->bluetooth_devices, device_bluetooth);
|
||||
g_hash_table_insert (self->nm_device_to_device, device, device_bluetooth);
|
||||
|
||||
/* Update the device_bluetooth section if we're adding a bluetooth
|
||||
* device. This is a temporary solution though, for these will
|
||||
* be handled by the future Mobile Broadband panel */
|
||||
update_bluetooth_section (self);
|
||||
break;
|
||||
|
||||
/* For Wi-Fi and VPN we handle connections separately; we correctly manage
|
||||
|
@ -460,35 +458,24 @@ panel_add_device (CcNetworkPanel *self, NMDevice *device)
|
|||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
g_hash_table_insert (self->nm_device_to_device, device, net_device);
|
||||
|
||||
/* Update the device_bluetooth section if we're adding a bluetooth
|
||||
* device. This is a temporary solution though, for these will
|
||||
* be handled by the future Mobile Broadband panel */
|
||||
if (NET_IS_DEVICE_BLUETOOTH (net_device))
|
||||
update_bluetooth_section (self);
|
||||
}
|
||||
|
||||
static void
|
||||
panel_remove_device (CcNetworkPanel *self, NMDevice *device)
|
||||
{
|
||||
NetObject *net_device = NULL;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *net_device;
|
||||
|
||||
net_device = g_hash_table_lookup (self->nm_device_to_device, device);
|
||||
if (net_device == NULL)
|
||||
return;
|
||||
|
||||
widget = g_hash_table_lookup (self->device_to_widget, device);
|
||||
if (widget != NULL)
|
||||
gtk_widget_destroy (widget);
|
||||
|
||||
g_ptr_array_remove (self->bluetooth_devices, net_device);
|
||||
g_ptr_array_remove (self->ethernet_devices, net_device);
|
||||
g_ptr_array_remove (self->mobile_devices, net_device);
|
||||
g_hash_table_remove (self->nm_device_to_device, device);
|
||||
|
||||
gtk_widget_destroy (net_device);
|
||||
|
||||
/* update vpn widgets */
|
||||
update_vpn_section (self);
|
||||
|
||||
|
@ -722,7 +709,6 @@ cc_network_panel_class_init (CcNetworkPanelClass *klass)
|
|||
gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, box_wired);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, container_bluetooth);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, empty_listbox);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, sizegroup);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, create_connection_cb);
|
||||
}
|
||||
|
@ -741,11 +727,10 @@ cc_network_panel_init (CcNetworkPanel *self)
|
|||
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
|
||||
self->bluetooth_devices = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
self->ethernet_devices = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
self->mobile_devices = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
self->bluetooth_devices = g_ptr_array_new ();
|
||||
self->ethernet_devices = g_ptr_array_new ();
|
||||
self->mobile_devices = g_ptr_array_new ();
|
||||
self->vpns = g_ptr_array_new ();
|
||||
self->device_to_widget = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
self->nm_device_to_device = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
|
||||
/* add the virtual proxy device */
|
||||
|
|
|
@ -179,6 +179,4 @@
|
|||
</object>
|
||||
</child>
|
||||
</template>
|
||||
<object class="GtkSizeGroup" id="sizegroup">
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
@ -43,7 +43,6 @@ sources = files(
|
|||
'net-device-ethernet.c',
|
||||
'net-device-mobile.c',
|
||||
'net-device-wifi.c',
|
||||
'net-object.c',
|
||||
'net-proxy.c',
|
||||
'net-vpn.c',
|
||||
'network-dialogs.c',
|
||||
|
|
|
@ -33,10 +33,8 @@
|
|||
|
||||
struct _NetDeviceBluetooth
|
||||
{
|
||||
NetObject parent;
|
||||
GtkBox parent;
|
||||
|
||||
GtkBuilder *builder;
|
||||
GtkBox *box;
|
||||
GtkLabel *device_label;
|
||||
GtkSwitch *device_off_switch;
|
||||
GtkButton *options_button;
|
||||
|
@ -47,7 +45,7 @@ struct _NetDeviceBluetooth
|
|||
gboolean updating_device;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (NetDeviceBluetooth, net_device_bluetooth, NET_TYPE_OBJECT)
|
||||
G_DEFINE_TYPE (NetDeviceBluetooth, net_device_bluetooth, GTK_TYPE_BOX)
|
||||
|
||||
void
|
||||
net_device_bluetooth_set_show_separator (NetDeviceBluetooth *self,
|
||||
|
@ -57,15 +55,6 @@ net_device_bluetooth_set_show_separator (NetDeviceBluetooth *self,
|
|||
gtk_widget_set_visible (GTK_WIDGET (self->separator), show_separator);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
device_bluetooth_get_widget (NetObject *object,
|
||||
GtkSizeGroup *heading_size_group)
|
||||
{
|
||||
NetDeviceBluetooth *self = NET_DEVICE_BLUETOOTH (object);
|
||||
|
||||
return GTK_WIDGET (self->box);
|
||||
}
|
||||
|
||||
static void
|
||||
update_off_switch_from_device_state (GtkSwitch *sw,
|
||||
NMDeviceState state,
|
||||
|
@ -161,7 +150,6 @@ net_device_bluetooth_finalize (GObject *object)
|
|||
{
|
||||
NetDeviceBluetooth *self = NET_DEVICE_BLUETOOTH (object);
|
||||
|
||||
g_clear_object (&self->builder);
|
||||
g_clear_object (&self->client);
|
||||
g_clear_object (&self->device);
|
||||
|
||||
|
@ -172,31 +160,22 @@ static void
|
|||
net_device_bluetooth_class_init (NetDeviceBluetoothClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
NetObjectClass *parent_class = NET_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->finalize = net_device_bluetooth_finalize;
|
||||
parent_class->get_widget = device_bluetooth_get_widget;
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/network/network-bluetooth.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceBluetooth, device_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceBluetooth, device_off_switch);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceBluetooth, options_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceBluetooth, separator);
|
||||
}
|
||||
|
||||
static void
|
||||
net_device_bluetooth_init (NetDeviceBluetooth *self)
|
||||
{
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
self->builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_resource (self->builder,
|
||||
"/org/gnome/control-center/network/network-bluetooth.ui",
|
||||
&error);
|
||||
if (error != NULL) {
|
||||
g_warning ("Could not load interface file: %s", error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
self->box = GTK_BOX (gtk_builder_get_object (self->builder, "box"));
|
||||
self->device_label = GTK_LABEL (gtk_builder_get_object (self->builder, "device_label"));
|
||||
self->device_off_switch = GTK_SWITCH (gtk_builder_get_object (self->builder, "device_off_switch"));
|
||||
self->options_button = GTK_BUTTON (gtk_builder_get_object (self->builder, "options_button"));
|
||||
self->separator = GTK_SEPARATOR (gtk_builder_get_object (self->builder, "separator"));
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
|
||||
g_signal_connect_swapped (self->device_off_switch, "notify::active",
|
||||
G_CALLBACK (device_off_toggled), self);
|
||||
|
@ -211,7 +190,7 @@ net_device_bluetooth_new (NMClient *client, NMDevice *device)
|
|||
{
|
||||
NetDeviceBluetooth *self;
|
||||
|
||||
self = g_object_new (NET_TYPE_DEVICE_BLUETOOTH, NULL);
|
||||
self = g_object_new (net_device_bluetooth_get_type (), NULL);
|
||||
self->client = g_object_ref (client);
|
||||
self->device = g_object_ref (device);
|
||||
|
||||
|
|
|
@ -22,14 +22,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "net-object.h"
|
||||
#include <gtk/gtk.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NET_TYPE_DEVICE_BLUETOOTH (net_device_bluetooth_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (NetDeviceBluetooth, net_device_bluetooth, NET, DEVICE_BLUETOOTH, NetObject)
|
||||
G_DECLARE_FINAL_TYPE (NetDeviceBluetooth, net_device_bluetooth, NET, DEVICE_BLUETOOTH, GtkBox)
|
||||
|
||||
NetDeviceBluetooth *net_device_bluetooth_new (NMClient *client,
|
||||
NMDevice *device);
|
||||
|
|
|
@ -37,11 +37,9 @@
|
|||
|
||||
struct _NetDeviceEthernet
|
||||
{
|
||||
NetObject parent;
|
||||
GtkBox parent;
|
||||
|
||||
GtkBuilder *builder;
|
||||
GtkButton *add_profile_button;
|
||||
GtkBox *box;
|
||||
GtkButton *details_button;
|
||||
GtkFrame *details_frame;
|
||||
HdyActionRow *details_row;
|
||||
|
@ -56,16 +54,7 @@ struct _NetDeviceEthernet
|
|||
GHashTable *connections;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (NetDeviceEthernet, net_device_ethernet, NET_TYPE_OBJECT)
|
||||
|
||||
static GtkWidget *
|
||||
device_ethernet_get_widget (NetObject *object,
|
||||
GtkSizeGroup *heading_size_group)
|
||||
{
|
||||
NetDeviceEthernet *self = NET_DEVICE_ETHERNET (object);
|
||||
|
||||
return GTK_WIDGET (self->box);
|
||||
}
|
||||
G_DEFINE_TYPE (NetDeviceEthernet, net_device_ethernet, GTK_TYPE_BOX)
|
||||
|
||||
static void
|
||||
add_details_row (GtkWidget *details, gint top, const gchar *heading, const gchar *value)
|
||||
|
@ -234,7 +223,7 @@ show_details (NetDeviceEthernet *self, GtkButton *button, const gchar *title)
|
|||
GtkWidget *window;
|
||||
NetConnectionEditor *editor;
|
||||
|
||||
window = gtk_widget_get_toplevel (GTK_WIDGET (self->box));
|
||||
window = gtk_widget_get_toplevel (GTK_WIDGET (self));
|
||||
|
||||
row = g_object_get_data (G_OBJECT (button), "row");
|
||||
connection = NM_CONNECTION (g_object_get_data (G_OBJECT (row), "connection"));
|
||||
|
@ -426,7 +415,7 @@ add_profile (NetDeviceEthernet *self)
|
|||
|
||||
nm_connection_add_setting (connection, nm_setting_wired_new ());
|
||||
|
||||
window = gtk_widget_get_toplevel (GTK_WIDGET (self->box));
|
||||
window = gtk_widget_get_toplevel (GTK_WIDGET (self));
|
||||
|
||||
editor = net_connection_editor_new (GTK_WINDOW (window), connection, self->device, NULL, self->client);
|
||||
g_signal_connect_swapped (editor, "done", G_CALLBACK (editor_done), self);
|
||||
|
@ -476,7 +465,6 @@ device_ethernet_finalize (GObject *object)
|
|||
{
|
||||
NetDeviceEthernet *self = NET_DEVICE_ETHERNET (object);
|
||||
|
||||
g_clear_object (&self->builder);
|
||||
g_clear_object (&self->client);
|
||||
g_clear_object (&self->device);
|
||||
g_hash_table_destroy (self->connections);
|
||||
|
@ -487,35 +475,26 @@ device_ethernet_finalize (GObject *object)
|
|||
static void
|
||||
net_device_ethernet_class_init (NetDeviceEthernetClass *klass)
|
||||
{
|
||||
NetObjectClass *obj_class = NET_OBJECT_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
obj_class->get_widget = device_ethernet_get_widget;
|
||||
object_class->finalize = device_ethernet_finalize;
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/network/network-ethernet.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, add_profile_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, details_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, details_frame);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, details_row);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, device_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, device_off_switch);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, scrolled_window);
|
||||
}
|
||||
|
||||
static void
|
||||
net_device_ethernet_init (NetDeviceEthernet *self)
|
||||
{
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
self->builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_resource (self->builder,
|
||||
"/org/gnome/control-center/network/network-ethernet.ui",
|
||||
&error);
|
||||
if (error != NULL) {
|
||||
g_warning ("Could not load interface file: %s", error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
self->add_profile_button = GTK_BUTTON (gtk_builder_get_object (self->builder, "add_profile_button"));
|
||||
self->box = GTK_BOX (gtk_builder_get_object (self->builder, "box"));
|
||||
self->details_button = GTK_BUTTON (gtk_builder_get_object (self->builder, "details_button"));
|
||||
self->details_frame = GTK_FRAME (gtk_builder_get_object (self->builder, "details_frame"));
|
||||
self->details_row = HDY_ACTION_ROW (gtk_builder_get_object (self->builder, "details_row"));
|
||||
self->device_label = GTK_LABEL (gtk_builder_get_object (self->builder, "device_label"));
|
||||
self->device_off_switch = GTK_SWITCH (gtk_builder_get_object (self->builder, "device_off_switch"));
|
||||
self->scrolled_window = GTK_SCROLLED_WINDOW (gtk_builder_get_object (self->builder, "scrolled_window"));
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
|
||||
self->connections = g_hash_table_new (NULL, NULL);
|
||||
|
||||
|
@ -542,7 +521,7 @@ net_device_ethernet_new (NMClient *client, NMDevice *device)
|
|||
{
|
||||
NetDeviceEthernet *self;
|
||||
|
||||
self = g_object_new (NET_TYPE_DEVICE_ETHERNET, NULL);
|
||||
self = g_object_new (net_device_ethernet_get_type (), NULL);
|
||||
self->client = g_object_ref (client);
|
||||
self->device = g_object_ref (device);
|
||||
|
||||
|
|
|
@ -21,14 +21,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "net-object.h"
|
||||
#include <gtk/gtk.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
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)
|
||||
G_DECLARE_FINAL_TYPE (NetDeviceEthernet, net_device_ethernet, NET, DEVICE_ETHERNET, GtkBox)
|
||||
|
||||
NetDeviceEthernet *net_device_ethernet_new (NMClient *client,
|
||||
NMDevice *device);
|
||||
|
|
|
@ -37,10 +37,8 @@ static void nm_device_mobile_refresh_ui (NetDeviceMobile *self);
|
|||
|
||||
struct _NetDeviceMobile
|
||||
{
|
||||
NetObject parent;
|
||||
GtkBox parent;
|
||||
|
||||
GtkBuilder *builder;
|
||||
GtkBox *box;
|
||||
GtkLabel *device_label;
|
||||
GtkSwitch *device_off_switch;
|
||||
GtkLabel *dns_heading_label;
|
||||
|
@ -85,20 +83,7 @@ enum {
|
|||
COLUMN_LAST
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (NetDeviceMobile, net_device_mobile, NET_TYPE_OBJECT)
|
||||
|
||||
static GtkWidget *
|
||||
device_mobile_get_widget (NetObject *object,
|
||||
GtkSizeGroup *heading_size_group)
|
||||
{
|
||||
NetDeviceMobile *self = NET_DEVICE_MOBILE (object);
|
||||
|
||||
/* add widgets to size group */
|
||||
gtk_size_group_add_widget (heading_size_group, GTK_WIDGET (self->imei_heading_label));
|
||||
gtk_size_group_add_widget (heading_size_group, GTK_WIDGET (self->network_label));
|
||||
|
||||
return GTK_WIDGET (self->box);
|
||||
}
|
||||
G_DEFINE_TYPE (NetDeviceMobile, net_device_mobile, GTK_TYPE_BOX)
|
||||
|
||||
static void
|
||||
connection_activate_cb (GObject *source_object,
|
||||
|
@ -136,7 +121,7 @@ mobile_connection_changed_cb (NetDeviceMobile *self)
|
|||
COLUMN_ID, &object_path,
|
||||
-1);
|
||||
if (g_strcmp0 (object_path, NULL) == 0) {
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self->box));
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
|
||||
cc_network_panel_connect_to_3g_network (toplevel, self->client, self->device);
|
||||
return;
|
||||
}
|
||||
|
@ -729,7 +714,6 @@ net_device_mobile_dispose (GObject *object)
|
|||
|
||||
g_cancellable_cancel (self->cancellable);
|
||||
|
||||
g_clear_object (&self->builder);
|
||||
g_clear_object (&self->client);
|
||||
g_clear_object (&self->device);
|
||||
g_clear_object (&self->modem);
|
||||
|
@ -752,47 +736,39 @@ static void
|
|||
net_device_mobile_class_init (NetDeviceMobileClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
NetObjectClass *parent_class = NET_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->dispose = net_device_mobile_dispose;
|
||||
parent_class->get_widget = device_mobile_get_widget;
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/network/network-mobile.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, device_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, device_off_switch);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, dns_heading_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, dns_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, imei_heading_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, imei_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, ipv4_heading_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, ipv4_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, ipv6_heading_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, ipv6_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, mobile_connections_list_store);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, network_combo);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, network_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, options_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, provider_heading_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, provider_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, route_heading_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, route_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, status_label);
|
||||
}
|
||||
|
||||
static void
|
||||
net_device_mobile_init (NetDeviceMobile *self)
|
||||
{
|
||||
g_autoptr(GError) error = NULL;
|
||||
GtkCellRenderer *renderer;
|
||||
|
||||
self->builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_resource (self->builder,
|
||||
"/org/gnome/control-center/network/network-mobile.ui",
|
||||
&error);
|
||||
if (error != NULL) {
|
||||
g_warning ("Could not load interface file: %s", error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
self->box = GTK_BOX (gtk_builder_get_object (self->builder, "box"));
|
||||
self->device_label = GTK_LABEL (gtk_builder_get_object (self->builder, "device_label"));
|
||||
self->device_off_switch = GTK_SWITCH (gtk_builder_get_object (self->builder, "device_off_switch"));
|
||||
self->dns_heading_label = GTK_LABEL (gtk_builder_get_object (self->builder, "dns_heading_label"));
|
||||
self->dns_label = GTK_LABEL (gtk_builder_get_object (self->builder, "dns_label"));
|
||||
self->imei_heading_label = GTK_LABEL (gtk_builder_get_object (self->builder, "imei_heading_label"));
|
||||
self->imei_label = GTK_LABEL (gtk_builder_get_object (self->builder, "imei_label"));
|
||||
self->ipv4_heading_label = GTK_LABEL (gtk_builder_get_object (self->builder, "ipv4_heading_label"));
|
||||
self->ipv4_label = GTK_LABEL (gtk_builder_get_object (self->builder, "ipv4_label"));
|
||||
self->ipv6_heading_label = GTK_LABEL (gtk_builder_get_object (self->builder, "ipv6_heading_label"));
|
||||
self->ipv6_label = GTK_LABEL (gtk_builder_get_object (self->builder, "ipv6_label"));
|
||||
self->mobile_connections_list_store = GTK_LIST_STORE (gtk_builder_get_object (self->builder, "mobile_connections_list_store"));
|
||||
self->network_combo = GTK_COMBO_BOX (gtk_builder_get_object (self->builder, "network_combo"));
|
||||
self->network_label = GTK_LABEL (gtk_builder_get_object (self->builder, "network_label"));
|
||||
self->options_button = GTK_BUTTON (gtk_builder_get_object (self->builder, "options_button"));
|
||||
self->provider_heading_label = GTK_LABEL (gtk_builder_get_object (self->builder, "provider_heading_label"));
|
||||
self->provider_label = GTK_LABEL (gtk_builder_get_object (self->builder, "provider_label"));
|
||||
self->route_heading_label = GTK_LABEL (gtk_builder_get_object (self->builder, "route_heading_label"));
|
||||
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"));
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
|
||||
self->cancellable = g_cancellable_new ();
|
||||
|
||||
|
@ -822,7 +798,7 @@ net_device_mobile_new (NMClient *client, NMDevice *device, GDBusObject *modem)
|
|||
NetDeviceMobile *self;
|
||||
NMDeviceModemCapabilities caps;
|
||||
|
||||
self = g_object_new (NET_TYPE_DEVICE_MOBILE, NULL);
|
||||
self = g_object_new (net_device_mobile_get_type (), NULL);
|
||||
self->client = g_object_ref (client);
|
||||
self->device = g_object_ref (device);
|
||||
|
||||
|
|
|
@ -21,15 +21,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "net-object.h"
|
||||
|
||||
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)
|
||||
G_DECLARE_FINAL_TYPE (NetDeviceMobile, net_device_mobile, NET, DEVICE_MOBILE, GtkBox)
|
||||
|
||||
NetDeviceMobile *net_device_mobile_new (NMClient *client,
|
||||
NMDevice *device,
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||
*
|
||||
* Copyright (C) 2011 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 "net-object.h"
|
||||
|
||||
G_DEFINE_TYPE (NetObject, net_object, G_TYPE_OBJECT)
|
||||
|
||||
GtkWidget *
|
||||
net_object_get_widget (NetObject *self,
|
||||
GtkSizeGroup *heading_size_group)
|
||||
{
|
||||
NetObjectClass *klass = NET_OBJECT_GET_CLASS (self);
|
||||
|
||||
return klass->get_widget (self, heading_size_group);
|
||||
}
|
||||
|
||||
static void
|
||||
net_object_class_init (NetObjectClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
net_object_init (NetObject *self)
|
||||
{
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||
*
|
||||
* Copyright (C) 2011 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "cc-network-panel.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NET_TYPE_OBJECT (net_object_get_type ())
|
||||
|
||||
G_DECLARE_DERIVABLE_TYPE (NetObject, net_object, NET, OBJECT, GObject)
|
||||
|
||||
struct _NetObjectClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
/* vtable */
|
||||
GtkWidget *(*get_widget) (NetObject *object,
|
||||
GtkSizeGroup *heading_size_group);
|
||||
};
|
||||
|
||||
GtkWidget *net_object_get_widget (NetObject *object,
|
||||
GtkSizeGroup *heading_size_group);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.0 -->
|
||||
<object class="GtkBox" id="box">
|
||||
<property name="visible">True</property>
|
||||
<template class="NetDeviceBluetooth" parent="GtkBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
|
@ -83,5 +82,5 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</template>
|
||||
</interface>
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.0 -->
|
||||
<object class="GtkBox" id="box">
|
||||
<property name="visible">True</property>
|
||||
<template class="NetDeviceEthernet" parent="GtkBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="orientation">vertical</property>
|
||||
|
@ -112,5 +111,5 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</template>
|
||||
</interface>
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkBox" id="box">
|
||||
<property name="visible">True</property>
|
||||
<template class="NetDeviceMobile" parent="GtkBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">12</property>
|
||||
<property name="orientation">vertical</property>
|
||||
|
@ -416,5 +415,5 @@
|
|||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</template>
|
||||
</interface>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue