summaryrefslogtreecommitdiff
path: root/gtk/gtkobject-support.c
diff options
context:
space:
mode:
authorMatt Wilson <msw@redhat.com>2001-11-15 07:33:23 +0000
committerMatt Wilson <msw@src.gnome.org>2001-11-15 07:33:23 +0000
commit67716f5f79a376ab5f80d50ab497c250c2fa7ed0 (patch)
treede76cb3986b7a9a227d8985a6985f208401ed2cf /gtk/gtkobject-support.c
parent9128a8867fc02bdef53a81d11c7d0f89efe8fb3b (diff)
downloadpygtk-67716f5f79a376ab5f80d50ab497c250c2fa7ed0.tar.gz
added PyGFatalExceptionFunc typedef, API wrapper for
2001-11-15 Matt Wilson <msw@redhat.com> * pygobject.h: added PyGFatalExceptionFunc typedef, API wrapper for pyg_fatal_exceptions_{add,remove}. * gobjectmodule.c (pyg_boxed_new): return NULL on assertion failures, #62814 (pyg_closure_new): actually assign swap_data to the closure. (pyg_fatal_exceptions_notify, pyg_fatal_exceptions_notify_add, pyg_fatal_exceptions_remove): added mechanism for gobjectmodule using modules to get a function called when a fatal exception happens in closures, etc. (pyg_closure_marshal, pyg_signal_class_closure_marshal): return NULL if a gobjectmodule using module registered a fatal exception function. * gtk/pygtk-private.h: added declarations for pygtk_custom_destroy_notify, pygtk_tree_selection_marshal, pygtk_tree_foreach_marshal. Added typedef for PyGtkCustomNotify. #62814 * gtk/gtkmodule.c (init_gtk): register stock items, #62814. Set up fatal exception stuff if PYGTK_FATAL_EXCEPTIONS is set. This isn't 100% done yet, gtk mainloop specific functions still need work. * gtk/gtkobject-support.c (pygtk_tree_selection_marshal): added, #62814 (pygtk_tree_foreach_marshal): added, #62814 (pygtk_custom_destroy_notify): added, #62814 * gtk/gtk.override (_wrap_gtk_tree_selection_set_select_function): added, #62814 (_wrap_gtk_tree_selection_selected_foreach): added, #62814
Diffstat (limited to 'gtk/gtkobject-support.c')
-rw-r--r--gtk/gtkobject-support.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/gtk/gtkobject-support.c b/gtk/gtkobject-support.c
index 9666d187..9c91d83c 100644
--- a/gtk/gtkobject-support.c
+++ b/gtk/gtkobject-support.c
@@ -79,6 +79,17 @@ pygtk_destroy_notify(gpointer user_data)
PyGTK_UNBLOCK_THREADS
}
+void
+pygtk_custom_destroy_notify(gpointer user_data)
+{
+ PyGtkCustomNotify *cunote = user_data;
+
+ PyGTK_BLOCK_THREADS
+ Py_XDECREF(cunote->func);
+ Py_XDECREF(cunote->data);
+ PyGTK_UNBLOCK_THREADS
+ g_free(cunote);
+}
/* used for timeout and idle functions */
void
@@ -135,5 +146,67 @@ pygtk_input_marshal(gpointer a, PyObject *func, int nargs, GtkArg *args)
PyGTK_UNBLOCK_THREADS
}
+void
+pygtk_tree_foreach_marshal(GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ PyGtkCustomNotify *cunote = data;
+ PyObject *pypath, *retobj;
+
+ g_assert(cunote->func);
+
+ PyGTK_BLOCK_THREADS
+
+ pypath = pygtk_tree_path_to_pyobject(path);
+ if (cunote->data)
+ retobj = PyEval_CallFunction(cunote->func, "(OO)", pypath,
+ cunote->data);
+ else
+ retobj = PyEval_CallFunction(cunote->func, "(O)", pypath);
+ Py_DECREF(pypath);
+ Py_XDECREF(retobj);
+
+ PyGTK_UNBLOCK_THREADS
+}
+gboolean
+pygtk_tree_selection_marshal(GtkTreeSelection *selection,
+ GtkTreeModel *model,
+ GtkTreePath *path,
+ gboolean path_currently_selected,
+ gpointer data)
+{
+ gboolean retval = FALSE;
+ PyGtkCustomNotify *cunote = data;
+ PyObject *pypath, *retobj;
+
+ g_assert(cunote->func);
+
+ PyGTK_BLOCK_THREADS
+
+ pypath = pygtk_tree_path_to_pyobject(path);
+ if (cunote->data)
+ retobj = PyEval_CallFunction(cunote->func, "(OO)", pypath,
+ cunote->data);
+ else
+ retobj = PyEval_CallFunction(cunote->func, "(O)", pypath);
+ Py_DECREF(pypath);
+ if (retobj) {
+ if(retobj == Py_None);
+ else if(PyInt_Check(retobj))
+ retval = PyInt_AsLong(retobj) && TRUE;
+ else if(PyLong_Check(retobj))
+ retval = PyLong_AsLongLong(retobj) && TRUE;
+ else if(PyString_Check(retobj))
+ retval = PyString_GET_SIZE(retobj) && TRUE;
+
+ Py_DECREF(retobj);
+ }
+
+ PyGTK_UNBLOCK_THREADS
+
+ return retval;
+}