[pygobject/gsoc2009: 52/160] Complete filename conversion support
- From: Simon van der Linden <svdlinden src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pygobject/gsoc2009: 52/160] Complete filename conversion support
- Date: Fri, 14 Aug 2009 21:26:27 +0000 (UTC)
commit 62703f84614a513c9f4f3029f9a9a9d07e78f136
Author: Simon van der Linden <svdlinden src gnome org>
Date: Wed Jul 22 12:41:32 2009 +0200
Complete filename conversion support
gi/pygargument.c | 40 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/gi/pygargument.c b/gi/pygargument.c
index ad8d337..c94de9a 100644
--- a/gi/pygargument.c
+++ b/gi/pygargument.c
@@ -251,6 +251,7 @@ check_number_clean:
break;
}
case GI_TYPE_TAG_UTF8:
+ case GI_TYPE_TAG_FILENAME:
if (!PyString_Check(object)) {
PyErr_Format(PyExc_TypeError, "Must be string, not %s",
object->ob_type->tp_name);
@@ -380,7 +381,6 @@ check_number_clean:
break;
}
case GI_TYPE_TAG_TIME_T:
- case GI_TYPE_TAG_FILENAME:
case GI_TYPE_TAG_GLIST:
case GI_TYPE_TAG_GSLIST:
case GI_TYPE_TAG_GHASH:
@@ -440,6 +440,7 @@ pygi_gi_type_tag_get_size(GITypeTag type_tag)
size = sizeof(gdouble);
break;
case GI_TYPE_TAG_UTF8:
+ case GI_TYPE_TAG_FILENAME:
size = sizeof(gchar *);
break;
default:
@@ -612,6 +613,24 @@ pygi_g_argument_from_py_object(PyObject *object, GITypeInfo *type_info)
g_base_info_unref(info);
break;
}
+ case GI_TYPE_TAG_FILENAME:
+ {
+ GError *error = NULL;
+ const gchar *string;
+
+ string = PyString_AsString(object);
+ if (string == NULL) {
+ break;
+ }
+
+ arg.v_string = g_filename_from_utf8(string, -1, NULL, NULL, &error);
+ if (arg.v_string == NULL) {
+ PyErr_SetString(PyExc_Exception, error->message);
+ /* TODO: Convert the error to an exception. */
+ }
+
+ break;
+ }
case GI_TYPE_TAG_ARRAY:
{
gboolean is_zero_terminated;
@@ -767,7 +786,6 @@ pygi_g_argument_to_py_object(GArgument arg, GITypeInfo *type_info)
case GI_TYPE_TAG_DOUBLE:
object = PyFloat_FromDouble(arg.v_double);
break;
- case GI_TYPE_TAG_FILENAME:
case GI_TYPE_TAG_UTF8:
object = PyString_FromString(arg.v_string);
break;
@@ -853,6 +871,24 @@ struct_error_clean:
break;
}
+ case GI_TYPE_TAG_FILENAME:
+ {
+ GError *error = NULL;
+ gchar *string;
+
+ string = g_filename_to_utf8(arg.v_string, -1, NULL, NULL, &error);
+ if (string == NULL) {
+ PyErr_SetString(PyExc_Exception, error->message);
+ /* TODO: Convert the error to an exception. */
+ break;
+ }
+
+ object = PyString_FromString(string);
+
+ g_free(string);
+
+ break;
+ }
case GI_TYPE_TAG_ARRAY:
{
GArray *array;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]