network: Replace method with a helper function.
This removes a case where an object was being temporarily created just to use this mehtod.
This commit is contained in:
parent
966cb97d45
commit
d7e17ca02f
6 changed files with 32 additions and 46 deletions
|
@ -127,12 +127,13 @@ device_off_toggled (NetDeviceBluetooth *self)
|
|||
if (self->updating_device)
|
||||
return;
|
||||
|
||||
client = net_object_get_client (NET_OBJECT (self));
|
||||
connection = net_device_get_find_connection (client, net_device_get_nm_device (NET_DEVICE (self)));
|
||||
if (connection == NULL)
|
||||
return;
|
||||
|
||||
active = gtk_switch_get_active (self->device_off_switch);
|
||||
if (active) {
|
||||
client = net_object_get_client (NET_OBJECT (self));
|
||||
connection = net_device_get_find_connection (NET_DEVICE (self));
|
||||
if (connection == NULL)
|
||||
return;
|
||||
nm_client_activate_connection_async (client,
|
||||
connection,
|
||||
net_device_get_nm_device (NET_DEVICE (self)),
|
||||
|
@ -140,11 +141,7 @@ device_off_toggled (NetDeviceBluetooth *self)
|
|||
} else {
|
||||
const gchar *uuid;
|
||||
|
||||
connection = net_device_get_find_connection (NET_DEVICE (self));
|
||||
if (connection == NULL)
|
||||
return;
|
||||
uuid = nm_connection_get_uuid (connection);
|
||||
client = net_object_get_client (NET_OBJECT (self));
|
||||
acs = nm_client_get_active_connections (client);
|
||||
for (i = 0; acs && i < acs->len; i++) {
|
||||
a = (NMActiveConnection*)acs->pdata[i];
|
||||
|
@ -164,7 +161,7 @@ edit_connection (NetDeviceBluetooth *self)
|
|||
g_autoptr(GError) error = NULL;
|
||||
NMConnection *connection;
|
||||
|
||||
connection = net_device_get_find_connection (NET_DEVICE (self));
|
||||
connection = net_device_get_find_connection (net_object_get_client (NET_OBJECT (self)), net_device_get_nm_device (NET_DEVICE (self)));
|
||||
uuid = nm_connection_get_uuid (connection);
|
||||
cmdline = g_strdup_printf ("nm-connection-editor --edit %s", uuid);
|
||||
g_debug ("Launching '%s'\n", cmdline);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue