[nautilus-python/nautilus-3.0] Import the Nautilus.OperationHandle type and convert the handle pointer to that type before passing
- From: Adam Plumb <adamplumb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-python/nautilus-3.0] Import the Nautilus.OperationHandle type and convert the handle pointer to that type before passing
- Date: Mon, 14 Mar 2011 17:44:03 +0000 (UTC)
commit 2807405174056f9263e1ddd140284f613c483971
Author: Adam Plumb <adamplumb gmail com>
Date: Mon Mar 14 13:16:50 2011 -0400
Import the Nautilus.OperationHandle type and convert the handle pointer to that type before passing it to python extensions
src/nautilus-python-object.c | 19 ++++++++++++++++---
src/nautilus-python.c | 1 +
src/nautilus-python.h | 3 +++
3 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-python-object.c b/src/nautilus-python-object.c
index 168e301..83c9823 100644
--- a/src/nautilus-python-object.c
+++ b/src/nautilus-python-object.c
@@ -128,6 +128,17 @@ free_pygobject_data_list(GList *list)
g_list_foreach(list, (GFunc)free_pygobject_data, NULL);
}
+static PyObject *
+nautilus_python_boxed_new (PyTypeObject *type, gpointer boxed, gboolean free_on_dealloc)
+{
+ PyGBoxed *self = (PyGBoxed *) type->tp_alloc (type, 0);
+ self->gtype = pyg_type_from_object ( (PyObject *) type);
+ self->boxed = boxed;
+ self->free_on_dealloc = free_on_dealloc;
+
+ return (PyObject *) self;
+}
+
#define METHOD_NAME "get_property_pages"
static GList *
nautilus_python_object_get_property_pages (NautilusPropertyPageProvider *provider,
@@ -358,6 +369,7 @@ nautilus_python_object_cancel_update (NautilusInfoProvider *provider,
{
NautilusPythonObject *object = (NautilusPythonObject*)provider;
PyGILState_STATE state = pyg_gil_state_ensure();
+ PyObject *py_handle = nautilus_python_boxed_new (_PyNautilusOperationHandle_Type, handle, FALSE);
debug_enter();
@@ -367,7 +379,7 @@ nautilus_python_object_cancel_update (NautilusInfoProvider *provider,
PyObject_CallMethod(object->instance,
METHOD_PREFIX METHOD_NAME, "(NN)",
pygobject_new((GObject*)provider),
- pyg_pointer_new(G_TYPE_POINTER, handle));
+ py_handle);
beach:
pyg_gil_state_release(state);
@@ -384,7 +396,8 @@ nautilus_python_object_update_file_info (NautilusInfoProvider *provider,
NautilusPythonObject *object = (NautilusPythonObject*)provider;
NautilusOperationResult ret = NAUTILUS_OPERATION_COMPLETE;
PyObject *py_ret = NULL;
- PyGILState_STATE state = pyg_gil_state_ensure(); \
+ PyGILState_STATE state = pyg_gil_state_ensure();
+ PyObject *py_handle = nautilus_python_boxed_new (_PyNautilusOperationHandle_Type, *handle, FALSE);
debug_enter();
@@ -395,7 +408,7 @@ nautilus_python_object_update_file_info (NautilusInfoProvider *provider,
py_ret = PyObject_CallMethod(object->instance,
METHOD_PREFIX "update_file_info_full", "(NNNN)",
pygobject_new((GObject*)provider),
- pyg_pointer_new(G_TYPE_POINTER, *handle),
+ py_handle,
pyg_boxed_new(G_TYPE_CLOSURE, update_complete, TRUE, TRUE),
pygobject_new((GObject*)file));
}
diff --git a/src/nautilus-python.c b/src/nautilus-python.c
index 0908477..3307690 100644
--- a/src/nautilus-python.c
+++ b/src/nautilus-python.c
@@ -265,6 +265,7 @@ nautilus_python_init_python (void)
IMPORT(MenuProvider, "MenuProvider");
IMPORT(PropertyPage, "PropertyPage");
IMPORT(PropertyPageProvider, "PropertyPageProvider");
+ IMPORT(OperationHandle, "OperationHandle");
#undef IMPORT
diff --git a/src/nautilus-python.h b/src/nautilus-python.h
index 4745d22..f15244f 100644
--- a/src/nautilus-python.h
+++ b/src/nautilus-python.h
@@ -75,4 +75,7 @@ PyTypeObject *_PyNautilusPropertyPage_Type;
PyTypeObject *_PyNautilusPropertyPageProvider_Type;
#define PyNautilusPropertyPageProvider_Type (*_PyNautilusPropertyPageProvider_Type)
+PyTypeObject *_PyNautilusOperationHandle_Type;
+#define PyNautilusOperationHandle_Type (*_PyNautilusOperationHandle_Type)
+
#endif /* NAUTILUS_PYTHON_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]