summaryrefslogtreecommitdiffstats
path: root/gobject
diff options
context:
space:
mode:
authorGustavo J. A. M. Carneiro <gjc@src.gnome.org>2006-06-24 18:56:04 +0000
committerGustavo J. A. M. Carneiro <gjc@src.gnome.org>2006-06-24 18:56:04 +0000
commitbbe3b88b3a15a15b5d015d9ef1911b1181032141 (patch)
tree660aa93a1deb1e2883eccccce58ac61ba34e73f2 /gobject
parentda89a7fed41a58ba9fda0413c8d183608cca2c39 (diff)
downloadpygobject-bbe3b88b3a15a15b5d015d9ef1911b1181032141.tar.gz
pygobject-bbe3b88b3a15a15b5d015d9ef1911b1181032141.tar.xz
pygobject-bbe3b88b3a15a15b5d015d9ef1911b1181032141.zip
gobject.filename_from_utf8
Diffstat (limited to 'gobject')
-rw-r--r--gobject/gobjectmodule.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index b5dd261..00630ae 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -2648,6 +2648,29 @@ pyg_filename_display_basename(PyGObject *self, PyObject *args)
return py_display_basename;
}
+static PyObject *
+pyg_filename_from_utf8(PyGObject *self, PyObject *args)
+{
+ char *filename, *utf8string;
+ int utf8string_len;
+ gsize bytes_written;
+ GError *error = NULL;
+ PyObject *py_filename;
+
+ if (!PyArg_ParseTuple(args, "s#:gobject.filename_from_utf8",
+ &utf8string, &utf8string_len))
+ return NULL;
+
+ filename = g_filename_from_utf8(utf8string, utf8string_len, NULL, &bytes_written, &error);
+ if (pyg_error_check(&error)) {
+ g_free(filename);
+ return NULL;
+ }
+ py_filename = PyString_FromStringAndSize(filename, bytes_written);
+ g_free(filename);
+ return py_filename;
+}
+
static PyMethodDef pygobject_functions[] = {
{ "type_name", pyg_type_name, METH_VARARGS },
{ "type_from_name", pyg_type_from_name, METH_VARARGS },
@@ -2705,6 +2728,8 @@ static PyMethodDef pygobject_functions[] = {
(PyCFunction)pyg_filename_display_name, METH_VARARGS },
{ "filename_display_basename",
(PyCFunction)pyg_filename_display_basename, METH_VARARGS },
+ { "filename_from_utf8",
+ (PyCFunction)pyg_filename_from_utf8, METH_VARARGS },
{ NULL, NULL, 0 }
};
@@ -2775,7 +2800,7 @@ pyg_enum_add_constants(PyObject *module, GType enum_type,
gint value = eclass->values[i].value;
PyModule_AddIntConstant(module,
- pyg_constant_strip_prefix(name, strip_prefix),
+ (char*) pyg_constant_strip_prefix(name, strip_prefix),
(long) value);
}
@@ -2814,7 +2839,7 @@ pyg_flags_add_constants(PyObject *module, GType flags_type,
guint value = fclass->values[i].value;
PyModule_AddIntConstant(module,
- pyg_constant_strip_prefix(name, strip_prefix),
+ (char*) pyg_constant_strip_prefix(name, strip_prefix),
(long) value);
}