o T`YI@sddlZddlmZmZddlmZmZmZddlm Z ddl m Z ddl m Z ddlZe dZgZGd d d ejZeeZed d/d d ZeGd ddejZedeGdddejZedeGdddejZedeGdddejZedeGdddejZedeGdddejZedeGdddejZedGdddejZeeZedGdddejZeeZedGdd d ejZeeZed Gd!d"d"ejZeeZed"Gd#d$d$ZGd%d&d&ej Z ee Z ed&Gd'd(d(ej!Z!ee!Z!ed(e j"e j#e j$fd)kr.new_initr)r$r%r&rr#r _warn_init1s r'c@seZdZeejdZdS) VolumeMonitorzGio.VolumeMonitor.get()N)rrrr'r r(rrrrrr(Csr(c@eZdZeejZdS)DBusAnnotationInfoN)rrrr'r r*rrrrrr*Lr*c@r)) DBusArgInfoN)rrrr'r r,rrrrrr,Tr+r,c@r))DBusMethodInfoN)rrrr'r r-rrrrrr-\r+r-c@r))DBusSignalInfoN)rrrr'r r.rrrrrr.dr+r.c@r))DBusInterfaceInfoN)rrrr'r r/rrrrrr/lr+r/c@r)) DBusNodeInfoN)rrrr'r r0rrrrrr0tr+r0c@seZdZdddZdS) ActionMapNcsNzt|Wn tytdw  dfdd }|D]}||qdS)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 zentries must be iterableNcs|rtj|std||ftj|}nd}|dur:tjd|dd}tj |||}|dur9| d|n|durFt d||ftj||d}|durX| d| |dS)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_typeactivate) r VariantTypestring_is_valid TypeErrornewVariantparser SimpleAction new_statefulconnect ValueError add_action)r"r3r2state change_statevariant_parameter variant_stateactionr user_datarr_process_actions.  z5ActionMap.add_action_entries.._process_action)NNNN)iterr6)rentriesrErFentryrrDradd_action_entries}s   zActionMap.add_action_entriesr)rrrrJrrrrr1|sr1c@s eZdZddZddZeZdS)FileEnumeratorcCs|Srrrrrr__iter__szFileEnumerator.__iter__cCs|d}|dur |Str) next_file StopIteration)r file_inforrr__next__s zFileEnumerator.__next__N)rrrrMrQnextrrrrrKs rKc@r )MenuItemcCs(|D]\}}}||t||qdSr)set_attribute_valuer r8)r attributesr" format_stringvaluerrr set_attributeszMenuItem.set_attributeN)rrrrXrrrrrSs rSc@s\eZdZdZeejjddZddZddZ dd Z d d Z e Z d d Z ddZddZdS)Settingsz0Provide dictionary-like access to GLib.Settings.)schemapathbackend) arg_namescCs ||vSr list_keysrkeyrrr __contains__ zSettings.__contains__cCs t|Sr)lenr_rLrrr__len__rczSettings.__len__ccs|D]}|VqdSrr^r`rrrrMs zSettings.__iter__cCsdS)NTrrLrrr__bool__szSettings.__bool__cCs$||vr td|f||S)Nunknown key: %r)KeyError get_valueunpackr`rrr __getitem__szSettings.__getitem__c Cs8||vr td|f||}|d}|d}|dkr5|d}|ds.J|dd}n[|dkr`|ddsEJ|dd}|}||vr_td||fn0|dkr|d}|d}|\} } || ks~|| krtd || | fntd t || |t ||dS) Nrgrrtypeaenumz$value %s is not an allowed enum (%s)rangezvalue %s not in range (%s - %s)z'Cannot handle allowed type range class ) rh get_rangeget_child_value get_stringget_type_string startswithrjr=NotImplementedErrorstr set_valuer r8) rrarWrotype_vtype_strallowedtuple_min_max_rrr __setitem__s6     zSettings.__setitem__cC|Srr^rLrrrkeys(z Settings.keysN)rrr__doc__rr rYrrbrerMrf __nonzero__rkrrrrrrrYs !rYc@s4eZdZdZddZddZddZedd Zd S) _DBusProxyMethodCallz1Helper class to implement DBusProxy method calls.cCs||_||_dSr) dbus_proxy method_name)rrrrrrr3s z_DBusProxyMethodCall.__init__c Csz|\}}}z||}Wn%ty1tdd\}} |r(||| |YdS||| |YdSw|||||dS)Nr) call_finish Exceptionsysexc_info_unpack_result) robjresultrEresult_callbackerror_callbackreal_user_dataretetypeerrr__async_result_handler7s     z+_DBusProxyMethodCall.__async_result_handlerc Os|r|d}|dd}t|tstd|nd}t|t|}d|vrK|d|d|df}|j|j ||dd|d d d|j |dS|j |j ||dd|d d d}| |S) Nrrz6first argument must be the method signature string: %rz()result_handler error_handlerrEflagstimeoutr) isinstancervr6r r8tuplegetrcallr*_DBusProxyMethodCall__async_result_handler call_syncr)rrr signature arg_variantrErrrr__call__Fs.        z_DBusProxyMethodCall.__call__cCs4|}t|dkr|d}|St|dkrd}|S)z?Convert a D-BUS return variant into an appropriate return valuerrN)rjrd)klassrrrrrcs  z#_DBusProxyMethodCall._unpack_resultN) rrrrrrr classmethodrrrrrr0src@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||Sr)r)rr"rrr __getattr__s zDBusProxy.__getattr__N)rrrrrrrrrrss ,rc@s,eZdZddZddZddZddZd S) ListModelcsrt|trfddt|tDSt|tr7|dkr$|t7}|dkr*t|}|dur5t|St)Ncsg|]}|qSr)get_item).0irLrr sz)ListModel.__getitem__..r) rsliceroindicesrdint IndexErrorrr6)rrarrrLrrks     zListModel.__getitem__cCsD|j}t||std|j|jf|D] }||krdSqdS)NExpected type %s.%sTF) get_item_typepytyperr6rr)ritemrrrrrrbs  zListModel.__contains__cCrr) get_n_itemsrLrrrrerzListModel.__len__ccs$tt|D]}||VqdSr)rordr)rrrrrrMszListModel.__iter__N)rrrrkrbrerMrrrrrs  r)r9rcCs,|||gt|D]}|||q dSr)splicereversedinsert)rposition n_removals additionsryrrr_list_store_splices rcCs||||dSr)r)rrrrrrrrscs8eZdZfddZfddZddZddZZS) ListStorecs t|}tt|j|g|RSr)rrrsort)r compare_funcrE __class__rrrszListStore.sortcs"t|}tt|j||g|RSr)rrr insert_sorted)rrrrErrrrs  zListStore.insert_sortedcCst|trI|t|\}}}|dkr!t||t||dgdS|dkr5t||dt||dgdStt|||ddD]}||q?dSt|t rk|dkrX|t|7}|dksb|t|krdt ||dSt )NrrrT)reverse) rrrrdrmaxsortedroremoverrr6)rrastartstopsteprrrr __delitem__s     zListStore.__delitem__c Csvt|tr|j}g}|D]}t||std|j|jf||q|t |\}}}|dkrAt ||t ||d|dSt t |||} t | t |krSt|dkrlt ||dt ||d|ddddSt| |D] \} }t || d|gqqdSt|tr|dkr|t |7}|dks|t |krt|j}t||std|j|jft ||d|gdSt)Nrrrr)rrrrr6rrappendrrdrrlistror=ziprr) rrarWr valuelistryrrrrrrrrrsP         zListStore.__setitem__)rrrrrrr __classcell__rrrrrs   rr)'r _ossighelperrr overridesrrrmodulergir gi.repositoryr rr __all__r rr'r(r*r,r-r.r/r0r1rKrSrYrrr MAJOR_VERSION MINOR_VERSION MICRO_VERSIONrrrrrrsv            J   D C1 #  I