summaryrefslogtreecommitdiffstats
path: root/gio/pygio-utils.c
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2008-07-14 18:27:57 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-07-14 18:27:57 +0000
commitd63d49377bbb4951f81e00c7d833031f5642bb78 (patch)
tree110a8ebd08d06fab8f174379929a70c2397d9104 /gio/pygio-utils.c
parenteeac05d5cbd42308c33e777aecbf00595256519d (diff)
downloadpygobject-d63d49377bbb4951f81e00c7d833031f5642bb78.tar.gz
pygobject-d63d49377bbb4951f81e00c7d833031f5642bb78.tar.xz
pygobject-d63d49377bbb4951f81e00c7d833031f5642bb78.zip
Refactor cancellable check to a utility function, avoids
2008-07-14 Johan Dahlin <johan@gnome.org> * gio/Makefile.am: * gio/gfile.override: * gio/ginputstream.override: * gio/gio.override: * gio/goutputstream.override: * gio/pygio-utils.c (pygio_check_cancellable): * gio/pygio-utils.h: Refactor cancellable check to a utility function, avoids svn path=/trunk/; revision=797
Diffstat (limited to 'gio/pygio-utils.c')
-rw-r--r--gio/pygio-utils.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gio/pygio-utils.c b/gio/pygio-utils.c
new file mode 100644
index 0000000..b3c88b9
--- /dev/null
+++ b/gio/pygio-utils.c
@@ -0,0 +1,47 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * pygtk- Python bindings for the GTK toolkit.
+ * Copyright (C) 2008 Johan Dahlin
+ *
+ * giomodule.c: module wrapping the GIO library
+ *
+ * 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
+ */
+
+#include "pygio-utils.h"
+
+/**
+ * pygio_check_cancellable:
+ * @pycancellable:
+ * @cancellable:
+ *
+ * Returns:
+ */
+gboolean
+pygio_check_cancellable(PyGObject *pycancellable,
+ GCancellable **cancellable)
+{
+ if (pycancellable == NULL || (PyObject*)pycancellable == Py_None)
+ *cancellable = NULL;
+ else if (pygobject_check(pycancellable, &PyGCancellable_Type))
+ *cancellable = G_CANCELLABLE(pycancellable->obj);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "cancellable should be a gio.Cancellable");
+ return FALSE;
+ }
+ return TRUE;
+}