diff options
author | Gian Mario Tagliaretti <gianmt@src.gnome.org> | 2008-08-01 22:42:37 +0000 |
---|---|---|
committer | Gian Mario Tagliaretti <gianmt@src.gnome.org> | 2008-08-01 22:42:37 +0000 |
commit | 9e22741a4683e4184ffcdaf7382b0ba045f4a3be (patch) | |
tree | c00e01731781b6b3813d320b1dc89efaf84e6351 | |
parent | bd788d5972dc5d1896820740061bbc9250d80682 (diff) | |
download | pygobject-9e22741a4683e4184ffcdaf7382b0ba045f4a3be.tar.gz pygobject-9e22741a4683e4184ffcdaf7382b0ba045f4a3be.tar.xz pygobject-9e22741a4683e4184ffcdaf7382b0ba045f4a3be.zip |
Wrap GFile.query_writable_namespaces with docs and test
svn path=/trunk/; revision=909
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | gio/gfile.override | 46 | ||||
-rw-r--r-- | gio/gio.defs | 10 | ||||
-rw-r--r-- | tests/test_gio.py | 6 |
4 files changed, 70 insertions, 1 deletions
@@ -1,3 +1,12 @@ +2008-08-02 Gian Mario Tagliaretti <gianmt@gnome.org> + + Bug 545920 – Wrap GFile.query_writable_namespaces + + * tests/test_gio.py: + * gio/gfile.override: + * gio/gio.defs: + Wrap GFile.query_writable_namespaces with docs and test + 2008-08-02 Johan Dahlin <johan@gnome.org> * gio/gio.defs: diff --git a/gio/gfile.override b/gio/gfile.override index f95197e..d9c6d54 100644 --- a/gio/gfile.override +++ b/gio/gfile.override @@ -737,7 +737,52 @@ _wrap_g_file_query_settable_attributes(PyGObject *self, return Py_None; } } +%% +override g_file_query_writable_namespaces kwargs +static PyObject * +_wrap_g_file_query_writable_namespaces(PyGObject *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "cancellable", NULL }; + PyGObject *pycancellable = NULL; + GCancellable *cancellable = NULL; + GFileAttributeInfoList *ret; + GError *error = NULL; + gint i, n_infos; + GFileAttributeInfo *infos; + PyObject *py_ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|O:GFile.query_writable_namespaces", + kwlist, &pycancellable)) + return NULL; + if (!pygio_check_cancellable(pycancellable, &cancellable)) + return NULL; + + ret = g_file_query_writable_namespaces(G_FILE(self->obj), + (GCancellable *) cancellable, + &error); + if (pyg_error_check(&error)) + return NULL; + + n_infos = ret->n_infos; + infos = ret->infos; + + if (n_infos > 0) { + py_ret = PyList_New(n_infos); + for (i = 0; i < n_infos; i++) { + PyList_SetItem(py_ret, i, pyg_file_attribute_info_new(&infos[i])); + } + g_file_attribute_info_list_unref(ret); + return py_ret; + + } else { + Py_INCREF(Py_None); + return Py_None; + } +} /* GFile.append_to_async */ /* GFile.create_async */ /* GFile.eject_mountable */ @@ -749,7 +794,6 @@ _wrap_g_file_query_settable_attributes(PyGObject *self, /* GFile.set_display_name_async */ /* GFile.load_partial_contents_async: No ArgType for GFileReadMoreCallback */ /* GFile.move: No ArgType for GFileProgressCallback */ -/* GFile.query_writable_namespaces: No ArgType for GFileAttributeInfoList* */ /* GFile.set_attributes_finish: No ArgType for GFileInfo** */ /* GFile.load_partial_contents_finish: No ArgType for char** */ /* GFile.replace_contents: No ArgType for char** */ diff --git a/gio/gio.defs b/gio/gio.defs index dbd0f63..3ad3518 100644 --- a/gio/gio.defs +++ b/gio/gio.defs @@ -1818,6 +1818,16 @@ ) (define-method query_writable_namespaces + (docstring + "F.query_writable_namespaces([cancellable]) -> list\n\n" + "Obtain the list of attribute namespaces where new attributes can\n" + "be created by a user. An example of this is extended attributes\n" + "(in the "xattr" namespace).\n" + "If cancellable is not None, then the operation can be cancelled\n" + "by triggering the cancellable object from another thread. If the\n" + "operation was cancelled, the error gio.IO_ERROR_CANCELLED\n" + "will be returned." + ) (of-object "GFile") (c-name "g_file_query_writable_namespaces") (return-type "GFileAttributeInfoList*") diff --git a/tests/test_gio.py b/tests/test_gio.py index 5a3715b..3761b31 100644 --- a/tests/test_gio.py +++ b/tests/test_gio.py @@ -196,6 +196,12 @@ class TestFile(unittest.TestCase): self.assertEqual(info.flags, gio.FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED) + def testQueryWritableNamespaces(self): + infolist = self.file.query_writable_namespaces() + for info in infolist: + if info.name == "xattr": + self.assertEqual(info.type, gio.FILE_ATTRIBUTE_TYPE_STRING) + def testSetAttribute(self): self._f.write("testing attributes") self._f.seek(0) |