summaryrefslogtreecommitdiff
path: root/gi/overrides
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:46:23 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:46:27 +0900
commit392945d666d2cfb31a844826a72b1eb65a52546f (patch)
treea21354051734cbace4e92d6b10c8fa8cd2721dda /gi/overrides
parent4723e0bb24cc41607e5af3bb7036855fa767df0b (diff)
downloadpygobject2-392945d666d2cfb31a844826a72b1eb65a52546f.tar.gz
pygobject2-392945d666d2cfb31a844826a72b1eb65a52546f.tar.bz2
pygobject2-392945d666d2cfb31a844826a72b1eb65a52546f.zip
Imported Upstream version 3.25.1
Change-Id: I31412b37aa390505e71295f3a2c2e3cf2ba88b41 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi/overrides')
-rw-r--r--gi/overrides/GLib.py13
-rw-r--r--gi/overrides/GObject.py82
-rw-r--r--gi/overrides/Gdk.py4
-rw-r--r--gi/overrides/Gio.py19
-rw-r--r--gi/overrides/Gtk.py7
-rw-r--r--gi/overrides/Makefile.in34
-rw-r--r--gi/overrides/__init__.py32
7 files changed, 111 insertions, 80 deletions
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index ab0e83a..372d6d4 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -40,15 +40,14 @@ __all__.append('option')
# Types and functions still needed from static bindings
-from gi._gi import _glib
-from gi._gi import _gobject
+from gi import _gi
from gi._error import GError
Error = GError
-OptionContext = _glib.OptionContext
-OptionGroup = _glib.OptionGroup
-Pid = _glib.Pid
-spawn_async = _glib.spawn_async
+OptionContext = _gi.OptionContext
+OptionGroup = _gi.OptionGroup
+Pid = _gi.Pid
+spawn_async = _gi.spawn_async
def threads_init():
@@ -552,7 +551,7 @@ for name in ['G_MINFLOAT', 'G_MAXFLOAT', 'G_MINDOUBLE', 'G_MAXDOUBLE',
'G_MAXUINT', 'G_MINLONG', 'G_MAXLONG', 'G_MAXULONG', 'G_MAXSIZE',
'G_MINSSIZE', 'G_MAXSSIZE', 'G_MINOFFSET', 'G_MAXOFFSET']:
attr = name.split("_", 1)[-1]
- globals()[attr] = getattr(_gobject, name)
+ globals()[attr] = getattr(_gi, name)
__all__.append(attr)
diff --git a/gi/overrides/GObject.py b/gi/overrides/GObject.py
index 2e8f755..c252bfa 100644
--- a/gi/overrides/GObject.py
+++ b/gi/overrides/GObject.py
@@ -33,8 +33,8 @@ from gi import PyGIDeprecationWarning
from gi import _propertyhelper as propertyhelper
from gi import _signalhelper as signalhelper
+from gi import _gi
-_gobject = gi._gi._gobject
GObjectModule = gi.module.get_introspection_module('GObject')
@@ -42,7 +42,7 @@ __all__ = []
from gi import _option as option
-sys.modules['gi._gobject.option'] = option
+option = option
# API aliases for backwards compatibility
@@ -184,27 +184,27 @@ for name in ['SIGNAL_ACTION', 'SIGNAL_DETAILED', 'SIGNAL_NO_HOOKS',
__all__.append(name)
# Static types
-GBoxed = _gobject.GBoxed
-GEnum = _gobject.GEnum
-GFlags = _gobject.GFlags
-GInterface = _gobject.GInterface
-GObject = _gobject.GObject
-GObjectWeakRef = _gobject.GObjectWeakRef
-GParamSpec = _gobject.GParamSpec
-GPointer = _gobject.GPointer
-GType = _gobject.GType
-Warning = _gobject.Warning
+GBoxed = _gi.GBoxed
+GEnum = _gi.GEnum
+GFlags = _gi.GFlags
+GInterface = _gi.GInterface
+GObject = _gi.GObject
+GObjectWeakRef = _gi.GObjectWeakRef
+GParamSpec = _gi.GParamSpec
+GPointer = _gi.GPointer
+GType = _gi.GType
+Warning = _gi.Warning
__all__ += ['GBoxed', 'GEnum', 'GFlags', 'GInterface', 'GObject',
'GObjectWeakRef', 'GParamSpec', 'GPointer', 'GType',
'Warning']
-features = _gobject.features
-list_properties = _gobject.list_properties
-new = _gobject.new
-pygobject_version = _gobject.pygobject_version
+features = _gi.features
+list_properties = _gi.list_properties
+new = _gi.new
+pygobject_version = _gi.pygobject_version
threads_init = GLib.threads_init
-type_register = _gobject.type_register
+type_register = _gi.type_register
__all__ += ['features', 'list_properties', 'new',
'pygobject_version', 'threads_init', 'type_register']
@@ -228,15 +228,15 @@ class Value(GObjectModule.Value):
# Workaround the introspection marshalers inability to know
# these methods should be marshaling boxed types. This is because
# the type information is stored on the GValue.
- _gobject._gvalue_set(self, boxed)
+ _gi._gvalue_set(self, boxed)
def get_boxed(self):
- return _gobject._gvalue_get(self)
+ return _gi._gvalue_get(self)
def set_value(self, py_value):
gtype = self.g_type
- if gtype == _gobject.TYPE_INVALID:
+ if gtype == _gi.TYPE_INVALID:
raise TypeError("GObject.Value needs to be initialized first")
elif gtype == TYPE_BOOLEAN:
self.set_boolean(py_value)
@@ -527,8 +527,8 @@ __all__.append('signal_accumulator_true_handled')
# Statically bound signal functions which need to clobber GI (for now)
-add_emission_hook = _gobject.add_emission_hook
-signal_new = _gobject.signal_new
+add_emission_hook = _gi.add_emission_hook
+signal_new = _gi.signal_new
__all__ += ['add_emission_hook', 'signal_new']
@@ -596,23 +596,23 @@ class Object(GObjectModule.Object):
# The following methods are static APIs which need to leap frog the
# gi methods until we verify the gi methods can replace them.
- get_property = _gobject.GObject.get_property
- get_properties = _gobject.GObject.get_properties
- set_property = _gobject.GObject.set_property
- set_properties = _gobject.GObject.set_properties
- bind_property = _gobject.GObject.bind_property
- connect = _gobject.GObject.connect
- connect_after = _gobject.GObject.connect_after
- connect_object = _gobject.GObject.connect_object
- connect_object_after = _gobject.GObject.connect_object_after
- disconnect_by_func = _gobject.GObject.disconnect_by_func
- handler_block_by_func = _gobject.GObject.handler_block_by_func
- handler_unblock_by_func = _gobject.GObject.handler_unblock_by_func
- emit = _gobject.GObject.emit
- chain = _gobject.GObject.chain
- weak_ref = _gobject.GObject.weak_ref
- __copy__ = _gobject.GObject.__copy__
- __deepcopy__ = _gobject.GObject.__deepcopy__
+ get_property = _gi.GObject.get_property
+ get_properties = _gi.GObject.get_properties
+ set_property = _gi.GObject.set_property
+ set_properties = _gi.GObject.set_properties
+ bind_property = _gi.GObject.bind_property
+ connect = _gi.GObject.connect
+ connect_after = _gi.GObject.connect_after
+ connect_object = _gi.GObject.connect_object
+ connect_object_after = _gi.GObject.connect_object_after
+ disconnect_by_func = _gi.GObject.disconnect_by_func
+ handler_block_by_func = _gi.GObject.handler_block_by_func
+ handler_unblock_by_func = _gi.GObject.handler_unblock_by_func
+ emit = _gi.GObject.emit
+ chain = _gi.GObject.chain
+ weak_ref = _gi.GObject.weak_ref
+ __copy__ = _gi.GObject.__copy__
+ __deepcopy__ = _gi.GObject.__deepcopy__
def freeze_notify(self):
"""Freezes the object's property-changed notification queue.
@@ -648,9 +648,9 @@ class Object(GObjectModule.Object):
"""
flags = kwargs.get('connect_flags', 0)
if flags & GObjectModule.ConnectFlags.AFTER:
- connect_func = _gobject.GObject.connect_after
+ connect_func = _gi.GObject.connect_after
else:
- connect_func = _gobject.GObject.connect
+ connect_func = _gi.GObject.connect
if flags & GObjectModule.ConnectFlags.SWAPPED:
if len(data) != 1:
diff --git a/gi/overrides/Gdk.py b/gi/overrides/Gdk.py
index c5b9a39..bf1b9af 100644
--- a/gi/overrides/Gdk.py
+++ b/gi/overrides/Gdk.py
@@ -78,7 +78,6 @@ if hasattr(Gdk, 'Color'):
int(green * Color.MAX_VALUE),
int(blue * Color.MAX_VALUE))
-
Color = override(Color)
__all__.append('Color')
@@ -322,12 +321,15 @@ __all__.append('DragContext')
class Cursor(Gdk.Cursor):
+
def __new__(cls, *args, **kwds):
arg_len = len(args)
kwd_len = len(kwds)
total_len = arg_len + kwd_len
if total_len == 1:
+ if Gdk._version == "4.0":
+ raise ValueError("Wrong number of parameters")
# Since g_object_newv (super.__new__) does not seem valid for
# direct use with GdkCursor, we must assume usage of at least
# one of the C constructors to be valid.
diff --git a/gi/overrides/Gio.py b/gi/overrides/Gio.py
index bb320a5..cdb3ccb 100644
--- a/gi/overrides/Gio.py
+++ b/gi/overrides/Gio.py
@@ -18,8 +18,11 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
# USA
+import warnings
+
from ..overrides import override, deprecated_init
from ..module import get_introspection_module
+from gi import PyGIWarning
from gi.repository import GLib
@@ -30,6 +33,22 @@ Gio = get_introspection_module('Gio')
__all__ = []
+class VolumeMonitor(Gio.VolumeMonitor):
+
+ def __init__(self, *args, **kwargs):
+ super(VolumeMonitor, self).__init__(*args, **kwargs)
+
+ # https://bugzilla.gnome.org/show_bug.cgi?id=744690
+ warnings.warn(
+ "Gio.VolumeMonitor shouldn't be instantiated directly, "
+ "use Gio.VolumeMonitor.get() instead.",
+ PyGIWarning, stacklevel=2)
+
+
+VolumeMonitor = override(VolumeMonitor)
+__all__.append('VolumeMonitor')
+
+
class FileEnumerator(Gio.FileEnumerator):
def __iter__(self):
return self
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 2c0e870..08d2612 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -30,10 +30,8 @@ from gi import PyGIDeprecationWarning
if sys.version_info >= (3, 0):
_basestring = str
- _callable = lambda c: hasattr(c, '__call__')
else:
_basestring = basestring
- _callable = callable
Gtk = get_introspection_module('Gtk')
@@ -91,7 +89,7 @@ def _extract_handler_and_args(obj_or_map, handler_name):
args = handler[1:]
handler = handler[0]
- elif not _callable(handler):
+ elif not callable(handler):
raise TypeError('Handler %s is not a method, function or tuple' % handler)
return handler, args
@@ -745,9 +743,6 @@ class TextBuffer(Gtk.TextBuffer):
self.apply_tag(tag, start, iter)
def insert_with_tags_by_name(self, iter, text, *tags):
- if not tags:
- return
-
tag_objs = []
for tag in tags:
diff --git a/gi/overrides/Makefile.in b/gi/overrides/Makefile.in
index 6e0976d..61044db 100644
--- a/gi/overrides/Makefile.in
+++ b/gi/overrides/Makefile.in
@@ -89,10 +89,22 @@ build_triplet = @build@
host_triplet = @host@
subdir = gi/overrides
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \
- $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/libtool.m4 \
- $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
- $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \
+ $(top_srcdir)/m4/ax_append_flag.m4 \
+ $(top_srcdir)/m4/ax_append_link_flags.m4 \
+ $(top_srcdir)/m4/ax_check_compile_flag.m4 \
+ $(top_srcdir)/m4/ax_check_link_flag.m4 \
+ $(top_srcdir)/m4/ax_code_coverage.m4 \
+ $(top_srcdir)/m4/ax_compiler_flags.m4 \
+ $(top_srcdir)/m4/ax_compiler_flags_cflags.m4 \
+ $(top_srcdir)/m4/ax_compiler_flags_gir.m4 \
+ $(top_srcdir)/m4/ax_compiler_flags_ldflags.m4 \
+ $(top_srcdir)/m4/ax_is_release.m4 \
+ $(top_srcdir)/m4/ax_require_defined.m4 \
+ $(top_srcdir)/m4/glib-2.0.m4 $(top_srcdir)/m4/introspection.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pkg.m4 \
$(top_srcdir)/m4/python.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
@@ -157,7 +169,6 @@ am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/py-compile
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
-ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
@@ -180,7 +191,6 @@ CODE_COVERAGE_LIBS = @CODE_COVERAGE_LIBS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
-DATADIR = @DATADIR@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
@@ -213,8 +223,14 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@
INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@
+INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@
+INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@
+INTROSPECTION_LIBS = @INTROSPECTION_LIBS@
+INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@
INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@
+INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@
LCOV = @LCOV@
LD = @LD@
LDFLAGS = @LDFLAGS@
@@ -247,14 +263,12 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
-PLATFORM = @PLATFORM@
PYCAIRO_CFLAGS = @PYCAIRO_CFLAGS@
PYCAIRO_LIBS = @PYCAIRO_LIBS@
PYGOBJECT_MAJOR_VERSION = @PYGOBJECT_MAJOR_VERSION@
PYGOBJECT_MICRO_VERSION = @PYGOBJECT_MICRO_VERSION@
PYGOBJECT_MINOR_VERSION = @PYGOBJECT_MINOR_VERSION@
PYTHON = @PYTHON@
-PYTHON_BASENAME = @PYTHON_BASENAME@
PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
PYTHON_INCLUDES = @PYTHON_INCLUDES@
PYTHON_LIBS = @PYTHON_LIBS@
@@ -262,15 +276,17 @@ PYTHON_LIB_LOC = @PYTHON_LIB_LOC@
PYTHON_PLATFORM = @PYTHON_PLATFORM@
PYTHON_PREFIX = @PYTHON_PREFIX@
PYTHON_SO = @PYTHON_SO@
+PYTHON_VALGRIND_SUPP = @PYTHON_VALGRIND_SUPP@
PYTHON_VERSION = @PYTHON_VERSION@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
-THREADING_CFLAGS = @THREADING_CFLAGS@
VERSION = @VERSION@
WARN_CFLAGS = @WARN_CFLAGS@
+WARN_LDFLAGS = @WARN_LDFLAGS@
+WARN_SCANNERFLAGS = @WARN_SCANNERFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
diff --git a/gi/overrides/__init__.py b/gi/overrides/__init__.py
index 942e6ed..e262b6c 100644
--- a/gi/overrides/__init__.py
+++ b/gi/overrides/__init__.py
@@ -165,20 +165,6 @@ def load_overrides(introspection_module):
return proxy
-class overridefunc(object):
- """decorator for overriding a function"""
- def __init__(self, func):
- if not isinstance(func, CallableInfo):
- raise TypeError("func must be a gi function, got %s" % func)
-
- module_name = func.__module__.rsplit('.', 1)[-1]
- self.module = sys.modules["gi.repository." + module_name]
-
- def __call__(self, func):
- setattr(self.module, func.__name__, func)
- return func
-
-
def override(type_):
"""Decorator for registering an override.
@@ -187,8 +173,18 @@ def override(type_):
for example), so they have to be added to the module immediately.
"""
- if isinstance(type_, (types.FunctionType, CallableInfo)):
- return overridefunc(type_)
+ if isinstance(type_, CallableInfo):
+ func = type_
+ namespace = func.__module__.rsplit('.', 1)[-1]
+ module = sys.modules["gi.repository." + namespace]
+
+ def wrapper(func):
+ setattr(module, func.__name__, func)
+ return func
+
+ return wrapper
+ elif isinstance(type_, types.FunctionType):
+ raise TypeError("func must be a gi function, got %s" % type_)
else:
try:
info = getattr(type_, '__info__')
@@ -214,6 +210,10 @@ def override(type_):
return type_
+overridefunc = override
+"""Deprecated"""
+
+
def deprecated(fn, replacement):
"""Decorator for marking methods and classes as deprecated"""
@wraps(fn)