logitech_receiver: Remove GDK dependency

This commit is contained in:
MattHag 2024-09-15 14:53:37 +02:00 committed by Peter F. Patel-Schneider
parent ea0eb66f39
commit 8fb087be14
2 changed files with 14 additions and 6 deletions

View File

@ -23,6 +23,7 @@ import dataclasses
import logging import logging
import struct import struct
import threading import threading
import typing
from contextlib import contextmanager from contextlib import contextmanager
from random import getrandbits from random import getrandbits
@ -42,8 +43,9 @@ from . import hidpp20_constants
from .common import LOGITECH_VENDOR_ID from .common import LOGITECH_VENDOR_ID
from .common import BusID from .common import BusID
gi.require_version("Gdk", "3.0") if typing.TYPE_CHECKING:
from gi.repository import GLib # NOQA: E402 gi.require_version("Gdk", "3.0")
from gi.repository import GLib # NOQA: E402
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -178,9 +180,15 @@ def receivers_and_devices():
yield from hidapi.enumerate(filter) yield from hidapi.enumerate(filter)
def notify_on_receivers_glib(callback): def notify_on_receivers_glib(glib: GLib, callback):
"""Watch for matching devices and notifies the callback on the GLib thread.""" """Watch for matching devices and notifies the callback on the GLib thread.
return hidapi.monitor_glib(GLib, callback, filter)
Parameters
----------
glib
GLib instance.
"""
return hidapi.monitor_glib(glib, callback, filter)
def open_path(path): def open_path(path):

View File

@ -332,7 +332,7 @@ def setup_scanner(status_changed_callback, setting_changed_callback, error_callb
_status_callback = status_changed_callback _status_callback = status_changed_callback
_setting_callback = setting_changed_callback _setting_callback = setting_changed_callback
_error_callback = error_callback _error_callback = error_callback
base.notify_on_receivers_glib(_process_receiver_event) base.notify_on_receivers_glib(GLib, _process_receiver_event)
def _process_add(device_info, retry): def _process_add(device_info, retry):