pygobject r1053 - in trunk: . gio tests
- From: gianmt svn gnome org
- To: svn-commits-list gnome org
- Subject: pygobject r1053 - in trunk: . gio tests
- Date: Sat, 4 Apr 2009 16:13:17 +0000 (UTC)
Author: gianmt
Date: Sat Apr 4 16:13:17 2009
New Revision: 1053
URL: http://svn.gnome.org/viewvc/pygobject?rev=1053&view=rev
Log:
2009-04-04 Gian Mario Tagliaretti <gianmt gnome org>
* gio/gfile.override:
(_wrap_g_file_set_attributes_async)
(_wrap_g_file_set_attributes_finish) Wrap new GFile methods.
* tests/test_gio.py: Test the above methods.
Modified:
trunk/ChangeLog
trunk/gio/gfile.override
trunk/tests/test_gio.py
Modified: trunk/gio/gfile.override
==============================================================================
--- trunk/gio/gfile.override (original)
+++ trunk/gio/gfile.override Sat Apr 4 16:13:17 2009
@@ -1422,10 +1422,99 @@
pygio_notify_free(notify);
return NULL;
}
+%%
+override g_file_set_attributes_async kwargs
+static PyObject *
+_wrap_g_file_set_attributes_async(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "info", "callback", "flags",
+ "io_priority", "cancellable", "user_data", NULL };
+ PyGObject *info;
+ PyGIONotify *notify;
+ GFileQueryInfoFlags flags = G_FILE_QUERY_INFO_NONE;
+ int io_priority = G_PRIORITY_DEFAULT;
+ GCancellable *cancellable = NULL;
+ PyGObject *py_cancellable = NULL;
+
+ notify = pygio_notify_new();
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!O|OiOO:GFile.set_attributes_async",
+ kwlist,
+ &PyGFileInfo_Type,
+ &info,
+ ¬ify->callback,
+ &flags,
+ &io_priority,
+ &py_cancellable,
+ ¬ify->data))
+ goto error;
+
+ if (!pygio_notify_callback_is_valid(notify))
+ goto error;
+
+
+ if (!pygio_check_cancellable(py_cancellable, &cancellable))
+ goto error;
+
+ pygio_notify_reference_callback(notify);
+
+ g_file_set_attributes_async(G_FILE(self->obj),
+ G_FILE_INFO(info->obj),
+ flags,
+ io_priority,
+ (GCancellable *) cancellable,
+ (GAsyncReadyCallback)async_result_callback_marshal,
+ notify);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+
+ error:
+ pygio_notify_free(notify);
+ return NULL;
+}
+
+%%
+override g_file_set_attributes_finish kwargs
+static PyObject *
+_wrap_g_file_set_attributes_finish(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "result", NULL };
+ PyGObject *res;
+ GFileInfo *info = NULL;
+ GError *error = NULL;
+ gboolean ret;
+ PyObject *py_ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:File.set_attributes_finish",
+ kwlist,
+ &PyGAsyncResult_Type,
+ &res))
+ return NULL;
+
+ ret = g_file_set_attributes_finish(G_FILE(self->obj),
+ G_ASYNC_RESULT(res->obj), &info,
+ &error);
+
+ if (pyg_error_check(&error))
+ return NULL;
+
+ if (ret) {
+ py_ret = pygobject_new((GObject *)info);
+ } else {
+ py_ret = Py_None;
+ Py_INCREF(py_ret);
+ }
+
+ return py_ret;
+}
-/* GFile.set_attributes_async */
/* GFile.set_display_name_async */
/* GFile.load_partial_contents_async: No ArgType for GFileReadMoreCallback */
-/* GFile.move: No ArgType for GFileProgressCallback */
-/* GFile.set_attributes_finish: No ArgType for GFileInfo** */
/* GFile.load_partial_contents_finish: No ArgType for char** */
Modified: trunk/tests/test_gio.py
==============================================================================
--- trunk/tests/test_gio.py (original)
+++ trunk/tests/test_gio.py Sat Apr 4 16:13:17 2009
@@ -404,6 +404,24 @@
10, gio.FILE_QUERY_INFO_NONE)
self.assertEqual(ret, True)
+ def testSetAttributesAsync(self):
+ def callback(gfile, result):
+ try:
+ info = gfile.set_attributes_finish(result)
+ usec = info.get_attribute_uint32("time::modified-usec")
+ self.assertEqual(usec, 10)
+ finally:
+ loop.quit()
+
+ info = gio.FileInfo()
+ info.set_attribute_uint32("time::modified-usec", 10)
+
+ canc = gio.Cancellable()
+ self.file.set_attributes_async(info, callback)
+
+ loop = glib.MainLoop()
+ loop.run()
+
def testReplaceContents(self):
self.file.replace_contents("testing replace_contents")
cont, leng, etag = self.file.load_contents()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]