[nautilus-python] Broke off the handle dict entry into its own parameter, updated documentation



commit 465e7732670143c0a3f7bec51c2c51a7fd754897
Author: Adam Plumb <adamplumb gmail com>
Date:   Tue Apr 27 16:53:51 2010 -0400

    Broke off the handle dict entry into its own parameter, updated documentation

 examples/documentation.py    |   21 ++++++++++++++-------
 src/nautilus-python-object.c |    4 ++--
 src/nautilus.override        |   10 ++--------
 3 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/examples/documentation.py b/examples/documentation.py
index bad17cd..c7e70da 100644
--- a/examples/documentation.py
+++ b/examples/documentation.py
@@ -57,11 +57,14 @@ class InfoProvider:
         and use together with the other extensions.
         """
 
-    def update_file_info_async(self, file, info):
+    def update_file_info_async(self, file, handle, info):
         """
         @param file   selected file
         @type  file   list of nautilus.FileInfo
 
+        @param  handle  unique handle for identifying this update_file_info call
+        @type   handle  gpointer
+
         @param info   data that needs to be passed back in a 
                         self.update_complete_invoke(info) call
                         {"handle":<gpointer>, "provider":<gobject>, "closure":<gclosure>}
@@ -76,8 +79,8 @@ class InfoProvider:
         
         In order to use this method asynchronously, you must return the 
         nautilus.OPERATION_IN_PROGRESS enum.  Then, when the operation has
-        completed, call the self.update_complete_invoke method, passing the info variable
-        as a parameter.
+        completed, call the self.update_complete_invoke method, passing the handle and info variables
+        as parameters.
         
         Note: This method exists for backwards compatibility reasons.  If your
         extension used the update_file_info method and you want non-blocking 
@@ -93,17 +96,21 @@ class InfoProvider:
         This method is called by nautilus when an update_file_info call is being
         canceled.  This may happen because the user is moving directories or a file
         has been deleted, etc.  You may use the handle parameter here to match the
-        info["handle"] value passed in update_file_info.
+        handle parameter passed in update_file_info_async.
         """
 
-    def update_complete_invoke(self, info):
+    def update_complete_invoke(self, handle, info):
         """
-        @param  info    unique data for each update_file_info call
+        @param  handle  unique handle for determining which file update call
+                        has been canceled
+        @type   handle  gpointer
+
+        @param  info    data for each update_file_info call
         @type   info    dict
         
         The extension must call this method for each update_file_info method that
         returns the OPERATION_IN_PROGRESS enum.  The method must be called with 
-        the info parameter as passed to the update_file_info method.
+        the handle and info parameters passed to the update_file_info_async method.
         """
 
 class Menu:
diff --git a/src/nautilus-python-object.c b/src/nautilus-python-object.c
index 1bb4e67..69f9b1f 100644
--- a/src/nautilus-python-object.c
+++ b/src/nautilus-python-object.c
@@ -396,11 +396,11 @@ nautilus_python_object_update_file_info (NautilusInfoProvider 		*provider,
 		info = PyDict_New();
 		PyDict_SetItem(info, Py_BuildValue("s", "provider"), pygobject_new((GObject*)provider));
 		PyDict_SetItem(info, Py_BuildValue("s", "closure"), pyg_boxed_new(G_TYPE_CLOSURE, update_complete, TRUE, TRUE));
-		PyDict_SetItem(info, Py_BuildValue("s", "handle"), pyg_pointer_new(G_TYPE_POINTER, *handle));
 
 		py_ret = PyObject_CallMethod(object->instance,
-									 METHOD_PREFIX "update_file_info_async", "(NN)",
+									 METHOD_PREFIX "update_file_info_async", "(NNN)",
 									 pygobject_new((GObject*)file),
+									 pyg_pointer_new(G_TYPE_POINTER, *handle),
 									 info);
 	}
 	else if (PyObject_HasAttrString(object->instance, METHOD_NAME))
diff --git a/src/nautilus.override b/src/nautilus.override
index 07be626..de97286 100644
--- a/src/nautilus.override
+++ b/src/nautilus.override
@@ -99,15 +99,14 @@ _wrap_nautilus_info_provider_update_complete_invoke(PyGObject *self, PyObject *a
     NautilusOperationHandle *handle;
     NautilusOperationResult result = NAUTILUS_OPERATION_COMPLETE;
 
-    if (!PyArg_ParseTuple(args, "O!:NautilusInfoProvider.update_complete_invoke", 
-            &PyDict_Type, &info))
+    if (!PyArg_ParseTuple(args, "OO!:NautilusInfoProvider.update_complete_invoke", 
+            &py_handle, &PyDict_Type, &info))
     {
         return NULL;
     }
 
     py_provider = (PyGObject *)PyDict_GetItem(info, Py_BuildValue("s", "provider"));
     py_closure = PyDict_GetItem(info, Py_BuildValue("s", "closure"));
-    py_handle = PyDict_GetItem(info, Py_BuildValue("s", "handle"));
 
     closure = pyg_boxed_get(py_closure, GClosure);
     handle = pyg_pointer_get(py_handle, NautilusOperationHandle);
@@ -115,11 +114,6 @@ _wrap_nautilus_info_provider_update_complete_invoke(PyGObject *self, PyObject *a
     nautilus_info_provider_update_complete_invoke(closure, 
         NAUTILUS_INFO_PROVIDER(py_provider->obj), handle, result);
 
-    Py_DECREF(py_provider);
-    Py_DECREF(py_closure);
-    Py_DECREF(py_handle);
-    Py_DECREF(info);
-
     Py_INCREF(Py_None);
     return Py_None;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]