mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-20 04:20:04 +01:00
linux: up-backend: Add and remove keyboard backlight LED device
These are the callback functions for the signals "device-added" and "device-removed" to add and remove keyboard backlight devices.
This commit is contained in:
parent
9f9b8478bd
commit
1d40bc2027
1 changed files with 22 additions and 9 deletions
|
|
@ -33,6 +33,7 @@
|
|||
#include "up-backend.h"
|
||||
#include "up-daemon.h"
|
||||
#include "up-device.h"
|
||||
#include "up-device-kbd-backlight.h"
|
||||
|
||||
#include "up-enumerator-udev.h"
|
||||
|
||||
|
|
@ -421,9 +422,13 @@ up_device_disconnected_cb (GObject *gobject,
|
|||
NULL);
|
||||
if (disconnected) {
|
||||
g_debug("Device %s became disconnected, hiding device", path);
|
||||
if (up_device_is_registered (UP_DEVICE (gobject))) {
|
||||
g_signal_emit (backend, signals[SIGNAL_DEVICE_REMOVED], 0, gobject);
|
||||
up_device_unregister (UP_DEVICE (gobject));
|
||||
if (UP_IS_DEVICE (gobject)) {
|
||||
if (up_device_is_registered (UP_DEVICE (gobject))) {
|
||||
g_signal_emit (backend, signals[SIGNAL_DEVICE_REMOVED], 0, gobject);
|
||||
up_device_unregister (UP_DEVICE (gobject));
|
||||
}
|
||||
} else if (UP_IS_DEVICE_KBD_BACKLIGHT (gobject)) {
|
||||
up_device_kbd_backlight_unregister (UP_DEVICE_KBD_BACKLIGHT (gobject));
|
||||
}
|
||||
} else {
|
||||
g_debug ("Device %s became connected, showing device", path);
|
||||
|
|
@ -433,20 +438,28 @@ up_device_disconnected_cb (GObject *gobject,
|
|||
}
|
||||
|
||||
static void
|
||||
udev_device_added_cb (UpBackend *backend, UpDevice *device)
|
||||
udev_device_added_cb (UpBackend *backend, GObject *device)
|
||||
{
|
||||
g_debug ("Got new device from udev enumerator: %p", device);
|
||||
g_signal_connect (device, "notify::disconnected",
|
||||
G_CALLBACK (up_device_disconnected_cb), backend);
|
||||
if (update_added_duplicate_device (backend, device))
|
||||
if (UP_IS_DEVICE (device)) {
|
||||
if (update_added_duplicate_device (backend, UP_DEVICE (device)))
|
||||
g_signal_emit (backend, signals[SIGNAL_DEVICE_ADDED], 0, device);
|
||||
} else if (UP_IS_DEVICE_KBD_BACKLIGHT (device)) {
|
||||
g_signal_emit (backend, signals[SIGNAL_DEVICE_ADDED], 0, device);
|
||||
} else {
|
||||
g_warning ("Unknown device type");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
udev_device_removed_cb (UpBackend *backend, UpDevice *device)
|
||||
udev_device_removed_cb (UpBackend *backend, GObject *device)
|
||||
{
|
||||
g_debug ("Removing device from udev enumerator: %p", device);
|
||||
update_removed_duplicate_device (backend, device);
|
||||
|
||||
if (UP_IS_DEVICE (device))
|
||||
update_removed_duplicate_device (backend, UP_DEVICE (device));
|
||||
g_signal_emit (backend, signals[SIGNAL_DEVICE_REMOVED], 0, device);
|
||||
}
|
||||
|
||||
|
|
@ -775,13 +788,13 @@ up_backend_class_init (UpBackendClass *klass)
|
|||
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (UpBackendClass, device_added),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1, UP_TYPE_DEVICE);
|
||||
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||
signals [SIGNAL_DEVICE_REMOVED] =
|
||||
g_signal_new ("device-removed",
|
||||
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (UpBackendClass, device_removed),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1, UP_TYPE_DEVICE);
|
||||
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue