3 <_>#@sJddlZddlmZmZddlmZmZddlmZddl m Z ddl m Z ddl Z edZgZGd d d ejZeeZejd Gd d d ejZeeZejd Gd ddejZeeZejdGdddejZeeZejdGdddejZeeZejdGdddZGdddejZeeZejddS)N)wakeup_on_signalregister_sigint_fallback)overridedeprecated_init)get_introspection_module) PyGIWarning)GLibGioc@seZdZddZdS) ApplicationcOs<t|j(ttjj|f||SQRXWdQRXdS)N)rquitrr r run)selfargskwargsr/usr/lib64/python3.6/Gio.pyr 's zApplication.runN)__name__ __module__ __qualname__r rrrrr %sr cseZdZfddZZS) VolumeMonitorcs&tt|j||tjdtdddS)NzZGio.VolumeMonitor shouldn't be instantiated directly, use Gio.VolumeMonitor.get() instead.r) stacklevel)superr__init__warningswarnr)rrr) __class__rrr3szVolumeMonitor.__init__)rrrr __classcell__rr)rrr1src@s eZdZddZddZeZdS)FileEnumeratorcCs|S)Nr)rrrr__iter__BszFileEnumerator.__iter__cCs|jd}|dk r|StdS)N)Z next_file StopIteration)r file_inforrr__next__Es zFileEnumerator.__next__N)rrrrr"nextrrrrrAs rc@seZdZddZdS)MenuItemcCs,x&|D]\}}}|j|tj||qWdS)N)Zset_attribute_valuer Variant)rZ attributesname format_stringvaluerrr set_attributeVszMenuItem.set_attributeN)rrrr)rrrrr$Usr$c@sTeZdZdZeejjddZddZdd Z d d Z e Z d d Z ddZ ddZdS)Settingsz0Provide dictionary-like access to GLib.Settings.schemapathbackend)Z arg_namescCs ||jkS)N) list_keys)rkeyrrr __contains__eszSettings.__contains__cCs t|jS)N)lenr.)rrrr__len__hszSettings.__len__cCsdS)NTr)rrrr__bool__kszSettings.__bool__cCs$||krtd|f|j|jS)Nzunknown key: %r)KeyErrorZ get_valueunpack)rr/rrr __getitem__sszSettings.__getitem__cCs||krtd|f|j|}|jdj}|jd}|dkrj|jdj}|jds\t|dd}nf|dkr|jdjjdst|jdjdj}|j}||krtd||fnt dt ||j |t j ||dS) Nzunknown key: %rrtypeaenumz$value %s is not an allowed enum (%s)z'Cannot handle allowed type range class )r4Z get_rangeZget_child_valueZ get_stringZget_type_string startswithAssertionErrorr5 ValueErrorNotImplementedErrorstrZ set_valuer r%)rr/r(rangeZtype_vZtype_strZallowedrrr __setitem__zs"  zSettings.__setitem__cCs|jS)N)r.)rrrrkeyssz Settings.keysN)r+r,r-)rrr__doc__rr r*rr0r2r3Z __nonzero__r6rBrCrrrrr*_sr*c@s4eZdZdZddZddZddZedd Zd S) _DBusProxyMethodCallz1Helper class to implement DBusProxy method calls.cCs||_||_dS)N) dbus_proxy method_name)rrFrGrrrrsz_DBusProxyMethodCall.__init__c Csv|\}}}y|j|}WnFtk r^tjdd\}} |rN||| |n ||| |dSX|||j||dS)Nr)Z call_finish Exceptionsysexc_info_unpack_result) robjresult user_dataZresult_callbackZerror_callbackZreal_user_dataretetypeerrrZ__async_result_handlers  z+_DBusProxyMethodCall.__async_result_handlercOs|r0|d}|dd}t|ts4td|nd}tj|t|}d|kr|d|jd|jdf}|jj|j ||jdd|jd d d|j |n0|jj |j ||jdd|jd d d}|j |SdS) Nrr7z6first argument must be the method signature string: %rz()Zresult_handlerZ error_handlerrNflagsZtimeoutrS) isinstancer? TypeErrorr r%tuplegetrFZcallrG*_DBusProxyMethodCall__async_result_handlerZ call_syncrK)rrrZ signatureZ arg_variantrNrMrrr__call__s&        z_DBusProxyMethodCall.__call__cCs2|j}t|dkr|d}nt|dkr.d}|S)z?Convert a D-BUS return variant into an appropriate return valuer7rN)r5r1)klassrMrrrrKs    z#_DBusProxyMethodCall._unpack_resultN) rrrrDrrXrY classmethodrKrrrrrEs rEc@seZdZdZddZdS) 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') cCs t||S)N)rE)rr&rrr __getattr__ szDBusProxy.__getattr__N)rrrrDr]rrrrr\s,r\)rZ _ossighelperrrZ overridesrrmodulerZgirZ gi.repositoryr rIr __all__r appendrrr$r*rEr\rrrrs6        9 C1