[pygobject/invoke-rewrite] [gtk-overrides] special case TreeModel columns of PYGOBJECT types
- From: John Palmieri <johnp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/invoke-rewrite] [gtk-overrides] special case TreeModel columns of PYGOBJECT types
- Date: Tue, 28 Jun 2011 22:15:28 +0000 (UTC)
commit b6842e4b2a28733e143d4022864041ca82e91f7a
Author: John (J5) Palmieri <johnp redhat com>
Date: Tue Jun 28 18:13:38 2011 -0400
[gtk-overrides] special case TreeModel columns of PYGOBJECT types
* box the PYGOBJECT in a GValue so we can store PyGObjects in a TreeModel row
gi/overrides/Gtk.py | 7 ++++---
gobject/pygtype.c | 7 ++++---
2 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 544106e..9459a33 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -749,9 +749,7 @@ class TreeModel(Gtk.TreeModel):
# we may need to convert to a basic type
type_ = self.get_column_type(column)
- if type_ == GObject.TYPE_PYOBJECT:
- pass # short-circut branching
- elif type_ == GObject.TYPE_STRING:
+ if type_ == GObject.TYPE_STRING:
if isinstance(value, str):
value = str(value)
elif sys.version_info < (3, 0):
@@ -819,6 +817,9 @@ class TreeModel(Gtk.TreeModel):
elif type_ == GObject.TYPE_UINT64:
value_container.set_uint64(value)
value = value_container
+ elif type_ == GObject.TYPE_PYOBJECT:
+ value_container.set_boxed(value)
+ value = value_container
return value
diff --git a/gobject/pygtype.c b/gobject/pygtype.c
index 63ac1c6..ffd99a5 100644
--- a/gobject/pygtype.c
+++ b/gobject/pygtype.c
@@ -743,11 +743,12 @@ int
pyg_value_from_pyobject(GValue *value, PyObject *obj)
{
PyObject *tmp;
+ GType value_type = G_VALUE_TYPE(value);
- switch (G_TYPE_FUNDAMENTAL(G_VALUE_TYPE(value))) {
+ switch (G_TYPE_FUNDAMENTAL(value_type)) {
case G_TYPE_INTERFACE:
/* we only handle interface types that have a GObject prereq */
- if (g_type_is_a(G_VALUE_TYPE(value), G_TYPE_OBJECT)) {
+ if (g_type_is_a(value_type, G_TYPE_OBJECT)) {
if (obj == Py_None)
g_value_set_object(value, NULL);
else {
@@ -755,7 +756,7 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj)
return -1;
}
if (!G_TYPE_CHECK_INSTANCE_TYPE(pygobject_get(obj),
- G_VALUE_TYPE(value))) {
+ value_type)) {
return -1;
}
g_value_set_object(value, pygobject_get(obj));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]