summaryrefslogtreecommitdiff
path: root/gi/overrides
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:46:37 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:46:40 +0900
commitd71148e4448b78edde9dd063d65c00a13ed27cef (patch)
treeeeadb214137573fd724c40b8698eabe38f34c18a /gi/overrides
parentdca4e6423c560689ee831785473ad3ab48e7548a (diff)
downloadpygobject2-d71148e4448b78edde9dd063d65c00a13ed27cef.tar.gz
pygobject2-d71148e4448b78edde9dd063d65c00a13ed27cef.tar.bz2
pygobject2-d71148e4448b78edde9dd063d65c00a13ed27cef.zip
Imported Upstream version 3.3.2
Change-Id: I655e3eb809d4970acd866fd9eebd35be45b6f79c Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi/overrides')
-rw-r--r--gi/overrides/GLib.py3
-rw-r--r--gi/overrides/Gdk.py44
-rw-r--r--gi/overrides/Gtk.py25
-rw-r--r--gi/overrides/Makefile.in31
4 files changed, 97 insertions, 6 deletions
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index 41904c8..dcb2728 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -171,6 +171,9 @@ class Variant(GLib.Variant):
raise TypeError('invalid remaining format string: "%s"' % rest_format)
return v
+ def __del__(self):
+ self.unref()
+
def __repr__(self):
return '<GLib.Variant(%s)>' % getattr(self, 'print')(True)
diff --git a/gi/overrides/Gdk.py b/gi/overrides/Gdk.py
index 604ac37..66d47ef 100644
--- a/gi/overrides/Gdk.py
+++ b/gi/overrides/Gdk.py
@@ -30,6 +30,7 @@ __all__ = []
class Color(Gdk.Color):
+ MAX_VALUE = 65535
def __init__(self, red, green, blue):
Gdk.Color.__init__(self)
@@ -46,6 +47,28 @@ class Color(Gdk.Color):
def __repr__(self):
return '<Gdk.Color(red=%d, green=%d, blue=%d)>' % (self.red, self.green, self.blue)
+ red_float = property(fget=lambda self: self.red / float(self.MAX_VALUE),
+ fset=lambda self, v: setattr(self, 'red', int(v * self.MAX_VALUE)))
+
+ green_float = property(fget=lambda self: self.green / float(self.MAX_VALUE),
+ fset=lambda self, v: setattr(self, 'green', int(v * self.MAX_VALUE)))
+
+ blue_float = property(fget=lambda self: self.blue / float(self.MAX_VALUE),
+ fset=lambda self, v: setattr(self, 'blue', int(v * self.MAX_VALUE)))
+
+ def to_floats(self):
+ """Return (red_float, green_float, blue_float) triple."""
+
+ return (self.red_float, self.green_float, self.blue_float)
+
+ @staticmethod
+ def from_floats(red, green, blue):
+ """Return a new Color object from red/green/blue values from 0.0 to 1.0."""
+
+ return Color(int(red * Color.MAX_VALUE),
+ int(green * Color.MAX_VALUE),
+ int(blue * Color.MAX_VALUE))
+
Color = override(Color)
__all__.append('Color')
@@ -67,6 +90,27 @@ if Gdk._version == '3.0':
def __repr__(self):
return '<Gdk.Color(red=%f, green=%f, blue=%f, alpha=%f)>' % (self.red, self.green, self.blue, self.alpha)
+ def __iter__(self):
+ """Iterator which allows easy conversion to tuple and list types."""
+
+ yield self.red
+ yield self.green
+ yield self.blue
+ yield self.alpha
+
+ def to_color(self):
+ """Converts this RGBA into a Color instance which excludes alpha."""
+
+ return Color(int(self.red * Color.MAX_VALUE),
+ int(self.green * Color.MAX_VALUE),
+ int(self.blue * Color.MAX_VALUE))
+
+ @classmethod
+ def from_color(cls, color):
+ """Returns a new RGBA instance given a Color instance."""
+
+ return cls(color.red_float, color.green_float, color.blue_float)
+
RGBA = override(RGBA)
__all__.append('RGBA')
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 5ae61b2..1043cbf 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -750,9 +750,9 @@ class TreeModel(Gtk.TreeModel):
# alias for Python 2.x object protocol
__nonzero__ = __bool__
- def __getitem__(self, key):
+ def _getiter(self, key):
if isinstance(key, Gtk.TreeIter):
- return TreeModelRow(self, key)
+ return key
elif isinstance(key, int) and key < 0:
index = len(self) + key
if index < 0:
@@ -761,18 +761,26 @@ class TreeModel(Gtk.TreeModel):
aiter = self.get_iter(index)
except ValueError:
raise IndexError("could not find tree path '%s'" % key)
- return TreeModelRow(self, aiter)
+ return aiter
else:
try:
aiter = self.get_iter(key)
except ValueError:
raise IndexError("could not find tree path '%s'" % key)
- return TreeModelRow(self, aiter)
+ return aiter
+
+ def __getitem__(self, key):
+ aiter = self._getiter(key)
+ return TreeModelRow(self, aiter)
def __setitem__(self, key, value):
row = self[key]
self.set_row(row.iter, value)
+ def __delitem__(self, key):
+ aiter = self._getiter(key)
+ self.remove(aiter)
+
def __iter__(self):
return TreeModelRowIter(self, self.get_iter_first())
@@ -1080,6 +1088,10 @@ class TreeModelRow(object):
return self.get_next()
@property
+ def previous(self):
+ return self.get_previous()
+
+ @property
def parent(self):
return self.get_parent()
@@ -1088,6 +1100,11 @@ class TreeModelRow(object):
if next_iter:
return TreeModelRow(self.model, next_iter)
+ def get_previous(self):
+ prev_iter = self.model.iter_previous(self.iter)
+ if prev_iter:
+ return TreeModelRow(self.model, prev_iter)
+
def get_parent(self):
parent_iter = self.model.iter_parent(self.iter)
if parent_iter:
diff --git a/gi/overrides/Makefile.in b/gi/overrides/Makefile.in
index d5409a3..85abd08 100644
--- a/gi/overrides/Makefile.in
+++ b/gi/overrides/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.3 from Makefile.am.
+# Makefile.in generated by automake 1.11.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -15,6 +15,23 @@
@SET_MAKE@
VPATH = @srcdir@
+am__make_dryrun = \
+ { \
+ am__dry=no; \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
+ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+ *) \
+ for am__flg in $$MAKEFLAGS; do \
+ case $$am__flg in \
+ *=*|--*) ;; \
+ *n*) am__dry=yes; break;; \
+ esac; \
+ done;; \
+ esac; \
+ test $$am__dry = yes; \
+ }
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -56,6 +73,11 @@ am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
SOURCES =
DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -97,6 +119,8 @@ AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
@@ -296,8 +320,11 @@ clean-libtool:
-rm -rf .libs _libs
install-pygioverridesPYTHON: $(pygioverrides_PYTHON)
@$(NORMAL_INSTALL)
- test -z "$(pygioverridesdir)" || $(MKDIR_P) "$(DESTDIR)$(pygioverridesdir)"
@list='$(pygioverrides_PYTHON)'; dlist=; list2=; test -n "$(pygioverridesdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pygioverridesdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pygioverridesdir)" || exit 1; \
+ fi; \
for p in $$list; do \
if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
if test -f $$b$$p; then \