summaryrefslogtreecommitdiff
path: root/gtk/gtk-types.c
diff options
context:
space:
mode:
authorJames Henstridge <james@daa.com.au>2002-07-07 12:45:45 +0000
committerJames Henstridge <jamesh@src.gnome.org>2002-07-07 12:45:45 +0000
commit49c06de6579d07d8bcae99d3507970e58ad85b5c (patch)
treeecfd5632840dd54d6b9d3654a840ecf55c4c3211 /gtk/gtk-types.c
parent160d5162ae53ba04e403814e7bede78a26c47e0b (diff)
downloadpygtk-49c06de6579d07d8bcae99d3507970e58ad85b5c.tar.gz
update to use this function. (ArgMatcher.register_boxed): short circuit if
2002-07-07 James Henstridge <james@daa.com.au> * codegen/argtypes.py (GtkTreePathArg.write_return): update to use this function. (ArgMatcher.register_boxed): short circuit if there is already a handler for the boxed type (helps with setting custom handlers for boxed types). * gtk/gtk-types.c (pygdk_rectangle_from_pyobject): new function to parse a GdkRectangle from a PyObject. * gtk/pygtktreemodel.c (pygtk_generic_tree_model_get_path): print a warning if the return value could not be converted to a GtkTreePath. * gtk/gtk.override (_wrap_gtk_tree_model_get_value): don't assume tree paths are tuples. * codegen/argtypes.py (GtkTreePathArg.write_param): fix up code generator to get rid of assumption that tree paths are tuples, and catch case where pygtk_tree_path_from_pyobject() returns NULL. * gtk/gtk-types.c (pygtk_tree_path_from_pyobject): change so that we treat an integer PyObject as a tree path with a single index. * pygtype.c (pyg_closure_marshal): apply patch from Arjan Molenaar <arjanmolenaar@hetnet.nl> that fixes a reference leak for the argument tuple passed to the callback. (pyg_signal_class_closure_marshal): apply similar fix here.
Diffstat (limited to 'gtk/gtk-types.c')
-rw-r--r--gtk/gtk-types.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/gtk/gtk-types.c b/gtk/gtk-types.c
index 2b1ff0ba..01d86cf1 100644
--- a/gtk/gtk-types.c
+++ b/gtk/gtk-types.c
@@ -774,7 +774,13 @@ pygtk_tree_path_to_pyobject(GtkTreePath *path)
GtkTreePath *
pygtk_tree_path_from_pyobject(PyObject *object)
{
- if (PyTuple_Check(object)) {
+ if (PyInt_Check(object)) {
+ GtkTreePath *path;
+
+ path = gtk_tree_path_new();
+ gtk_tree_path_append_index(path, PyInt_AsLong(object));
+ return path;
+ } else if (PyTuple_Check(object)) {
GtkTreePath *path;
guint len, i;
@@ -819,6 +825,24 @@ PyGtkTreePath_to_value(GValue *value, PyObject *object)
return -1;
}
+gboolean
+pygdk_rectangle_from_pyobject(PyObject *object, GdkRectangle *rectangle)
+{
+ g_return_val_if_fail(rectangle != NULL, FALSE);
+
+ if (pyg_boxed_check(object, GDK_TYPE_RECTANGLE)) {
+ *rectangle = *pyg_boxed_get(object, GdkRectangle);
+ return TRUE;
+ }
+ if (PyArg_ParseTuple(object, "iiii", &rectangle->x, &rectangle->y,
+ &rectangle->width, &rectangle->height)) {
+ return TRUE;
+ }
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError, "could not convert to GdkRectangle");
+ return FALSE;
+}
+
/* We have to set ob_type here because stupid win32 does not allow you
* to use variables from another dll in a global variable initialisation.
*/