network: Remove net_object_get_panel

It was only being used for WiFi devices
This commit is contained in:
Robert Ancell 2019-10-23 12:08:54 +13:00
parent 76de0ce408
commit 0b3ce1e15d
12 changed files with 26 additions and 77 deletions

View file

@ -465,24 +465,21 @@ panel_add_device (CcNetworkPanel *self, NMDevice *device)
switch (type) {
case NM_DEVICE_TYPE_ETHERNET:
case NM_DEVICE_TYPE_INFINIBAND:
net_device = NET_DEVICE (net_device_ethernet_new (CC_PANEL (self),
self->cancellable,
net_device = NET_DEVICE (net_device_ethernet_new (self->cancellable,
self->client,
device,
nm_device_get_udi (device)));
add_object (self, NET_OBJECT (net_device), GTK_CONTAINER (self->box_wired));
break;
case NM_DEVICE_TYPE_MODEM:
net_device = NET_DEVICE (net_device_mobile_new (CC_PANEL (self),
self->cancellable,
net_device = NET_DEVICE (net_device_mobile_new (self->cancellable,
self->client,
device,
nm_device_get_udi (device)));
add_object (self, NET_OBJECT (net_device), GTK_CONTAINER (self->box_wired));
break;
case NM_DEVICE_TYPE_BT:
net_device = NET_DEVICE (net_device_bluetooth_new (CC_PANEL (self),
self->cancellable,
net_device = NET_DEVICE (net_device_bluetooth_new (self->cancellable,
self->client,
device,
nm_device_get_udi (device)));
@ -686,8 +683,7 @@ panel_add_vpn_device (CcNetworkPanel *self, NMConnection *connection)
return;
/* add as a VPN object */
net_vpn = net_vpn_new (CC_PANEL (self),
id,
net_vpn = net_vpn_new (id,
connection,
self->client);
g_signal_connect_object (net_vpn, "removed",

View file

@ -233,14 +233,12 @@ net_device_bluetooth_init (NetDeviceBluetooth *self)
}
NetDeviceBluetooth *
net_device_bluetooth_new (CcPanel *panel,
GCancellable *cancellable,
net_device_bluetooth_new (GCancellable *cancellable,
NMClient *client,
NMDevice *device,
const gchar *id)
{
return g_object_new (NET_TYPE_DEVICE_BLUETOOTH,
"panel", panel,
"cancellable", cancellable,
"client", client,
"nm-device", device,

View file

@ -31,8 +31,7 @@ G_BEGIN_DECLS
#define NET_TYPE_DEVICE_BLUETOOTH (net_device_bluetooth_get_type ())
G_DECLARE_FINAL_TYPE (NetDeviceBluetooth, net_device_bluetooth, NET, DEVICE_BLUETOOTH, NetDevice)
NetDeviceBluetooth *net_device_bluetooth_new (CcPanel *panel,
GCancellable *cancellable,
NetDeviceBluetooth *net_device_bluetooth_new (GCancellable *cancellable,
NMClient *client,
NMDevice *device,
const gchar *id);

View file

@ -592,14 +592,12 @@ net_device_ethernet_init (NetDeviceEthernet *self)
}
NetDeviceEthernet *
net_device_ethernet_new (CcPanel *panel,
GCancellable *cancellable,
net_device_ethernet_new (GCancellable *cancellable,
NMClient *client,
NMDevice *device,
const gchar *id)
{
return g_object_new (NET_TYPE_DEVICE_ETHERNET,
"panel", panel,
"cancellable", cancellable,
"client", client,
"nm-device", device,

View file

@ -30,8 +30,7 @@ G_BEGIN_DECLS
#define NET_TYPE_DEVICE_ETHERNET (net_device_ethernet_get_type ())
G_DECLARE_FINAL_TYPE (NetDeviceEthernet, net_device_ethernet, NET, DEVICE_ETHERNET, NetDevice)
NetDeviceEthernet *net_device_ethernet_new (CcPanel *panel,
GCancellable *cancellable,
NetDeviceEthernet *net_device_ethernet_new (GCancellable *cancellable,
NMClient *client,
NMDevice *device,
const gchar *id);

View file

@ -124,7 +124,6 @@ mobile_connection_changed_cb (NetDeviceMobile *self)
NMConnection *connection;
NMDevice *device;
NMClient *client;
CcNetworkPanel *panel;
GtkWidget *toplevel;
if (self->updating_device)
@ -145,8 +144,7 @@ mobile_connection_changed_cb (NetDeviceMobile *self)
COLUMN_ID, &object_path,
-1);
if (g_strcmp0 (object_path, NULL) == 0) {
panel = net_object_get_panel (NET_OBJECT (self));
toplevel = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel)));
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self->box));
cc_network_panel_connect_to_3g_network (toplevel,
client,
device);
@ -981,14 +979,12 @@ net_device_mobile_init (NetDeviceMobile *self)
}
NetDeviceMobile *
net_device_mobile_new (CcPanel *panel,
GCancellable *cancellable,
net_device_mobile_new (GCancellable *cancellable,
NMClient *client,
NMDevice *device,
const gchar *id)
{
return g_object_new (NET_TYPE_DEVICE_MOBILE,
"panel", panel,
"cancellable", cancellable,
"client", client,
"nm-device", device,

View file

@ -31,8 +31,7 @@ G_BEGIN_DECLS
#define NET_TYPE_DEVICE_MOBILE (net_device_mobile_get_type ())
G_DECLARE_FINAL_TYPE (NetDeviceMobile, net_device_mobile, NET, DEVICE_MOBILE, NetDevice)
NetDeviceMobile *net_device_mobile_new (CcPanel *panel,
GCancellable *cancellable,
NetDeviceMobile *net_device_mobile_new (GCancellable *cancellable,
NMClient *client,
NMDevice *device,
const gchar *id);

View file

@ -77,6 +77,7 @@ struct _NetDeviceWifi
GtkLabel *status_label;
GtkLabel *title_label;
CcPanel *panel;
gboolean updating_device;
gchar *selected_ssid_title;
gchar *selected_connection_id;
@ -106,13 +107,14 @@ net_device_wifi_new (CcPanel *panel,
NMDevice *device,
const gchar *id)
{
return g_object_new (NET_TYPE_DEVICE_WIFI,
"panel", panel,
NetDeviceWifi *self = g_object_new (NET_TYPE_DEVICE_WIFI,
"cancellable", cancellable,
"client", client,
"nm-device", device,
"id", id,
NULL);
self->panel = panel;
return self;
}
GtkWidget *
@ -472,12 +474,10 @@ static void
connect_to_hidden_network (NetDeviceWifi *self)
{
NMClient *client;
CcNetworkPanel *panel;
GtkWidget *toplevel;
client = net_object_get_client (NET_OBJECT (self));
panel = net_object_get_panel (NET_OBJECT (self));
toplevel = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel)));
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self->notebook));
cc_network_panel_connect_to_hidden_network (toplevel, client);
}
@ -599,7 +599,6 @@ wireless_try_to_connect (NetDeviceWifi *self,
connection_add_activate_cb,
self);
} else {
CcNetworkPanel *panel;
g_autoptr(GVariantBuilder) builder = NULL;
GVariant *parameters;
@ -610,8 +609,7 @@ wireless_try_to_connect (NetDeviceWifi *self,
g_variant_builder_add (builder, "v", g_variant_new_string (ap_object_path));
parameters = g_variant_new ("av", builder);
panel = net_object_get_panel (NET_OBJECT (self));
g_object_set (G_OBJECT (panel), "parameters", parameters, NULL);
g_object_set (self->panel, "parameters", parameters, NULL);
}
}
@ -897,13 +895,11 @@ switch_hotspot_changed_cb (NetDeviceWifi *self)
{
GtkWidget *dialog;
GtkWidget *window;
CcNetworkPanel *panel;
if (self->updating_device)
return;
panel = net_object_get_panel (NET_OBJECT (self));
window = gtk_widget_get_toplevel (GTK_WIDGET (panel));
window = gtk_widget_get_toplevel (GTK_WIDGET (self->notebook));
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_OTHER,
@ -1239,7 +1235,6 @@ open_history (NetDeviceWifi *self)
{
GtkWidget *dialog;
GtkWidget *window;
CcNetworkPanel *panel;
GtkWidget *forget;
GtkWidget *header;
GtkWidget *swin;
@ -1250,8 +1245,7 @@ open_history (NetDeviceWifi *self)
GList *list_rows;
dialog = g_object_new (HDY_TYPE_DIALOG, "use-header-bar", 1, NULL);
panel = net_object_get_panel (NET_OBJECT (self));
window = gtk_widget_get_toplevel (GTK_WIDGET (panel));
window = gtk_widget_get_toplevel (GTK_WIDGET (self->notebook));
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
gtk_window_set_title (GTK_WINDOW (dialog), _("Known Wi-Fi Networks"));
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);

View file

@ -32,7 +32,6 @@ typedef struct
gchar *title;
GCancellable *cancellable;
NMClient *client;
CcNetworkPanel *panel;
} NetObjectPrivate;
enum {
@ -41,7 +40,6 @@ enum {
PROP_TITLE,
PROP_CLIENT,
PROP_CANCELLABLE,
PROP_PANEL,
PROP_LAST
};
@ -132,15 +130,6 @@ net_object_get_cancellable (NetObject *self)
return priv->cancellable;
}
CcNetworkPanel *
net_object_get_panel (NetObject *self)
{
NetObjectPrivate *priv = net_object_get_instance_private (self);
g_return_val_if_fail (NET_IS_OBJECT (self), NULL);
return priv->panel;
}
GtkWidget *
net_object_get_widget (NetObject *self,
GtkSizeGroup *heading_size_group)
@ -191,9 +180,6 @@ net_object_get_property (GObject *object,
case PROP_CANCELLABLE:
g_value_set_object (value, priv->cancellable);
break;
case PROP_PANEL:
g_value_set_pointer (value, priv->panel);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -230,12 +216,6 @@ net_object_set_property (GObject *object,
g_assert (!priv->cancellable);
priv->cancellable = g_value_dup_object (value);
break;
case PROP_PANEL:
g_assert (!priv->panel);
priv->panel = g_value_get_pointer (value);
if (priv->panel)
g_object_add_weak_pointer (G_OBJECT (priv->panel), (gpointer *) (&priv->panel));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -254,8 +234,6 @@ net_object_finalize (GObject *object)
if (priv->client)
g_object_remove_weak_pointer (G_OBJECT (priv->client), (gpointer *) (&priv->client));
if (priv->panel)
g_object_remove_weak_pointer (G_OBJECT (priv->panel), (gpointer *) (&priv->panel));
G_OBJECT_CLASS (net_object_parent_class)->finalize (object);
}
@ -288,10 +266,6 @@ net_object_class_init (NetObjectClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (object_class, PROP_CANCELLABLE, pspec);
pspec = g_param_spec_pointer ("panel", NULL, NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (object_class, PROP_PANEL, pspec);
signals[SIGNAL_CHANGED] =
g_signal_new ("changed",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,

View file

@ -51,7 +51,6 @@ void net_object_set_title (NetObject *object,
const gchar *title);
NMClient *net_object_get_client (NetObject *object);
GCancellable *net_object_get_cancellable (NetObject *object);
CcNetworkPanel *net_object_get_panel (NetObject *object);
void net_object_emit_changed (NetObject *object);
void net_object_emit_removed (NetObject *object);
void net_object_refresh (NetObject *object);

View file

@ -61,13 +61,11 @@ G_DEFINE_TYPE (NetVpn, net_vpn, NET_TYPE_OBJECT)
static void nm_device_refresh_vpn_ui (NetVpn *self);
NetVpn *
net_vpn_new (CcPanel *panel,
const gchar *id,
net_vpn_new (const gchar *id,
NMConnection *connection,
NMClient *client)
{
return g_object_new (NET_TYPE_VPN,
"panel", panel,
"id", id,
"connection", connection,
"client", client,

View file

@ -31,8 +31,7 @@ G_BEGIN_DECLS
#define NET_TYPE_VPN (net_vpn_get_type ())
G_DECLARE_FINAL_TYPE (NetVpn, net_vpn, NET, VPN, NetObject)
NetVpn *net_vpn_new (CcPanel *panel,
const gchar *id,
NetVpn *net_vpn_new (const gchar *id,
NMConnection *connection,
NMClient *client);