diff options
author | Gian Mario Tagliaretti <gianmt@src.gnome.org> | 2008-07-29 21:29:25 +0000 |
---|---|---|
committer | Gian Mario Tagliaretti <gianmt@src.gnome.org> | 2008-07-29 21:29:25 +0000 |
commit | 4a8c6c88a38e1b99b22ecc675ca70e752326a3a9 (patch) | |
tree | 52f7cac7b26928e43a697b7bc126674a31c187f0 /gio/pygio-utils.c | |
parent | b569c69f5759188e674e4808a52b7d2dd633306e (diff) | |
download | pygobject-4a8c6c88a38e1b99b22ecc675ca70e752326a3a9.tar.gz pygobject-4a8c6c88a38e1b99b22ecc675ca70e752326a3a9.tar.xz pygobject-4a8c6c88a38e1b99b22ecc675ca70e752326a3a9.zip |
Wrap g_app_info_launch_uris, g_app_info_launch, g_app_launch_context_get_display and g_app_launch_context_get_startup_notify_id
svn path=/trunk/; revision=898
Diffstat (limited to 'gio/pygio-utils.c')
-rw-r--r-- | gio/pygio-utils.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/gio/pygio-utils.c b/gio/pygio-utils.c index b3c88b9..313b147 100644 --- a/gio/pygio-utils.c +++ b/gio/pygio-utils.c @@ -1,6 +1,7 @@ /* -*- Mode: C; c-basic-offset: 4 -*- * pygtk- Python bindings for the GTK toolkit. * Copyright (C) 2008 Johan Dahlin + * Copyright (C) 2008 Gian Mario Tagliaretti * * giomodule.c: module wrapping the GIO library * @@ -45,3 +46,85 @@ pygio_check_cancellable(PyGObject *pycancellable, } return TRUE; } + +/** + * pygio_check_launch_context: + * @pycontext: + * @context: + * + * Returns: + */ +gboolean +pygio_check_launch_context(PyGObject *pycontext, + GAppLaunchContext **context) +{ + if (pycontext == NULL || (PyObject*)pycontext == Py_None) + *context = NULL; + else if (pygobject_check(pycontext, &PyGAppLaunchContext_Type)) + *context = G_APP_LAUNCH_CONTEXT(pycontext->obj); + else + { + PyErr_SetString(PyExc_TypeError, + "launch_context should be a GAppLaunchContext or None"); + return FALSE; + } + return TRUE; +} + +/** + * pygio_pylist_to_gfile_glist: + * @pyfile_list: + * + * Returns: + */ +GList * +pygio_pylist_to_gfile_glist(PyObject *pyfile_list) +{ + GList *file_list = NULL; + PyObject *item; + int len, i; + + len = PySequence_Size(pyfile_list); + for (i = 0; i < len; i++) { + item = PySequence_GetItem(pyfile_list, i); + if (!PyObject_TypeCheck(item, &PyGFile_Type)) { + PyErr_SetString(PyExc_TypeError, + "files must be a list or tuple of GFile"); + g_list_free(file_list); + return NULL; + } + file_list = g_list_prepend(file_list, ((PyGObject *)item)->obj); + } + file_list = g_list_reverse(file_list); + + return file_list; +} + +/** + * pygio_pylist_to_uri_glist: + * @pyfile_list: + * + * Returns: + */ +GList * +pygio_pylist_to_uri_glist(PyObject *pyfile_list) +{ + GList *file_list = NULL; + PyObject *item; + int len, i; + + len = PySequence_Size(pyfile_list); + for (i = 0; i < len; i++) { + item = PySequence_GetItem(pyfile_list, i); + if (!PyString_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "files must be strings"); + g_list_free(file_list); + return NULL; + } + file_list = g_list_prepend(file_list, PyString_AsString(item)); + } + file_list = g_list_reverse(file_list); + + return file_list; +} |