
    9*b
                     r    d Z ddlmZ  G d de      Z G d de      Zd Z G d d	e      Z G d
 de      Zy)z
    pyudev._qt_base
    ===============

    Base mixin class for Qt4,Qt5 support.

    .. moduleauthor::  Sebastian Wiesner  <lunaryorn@gmail.com>
    )Devicec                   V    e Zd ZdZd Zed        Zej                  d        Zd Zd Z	y)MonitorObserverMixinz0
    Base mixin for pyqt monitor observers.
    c                     || _          ||j                         |j                  |       | _        | j                  j                  t
           j                  | j                         y N)monitorfilenoReadnotifier	activatedintconnect_process_udev_event)selfr   notifier_classs      1/usr/lib/python3/dist-packages/pyudev/_qt_base.py_setup_notifierz$MonitorObserverMixin._setup_notifier%   sI    &w~~'79L9LdS$,,T-E-EF    c                 6    | j                   j                         S )aY  
        Whether this observer is enabled or not.

        If ``True`` (the default), this observer is enabled, and emits events.
        Otherwise it is disabled and does not emit any events.  This merely
        reflects the state of the ``enabled`` property of the underlying
        :attr:`notifier`.

        .. versionadded:: 0.14
        )r   	isEnabled)r   s    r   enabledzMonitorObserverMixin.enabled*   s     }}&&((r   c                 :    | j                   j                  |       y r   )r   
setEnabled)r   values     r   r   zMonitorObserverMixin.enabled8   s      'r   c                 d    | j                   j                  d      }|| j                  |       yy)z
        Attempt to receive a single device event from the monitor, process
        the event and emit corresponding signals.

        Called by ``QSocketNotifier``, if data is available on the udev
        monitoring socket.
        r   )timeoutN)r   poll_emit_eventr   devices     r   r   z(MonitorObserverMixin._process_udev_event<   s4     ""1"-V$ r   c                 :    | j                   j                  |       y r   )deviceEventemitr   s     r   r   z MonitorObserverMixin._emit_eventH   s    f%r   N)
__name__
__module____qualname____doc__r   propertyr   setterr   r    r   r   r   r      sC    G
 ) ) ^^( (
%&r   r   c                       e Zd ZdZd Zd Zy)QUDevMonitorObserverMixinz*
    Obsolete monitor observer mixin.
    c                     t         j                  | ||       | j                  | j                  | j                  | j
                  d| _        dd l}|j                  dt               y )N)addremovechangemover   zAWill be removed in 1.0. Use pyudev.pyqt4.MonitorObserver instead.)
r   r   deviceAddeddeviceRemoveddeviceChangeddeviceMoved_action_signal_mapwarningswarnDeprecationWarning)r   r   r   r7   s       r   r   z)QUDevMonitorObserverMixin._setup_notifierS   sY    ,,T7NK##(((($$	#
 	R	
r   c                     | j                   j                  |j                  |       | j                  j	                  |j                        }||j                  |       y y r   )r"   r#   actionr6   get)r   r    signals      r   r   z%QUDevMonitorObserverMixin._emit_eventc   sM    fmmV4((,,V]];KK r   N)r$   r%   r&   r'   r   r   r*   r   r   r,   r,   L   s    
  r   r,   c                      d fd	}|S )a  
    Generates an initializer to observer the given ``monitor``
    (a :class:`~pyudev.Monitor`):

    ``parent`` is the parent :class:`~PyQt{4,5}.QtCore.QObject` of this
    object.  It is passed unchanged to the inherited constructor of
    :class:`~PyQt{4,5}.QtCore.QObject`.
    c                 N    j                  | |       | j                  |       y r   )__init__r   )r   r   parentqobjectsocket_notifiers      r   r@   zmake_init.<locals>.__init__t   s#    v&Wo6r   r   r*   )rB   rC   r@   s   `` r   	make_initrD   j   s    7
 Or   c                        e Zd ZdZed        Zy)MonitorObserverGenerator4
    Class to generate a MonitorObserver class.
    c           
          t        t        d      | t        ft        d      t        | |      t        d       |t              i      S )a  Generates an observer for device events integrating into the
        PyQt{4,5} mainloop.

        This class inherits :class:`~PyQt{4,5}.QtCore.QObject` to turn device
        events into Qt signals:

        >>> from pyudev import Context, Monitor
        >>> from pyudev.pyqt4 import MonitorObserver
        >>> context = Context()
        >>> monitor = Monitor.from_netlink(context)
        >>> monitor.filter_by(subsystem='input')
        >>> observer = MonitorObserver(monitor)
        >>> def device_event(device):
        ...     print('event {0} on device {1}'.format(device.action, device))
        >>> observer.deviceEvent.connect(device_event)
        >>> monitor.start()

        This class is a child of :class:`~{PySide, PyQt{4,5}}.QtCore.QObject`.

        MonitorObserverr@   r"   )typestrr   rD   r   rB   r=   rC   s      r   make_monitor_observerz.MonitorObserverGenerator.make_monitor_observer   sF    , !"*+J7O!DM"F6N
 	
r   Nr$   r%   r&   r'   staticmethodrM   r*   r   r   rF   rF   |   s     
 
r   rF   c                        e Zd ZdZed        Zy)QUDevMonitorObserverGeneratorrG   c                 @   t        t        d      | t        ft        d      t        | |      t        d       |t        t              t        d       |t              t        d       |t              t        d       |t              t        d       |t              i      S )a  Generates an observer for device events integrating into the
        PyQt{4,5} mainloop.

        This class inherits :class:`~PyQt{4,5}.QtCore.QObject` to turn device
        events into Qt signals:

        >>> from pyudev import Context, Monitor
        >>> from pyudev.pyqt4 import MonitorObserver
        >>> context = Context()
        >>> monitor = Monitor.from_netlink(context)
        >>> monitor.filter_by(subsystem='input')
        >>> observer = MonitorObserver(monitor)
        >>> def device_event(device):
        ...     print('event {0} on device {1}'.format(device.action, device))
        >>> observer.deviceEvent.connect(device_event)
        >>> monitor.start()

        This class is a child of :class:`~{PyQt{4,5}, PySide}.QtCore.QObject`.

        QUDevMonitorObserverr@   r"   r2   r3   r4   r5   )rJ   rK   r,   rD   r   rL   s      r   rM   z3QUDevMonitorObserverGenerator.make_monitor_observer   s    , &'/0J7O!DM"F3$7M"F6NO$fVnO$fVnM"F6N
 	
r   NrN   r*   r   r   rQ   rQ      s     %
 %
r   rQ   N)	r'   pyudev.devicer   objectr   r,   rD   rF   rQ   r*   r   r   <module>rV      sG   " !+&6 +&\  4  <$$
v $
N-
F -
r   