o
    Š¦T`YI  ã                   @   s¨  d dl Z ddlmZmZ ddlmZmZmZ ddlm	Z	 d dl
mZ d dlmZ d dlZe	dƒZg ZG d	d
„ d
ejƒZeeƒZe d
¡ d/dd„ZeG dd„ dejƒƒZe d¡ eG dd„ dejƒƒZe d¡ eG dd„ dejƒƒZe d¡ eG dd„ dejƒƒZe d¡ eG dd„ dejƒƒZe d¡ eG dd„ dejƒƒZe d¡ eG dd„ dejƒƒZe d¡ G dd„ dejƒZeeƒZe d¡ G dd„ dejƒZeeƒZe d¡ G dd „ d ejƒZeeƒZe d ¡ G d!d"„ d"ejƒZeeƒZe d"¡ G d#d$„ d$ƒZG d%d&„ d&ej ƒZ ee ƒZ e d&¡ G d'd(„ d(ej!ƒZ!ee!ƒZ!e d(¡ ej"ej#ej$fd)k �r<d*d+„ Z%nd,d+„ Z%G d-d.„ d.ej&ƒZ&ee&ƒZ&e d.¡ dS )0é    Né   )Úwakeup_on_signalÚregister_sigint_fallback)ÚoverrideÚdeprecated_initÚwrap_list_store_sort_func)Úget_introspection_module)ÚPyGIWarning)ÚGLibÚGioc                   @   ó   e Zd Zdd„ ZdS )ÚApplicationc              	   O   s~   t | jƒ�0 tƒ � tjj| g|¢R i |¤ŽW  d   ƒ W  d   ƒ S 1 s(w   Y  W d   ƒ d S 1 s8w   Y  d S ©N)r   Úquitr   r   r   Úrun)ÚselfÚargsÚkwargs© r   ú2/usr/lib/python3/dist-packages/gi/overrides/Gio.pyr   '   s   ÿÿ"ÿzApplication.runN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   %   s    r   c                    s   ‡ ‡fdd„}|S )Nc                    sl   t ˆ | ƒj|i |¤Ž ˆ j dd¡d d ˆ j }ˆr)tjd|ˆf tdd� d S tjd|f tdd� d S )NÚ.é   éÿÿÿÿz6%s shouldn't be instantiated directly, use %s instead.r   )Ú
stacklevelz&%s shouldn't be instantiated directly.)ÚsuperÚ__init__r   Úrsplitr   ÚwarningsÚwarnr	   )r   r   r   Úname©ÚclsÚinsteadr   r   Únew_init3   s   ÿ
ý
þz_warn_init.<locals>.new_initr   )r$   r%   r&   r   r#   r   Ú
_warn_init1   s   r'   c                   @   s   e Zd ZeejdƒZdS )ÚVolumeMonitorzGio.VolumeMonitor.get()N)r   r   r   r'   r   r(   r   r   r   r   r   r(   C   s    r(   c                   @   ó   e Zd ZeejƒZdS )ÚDBusAnnotationInfoN)r   r   r   r'   r   r*   r   r   r   r   r   r*   L   ó    r*   c                   @   r)   )ÚDBusArgInfoN)r   r   r   r'   r   r,   r   r   r   r   r   r,   T   r+   r,   c                   @   r)   )ÚDBusMethodInfoN)r   r   r   r'   r   r-   r   r   r   r   r   r-   \   r+   r-   c                   @   r)   )ÚDBusSignalInfoN)r   r   r   r'   r   r.   r   r   r   r   r   r.   d   r+   r.   c                   @   r)   )ÚDBusInterfaceInfoN)r   r   r   r'   r   r/   r   r   r   r   r   r/   l   r+   r/   c                   @   r)   )ÚDBusNodeInfoN)r   r   r   r'   r   r0   r   r   r   r   r   r0   t   r+   r0   c                   @   s   e Zd Zddd„ZdS )Ú	ActionMapNc                    sN   zt |ƒ W n ty   tdƒ‚w 		d‡ ‡fdd„	}|D ]}||Ž  qdS )aÕ  
        The add_action_entries() method is a convenience function for creating
        multiple Gio.SimpleAction instances and adding them to a Gio.ActionMap.
        Each action is constructed as per one entry.

        :param list entries:
            List of entry tuples for add_action() method. The entry tuple can
            vary in size with the following information:

                * The name of the action. Must be specified.
                * The callback to connect to the "activate" signal of the
                  action. Since GLib 2.40, this can be None for stateful
                  actions, in which case the default handler is used. For
                  boolean-stated actions with no parameter, this is a toggle.
                  For other state types (and parameter type equal to the state
                  type) this will be a function that just calls change_state
                  (which you should provide).
                * The type of the parameter that must be passed to the activate
                  function for this action, given as a single GLib.Variant type
                  string (or None for no parameter)
                * The initial state for this action, given in GLib.Variant text
                  format. The state is parsed with no extra type information, so
                  type tags must be added to the string if they are necessary.
                  Stateless actions should give None here.
                * The callback to connect to the "change-state" signal of the
                  action. All stateful actions should provide a handler here;
                  stateless actions should not.

        :param user_data:
            The user data for signal connections, or None
        zentries must be iterableNc                    s¾   |rt j |¡std|| f ƒ‚t j |¡}nd }|d ur:t j d |d d ¡}tj 	| ||¡}|d ur9| 
d|ˆ¡ n|d urFtd| |f ƒ‚tj| |d�}|d urX| 
d|ˆ¡ ˆ  |¡ d S )NzfThe type string '%s' given as the parameter type for action '%s' is not a valid GVariant type string. zchange-statezDStateless action '%s' should give None for 'change_state', not '%s'.)r"   Úparameter_typeÚactivate)r
   ÚVariantTypeÚstring_is_validÚ	TypeErrorÚnewÚVariantÚparser   ÚSimpleActionÚnew_statefulÚconnectÚ
ValueErrorÚ
add_action)r"   r3   r2   ÚstateÚchange_stateÚvariant_parameterÚvariant_stateÚaction©r   Ú	user_datar   r   Ú_process_action¢   s.   ý
ÿ€þz5ActionMap.add_action_entries.<locals>._process_action)NNNN)Úiterr6   )r   ÚentriesrE   rF   Úentryr   rD   r   Úadd_action_entries}   s    ÿÿ
þzActionMap.add_action_entriesr   )r   r   r   rJ   r   r   r   r   r1   |   s    r1   c                   @   s    e Zd Zdd„ Zdd„ ZeZdS )ÚFileEnumeratorc                 C   s   | S r   r   ©r   r   r   r   Ú__iter__Ë   s   zFileEnumerator.__iter__c                 C   s   |   d ¡}|d ur|S t‚r   )Ú	next_fileÚStopIteration)r   Ú	file_infor   r   r   Ú__next__Î   s   
zFileEnumerator.__next__N)r   r   r   rM   rQ   Únextr   r   r   r   rK   Ê   s    	rK   c                   @   r   )ÚMenuItemc                 C   s(   |D ]\}}}|   |t ||¡¡ qd S r   )Úset_attribute_valuer
   r8   )r   Ú
attributesr"   Úformat_stringÚvaluer   r   r   Úset_attributeß   s   ÿzMenuItem.set_attributeN)r   r   r   rX   r   r   r   r   rS   Þ   s    rS   c                   @   s\   e Zd ZdZeejjdd�Zdd„ Zdd„ Z	dd	„ Z
d
d„ ZeZdd„ Zdd„ Zdd„ ZdS )ÚSettingsz0Provide dictionary-like access to GLib.Settings.)ÚschemaÚpathÚbackend)Ú	arg_namesc                 C   s   ||   ¡ v S r   ©Ú	list_keys©r   Úkeyr   r   r   Ú__contains__î   ó   zSettings.__contains__c                 C   s   t |  ¡ ƒS r   )Úlenr_   rL   r   r   r   Ú__len__ñ   rc   zSettings.__len__c                 c   s   � |   ¡ D ]}|V  qd S r   r^   r`   r   r   r   rM   ô   s   €ÿzSettings.__iter__c                 C   s   dS )NTr   rL   r   r   r   Ú__bool__ø   s   zSettings.__bool__c                 C   s$   || vrt d|f ƒ‚|  |¡ ¡ S )Núunknown key: %r)ÚKeyErrorÚ	get_valueÚunpackr`   r   r   r   Ú__getitem__   s   zSettings.__getitem__c                 C   s8  || vrt d|f ƒ‚|  |¡}| d¡ ¡ }| d¡}|dkr5| d¡ ¡ }| d¡s.J ‚|dd … }n[|dkr`| d¡ ¡  d¡sEJ ‚| d¡ d¡ ¡ }| ¡ }||vr_td||f ƒ‚n0|dkrˆ| d¡}| d¡ ¡ }| ¡ \}	}
||	k s~||
kr‡td	||	|
f ƒ‚ntd
t	|ƒ ƒ‚|  
|t ||¡¡ d S )Nrg   r   r   ÚtypeÚaÚenumz$value %s is not an allowed enum (%s)Úrangezvalue %s not in range (%s - %s)z'Cannot handle allowed type range class )rh   Ú	get_rangeÚget_child_valueÚ
get_stringÚget_type_stringÚ
startswithrj   r=   ÚNotImplementedErrorÚstrÚ	set_valuer
   r8   )r   ra   rW   ro   Útype_ÚvÚtype_strÚallowedÚtuple_Úmin_Úmax_r   r   r   Ú__setitem__  s6   

ÿ
ÿÿzSettings.__setitem__c                 C   ó   |   ¡ S r   r^   rL   r   r   r   Úkeys(  ó   zSettings.keysN)r   r   r   Ú__doc__r   r   rY   r   rb   re   rM   rf   Ú__nonzero__rk   r   r�   r   r   r   r   rY   è   s    ÿ!rY   c                   @   s4   e Zd ZdZdd„ Zdd„ Zdd„ Zedd	„ ƒZd
S )Ú_DBusProxyMethodCallz1Helper class to implement DBusProxy method calls.c                 C   s   || _ || _d S r   )Ú
dbus_proxyÚmethod_name)r   r†   r‡   r   r   r   r   3  s   
z_DBusProxyMethodCall.__init__c           
      C   sz   |\}}}z|  |¡}W n% ty1   t ¡ d d… \}}	|r(|||	|ƒ Y d S |||	|ƒ Y d S w |||  |¡|ƒ d S )Nr   )Úcall_finishÚ	ExceptionÚsysÚexc_infoÚ_unpack_result)
r   ÚobjÚresultrE   Úresult_callbackÚerror_callbackÚreal_user_dataÚretÚetypeÚer   r   r   Ú__async_result_handler7  s   
ÿù	z+_DBusProxyMethodCall.__async_result_handlerc              	   O   sÆ   |r|d }|dd … }t |tƒstd| ƒ‚nd}t |t|ƒ¡}d|v rK|d | d¡| d¡f}| j | j	|| dd¡| d	d
¡d | j
|¡ d S | j | j	|| dd¡| d	d
¡d ¡}|  |¡S )Nr   r   z6first argument must be the method signature string: %rz()Úresult_handlerÚerror_handlerrE   ÚflagsÚtimeoutr   )Ú
isinstancerv   r6   r
   r8   ÚtupleÚgetr†   Úcallr‡   Ú*_DBusProxyMethodCall__async_result_handlerÚ	call_syncrŒ   )r   r   r   Ú	signatureÚarg_variantrE   rŽ   r   r   r   Ú__call__F  s.   
ÿþþ

ý
z_DBusProxyMethodCall.__call__c                 C   s4   |  ¡ }t|ƒdkr|d }|S t|ƒdkrd}|S )z?Convert a D-BUS return variant into an appropriate return valuer   r   N)rj   rd   )ÚklassrŽ   r   r   r   rŒ   c  s   ýz#_DBusProxyMethodCall._unpack_resultN)	r   r   r   rƒ   r   rž   r¢   ÚclassmethodrŒ   r   r   r   r   r…   0  s    r…   c                   @   s   e Zd ZdZdd„ ZdS )Ú	DBusProxya$  Provide comfortable and pythonic method calls.

    This marshalls the method arguments into a GVariant, invokes the
    call_sync() method on the DBusProxy object, and unmarshalls the result
    GVariant back into a Python tuple.

    The first argument always needs to be the D-Bus signature tuple of the
    method call. Example:

      proxy = Gio.DBusProxy.new_sync(...)
      result = proxy.MyMethod('(is)', 42, 'hello')

    The exception are methods which take no arguments, like
    proxy.MyMethod('()'). For these you can omit the signature and just write
    proxy.MyMethod().

    Optional keyword arguments:

    - timeout: timeout for the call in milliseconds (default to D-Bus timeout)

    - flags: Combination of Gio.DBusCallFlags.*

    - result_handler: Do an asynchronous method call and invoke
         result_handler(proxy_object, result, user_data) when it finishes.

    - error_handler: If the asynchronous call raises an exception,
      error_handler(proxy_object, exception, user_data) is called when it
      finishes. If error_handler is not given, result_handler is called with
      the exception object as result instead.

    - user_data: Optional user data to pass to result_handler for
      asynchronous calls.

    Example for asynchronous calls:

      def mymethod_done(proxy, result, user_data):
          if isinstance(result, Exception):
              # handle error
          else:
              # do something with result

      proxy.MyMethod('(is)', 42, 'hello',
          result_handler=mymethod_done, user_data='data')
    c                 C   s
   t | |ƒS r   )r…   )r   r"   r   r   r   Ú__getattr__   s   
zDBusProxy.__getattr__N)r   r   r   rƒ   r¦   r   r   r   r   r¥   s  s    ,r¥   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
Ú	ListModelc                    sr   t |tƒr‡ fdd„t| tˆ ƒ¡Ž D ƒS t |tƒr7|dk r$|tˆ ƒ7 }|dk r*t‚ˆ  |¡}|d u r5t‚|S t‚)Nc                    s   g | ]}ˆ   |¡‘qS r   )Úget_item)Ú.0ÚirL   r   r   Ú
<listcomp>¬  s    z)ListModel.__getitem__.<locals>.<listcomp>r   )	rš   Úslicero   Úindicesrd   ÚintÚ
IndexErrorr¨   r6   )r   ra   r’   r   rL   r   rk   ª  s   
 

zListModel.__getitem__c                 C   sD   |   ¡ j}t||ƒstd|j|jf ƒ‚| D ]	}||kr dS qdS )NúExpected type %s.%sTF)Úget_item_typeÚpytyperš   r6   r   r   )r   Úitemr²   rª   r   r   r   rb   ¹  s   

ÿÿzListModel.__contains__c                 C   r€   r   )Úget_n_itemsrL   r   r   r   re   Ã  r‚   zListModel.__len__c                 c   s$   � t t| ƒƒD ]}|  |¡V  qd S r   )ro   rd   r¨   )r   rª   r   r   r   rM   Æ  s   €ÿzListModel.__iter__N)r   r   r   rk   rb   re   rM   r   r   r   r   r§   ¨  s
    
r§   )r   é9   r   c                 C   s,   |   ||g ¡ t|ƒD ]}|  ||¡ qd S r   )ÚspliceÚreversedÚinsert)r   ÚpositionÚ
n_removalsÚ	additionsry   r   r   r   Ú_list_store_spliceÓ  s   ÿr¼   c                 C   s   |   |||¡ d S r   )r¶   )r   r¹   rº   r»   r   r   r   r¼   Ø  s   c                       s8   e Zd Z‡ fdd„Z‡ fdd„Zdd„ Zdd„ Z‡  ZS )	Ú	ListStorec                    s    t |ƒ}tt| ƒj|g|¢R Ž S r   )r   r   r½   Úsort)r   Úcompare_funcrE   ©Ú	__class__r   r   r¾   Þ  s   zListStore.sortc                    s"   t |ƒ}tt| ƒj||g|¢R Ž S r   )r   r   r½   Úinsert_sorted)r   r³   r¿   rE   rÀ   r   r   rÂ   â  s   
ÿÿzListStore.insert_sortedc                 C   sÚ   t |tƒrI| t| ƒ¡\}}}|dkr!t| |t|| dƒg ƒ d S |dkr5t| |d t|| dƒg ƒ d S tt|||ƒdd�D ]}|  |¡ q?d S t |t	ƒrk|dk rX|t| ƒ7 }|dk sb|t| ƒkrdt
‚|  |¡ d S t‚)Nr   r   r   T)Úreverse)rš   r¬   r­   rd   r¼   ÚmaxÚsortedro   Úremover®   r¯   r6   )r   ra   ÚstartÚstopÚsteprª   r   r   r   Ú__delitem__ç  s    
 ÿ
zListStore.__delitem__c                 C   sv  t |tƒr€|  ¡ j}g }|D ]}t ||ƒstd|j|jf ƒ‚| |¡ q| t	| ƒ¡\}}}|dkrAt
| |t|| dƒ|ƒ d S tt|||ƒƒ}	t	|	ƒt	|ƒkrSt‚|dkrlt
| |d t|| dƒ|d d d… ƒ d S t|	|ƒD ]\}
}t
| |
d|gƒ qqd S t |tƒr¹|dk r�|t	| ƒ7 }|dk s™|t	| ƒkr›t‚|  ¡ j}t ||ƒs¯td|j|jf ƒ‚t
| |d|gƒ d S t‚)Nr°   r   r   r   )rš   r¬   r±   r²   r6   r   r   Úappendr­   rd   r¼   rÄ   Úlistro   r=   Úzipr®   r¯   )r   ra   rW   r²   Ú	valuelistry   rÇ   rÈ   rÉ   r­   rª   r   r   r   r   ú  sP   


ÿÿÿ ÿÿ


ÿÿzListStore.__setitem__)r   r   r   r¾   rÂ   rÊ   r   Ú__classcell__r   r   rÀ   r   r½   Ü  s
    r½   r   )'r    Ú_ossighelperr   r   Ú	overridesr   r   r   Úmoduler   Úgir	   Úgi.repositoryr
   rŠ   r   Ú__all__r   rË   r'   r(   r*   r,   r-   r.   r/   r0   r1   rK   rS   rY   r…   r¥   r§   ÚMAJOR_VERSIONÚMINOR_VERSIONÚMICRO_VERSIONr¼   r½   r   r   r   r   Ú<module>   sv   








J


D
C1
#

I