diff options
| author | Johan Dahlin <jdahlin@async.com.br> | 2008-04-08 20:50:46 +0000 |
|---|---|---|
| committer | Johan Dahlin <johan@src.gnome.org> | 2008-04-08 20:50:46 +0000 |
| commit | 5f743cddfc05aecf25b9713ae84259d2583b499e (patch) | |
| tree | 66dfbc41d9afed9908dd28a2cde4fa20e46b1059 /gio | |
| parent | b8ab661462d9312f4b723aa25bee8d08c5b46303 (diff) | |
| download | pygobject-5f743cddfc05aecf25b9713ae84259d2583b499e.tar.gz pygobject-5f743cddfc05aecf25b9713ae84259d2583b499e.tar.xz pygobject-5f743cddfc05aecf25b9713ae84259d2583b499e.zip | |
Implement GAppInfo constructor, add tests.
2008-04-08 Johan Dahlin <jdahlin@async.com.br>
* gio/Makefile.am:
* gio/__init__.py:
* gio/gappinfo.override:
* gio/gio.defs:
* gio/gio.override:
* tests/test_gio.py:
Implement GAppInfo constructor, add tests.
svn path=/trunk/; revision=772
Diffstat (limited to 'gio')
| -rw-r--r-- | gio/Makefile.am | 1 | ||||
| -rw-r--r-- | gio/__init__.py | 11 | ||||
| -rw-r--r-- | gio/gappinfo.override | 70 | ||||
| -rw-r--r-- | gio/gio.defs | 8 | ||||
| -rw-r--r-- | gio/gio.override | 1 |
5 files changed, 86 insertions, 5 deletions
diff --git a/gio/Makefile.am b/gio/Makefile.am index d67269b..348d9c0 100644 --- a/gio/Makefile.am +++ b/gio/Makefile.am @@ -34,6 +34,7 @@ EXTRA_DIST = # gio module GIO_OVERRIDES = \ + gappinfo.override \ gio.override \ gfile.override \ gfileenumerator.override \ diff --git a/gio/__init__.py b/gio/__init__.py index 5735161..38873f2 100644 --- a/gio/__init__.py +++ b/gio/__init__.py @@ -1,4 +1,4 @@ -# -*- Mode: Python; py-indent-offset: 4 -*- +# -*- Mode: Python -*- # pygobject - Python bindings for the GObject library # Copyright (C) 2008 Johan Dahlin # @@ -29,7 +29,9 @@ except ImportError: from gobject import GObjectMeta from _gio import * -from _gio import _file_init, _install_file_meta +from _gio import \ + _app_info_init, _install_app_info_meta, \ + _file_init, _install_file_meta try: import unix unix # pyflakes @@ -39,5 +41,8 @@ del _gio class GFileMeta(GObjectMeta): __call__ = _file_init - _install_file_meta(GFileMeta) + +class GAppInfoMeta(GObjectMeta): + __call__ = _app_info_init +_install_app_info_meta(GAppInfoMeta) diff --git a/gio/gappinfo.override b/gio/gappinfo.override new file mode 100644 index 0000000..d41b977 --- /dev/null +++ b/gio/gappinfo.override @@ -0,0 +1,70 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- + * pygobject - Python bindings for GObject + * Copyright (C) 2008 Johan Dahlin + * + * gappinfo.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 + */ +%% +define _install_app_info_meta +static PyObject * +_wrap__install_app_info_meta(PyObject *self, PyObject *args) +{ + PyObject *metaclass; + + if (!PyArg_ParseTuple(args, "O", &metaclass)) + return NULL; + + Py_INCREF(metaclass); + PyGAppInfo_Type.ob_type = (PyTypeObject*)metaclass; + + Py_INCREF(Py_None); + return Py_None; +} +%% +define _app_info_init kwargs +static PyObject * +_wrap__app_info_init(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "commandline", "application_name", + "flags", NULL }; + char *commandline, *application_name = NULL; + PyObject *py_flags = NULL; + GAppInfo *ret; + GError *error = NULL; + GAppInfoCreateFlags flags = G_APP_INFO_CREATE_NONE; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "s|zO:gio.AppInfo", + kwlist, + &commandline, &application_name, + &py_flags)) + return NULL; + if (py_flags && pyg_flags_get_value(G_TYPE_APP_INFO_CREATE_FLAGS, + py_flags, (gpointer)&flags)) + return NULL; + + ret = g_app_info_create_from_commandline(commandline, + application_name, flags, &error); + + if (pyg_error_check(&error)) + return NULL; + + /* pygobject_new handles NULL checking */ + return pygobject_new((GObject *)ret); +} + diff --git a/gio/gio.defs b/gio/gio.defs index 32746a0..0dcc024 100644 --- a/gio/gio.defs +++ b/gio/gio.defs @@ -15,11 +15,12 @@ (define-function app_info_create_from_commandline (c-name "g_app_info_create_from_commandline") + (is-constructor-of "GAppInfo") (return-type "GAppInfo*") (parameters '("const-char*" "commandline") - '("const-char*" "application_name") - '("GAppInfoCreateFlags" "flags") + '("const-char*" "application_name" (null-ok) (default "NULL")) + '("GAppInfoCreateFlags" "flags" (default "G_APP_INFO_CREATE_NONE")) '("GError**" "error") ) ) @@ -1095,6 +1096,7 @@ (define-function file_new_for_path (c-name "g_file_new_for_path") + (is-constructor-of "GFile") (return-type "GFile*") (parameters '("const-char*" "path") @@ -1103,6 +1105,7 @@ (define-function file_new_for_uri (c-name "g_file_new_for_uri") + (is-constructor-of "GFile") (return-type "GFile*") (parameters '("const-char*" "uri") @@ -1110,6 +1113,7 @@ ) (define-function file_new_for_commandline_arg + (is-constructor-of "GFile") (c-name "g_file_new_for_commandline_arg") (return-type "GFile*") (parameters diff --git a/gio/gio.override b/gio/gio.override index 41f6013..6624ad0 100644 --- a/gio/gio.override +++ b/gio/gio.override @@ -78,6 +78,7 @@ async_result_callback_marshal(GObject *source_object, } %% include + gappinfo.override gfile.override gfileenumerator.override gfileinfo.override |
