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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -32,7 +32,6 @@ typedef struct
gchar *title; gchar *title;
GCancellable *cancellable; GCancellable *cancellable;
NMClient *client; NMClient *client;
CcNetworkPanel *panel;
} NetObjectPrivate; } NetObjectPrivate;
enum { enum {
@ -41,7 +40,6 @@ enum {
PROP_TITLE, PROP_TITLE,
PROP_CLIENT, PROP_CLIENT,
PROP_CANCELLABLE, PROP_CANCELLABLE,
PROP_PANEL,
PROP_LAST PROP_LAST
}; };
@ -132,15 +130,6 @@ net_object_get_cancellable (NetObject *self)
return priv->cancellable; 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 * GtkWidget *
net_object_get_widget (NetObject *self, net_object_get_widget (NetObject *self,
GtkSizeGroup *heading_size_group) GtkSizeGroup *heading_size_group)
@ -191,9 +180,6 @@ net_object_get_property (GObject *object,
case PROP_CANCELLABLE: case PROP_CANCELLABLE:
g_value_set_object (value, priv->cancellable); g_value_set_object (value, priv->cancellable);
break; break;
case PROP_PANEL:
g_value_set_pointer (value, priv->panel);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -230,12 +216,6 @@ net_object_set_property (GObject *object,
g_assert (!priv->cancellable); g_assert (!priv->cancellable);
priv->cancellable = g_value_dup_object (value); priv->cancellable = g_value_dup_object (value);
break; 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: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -254,8 +234,6 @@ net_object_finalize (GObject *object)
if (priv->client) if (priv->client)
g_object_remove_weak_pointer (G_OBJECT (priv->client), (gpointer *) (&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); 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_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (object_class, PROP_CANCELLABLE, pspec); 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] = signals[SIGNAL_CHANGED] =
g_signal_new ("changed", g_signal_new ("changed",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, 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); const gchar *title);
NMClient *net_object_get_client (NetObject *object); NMClient *net_object_get_client (NetObject *object);
GCancellable *net_object_get_cancellable (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_changed (NetObject *object);
void net_object_emit_removed (NetObject *object); void net_object_emit_removed (NetObject *object);
void net_object_refresh (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); static void nm_device_refresh_vpn_ui (NetVpn *self);
NetVpn * NetVpn *
net_vpn_new (CcPanel *panel, net_vpn_new (const gchar *id,
const gchar *id,
NMConnection *connection, NMConnection *connection,
NMClient *client) NMClient *client)
{ {
return g_object_new (NET_TYPE_VPN, return g_object_new (NET_TYPE_VPN,
"panel", panel,
"id", id, "id", id,
"connection", connection, "connection", connection,
"client", client, "client", client,

View file

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