static void
device_off_toggled (GtkSwitch         *sw,
                    GParamSpec        *pspec,
                    NetDeviceEthernet *device)
{
        NMClient *client;
        NMDevice *nm_device;
        NMConnection *connection;
        NMActiveConnection *a;

        if (device->updating_device)
                return;

        client = net_object_get_client (NET_OBJECT (device));
        nm_device = net_device_get_nm_device (NET_DEVICE (device));

        if (gtk_switch_get_active (sw)) {
                connection = net_device_get_find_connection (NET_DEVICE (device));
                if (connection != NULL) {
                        nm_client_activate_connection (client,
                                                       connection,
                                                       nm_device,
                                                       NULL, NULL, NULL);
                }
        } else {
                a = nm_device_get_active_connection (nm_device);
                if (a) {
                        nm_client_deactivate_connection (client, a);
                }
        }
}
Ejemplo n.º 2
0
static void
listbox_activated (NmtNewtListbox *listbox,
                   gpointer        user_data)
{
	NmtConnectConnectionList *list = NMT_CONNECT_CONNECTION_LIST (listbox);
	NMConnection *connection;
	NMDevice *device;
	NMObject *specific_object;
	NMActiveConnection *ac;

	if (!nmt_connect_connection_list_get_selection (list,
	                                                &connection,
	                                                &device,
	                                                &specific_object,
	                                                &ac))
		return;

	if (ac)
		nm_client_deactivate_connection (nm_client, ac, NULL, NULL);
	else
		activate_connection (connection, device, specific_object);
}