Mini Shell
3
���X2G � @ s^ d dddgZ ddlZddlmZ ddlmZ ddlZdZd Zd
Z G dd � d e
�Zd
dd�ZdS )�Registry�MAIN_LOOP_GLIB�MAIN_LOOP_NONE�set_default_registry� N)�Atspi)�GLibr ZQt�Nonec @ s� e Zd ZdZi Zdd� Zdd� Zd,dd�Zd d
� Zd-d
d�Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� ZdZdZdd� Zdd � Zg d!eefdddfd"d#�Zg d!eeffd$d%�Zd&d'� Zd(d)� Zd*d+� ZdS ).r a�
Wraps the Accessibility.Registry to provide more Pythonic registration for
events.
This object should be treated as a singleton, but such treatment is not
enforced. You can construct another instance of this object and give it a
reference to the Accessibility.Registry singleton. Doing so is harmless and
has no point.
@@ivar async: Should event dispatch to local listeners be decoupled from event
receiving from the registry?
@@type async: boolean
@@ivar reg: Reference to the real, wrapped registry object
@@type reg: Accessibility.Registry
@@ivar dev: Reference to the device controller
@@type dev: Accessibility.DeviceEventController
@@ivar clients: Map of event names to client listeners
@@type clients: dictionary
@@ivar observers: Map of event names to AT-SPI L{_Observer} objects
@@type observers: dictionary
c C sR | j | _y| jrd S W n tk
r* Y nX d| _d | _d | _d | _tj� | _ d S )NF)
�_Registry__shared_state�__dict__�has_implementations�AttributeErrorZdevice_event_registerZapp_event_registerZdesktopr ZMainLoop� main_loop)�self� r �/usr/lib/python3.6/registry.py�__init__C s zRegistry.__init__c C s | S )zn
@@return: This instance of the registry
@@rtype: L{Registry}
r )r r r r �__call__T s zRegistry.__call__Nc C s d| _ d| _d| _t� | _dS )a�
Creates a new 'Registry' object and sets this object
as the default returned by pyatspi.Registry.
The default registry (without calling this function) uses the
GLib main loop with caching. It connects to a registry daemon.
This function should be called before pyatspi is used if you
wish to change these defaults.
@@param main_loop_type: 'GLib', 'None' or 'Qt'. If 'None' is selected then caching
is disabled.
@@param use_registry: Whether to connect to a registry daemon for device events.
Without this the application to connect to must be declared in the
app_name parameter.
@@param app_name: D-Bus name of the application to connect to when not using the registry daemon.
TFN)r �async�started�dict�event_listeners)r Zmain_loop_type�app_namer r r �
_set_registry[ s zRegistry._set_registryc C s | j t� d S )N)r r )r r r r �_set_default_registryv s zRegistry._set_default_registryFTc sl �j s�j� d�_|rZ� �fdd�� d� _tj� �}tj� tj|� � jdk rb� j�ntj� d�_dS )a3
Enter the main loop to start receiving and dispatching events.
@@param async: Should event dispatch be asynchronous (decoupled) from
event receiving from the AT-SPI registry?
@@type async: boolean
@@param gil: Add an idle callback which releases the Python GIL for a few
milliseconds to allow other threads to run? Necessary if other threads
will be used in this process.
@@type gil: boolean
Tc sD yt jd� W n0 tk
r> } z| � _�j� W Y d d } ~ X nX dS )Ng{�G�z�?T)�timeZsleep�KeyboardInterrupt�keyboard_exception�stop)�e)�
releaseGILr r r r � s z"Registry.start.<locals>.releaseGILNF) r r r r r Zidle_addr Z
event_mainZ
source_remove)r r Zgil�ir )r r r �starty s
zRegistry.startc G s | j s| j� tj� dS )z6
Quits the main loop.
N)r r r Z
event_quit)r �argsr r r r � s z
Registry.stopc C s dS )z�
Gets the number of available desktops.
@@return: Number of desktops
@@rtype: integer
� r )r r r r �getDesktopCount� s zRegistry.getDesktopCountc C s | j s| j� tj|�S )z�
Gets a reference to the i-th desktop.
@@param i: Which desktop to get
@@type i: integer
@@return: Desktop reference
@@rtype: Accessibility.Desktop
)r r r Zget_desktop)r r r r r �
getDesktop� s zRegistry.getDesktopc C s ||�S )Nr )r Zevent�callbackr r r �eventWrapper� s zRegistry.eventWrapperc
G sd | j s| j� y| j| }W n& tjj| j|� }| j|<