???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................3
u1Wk                 @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlZddlmZ G dd	 d	e	Z
G d
d de
Zdd ZG dd de	ZG dd de	ZdS )z
    pyudev._qt_base
    ===============

    Base mixin class for Qt4,Qt5 support.

    .. moduleauthor::  Sebastian Wiesner  <lunaryorn@gmail.com>
    )absolute_import)division)print_function)unicode_literalsN)Devicec               @   sB   e Zd ZdZdd Zedd Zejdd Zdd Zd	d
 Z	dS )MonitorObserverMixinz0
    Base mixin for pyqt monitor observers.
    c             C   s2   || _ ||j |j| | _| jjt j| j d S )N)monitorfilenoZReadnotifierZ	activatedintZconnect_process_udev_event)selfr   notifier_class r   /usr/lib/python3.6/_qt_base.py_setup_notifier+   s    z$MonitorObserverMixin._setup_notifierc             C   s
   | 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
   Z	isEnabled)r   r   r   r   enabled1   s    zMonitorObserverMixin.enabledc             C   s   | j j| d S )N)r
   Z
setEnabled)r   valuer   r   r   r   ?   s    c             C   s$   | j jdd}|dk	r | j| dS )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   )ZtimeoutN)r   Zpoll_emit_event)r   devicer   r   r   r   C   s    z(MonitorObserverMixin._process_udev_eventc             C   s   | j j| d S )N)deviceEventemit)r   r   r   r   r   r   O   s    z MonitorObserverMixin._emit_eventN)
__name__
__module____qualname____doc__r   propertyr   setterr   r   r   r   r   r   r   %   s   r   c               @   s    e Zd ZdZdd Zdd ZdS )QUDevMonitorObserverMixinz*
    Obsolete monitor observer mixin.
    c             C   s>   t j| || | j| j| j| jd| _dd l}|jdt	 d S )N)addremoveZchangeZ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   r&   r   r   r   r   Y   s    z)QUDevMonitorObserverMixin._setup_notifierc             C   s4   | j j|j| | jj|j}|d k	r0|j| d S )N)r   r   actionr%   get)r   r   signalr   r   r   r   d   s    z%QUDevMonitorObserverMixin._emit_eventN)r   r   r   r   r   r   r   r   r   r   r   S   s   r   c                s   d fd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`.
    Nc                s    j | | | j| d S )N)__init__r   )r   r   parent)qobjectsocket_notifierr   r   r,   t   s    zmake_init.<locals>.__init__)Nr   )r.   r/   r,   r   )r.   r/   r   	make_initj   s    
r0   c               @   s   e Zd ZdZedd ZdS )MonitorObserverGeneratorz4
    Class to generate a MonitorObserver class.
    c             C   s.   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`.

        ZMonitorObserverr,   r   )typestrr   r0   r   )r.   r+   r/   r   r   r   make_monitor_observer   s
    z.MonitorObserverGenerator.make_monitor_observerN)r   r   r   r   staticmethodr4   r   r   r   r   r1   |   s   r1   c               @   s   e Zd ZdZedd ZdS )QUDevMonitorObserverGeneratorz4
    Class to generate a MonitorObserver class.
    c             C   sb   t td| tftdt| |td|tj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`.

        ZQUDevMonitorObserverr,   r   r!   r"   r#   r$   )r2   r3   r   r0   sixZ	text_typer   )r.   r+   r/   r   r   r   r4      s    z3QUDevMonitorObserverGenerator.make_monitor_observerN)r   r   r   r   r5   r4   r   r   r   r   r6      s   r6   )r   Z
__future__r   r   r   r   r7   Zpyudev.devicer   objectr   r   r0   r1   r6   r   r   r   r   <module>   s   .'