diff options
| author | Johan Dahlin <johan@gnome.org> | 2008-04-06 16:23:37 +0000 |
|---|---|---|
| committer | Johan Dahlin <johan@src.gnome.org> | 2008-04-06 16:23:37 +0000 |
| commit | ce77e933926c720f98af9b6fb7ab9efa5918b720 (patch) | |
| tree | e01811c55a6937594f51d1ce34f69a9c7991a86b | |
| parent | e03f39502593b3caecbd760768a07c72d37b8abd (diff) | |
| download | pygobject-ce77e933926c720f98af9b6fb7ab9efa5918b720.tar.gz pygobject-ce77e933926c720f98af9b6fb7ab9efa5918b720.tar.xz pygobject-ce77e933926c720f98af9b6fb7ab9efa5918b720.zip | |
Implement the python iteration protocol on GFileEnumerator
2008-04-06 Johan Dahlin <johan@gnome.org>
* Makefile.am:
* gio/gfileenumerator.override (_wrap_g_file_enumerator_tp_iter):
Implement the python iteration protocol on GFileEnumerator
svn path=/trunk/; revision=758
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | gio/Makefile.am | 1 | ||||
| -rw-r--r-- | gio/gfileenumerator.override | 49 |
3 files changed, 54 insertions, 0 deletions
@@ -1,5 +1,9 @@ 2008-04-06 Johan Dahlin <johan@gnome.org> + * Makefile.am: + * gio/gfileenumerator.override (_wrap_g_file_enumerator_tp_iter): + Implement the python iteration protocol on GFileEnumerator + * codegen/argtypes.py (arg): Add goffset to the int64 arg type 2008-04-02 Paul Pogonyshev <pogonyshev@gmx.net> diff --git a/gio/Makefile.am b/gio/Makefile.am index 0d40ea8..e37b5c3 100644 --- a/gio/Makefile.am +++ b/gio/Makefile.am @@ -36,6 +36,7 @@ EXTRA_DIST = GIO_OVERRIDES = \ gio.override \ gfile.override \ + gfileenumerator.override \ ginputstream.override \ goutputstream.override \ gvolumemonitor.override diff --git a/gio/gfileenumerator.override b/gio/gfileenumerator.override new file mode 100644 index 0000000..0dc9b11 --- /dev/null +++ b/gio/gfileenumerator.override @@ -0,0 +1,49 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- + * pygobject - Python bindings for GObject + * Copyright (C) 2008 Johan Dahlin + * + * ginputstream.override: module overrides for GInputStream + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ +%% +override-slot GFileEnumerator.tp_iter +static PyObject* +_wrap_g_file_enumerator_tp_iter(PyGObject *self) +{ + return (PyObject *) self; +} +%% +override-slot GFileEnumerator.tp_iternext +static PyObject* +_wrap_g_file_enumerator_tp_iternext(PyGObject *iter) +{ + GFileInfo *file_info; + GError *error = NULL; + + file_info = g_file_enumerator_next_file(G_FILE_ENUMERATOR(iter->obj), + NULL, + &error); + if (pyg_error_check(&error)) { + return NULL; + } + if (!file_info) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + + return pygobject_new((GObject*)file_info); +} |
