diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:44:59 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:45:02 +0900 |
commit | 55e9ab1b728021859bb9ef5d5f27049c530d880e (patch) | |
tree | 552ec5019ef1ab124a63dfde97be187374a2d505 /gi/overrides/Gio.py | |
parent | 8ee8219e2a010b7cc8ec068d42af27ad58556ada (diff) | |
download | pygobject2-55e9ab1b728021859bb9ef5d5f27049c530d880e.tar.gz pygobject2-55e9ab1b728021859bb9ef5d5f27049c530d880e.tar.bz2 pygobject2-55e9ab1b728021859bb9ef5d5f27049c530d880e.zip |
Imported Upstream version 3.2.0
Change-Id: Icdce2dbd074e763b749f5af1a12d4db4809a71b7
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi/overrides/Gio.py')
-rw-r--r-- | gi/overrides/Gio.py | 52 |
1 files changed, 14 insertions, 38 deletions
diff --git a/gi/overrides/Gio.py b/gi/overrides/Gio.py index e646821..20adf0c 100644 --- a/gi/overrides/Gio.py +++ b/gi/overrides/Gio.py @@ -18,18 +18,17 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA -from ..overrides import override, deprecated_init -from ..module import get_introspection_module +from ..overrides import override +from ..importer import modules from gi.repository import GLib import sys -Gio = get_introspection_module('Gio') +Gio = modules['Gio']._introspection_module __all__ = [] - class FileEnumerator(Gio.FileEnumerator): def __iter__(self): return self @@ -49,22 +48,11 @@ class FileEnumerator(Gio.FileEnumerator): FileEnumerator = override(FileEnumerator) __all__.append('FileEnumerator') - -class MenuItem(Gio.MenuItem): - def set_attribute(self, attributes): - for (name, format_string, value) in attributes: - self.set_attribute_value(name, GLib.Variant(format_string, value)) - - -MenuItem = override(MenuItem) -__all__.append('MenuItem') - - class Settings(Gio.Settings): '''Provide dictionary-like access to GLib.Settings.''' - __init__ = deprecated_init(Gio.Settings.__init__, - arg_names=('schema', 'path', 'backend')) + def __init__(self, schema, path=None, backend=None): + Gio.Settings.__init__(self, schema=schema, backend=backend, path=path) def __contains__(self, key): return key in self.list_keys() @@ -82,14 +70,14 @@ class Settings(Gio.Settings): def __getitem__(self, key): # get_value() aborts the program on an unknown key - if key not in self: + if not key in self: raise KeyError('unknown key: %r' % (key,)) return self.get_value(key).unpack() def __setitem__(self, key, value): # set_value() aborts the program on an unknown key - if key not in self: + if not key in self: raise KeyError('unknown key: %r' % (key,)) # determine type string of this key @@ -101,15 +89,8 @@ class Settings(Gio.Settings): type_str = v.get_child_value(0).get_type_string() assert type_str.startswith('a') type_str = type_str[1:] - elif type_ == 'enum': - # v is an array with the allowed values - assert v.get_child_value(0).get_type_string().startswith('a') - type_str = v.get_child_value(0).get_child_value(0).get_type_string() - allowed = v.unpack() - if value not in allowed: - raise ValueError('value %s is not an allowed enum (%s)' % (value, allowed)) else: - raise NotImplementedError('Cannot handle allowed type range class ' + str(type_)) + raise NotImplementedError('Cannot handle allowed type range class' + str(type_)) self.set_value(key, GLib.Variant(type_str, value)) @@ -119,7 +100,6 @@ class Settings(Gio.Settings): Settings = override(Settings) __all__.append('Settings') - class _DBusProxyMethodCall: '''Helper class to implement DBusProxy method calls.''' @@ -158,17 +138,14 @@ class _DBusProxyMethodCall: if 'result_handler' in kwargs: # asynchronous call user_data = (kwargs['result_handler'], - kwargs.get('error_handler'), - kwargs.get('user_data')) + kwargs.get('error_handler'), kwargs.get('user_data')) self.dbus_proxy.call(self.method_name, arg_variant, - kwargs.get('flags', 0), kwargs.get('timeout', -1), None, - self.__async_result_handler, user_data) + kwargs.get('flags', 0), kwargs.get('timeout', -1), None, + self.__async_result_handler, user_data) else: # synchronous call result = self.dbus_proxy.call_sync(self.method_name, arg_variant, - kwargs.get('flags', 0), - kwargs.get('timeout', -1), - None) + kwargs.get('flags', 0), kwargs.get('timeout', -1), None) return self._unpack_result(result) @classmethod @@ -186,10 +163,9 @@ class _DBusProxyMethodCall: return result - class DBusProxy(Gio.DBusProxy): '''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. @@ -217,7 +193,7 @@ class DBusProxy(Gio.DBusProxy): 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. |