diff options
author | Huang Peng <shawn.p.huang@gmail.com> | 2008-09-17 20:24:27 +0800 |
---|---|---|
committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-09-17 20:24:27 +0800 |
commit | ef96e9fec0699a8107c3f0e91956dd2738ebe46a (patch) | |
tree | 956f001b6e1d971d302b8942b1c62fe7485c3f87 /util | |
parent | 99f3479b93f98a65e88f394c50f861a1bfb31693 (diff) | |
download | ibus-ef96e9fec0699a8107c3f0e91956dd2738ebe46a.tar.gz |
Include gconf python binding from gnome-python2.
Diffstat (limited to 'util')
-rw-r--r-- | util/Makefile.am | 1 | ||||
-rw-r--r-- | util/gconf/Makefile.am | 44 | ||||
-rw-r--r-- | util/gconf/gconf-arg-types.py | 30 | ||||
-rw-r--r-- | util/gconf/gconf-fixes.c | 57 | ||||
-rw-r--r-- | util/gconf/gconf-fixes.h | 14 | ||||
-rw-r--r-- | util/gconf/gconf-types.c | 157 | ||||
-rw-r--r-- | util/gconf/gconf-types.h | 35 | ||||
-rw-r--r-- | util/gconf/gconf.defs | 1978 | ||||
-rw-r--r-- | util/gconf/gconf.override | 920 | ||||
-rw-r--r-- | util/gconf/gconfmodule.c | 33 | ||||
-rw-r--r-- | util/gconf/wscript | 47 |
11 files changed, 3316 insertions, 0 deletions
diff --git a/util/Makefile.am b/util/Makefile.am index de4882b7..0fcbd4ec 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -21,4 +21,5 @@ SUBDIRS = \ IMdkit \ + gconf \ $(NULL) diff --git a/util/gconf/Makefile.am b/util/gconf/Makefile.am new file mode 100644 index 00000000..8dcea056 --- /dev/null +++ b/util/gconf/Makefile.am @@ -0,0 +1,44 @@ +INCLUDES = $(PYTHON_INCLUDES) $(PYGTK_CFLAGS) + +defsdir = $(datadir)/pygtk/2.0/defs + +defs_DATA = gconf.defs + +common_ldflags = -module -avoid-version $(PYTHON_LDFLAGS) + +pkgpythondir = $(pyexecdir)/gtk-2.0 +pkgpyexecdir = $(pyexecdir)/gtk-2.0 + +# gconf binding + +pkgpyexec_LTLIBRARIES = gconf.la +gconf_la_CFLAGS = $(GCONF_CFLAGS) +gconf_la_LDFLAGS = $(common_ldflags) -export-symbols-regex initgconf +gconf_la_LIBADD = $(PYGTK_LIBS) $(GCONF_LIBS) $(PYTHON_LIBS) +gconf_la_SOURCES = \ + gconfmodule.c \ + gconf-fixes.c \ + gconf-fixes.h \ + gconf-types.c \ + gconf-types.h +nodist_gconf_la_SOURCES = gconf.c +CLEANFILES = gconf.c +EXTRA_DIST = gconf.defs gconf.override +gconf.c: gconf.defs gconf.override gconf-arg-types.py + +argtypesdir = $(datadir)/pygtk/2.0/argtypes +argtypes_PYTHON = gconf-arg-types.py + +.defs.c: + (cd $(srcdir) \ + && $(PYGTK_CODEGEN) \ + --py_ssize_t-clean \ + --load-types gconf-arg-types.py \ + --override $*.override \ + --prefix py$* $*.defs) > gen-$*.c \ + && cp gen-$*.c $*.c \ + && rm -f gen-$*.c + + +EXTRA_DIST += wscript + diff --git a/util/gconf/gconf-arg-types.py b/util/gconf/gconf-arg-types.py new file mode 100644 index 00000000..16104957 --- /dev/null +++ b/util/gconf/gconf-arg-types.py @@ -0,0 +1,30 @@ +import argtypes + +class GConfEngineArg (argtypes.ArgType): + engine = (' %(name)s = pygconf_engine_from_pyobject (py_%(name)s);\n' + ' if (PyErr_Occurred ())\n' + ' return NULL;\n') + + def write_param(self, ptype, pname, pdflt, pnull, info): + # pdflt and pnull not handled - we don't use "default" or "null-ok" + info.varlist.add ('GConfEngine*', pname) + info.varlist.add ('PyObject', '*py_' + pname + ' = NULL') + info.codebefore.append (self.engine % { 'name' : pname }) + info.arglist.append (pname) + info.add_parselist ('O', ['&py_' + pname], [pname]) + + def write_return (self, ptype, ownsreturn, info): + if ptype[-1] == '*': + ptype = ptype[:-1] + info.varlist.add (ptype, '*ret') + if ownsreturn: + info.varlist.add ('PyObject', '*py_ret') + info.codeafter.append (' py_ret = pygconf_engine_new (ret);\n' + ' if (ret != NULL)\n' + ' gconf_engine_unref (ret);\n' + ' return py_ret;') + else: + info.codeafter.append (' /* pygconf_engine_new() handles NULL checking */\n' + + ' return pygconf_engine_new (ret);') + +argtypes.matcher.register ("GConfEngine*", GConfEngineArg ()) diff --git a/util/gconf/gconf-fixes.c b/util/gconf/gconf-fixes.c new file mode 100644 index 00000000..dbef7546 --- /dev/null +++ b/util/gconf/gconf-fixes.c @@ -0,0 +1,57 @@ +/* GConf-python + * Copyright (C) 2002 Johan Dahlin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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. + * + * Author: Johan Dahlin <jdahlin@telia.com> + */ + +#include <gconf/gconf-client.h> +#include <gconf/gconf-value.h> + +#include "gconf-fixes.h" + +GConfMetaInfo* +gconf_meta_info_copy (const GConfMetaInfo *src) +{ + GConfMetaInfo *info; + + info = gconf_meta_info_new (); + + info->schema = g_strdup (src->schema); + info->mod_user = g_strdup (src->mod_user); + info->mod_time = src->mod_time; + + return info; +} + +#define BOILERPLATE_TYPE_BOXED(func,name) \ +GType \ +py##func##_get_type (void) \ +{ \ + static GType type = 0; \ + if (type == 0) { \ + type = g_boxed_type_register_static(name, \ + (GBoxedCopyFunc)func##_copy, \ + (GBoxedFreeFunc)func##_free); \ + } \ + return type; \ +} + +BOILERPLATE_TYPE_BOXED(gconf_value, "GConfValue") +BOILERPLATE_TYPE_BOXED(gconf_entry, "GConfEntry") +BOILERPLATE_TYPE_BOXED(gconf_schema, "GConfSchema") +BOILERPLATE_TYPE_BOXED(gconf_meta_info, "GConfMetaInfo") diff --git a/util/gconf/gconf-fixes.h b/util/gconf/gconf-fixes.h new file mode 100644 index 00000000..50eb7ec6 --- /dev/null +++ b/util/gconf/gconf-fixes.h @@ -0,0 +1,14 @@ +#include <glib-object.h> +#include <gconf/gconf-value.h> + +extern GConfEntry* gconf_entry_copy (const GConfEntry *src); + +GType pygconf_value_get_type (void); +GType pygconf_entry_get_type (void); +GType pygconf_schema_get_type (void); +GType pygconf_meta_info_get_type (void); + +#define GCONF_TYPE_VALUE (pygconf_value_get_type ()) +#define GCONF_TYPE_ENTRY (pygconf_entry_get_type ()) +#define GCONF_TYPE_SCHEMA (pygconf_schema_get_type ()) +#define GCONF_TYPE_METAINFO (pygconf_meta_info_get_type ()) diff --git a/util/gconf/gconf-types.c b/util/gconf/gconf-types.c new file mode 100644 index 00000000..9e0b1a94 --- /dev/null +++ b/util/gconf/gconf-types.c @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2005 Red Hat, Inc. + * + * gconf-types.c: wrappers for some specialised GConf types. + * + * 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 "gconf-types.h" +#define NO_IMPORT_PYGOBJECT +#include <pygobject.h> + +typedef struct { + PyObject_HEAD + GConfEngine *engine; +} PyGConfEngine; +extern PyTypeObject PyGConfEngine_Type; + +static void +pygconf_engine_dealloc (PyGConfEngine *self) +{ + pyg_begin_allow_threads; + gconf_engine_unref (self->engine); + pyg_end_allow_threads; + PyObject_DEL (self); +} + + +static PyObject * +pygconf_engine_associate_schema(PyGConfEngine *self, PyObject *args, PyObject *kwargs) +{ + gchar *key, *schema_key; + gboolean result; + GError *err = NULL; + char *kwlist[] = {"key", "schema_key", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "ss:gconf.Engine.associate_schema", + kwlist, &key, &schema_key)) + return NULL; + + result = gconf_engine_associate_schema(self->engine, key, schema_key, &err); + + if (pyg_error_check(&err)) + return NULL; + + if (result) { + Py_INCREF(Py_True); + return Py_True; + } else { + Py_INCREF(Py_False); + return Py_False; + } +} + +static PyMethodDef pygconf_engine_methods[] = { + {"associate_schema", (PyCFunction)pygconf_engine_associate_schema, + METH_KEYWORDS, NULL}, + + {NULL, NULL, 0, NULL} +}; + + +PyTypeObject PyGConfEngine_Type = { + PyObject_HEAD_INIT (NULL) + 0, + "gconf.GConfEngine", + sizeof (PyGConfEngine), + 0, + (destructor) pygconf_engine_dealloc, + (printfunc) 0, + (getattrfunc) 0, + (setattrfunc) 0, + (cmpfunc) 0, + (reprfunc) 0, + 0, + 0, + 0, + (hashfunc) 0, + (ternaryfunc) 0, + (reprfunc) 0, + (getattrofunc) 0, + (setattrofunc) 0, + 0, + Py_TPFLAGS_DEFAULT, + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + pygconf_engine_methods, /* tp_methods */ +}; + +PyObject * +pygconf_engine_new (GConfEngine *engine) +{ + PyGConfEngine *self; + + if (engine == NULL) + { + Py_INCREF (Py_None); + return Py_None; + } + + self = (PyGConfEngine *) PyObject_NEW (PyGConfEngine, &PyGConfEngine_Type); + if (self == NULL) + return NULL; + + pyg_begin_allow_threads; + self->engine = engine; + gconf_engine_ref (engine); + pyg_end_allow_threads; + + return (PyObject *) self; +} + +GConfEngine * +pygconf_engine_from_pyobject (PyObject *object) +{ + PyGConfEngine *self; + + if (object == NULL) + return NULL; + + if (!PyObject_TypeCheck (object, &PyGConfEngine_Type)) + { + PyErr_SetString (PyExc_TypeError, "unable to convert argument to GConfEngine*"); + return NULL; + } + + self = (PyGConfEngine *) object; + + return self->engine; +} + +void +pygconf_register_engine_type (PyObject *moddict) +{ + PyGConfEngine_Type.ob_type = &PyType_Type; + + PyType_Ready(&PyGConfEngine_Type); +} diff --git a/util/gconf/gconf-types.h b/util/gconf/gconf-types.h new file mode 100644 index 00000000..210a417b --- /dev/null +++ b/util/gconf/gconf-types.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2005 Red Hat, Inc. + * + * gconf-types.h: wrappers for some specialised GConf types. + * + * 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 + * + * Author: + * Mark McLoughlin <mark@skynet.ie> + */ + +#ifndef __GCONF_TYPES_H__ +#define __GCONF_TYPES_H__ + +#include <Python.h> +#include <gconf/gconf.h> + +void pygconf_register_engine_type (PyObject *moddict); +PyObject *pygconf_engine_new (GConfEngine *engine); +GConfEngine *pygconf_engine_from_pyobject (PyObject *object); + +#endif /* __GCONF_TYPES_H__ */ diff --git a/util/gconf/gconf.defs b/util/gconf/gconf.defs new file mode 100644 index 00000000..7cc02294 --- /dev/null +++ b/util/gconf/gconf.defs @@ -0,0 +1,1978 @@ +;; -*- scheme -*- + +(define-object Client + (in-module "GConf") + (parent "GObject") + (c-name "GConfClient") + (gtype-id "GCONF_TYPE_CLIENT") +) + +(define-boxed Value + (in-module "GConf") + (c-name "GConfValue") + (gtype-id "GCONF_TYPE_VALUE") + (copy-func "gconf_value_copy") + (release-func "gconf_value_free") + (fields + '("GConfValueType" "type") + ) +) + +(define-boxed Entry + (in-module "GConf") + (c-name "GConfEntry") + (gtype-id "GCONF_TYPE_ENTRY") + (copy-func "gconf_entry_copy") + (release-func "gconf_entry_free") + (fields + '("gchar*" "key") + '("GConfValue*" "value") + ) +) + +(define-boxed Schema + (in-module "GConf") + (c-name "GConfSchema") + (gtype-id "GCONF_TYPE_SCHEMA") + (copy-func "gconf_schema_copy") + (release-func "gconf_schema_free") +) + +(define-boxed MetaInfo + (in-module "GConf") + (c-name "GConfMetaInfo") + (gtype-id "GCONF_TYPE_METAINFO") + (copy-func "gconf_metainfo_copy") + (release-func "gconf_metainfo_free") +) + +(define-boxed ChangeSet + (in-module "GConf") + (c-name "GConfChangeSet") + (gtype-id "GCONF_TYPE_CHANGE_SET") +) + +(define-enum ClientPreloadType + (in-module "GConf") + (c-name "GConfClientPreloadType") + (gtype-id "GCONF_TYPE_CLIENT_PRELOAD_TYPE") + (values + '("none" "GCONF_CLIENT_PRELOAD_NONE") + '("onelevel" "GCONF_CLIENT_PRELOAD_ONELEVEL") + '("recursive" "GCONF_CLIENT_PRELOAD_RECURSIVE") + ) +) + +(define-enum ClientErrorHandlingMode + (in-module "GConf") + (c-name "GConfClientErrorHandlingMode") + (gtype-id "GCONF_TYPE_CLIENT_ERROR_HANDLING_MODE") + (values + '("none" "GCONF_CLIENT_HANDLE_NONE") + '("unreturned" "GCONF_CLIENT_HANDLE_UNRETURNED") + '("all" "GCONF_CLIENT_HANDLE_ALL") + ) +) + +(define-enum Error + (in-module "GConf") + (c-name "GConfError") + (gtype-id "GCONF_TYPE_ERROR") + (values + '("success" "GCONF_ERROR_SUCCESS") + '("failed" "GCONF_ERROR_FAILED") + '("no-server" "GCONF_ERROR_NO_SERVER") + '("no-permission" "GCONF_ERROR_NO_PERMISSION") + '("bad-address" "GCONF_ERROR_BAD_ADDRESS") + '("bad-key" "GCONF_ERROR_BAD_KEY") + '("parse-error" "GCONF_ERROR_PARSE_ERROR") + '("corrupt" "GCONF_ERROR_CORRUPT") + '("type-mismatch" "GCONF_ERROR_TYPE_MISMATCH") + '("is-dir" "GCONF_ERROR_IS_DIR") + '("is-key" "GCONF_ERROR_IS_KEY") + '("overridden" "GCONF_ERROR_OVERRIDDEN") + '("oaf-error" "GCONF_ERROR_OAF_ERROR") + '("local-engine" "GCONF_ERROR_LOCAL_ENGINE") + '("lock-failed" "GCONF_ERROR_LOCK_FAILED") + '("no-writable-database" "GCONF_ERROR_NO_WRITABLE_DATABASE") + '("in-shutdown" "GCONF_ERROR_IN_SHUTDOWN") + ) +) + +(define-enum ValueType + (in-module "GConf") + (c-name "GConfValueType") + (gtype-id "GCONF_TYPE_VALUE_TYPE") + (values + '("invalid" "GCONF_VALUE_INVALID") + '("string" "GCONF_VALUE_STRING") + '("int" "GCONF_VALUE_INT") + '("float" "GCONF_VALUE_FLOAT") + '("bool" "GCONF_VALUE_BOOL") + '("schema" "GCONF_VALUE_SCHEMA") + '("list" "GCONF_VALUE_LIST") + '("pair" "GCONF_VALUE_PAIR") + ) +) + +(define-flags UnsetFlags + (in-module "GConf") + (c-name "GConfUnsetFlags") + (gtype-id "GCONF_TYPE_UNSET_FLAGS") +) + +(define-method commit_change_set + (of-object "GConfEngine") + (c-name "gconf_engine_commit_change_set") + (return-type "gboolean") + (parameters + '("GConfChangeSet*" "cs") + '("gboolean" "remove_committed") + '("GError**" "err") + ) +) + +(define-method reverse_change_set + (of-object "GConfEngine") + (c-name "gconf_engine_reverse_change_set") + (return-type "GConfChangeSet*") + (parameters + '("GConfChangeSet*" "cs") + '("GError**" "err") + ) +) + +(define-method change_set_from_currentv + (of-object "GConfEngine") + (c-name "gconf_engine_change_set_from_currentv") + (return-type "GConfChangeSet*") + (parameters + '("const-gchar**" "keys") + '("GError**" "err") + ) +) + +(define-method change_set_from_current + (of-object "GConfEngine") + (c-name "gconf_engine_change_set_from_current") + (return-type "GConfChangeSet*") + (parameters + '("GError**" "err") + '("const-gchar*" "first_key") + ) + (varargs #t) +) + +(define-function change_set_get_type + (c-name "gconf_change_set_get_type") + (return-type "GType") +) + +(define-function change_set_new + (is-constructor-of "GConfChangeSet") + (c-name "gconf_change_set_new") + (caller-owns-return #t) + (return-type "GConfChangeSet*") +) + +(define-method ref + (of-object "GConfChangeSet") + (c-name "gconf_change_set_ref") + (return-type "none") +) + +(define-method unref + (of-object "GConfChangeSet") + (c-name "gconf_change_set_unref") + (return-type "none") +) + +(define-method clear + (of-object "GConfChangeSet") + (c-name "gconf_change_set_clear") + (return-type "none") +) + +(define-method size + (of-object "GConfChangeSet") + (c-name "gconf_change_set_size") + (return-type "guint") +) + +(define-method remove + (of-object "GConfChangeSet") + (c-name "gconf_change_set_remove") + (return-type "none") + (parameters + '("const-gchar*" "key") + ) +) + +(define-method foreach + (of-object "GConfChangeSet") + (c-name "gconf_change_set_foreach") + (return-type "none") + (parameters + '("GConfChangeSetForeachFunc" "func") + '("gpointer" "user_data") + ) +) + +(define-method check_value + (of-object "GConfChangeSet") + (c-name "gconf_change_set_check_value") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GConfValue**" "value_retloc") + ) +) + +(define-method set + (of-object "GConfChangeSet") + (c-name "gconf_change_set_set") + (return-type "none") + (parameters + '("const-gchar*" "key") + '("GConfValue*" "value") + ) +) + +(define-method set_nocopy + (of-object "GConfChangeSet") + (c-name "gconf_change_set_set_nocopy") + (return-type "none") + (parameters + '("const-gchar*" "key") + '("GConfValue*" "value") + ) +) + +(define-method unset + (of-object "GConfChangeSet") + (c-name "gconf_change_set_unset") + (return-type "none") + (parameters + '("const-gchar*" "key") + ) +) + +(define-method set_float + (of-object "GConfChangeSet") + (c-name "gconf_change_set_set_float") + (return-type "none") + (parameters + '("const-gchar*" "key") + '("gdouble" "val") + ) +) + +(define-method set_int + (of-object "GConfChangeSet") + (c-name "gconf_change_set_set_int") + (return-type "none") + (parameters + '("const-gchar*" "key") + '("gint" "val") + ) +) + +(define-method set_string + (of-object "GConfChangeSet") + (c-name "gconf_change_set_set_string") + (return-type "none") + (parameters + '("const-gchar*" "key") + '("const-gchar*" "val") + ) +) + +(define-method set_bool + (of-object "GConfChangeSet") + (c-name "gconf_change_set_set_bool") + (return-type "none") + (parameters + '("const-gchar*" "key") + '("gboolean" "val") + ) +) + +(define-method set_schema + (of-object "GConfChangeSet") + (c-name "gconf_change_set_set_schema") + (return-type "none") + (parameters + '("const-gchar*" "key") + '("GConfSchema*" "val") + ) +) + +(define-method set_list + (of-object "GConfChangeSet") + (c-name "gconf_change_set_set_list") + (return-type "none") + (parameters + '("const-gchar*" "key") + '("GConfValueType" "list_type") + '("GSList*" "list") + ) +) + +(define-method set_pair + (of-object "GConfChangeSet") + (c-name "gconf_change_set_set_pair") + (return-type "none") + (parameters + '("const-gchar*" "key") + '("GConfValueType" "car_type") + '("GConfValueType" "cdr_type") + '("gconstpointer" "address_of_car") + '("gconstpointer" "address_of_cdr") + ) +) + +(define-method set_user_data + (of-object "GConfChangeSet") + (c-name "gconf_change_set_set_user_data") + (return-type "none") + (parameters + '("gpointer" "data") + '("GDestroyNotify" "dnotify") + ) +) + +(define-method get_user_data + (of-object "GConfChangeSet") + (c-name "gconf_change_set_get_user_data") + (return-type "gpointer") +) + +(define-function client_get_type + (c-name "gconf_client_get_type") + (return-type "GType") +) + +(define-function client_get_default + (c-name "gconf_client_get_default") + (caller-owns-return #t) + (return-type "GConfClient*") +) + +(define-function client_get_for_engine + (c-name "gconf_client_get_for_engine") + (caller-owns-return #t) + (return-type "GConfClient*") + (parameters + '("GConfEngine*" "engine") + ) +) + +(define-method add_dir + (of-object "GConfClient") + (c-name "gconf_client_add_dir") + (return-type "none") + (parameters + '("const-gchar*" "dir") + '("GConfClientPreloadType" "preload") + '("GError**" "err") + ) +) + +(define-method remove_dir + (of-object "GConfClient") + (c-name "gconf_client_remove_dir") + (return-type "none") + (parameters + '("const-gchar*" "dir") + '("GError**" "err") + ) +) + +(define-method notify_add + (of-object "GConfClient") + (c-name "gconf_client_notify_add") + (return-type "guint") + (parameters + '("const-gchar*" "namespace_section") + '("GConfClientNotifyFunc" "func") + '("gpointer" "user_data") + '("GFreeFunc" "destroy_notify") + '("GError**" "err") + ) +) + +(define-method notify_remove + (of-object "GConfClient") + (c-name "gconf_client_notify_remove") + (return-type "none") + (parameters + '("guint" "cnxn") + ) +) + +(define-method notify + (of-object "GConfClient") + (c-name "gconf_client_notify") + (return-type "none") + (parameters + '("const-char*" "key") + ) +) + +(define-method set_error_handling + (of-object "GConfClient") + (c-name "gconf_client_set_error_handling") + (return-type "none") + (parameters + '("GConfClientErrorHandlingMode" "mode") + ) +) + +(define-function client_set_global_default_error_handler + (c-name "gconf_client_set_global_default_error_handler") + (return-type "none") + (parameters + '("GConfClientErrorHandlerFunc" "func") + ) +) + +(define-method clear_cache + (of-object "GConfClient") + (c-name "gconf_client_clear_cache") + (return-type "none") +) + +(define-method preload + (of-object "GConfClient") + (c-name "gconf_client_preload") + (return-type "none") + (parameters + '("const-gchar*" "dirname") + '("GConfClientPreloadType" "type") + '("GError**" "err") + ) +) + +(define-method set + (of-object "GConfClient") + (c-name "gconf_client_set") + (return-type "none") + (parameters + '("const-gchar*" "key") + '("const-GConfValue*" "val") + '("GError**" "err") + ) +) + +(define-method get + (of-object "GConfClient") + (c-name "gconf_client_get") + (caller-owns-return #t) + (return-type "GConfValue*") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_without_default + (of-object "GConfClient") + (c-name "gconf_client_get_without_default") + (caller-owns-return #t) + (return-type "GConfValue*") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_entry + (of-object "GConfClient") + (c-name "gconf_client_get_entry") + (caller-owns-return #t) + (return-type "GConfEntry*") + (parameters + '("const-gchar*" "key") + '("const-gchar*" "locale") + '("gboolean" "use_schema_default") + '("GError**" "err") + ) +) + +(define-method get_default_from_schema + (of-object "GConfClient") + (c-name "gconf_client_get_default_from_schema") + (caller-owns-return #t) + (return-type "GConfValue*") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method unset + (of-object "GConfClient") + (c-name "gconf_client_unset") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method recursive_unset + (of-object "GConfClient") + (c-name "gconf_client_recursive_unset") + (return-type "gboolean") + (parameters + '("const-char*" "key") + '("GConfUnsetFlags" "flags") + '("GError**" "err") + ) +) + +(define-method all_entries + (of-object "GConfClient") + (c-name "gconf_client_all_entries") + (return-type "GSList*") + (parameters + '("const-gchar*" "dir") + '("GError**" "err") + ) +) + +(define-method all_dirs + (of-object "GConfClient") + (c-name "gconf_client_all_dirs") + (return-type "GSList*") + (parameters + '("const-gchar*" "dir") + '("GError**" "err") + ) +) + +(define-method suggest_sync + (of-object "GConfClient") + (c-name "gconf_client_suggest_sync") + (return-type "none") + (parameters + '("GError**" "err") + ) +) + +(define-method dir_exists + (of-object "GConfClient") + (c-name "gconf_client_dir_exists") + (return-type "gboolean") + (parameters + '("const-gchar*" "dir") + '("GError**" "err") + ) +) + +(define-method key_is_writable + (of-object "GConfClient") + (c-name "gconf_client_key_is_writable") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_float + (of-object "GConfClient") + (c-name "gconf_client_get_float") + (return-type "gdouble") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_int + (of-object "GConfClient") + (c-name "gconf_client_get_int") + (return-type "gint") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_string + (of-object "GConfClient") + (c-name "gconf_client_get_string") + (caller-owns-return #t) + (return-type "gchar*") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_bool + (of-object "GConfClient") + (c-name "gconf_client_get_bool") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_schema + (of-object "GConfClient") + (c-name "gconf_client_get_schema") + (caller-owns-return #t) + (return-type "GConfSchema*") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_list + (of-object "GConfClient") + (c-name "gconf_client_get_list") + (caller-owns-return #t) + (return-type "GSList*") + (parameters + '("const-gchar*" "key") + '("GConfValueType" "list_type") + '("GError**" "err") + ) +) + +(define-method get_pair + (of-object "GConfClient") + (c-name "gconf_client_get_pair") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GConfValueType" "car_type") + '("GConfValueType" "cdr_type") + '("gpointer" "car_retloc") + '("gpointer" "cdr_retloc") + '("GError**" "err") + ) +) + +(define-method set_float + (of-object "GConfClient") + (c-name "gconf_client_set_float") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("gdouble" "val") + '("GError**" "err") + ) +) + +(define-method set_int + (of-object "GConfClient") + (c-name "gconf_client_set_int") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("gint" "val") + '("GError**" "err") + ) +) + +(define-method set_string + (of-object "GConfClient") + (c-name "gconf_client_set_string") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("const-gchar*" "val") + '("GError**" "err") + ) +) + +(define-method set_bool + (of-object "GConfClient") + (c-name "gconf_client_set_bool") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("gboolean" "val") + '("GError**" "err") + ) +) + +(define-method set_schema + (of-object "GConfClient") + (c-name "gconf_client_set_schema") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("const-GConfSchema*" "val") + '("GError**" "err") + ) +) + +(define-method set_list + (of-object "GConfClient") + (c-name "gconf_client_set_list") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GConfValueType" "list_type") + '("GSList*" "list") + '("GError**" "err") + ) +) + +(define-method set_pair + (of-object "GConfClient") + (c-name "gconf_client_set_pair") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GConfValueType" "car_type") + '("GConfValueType" "cdr_type") + '("gconstpointer" "address_of_car") + '("gconstpointer" "address_of_cdr") + '("GError**" "err") + ) +) + +(define-method error + (of-object "GConfClient") + (c-name "gconf_client_error") + (return-type "none") + (parameters + '("GError*" "error") + ) +) + +(define-method unreturned_error + (of-object "GConfClient") + (c-name "gconf_client_unreturned_error") + (return-type "none") + (parameters + '("GError*" "error") + ) +) + +(define-method value_changed + (of-object "GConfClient") + (c-name "gconf_client_value_changed") + (return-type "none") + (parameters + '("const-gchar*" "key") + '("GConfValue*" "value") + ) +) + +(define-method commit_change_set + (of-object "GConfClient") + (c-name "gconf_client_commit_change_set") + (return-type "gboolean") + (parameters + '("GConfChangeSet*" "cs") + '("gboolean" "remove_committed") + '("GError**" "err") + ) +) + +(define-method reverse_change_set + (of-object "GConfClient") + (c-name "gconf_client_reverse_change_set") + (return-type "GConfChangeSet*") + (parameters + '("GConfChangeSet*" "cs") + '("GError**" "err") + ) +) + +(define-method change_set_from_currentv + (of-object "GConfClient") + (c-name "gconf_client_change_set_from_currentv") + (return-type "GConfChangeSet*") + (parameters + '("const-gchar**" "keys") + '("GError**" "err") + ) +) + +(define-method change_set_from_current + (of-object "GConfClient") + (c-name "gconf_client_change_set_from_current") + (return-type "GConfChangeSet*") + (parameters + '("GError**" "err") + '("const-gchar*" "first_key") + ) + (varargs #t) +) + +(define-function engine_get_default + (c-name "gconf_engine_get_default") + (return-type "GConfEngine*") +) + +(define-function engine_get_for_address + (c-name "gconf_engine_get_for_address") + (caller-owns-return #t) + (return-type "GConfEngine*") + (parameters + '("const-gchar*" "address") + '("GError**" "err") + ) +) + +(define-function engine_get_for_addresses + (c-name "gconf_engine_get_for_addresses") + (return-type "GConfEngine*") + (parameters + '("GSList*" "addresses") + '("GError**" "err") + ) +) + +(define-method unref + (of-object "GConfEngine") + (c-name "gconf_engine_unref") + (return-type "none") +) + +(define-method ref + (of-object "GConfEngine") + (c-name "gconf_engine_ref") + (return-type "none") +) + +(define-method set_user_data + (of-object "GConfEngine") + (c-name "gconf_engine_set_user_data") + (return-type "none") + (parameters + '("gpointer" "data") + '("GDestroyNotify" "dnotify") + ) +) + +(define-method get_user_data + (of-object "GConfEngine") + (c-name "gconf_engine_get_user_data") + (return-type "gpointer") +) + +(define-function value_type_get_type + (c-name "gconf_value_type_get_type") + (return-type "GType") +) + +(define-function error_get_type + (c-name "gconf_error_get_type") + (return-type "GType") +) + +(define-function client_preload_type_get_type + (c-name "gconf_client_preload_type_get_type") + (return-type "GType") +) + +(define-function client_error_handling_mode_get_type + (c-name "gconf_client_error_handling_mode_get_type") + (return-type "GType") +) + +(define-function error_quark + (c-name "gconf_error_quark") + (return-type "GQuark") +) + +(define-function listeners_new + (is-constructor-of "GConfListeners") + (c-name "gconf_listeners_new") + (caller-owns-return #t) + (return-type "GConfListeners*") +) + +(define-method free + (of-object "GConfListeners") + (c-name "gconf_listeners_free") + (return-type "none") +) + +(define-method add + (of-object "GConfListeners") + (c-name "gconf_listeners_add") + (return-type "guint") + (parameters + '("const-gchar*" "listen_point") + '("gpointer" "listener_data") + '("GFreeFunc" "destroy_notify") + ) +) + +(define-method remove + (of-object "GConfListeners") + (c-name "gconf_listeners_remove") + (return-type "none") + (parameters + '("guint" "cnxn_id") + ) +) + +(define-method notify + (of-object "GConfListeners") + (c-name "gconf_listeners_notify") + (return-type "none") + (parameters + '("const-gchar*" "all_above") + '("GConfListenersCallback" "callback") + '("gpointer" "user_data") + ) +) + +(define-method count + (of-object "GConfListeners") + (c-name "gconf_listeners_count") + (return-type "guint") +) + +(define-method foreach + (of-object "GConfListeners") + (c-name "gconf_listeners_foreach") + (return-type "none") + (parameters + '("GConfListenersForeach" "callback") + '("gpointer" "user_data") + ) +) + +(define-method get_data + (of-object "GConfListeners") + (c-name "gconf_listeners_get_data") + (return-type "gboolean") + (parameters + '("guint" "cnxn_id") + '("gpointer*" "listener_data_p") + '("const-gchar**" "location_p") + ) +) + +(define-method remove_if + (of-object "GConfListeners") + (c-name "gconf_listeners_remove_if") + (return-type "none") + (parameters + '("GConfListenersPredicate" "predicate") + '("gpointer" "user_data") + ) +) + +(define-function schema_new + (is-constructor-of "GConfSchema") + (c-name "gconf_schema_new") + (caller-owns-return #t) + (return-type "GConfSchema*") +) + +(define-method free + (of-object "GConfSchema") + (c-name "gconf_schema_free") + (return-type "none") +) + +(define-method copy + (of-object "GConfSchema") + (c-name "gconf_schema_copy") + (return-type "GConfSchema*") +) + +(define-method set_type + (of-object "GConfSchema") + (c-name "gconf_schema_set_type") + (return-type "none") + (parameters + '("GConfValueType" "type") + ) +) + +(define-method set_list_type + (of-object "GConfSchema") + (c-name "gconf_schema_set_list_type") + (return-type "none") + (parameters + '("GConfValueType" "type") + ) +) + +(define-method set_car_type + (of-object "GConfSchema") + (c-name "gconf_schema_set_car_type") + (return-type "none") + (parameters + '("GConfValueType" "type") + ) +) + +(define-method set_cdr_type + (of-object "GConfSchema") + (c-name "gconf_schema_set_cdr_type") + (return-type "none") + (parameters + '("GConfValueType" "type") + ) +) + +(define-method set_locale + (of-object "GConfSchema") + (c-name "gconf_schema_set_locale") + (return-type "none") + (parameters + '("const-gchar*" "locale") + ) +) + +(define-method set_short_desc + (of-object "GConfSchema") + (c-name "gconf_schema_set_short_desc") + (return-type "none") + (parameters + '("const-gchar*" "desc") + ) +) + +(define-method set_long_desc + (of-object "GConfSchema") + (c-name "gconf_schema_set_long_desc") + (return-type "none") + (parameters + '("const-gchar*" "desc") + ) +) + +(define-method set_owner + (of-object "GConfSchema") + (c-name "gconf_schema_set_owner") + (return-type "none") + (parameters + '("const-gchar*" "owner") + ) +) + +(define-method set_default_value + (of-object "GConfSchema") + (c-name "gconf_schema_set_default_value") + (return-type "none") + (parameters + '("const-GConfValue*" "val") + ) +) + +(define-method set_default_value_nocopy + (of-object "GConfSchema") + (c-name "gconf_schema_set_default_value_nocopy") + (return-type "none") + (parameters + '("GConfValue*" "val") + ) +) + +(define-method get_type + (of-object "GConfSchema") + (c-name "gconf_schema_get_type") + (return-type "GConfValueType") +) + +(define-method get_list_type + (of-object "GConfSchema") + (c-name "gconf_schema_get_list_type") + (return-type "GConfValueType") +) + +(define-method get_car_type + (of-object "GConfSchema") + (c-name "gconf_schema_get_car_type") + (return-type "GConfValueType") +) + +(define-method get_cdr_type + (of-object "GConfSchema") + (c-name "gconf_schema_get_cdr_type") + (return-type "GConfValueType") +) + +(define-method get_locale + (of-object "GConfSchema") + (c-name "gconf_schema_get_locale") + (return-type "const-char*") +) + +(define-method get_short_desc + (of-object "GConfSchema") + (c-name "gconf_schema_get_short_desc") + (return-type "const-char*") +) + +(define-method get_long_desc + (of-object "GConfSchema") + (c-name "gconf_schema_get_long_desc") + (return-type "const-char*") +) + +(define-method get_owner + (of-object "GConfSchema") + (c-name "gconf_schema_get_owner") + (return-type "const-char*") +) + +(define-method get_default_value + (of-object "GConfSchema") + (c-name "gconf_schema_get_default_value") + (return-type "GConfValue*") +) + +(define-method get_string + (of-object "GConfValue") + (c-name "gconf_value_get_string") + (return-type "const-char*") +) + +(define-method get_int + (of-object "GConfValue") + (c-name "gconf_value_get_int") + (return-type "int") +) + +(define-method get_float + (of-object "GConfValue") + (c-name "gconf_value_get_float") + (return-type "double") +) + +(define-method get_list_type + (of-object "GConfValue") + (c-name "gconf_value_get_list_type") + (return-type "GConfValueType") +) + +(define-method get_list + (of-object "GConfValue") + (c-name "gconf_value_get_list") + (return-type "GSList*") +) + +(define-method get_car + (of-object "GConfValue") + (c-name "gconf_value_get_car") + (return-type "GConfValue*") +) + +(define-method get_cdr + (of-object "GConfValue") + (c-name "gconf_value_get_cdr") + (return-type "GConfValue*") +) + +(define-method get_bool + (of-object "GConfValue") + (c-name "gconf_value_get_bool") + (return-type "gboolean") +) + +(define-method get_schema + (of-object "GConfValue") + (c-name "gconf_value_get_schema") + (return-type "GConfSchema*") +) + +(define-function value_new + (is-constructor-of "GConfValue") + (c-name "gconf_value_new") + (caller-owns-return #t) + (return-type "GConfValue*") + (parameters + '("GConfValueType" "type") + ) +) + +(define-function value_new_from_string + (c-name "gconf_value_new_from_string") + (return-type "GConfValue*") + (parameters + '("GConfValueType" "type") + '("const-gchar*" "str") + '("GError**" "err") + ) +) + +(define-method copy + (of-object "GConfValue") + (c-name "gconf_value_copy") + (return-type "GConfValue*") +) + +(define-method free + (of-object "GConfValue") + (c-name "gconf_value_free") + (return-type "none") +) + +(define-method set_int + (of-object "GConfValue") + (c-name "gconf_value_set_int") + (return-type "none") + (parameters + '("gint" "the_int") + ) +) + +(define-method set_string + (of-object "GConfValue") + (c-name "gconf_value_set_string") + (return-type "none") + (parameters + '("const-gchar*" "the_str") + ) +) + +(define-method set_float + (of-object "GConfValue") + (c-name "gconf_value_set_float") + (return-type "none") + (parameters + '("gdouble" "the_float") + ) +) + +(define-method set_bool + (of-object "GConfValue") + (c-name "gconf_value_set_bool") + (return-type "none") + (parameters + '("gboolean" "the_bool") + ) +) + +(define-method set_schema + (of-object "GConfValue") + (c-name "gconf_value_set_schema") + (return-type "none") + (parameters + '("const-GConfSchema*" "sc") + ) +) + +(define-method set_schema_nocopy + (of-object "GConfValue") + (c-name "gconf_value_set_schema_nocopy") + (return-type "none") + (parameters + '("GConfSchema*" "sc") + ) +) + +(define-method set_car + (of-object "GConfValue") + (c-name "gconf_value_set_car") + (return-type "none") + (parameters + '("const-GConfValue*" "car") + ) +) + +(define-method set_car_nocopy + (of-object "GConfValue") + (c-name "gconf_value_set_car_nocopy") + (return-type "none") + (parameters + '("GConfValue*" "car") + ) +) + +(define-method set_cdr + (of-object "GConfValue") + (c-name "gconf_value_set_cdr") + (return-type "none") + (parameters + '("const-GConfValue*" "cdr") + ) +) + +(define-method set_cdr_nocopy + (of-object "GConfValue") + (c-name "gconf_value_set_cdr_nocopy") + (return-type "none") + (parameters + '("GConfValue*" "cdr") + ) +) + +(define-method set_list_type + (of-object "GConfValue") + (c-name "gconf_value_set_list_type") + (return-type "none") + (parameters + '("GConfValueType" "type") + ) +) + +(define-method set_list_nocopy + (of-object "GConfValue") + (c-name "gconf_value_set_list_nocopy") + (return-type "none") + (parameters + '("GSList*" "list") + ) +) + +(define-method set_list + (of-object "GConfValue") + (c-name "gconf_value_set_list") + (return-type "none") + (parameters + '("GSList*" "list") + ) +) + +(define-method to_string + (of-object "GConfValue") + (c-name "gconf_value_to_string") + (caller-owns-return #t) + (return-type "gchar*") +) + +(define-method get_schema + (of-object "GConfMetaInfo") + (c-name "gconf_meta_info_get_schema") + (return-type "const-char*") +) + +(define-method get_mod_user + (of-object "GConfMetaInfo") + (c-name "gconf_meta_info_get_mod_user") + (return-type "const-char*") +) + +(define-method mod_time + (of-object "GConfMetaInfo") + (c-name "gconf_meta_info_mod_time") + (return-type "GTime") +) + +(define-function meta_info_new + (is-constructor-of "GConfMetaInfo") + (c-name "gconf_meta_info_new") + (caller-owns-return #t) + (return-type "GConfMetaInfo*") +) + +(define-method free + (of-object "GConfMetaInfo") + (c-name "gconf_meta_info_free") + (return-type "none") +) + +(define-method set_schema + (of-object "GConfMetaInfo") + (c-name "gconf_meta_info_set_schema") + (return-type "none") + (parameters + '("const-gchar*" "schema_name") + ) +) + +(define-method set_mod_user + (of-object "GConfMetaInfo") + (c-name "gconf_meta_info_set_mod_user") + (return-type "none") + (parameters + '("const-gchar*" "mod_user") + ) +) + +(define-method set_mod_time + (of-object "GConfMetaInfo") + (c-name "gconf_meta_info_set_mod_time") + (return-type "none") + (parameters + '("GTime" "mod_time") + ) +) + +(define-method get_key + (of-object "GConfEntry") + (c-name "gconf_entry_get_key") + (return-type "const-char*") +) + +(define-method get_value + (of-object "GConfEntry") + (c-name "gconf_entry_get_value") + (return-type "GConfValue*") +) + +(define-method get_schema_name + (of-object "GConfEntry") + (c-name "gconf_entry_get_schema_name") + (return-type "const-char*") +) + +(define-method get_is_default + (of-object "GConfEntry") + (c-name "gconf_entry_get_is_default") + (return-type "gboolean") +) + +(define-method get_is_writable + (of-object "GConfEntry") + (c-name "gconf_entry_get_is_writable") + (return-type "gboolean") +) + +(define-function entry_new + (is-constructor-of "GConfEntry") + (c-name "gconf_entry_new") + (caller-owns-return #t) + (return-type "GConfEntry*") + (parameters + '("const-gchar*" "key") + '("const-GConfValue*" "val") + ) +) + +(define-function entry_new_nocopy + (c-name "gconf_entry_new_nocopy") + (return-type "GConfEntry*") + (parameters + '("gchar*" "key") + '("GConfValue*" "val") + ) +) + +(define-method copy + (of-object "GConfEntry") + (c-name "gconf_entry_copy") + (return-type "GConfEntry*") +) + +(define-method free + (of-object "GConfEntry") + (c-name "gconf_entry_free") + (return-type "none") +) + +(define-method ref + (of-object "GConfEntry") + (c-name "gconf_entry_ref") + (return-type "none") +) + +(define-method unref + (of-object "GConfEntry") + (c-name "gconf_entry_unref") + (return-type "none") +) + +(define-method steal_value + (of-object "GConfEntry") + (c-name "gconf_entry_steal_value") + (return-type "GConfValue*") +) + +(define-method set_value + (of-object "GConfEntry") + (c-name "gconf_entry_set_value") + (return-type "none") + (parameters + '("const-GConfValue*" "val") + ) +) + +(define-method set_value_nocopy + (of-object "GConfEntry") + (c-name "gconf_entry_set_value_nocopy") + (return-type "none") + (parameters + '("GConfValue*" "val") + ) +) + +(define-method set_schema_name + (of-object "GConfEntry") + (c-name "gconf_entry_set_schema_name") + (return-type "none") + (parameters + '("const-gchar*" "name") + ) +) + +(define-method set_is_default + (of-object "GConfEntry") + (c-name "gconf_entry_set_is_default") + (return-type "none") + (parameters + '("gboolean" "is_default") + ) +) + +(define-method set_is_writable + (of-object "GConfEntry") + (c-name "gconf_entry_set_is_writable") + (return-type "none") + (parameters + '("gboolean" "is_writable") + ) +) + +(define-method notify_add + (of-object "GConfEngine") + (c-name "gconf_engine_notify_add") + (return-type "guint") + (parameters + '("const-gchar*" "namespace_section") + '("GConfNotifyFunc" "func") + '("gpointer" "user_data") + '("GError**" "err") + ) +) + +(define-method notify_remove + (of-object "GConfEngine") + (c-name "gconf_engine_notify_remove") + (return-type "none") + (parameters + '("guint" "cnxn") + ) +) + +(define-method get + (of-object "GConfEngine") + (c-name "gconf_engine_get") + (return-type "GConfValue*") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_without_default + (of-object "GConfEngine") + (c-name "gconf_engine_get_without_default") + (caller-owns-return #t) + (return-type "GConfValue*") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_entry + (of-object "GConfEngine") + (c-name "gconf_engine_get_entry") + (caller-owns-return #t) + (return-type "GConfEntry*") + (parameters + '("const-gchar*" "key") + '("const-gchar*" "locale") + '("gboolean" "use_schema_default") + '("GError**" "err") + ) +) + +(define-method get_with_locale + (of-object "GConfEngine") + (c-name "gconf_engine_get_with_locale") + (caller-owns-return #t) + (return-type "GConfValue*") + (parameters + '("const-gchar*" "key") + '("const-gchar*" "locale") + '("GError**" "err") + ) +) + +(define-method get_default_from_schema + (of-object "GConfEngine") + (c-name "gconf_engine_get_default_from_schema") + (caller-owns-return #t) + (return-type "GConfValue*") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method set + (of-object "GConfEngine") + (c-name "gconf_engine_set") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("const-GConfValue*" "value") + '("GError**" "err") + ) +) + +(define-method unset + (of-object "GConfEngine") + (c-name "gconf_engine_unset") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method associate_schema + (of-object "GConfEngine") + (c-name "gconf_engine_associate_schema") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("const-gchar*" "schema_key") + '("GError**" "err") + ) +) + +(define-method all_entries + (of-object "GConfEngine") + (c-name "gconf_engine_all_entries") + (return-type "GSList*") + (parameters + '("const-gchar*" "dir") + '("GError**" "err") + ) +) + +(define-method all_dirs + (of-object "GConfEngine") + (c-name "gconf_engine_all_dirs") + (return-type "GSList*") + (parameters + '("const-gchar*" "dir") + '("GError**" "err") + ) +) + +(define-method suggest_sync + (of-object "GConfEngine") + (c-name "gconf_engine_suggest_sync") + (return-type "none") + (parameters + '("GError**" "err") + ) +) + +(define-method dir_exists + (of-object "GConfEngine") + (c-name "gconf_engine_dir_exists") + (return-type "gboolean") + (parameters + '("const-gchar*" "dir") + '("GError**" "err") + ) +) + +(define-method remove_dir + (of-object "GConfEngine") + (c-name "gconf_engine_remove_dir") + (return-type "none") + (parameters + '("const-gchar*" "dir") + '("GError**" "err") + ) +) + +(define-method key_is_writable + (of-object "GConfEngine") + (c-name "gconf_engine_key_is_writable") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-function valid_key + (c-name "gconf_valid_key") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("gchar**" "why_invalid") + ) +) + +(define-function key_is_below + (c-name "gconf_key_is_below") + (return-type "gboolean") + (parameters + '("const-gchar*" "above") + '("const-gchar*" "below") + ) +) + +(define-function concat_dir_and_key + (c-name "gconf_concat_dir_and_key") + (caller-owns-return #t) + (return-type "gchar*") + (parameters + '("const-gchar*" "dir") + '("const-gchar*" "key") + ) +) + +(define-function unique_key + (c-name "gconf_unique_key") + (caller-owns-return #t) + (return-type "gchar*") +) + +(define-function escape_key + (c-name "gconf_escape_key") + (caller-owns-return #t) + (return-type "char*") + (parameters + '("const-char*" "arbitrary_text") + '("int" "len") + ) +) + +(define-function unescape_key + (c-name "gconf_unescape_key") + (caller-owns-return #t) + (return-type "char*") + (parameters + '("const-char*" "escaped_key") + '("int" "len") + ) +) + +(define-method get_float + (of-object "GConfEngine") + (c-name "gconf_engine_get_float") + (return-type "gdouble") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_int + (of-object "GConfEngine") + (c-name "gconf_engine_get_int") + (return-type "gint") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_string + (of-object "GConfEngine") + (c-name "gconf_engine_get_string") + (caller-owns-return #t) + (return-type "gchar*") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_bool + (of-object "GConfEngine") + (c-name "gconf_engine_get_bool") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_schema + (of-object "GConfEngine") + (c-name "gconf_engine_get_schema") + (caller-owns-return #t) + (return-type "GConfSchema*") + (parameters + '("const-gchar*" "key") + '("GError**" "err") + ) +) + +(define-method get_list + (of-object "GConfEngine") + (c-name "gconf_engine_get_list") + (caller-owns-return #t) + (return-type "GSList*") + (parameters + '("const-gchar*" "key") + '("GConfValueType" "list_type") + '("GError**" "err") + ) +) + +(define-method get_pair + (of-object "GConfEngine") + (c-name "gconf_engine_get_pair") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GConfValueType" "car_type") + '("GConfValueType" "cdr_type") + '("gpointer" "car_retloc") + '("gpointer" "cdr_retloc") + '("GError**" "err") + ) +) + +(define-method set_float + (of-object "GConfEngine") + (c-name "gconf_engine_set_float") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("gdouble" "val") + '("GError**" "err") + ) +) + +(define-method set_int + (of-object "GConfEngine") + (c-name "gconf_engine_set_int") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("gint" "val") + '("GError**" "err") + ) +) + +(define-method set_string + (of-object "GConfEngine") + (c-name "gconf_engine_set_string") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("const-gchar*" "val") + '("GError**" "err") + ) +) + +(define-method set_bool + (of-object "GConfEngine") + (c-name "gconf_engine_set_bool") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("gboolean" "val") + '("GError**" "err") + ) +) + +(define-method set_schema + (of-object "GConfEngine") + (c-name "gconf_engine_set_schema") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("const-GConfSchema*" "val") + '("GError**" "err") + ) +) + +(define-method set_list + (of-object "GConfEngine") + (c-name "gconf_engine_set_list") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GConfValueType" "list_type") + '("GSList*" "list") + '("GError**" "err") + ) +) + +(define-method set_pair + (of-object "GConfEngine") + (c-name "gconf_engine_set_pair") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GConfValueType" "car_type") + '("GConfValueType" "cdr_type") + '("gconstpointer" "address_of_car") + '("gconstpointer" "address_of_cdr") + '("GError**" "err") + ) +) + +(define-function string_to_enum + (c-name "gconf_string_to_enum") + (return-type "gboolean") + (parameters + '("GConfEnumStringPair[]" "lookup_table") + '("const-gchar*" "str") + '("gint*" "enum_value_retloc") + ) +) + +(define-function enum_to_string + (c-name "gconf_enum_to_string") + (return-type "const-gchar*") + (parameters + '("GConfEnumStringPair[]" "lookup_table") + '("gint" "enum_value") + ) +) + +(define-function debug_shutdown + (c-name "gconf_debug_shutdown") + (return-type "int") +) + +(define-function init + (c-name "gconf_init") + (return-type "gboolean") + (parameters + '("int" "argc") + '("char**" "argv") + '("GError**" "err") + ) +) + +(define-function is_initialized + (c-name "gconf_is_initialized") + (return-type "gboolean") +) + +(define-function preinit + (c-name "gconf_preinit") + (return-type "none") + (parameters + '("gpointer" "app") + '("gpointer" "mod_info") + ) +) + +(define-function postinit + (c-name "gconf_postinit") + (return-type "none") + (parameters + '("gpointer" "app") + '("gpointer" "mod_info") + ) +) + +(define-method get_full + (of-object "GConfEngine") + (c-name "gconf_engine_get_full") + (return-type "GConfValue*") + (parameters + '("const-gchar*" "key") + '("const-gchar*" "locale") + '("gboolean" "use_schema_default") + '("gboolean*" "is_default_p") + '("gboolean*" "is_writable_p") + '("GError**" "err") + ) +) + diff --git a/util/gconf/gconf.override b/util/gconf/gconf.override new file mode 100644 index 00000000..337653d6 --- /dev/null +++ b/util/gconf/gconf.override @@ -0,0 +1,920 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- */ +%% +headers +#include <Python.h> + +#include "gconf-fixes.h" +#include "gconf-types.h" + +#define NO_IMPORT_PYGOBJECT +#include "pygobject.h" +#include <glib.h> +#include <gconf/gconf-client.h> +#include <gconf/gconf-enum-types.h> +#include "config.h" + +static gpointer pygconf_parse_pygvalue(GConfValueType gvalue_type, + PyObject *pyvalue); +%% +modulename gconf +%% +import gobject.GObject as PyGObject_Type +%% +ignore-glob + _* + gconf_*init +%% +ignore + gconf_change_set_get_type + gconf_client_get_type + gconf_value_type_get_type + gconf_error_get_type + gconf_client_preload_type_get_type + gconf_client_error_handling_mode_get_type + gconf_value_set_car_nocopy + gconf_value_set_cdr_nocopy + gconf_client_change_set_from_currentv + gconf_value_set_list_nocopy + +%% +override-slot GConfClient.tp_init + +static int +_wrap_gconf_client_tp_init(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { NULL }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, ":gconf.Client.__init__", kwlist)) { + return -1; + } + self->obj = (GObject *) gconf_client_get_default(); + pygobject_register_wrapper((PyObject *)self); + return 0; +} + +%% +override gconf_client_notify_add kwargs +void +pygconf_client_notify_add(GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + gpointer user_data) +{ + PyObject *func; + PyObject *userdata = NULL; + PyObject *ret; + PyObject *tuple = (PyObject*)user_data; + PyGILState_STATE state; + + state = pyg_gil_state_ensure(); + + g_assert(PyTuple_Check(tuple)); + func = PyTuple_GetItem(tuple, 0); + userdata = PyTuple_GetItem(tuple, 1); + + if (!userdata) { + ret = PyObject_CallFunction(func, "NNN", + pygobject_new((GObject *)client), + PyLong_FromUnsignedLong(cnxn_id), + pyg_boxed_new(GCONF_TYPE_ENTRY, + entry, + TRUE, TRUE)); + } else { + ret = PyObject_CallFunction(func, "NNNO", + pygobject_new((GObject *)client), + PyLong_FromUnsignedLong(cnxn_id), + pyg_boxed_new(GCONF_TYPE_ENTRY, + entry, + TRUE, TRUE), + userdata); + } + + if (ret == NULL) + PyErr_Print(); + else + Py_DECREF(ret); + + pyg_gil_state_release(state); +} + +static PyObject * +_wrap_gconf_client_notify_add(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "namespace_section", "func", + "user_data", NULL }; + gchar *namespace_section; + PyObject *callback; + PyObject *extra = NULL; + PyObject *data; + guint retval; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "sO|O:GConfClient.notify_ad", + kwlist, &namespace_section, + &callback, &extra)) { + return NULL; + } + + if (!PyCallable_Check(callback)) { + PyErr_SetString(PyExc_TypeError, "second arg not callable"); + return NULL; + } + + if (extra) { + Py_INCREF(extra); + } else { + extra = PyTuple_New(0); + } + + data = Py_BuildValue("(ON)", callback, extra); + + retval = gconf_client_notify_add(GCONF_CLIENT(self->obj), + namespace_section, + pygconf_client_notify_add, + data, + (GFreeFunc)pyg_destroy_notify, + NULL); + + return PyLong_FromUnsignedLong((unsigned long) retval); +} + +%% +override gconf_client_all_entries args +static PyObject * +_wrap_gconf_client_all_entries(PyGObject *self, PyObject *args) +{ + gchar *path; + GError *err = NULL; + GSList *values; + GSList *list; + PyObject *pylist; + int i = 0; + + if (!PyArg_ParseTuple(args, "s:GConfClient.all_entries", &path)) { + return NULL; + } + + values = gconf_client_all_entries(GCONF_CLIENT(self->obj), path, &err); + if (pyg_error_check(&err)) { + return NULL; + } + + pylist = PyTuple_New(g_slist_length(values)); + for (list = values; list; list = list->next) { + GConfEntry *entry = list->data; + PyObject *pyentry = pyg_boxed_new(GCONF_TYPE_ENTRY, entry, + FALSE, TRUE); + PyTuple_SetItem(pylist, i++, pyentry); + } + + return pylist; +} + +%% +override gconf_client_all_dirs args +static PyObject * +_wrap_gconf_client_all_dirs(PyGObject *self, PyObject *args) +{ + gchar *path; + GError *err = NULL; + GSList *values; + GSList *list; + PyObject *pylist; + int i = 0; + + if (!PyArg_ParseTuple(args, "s:GConfClient.all_dirs", &path)) { + return NULL; + } + + values = gconf_client_all_dirs(GCONF_CLIENT(self->obj), path, &err); + if (pyg_error_check(&err)) { + return NULL; + } + + pylist = PyTuple_New(g_slist_length(values)); + for (list = values; list; list = list->next) { + PyObject *pystring = PyString_FromString(list->data); + + PyTuple_SetItem(pylist, i++, pystring); + } + + return pylist; +} + +%% +override gconf_client_get_pair kwargs +/* Return a proper PyObject for retloc based on its type. */ +static PyObject * +pygconf_parse_gvalue(GConfValueType gvalue_type, gpointer retloc) +{ + PyObject *retval; + switch(gvalue_type) { + case GCONF_VALUE_INT: + case GCONF_VALUE_BOOL: + retval = PyInt_FromLong(*(gint*)retloc); + break; + case GCONF_VALUE_FLOAT: + retval = PyFloat_FromDouble(*(gdouble*)retloc); + break; + case GCONF_VALUE_STRING: + { + gchar **s = (gchar **) retloc; + if (*s) + retval = PyString_FromString(*s); + else { + Py_INCREF(Py_None); + return Py_None; + } + break; + } + case GCONF_VALUE_SCHEMA: + retval = pyg_boxed_new(GCONF_TYPE_SCHEMA, *(GConfSchema**)retloc, + TRUE, TRUE); + break; + default: + PyErr_SetString(PyExc_TypeError, "Unknown GConfValueType."); + retval = NULL; + break; + } + return retval; +} + +/* Get the value of a PyObject from its type. */ +/* g_new0() on returned pointer, need to free it. */ +static gpointer +pygconf_parse_pygvalue(GConfValueType gvalue_type, PyObject *pyvalue) +{ + gpointer retval; + retval = g_new0(gpointer, 1); + switch(gvalue_type) { + case GCONF_VALUE_INT: + case GCONF_VALUE_BOOL: + *(gint*)retval = (gint) PyInt_AsLong(pyvalue); + break; + case GCONF_VALUE_FLOAT: + *(gdouble*)retval = PyFloat_AsDouble(pyvalue); + break; + case GCONF_VALUE_STRING: + *(gchar**)retval = PyString_AsString(pyvalue); + break; + case GCONF_VALUE_SCHEMA: + if (pyg_boxed_check(pyvalue, GCONF_TYPE_SCHEMA)) { + *(GConfSchema**)retval = pyg_boxed_get(pyvalue, GConfSchema); + } else { + PyErr_SetString(PyExc_TypeError, + "value should be a GConfSchema"); + free(retval); + retval = NULL; + } + break; + default: + PyErr_SetString(PyExc_TypeError, "Unknown GConfValueType."); + free(retval); + retval = NULL; + break; + } + return retval; +} + +static gpointer +pygconf_new_type(GConfValueType t) +{ + gpointer retval; + switch(t) { + case GCONF_VALUE_INT: + case GCONF_VALUE_BOOL: + retval = g_new0(gint, 1); + break; + case GCONF_VALUE_FLOAT: + retval = g_new0(gdouble, 1); + break; + case GCONF_VALUE_STRING: + retval = g_new0(gchar, 1); + break; + case GCONF_VALUE_SCHEMA: + retval = gconf_schema_new(); + break; + default: + PyErr_SetString(PyExc_TypeError, "Unknown GConfValueType."); + retval = NULL; + break; + } + return retval; +} + +static PyObject * +_wrap_gconf_client_get_pair(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "key", "car_type", "cdr_type", NULL }; + char *key; + PyObject *pycar_type = NULL, *pycdr_type = NULL; + PyObject *retcar = NULL, *retcdr = NULL; + GConfValueType car_type, cdr_type; + gpointer car_retloc = NULL; + gpointer cdr_retloc = NULL; + int ret; + + GError *err = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sOO:GConfClient.get_pair", + kwlist, &key, &pycar_type, &pycdr_type)) + return NULL; + + if (pyg_enum_get_value(GCONF_TYPE_VALUE_TYPE, + pycar_type, (gint *)&car_type)) + return NULL; + if (pyg_enum_get_value(GCONF_TYPE_VALUE_TYPE, + pycdr_type, (gint *)&cdr_type)) + return NULL; + + car_retloc = pygconf_new_type(car_type); + if (!car_retloc) + return NULL; + cdr_retloc = pygconf_new_type(cdr_type); + if (!cdr_retloc) { + if(car_type == GCONF_VALUE_SCHEMA) + gconf_schema_free(car_retloc); + else + g_free(car_retloc); + return NULL; + } + + ret = gconf_client_get_pair(GCONF_CLIENT(self->obj), key, car_type, + cdr_type, car_retloc, cdr_retloc, &err); + if (pyg_error_check(&err)) + return NULL; + retcar = pygconf_parse_gvalue(car_type, car_retloc); + retcdr = pygconf_parse_gvalue(cdr_type, cdr_retloc); + + if (car_type != GCONF_VALUE_SCHEMA) + g_free(car_retloc); + /* FIXME: gconf_schema_free(car_retloc)? */ + else + gconf_schema_free(car_retloc); + + if (cdr_type != GCONF_VALUE_SCHEMA) + g_free(cdr_retloc); + else + gconf_schema_free(cdr_retloc); + + if (!retcar || !retcdr) + return NULL; + return Py_BuildValue("(NN)", retcar, retcdr); +} + +%% +override gconf_client_set_pair kwargs +static PyObject * +_wrap_gconf_client_set_pair(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "key", "car_type", "cdr_type", + "car", "cdr", NULL }; + char *key; + PyObject *pycar_type = NULL, *pycdr_type = NULL; + PyObject *pycar = NULL, *pycdr = NULL; + + GConfValueType car_type, cdr_type; + gpointer car, cdr; + int ret; + GError *err = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "sOOOO:GConfClient.set_pair", + kwlist, &key, &pycar_type, &pycdr_type, + &pycar, &pycdr)) + return NULL; + + if (pyg_enum_get_value(GCONF_TYPE_VALUE_TYPE, + pycar_type, (gint *)&car_type)) + return NULL; + if (pyg_enum_get_value(GCONF_TYPE_VALUE_TYPE, + pycdr_type, (gint *)&cdr_type)) + return NULL; + car = pygconf_parse_pygvalue(car_type, pycar); + if (!car) + return NULL; + cdr = pygconf_parse_pygvalue(cdr_type, pycdr); + if (!cdr) { + g_free(car); + return NULL; + } + + + ret = gconf_client_set_pair(GCONF_CLIENT(self->obj), + key, car_type, cdr_type, + car, cdr, &err); + + g_free(car); + g_free(cdr); + + if (pyg_error_check(&err)) + return NULL; + return PyInt_FromLong(ret); +} + +%% +override gconf_client_get_list kwargs + static PyObject * +pygconf_parse_listvalue(GConfValueType gvalue_type, gpointer retloc) +{ + PyObject *retval; + switch(gvalue_type) { + case GCONF_VALUE_INT: + case GCONF_VALUE_BOOL: + retval = PyInt_FromLong(GPOINTER_TO_INT(retloc)); + break; + case GCONF_VALUE_FLOAT: + retval = PyFloat_FromDouble(*(gdouble*)retloc); + break; + case GCONF_VALUE_STRING: + retval = PyString_FromString((gchar*)retloc); + break; + case GCONF_VALUE_SCHEMA: + retval = pyg_boxed_new(GCONF_TYPE_SCHEMA, (GConfSchema*)retloc, + TRUE, TRUE); + break; + default: + /* Should not reach here. get_list should always valid. */ + PyErr_SetString(PyExc_TypeError, "Unknown GConfValueType."); + retval = NULL; + break; + } + return retval; +} + +static PyObject * +_wrap_gconf_client_get_list(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "key", "list_type", NULL }; + char *key; + PyObject *py_type = NULL; + PyObject *py_list = NULL; + GConfValueType lstype; + GSList *retlist, *ilist; + gpointer data; + int lslen, i; + + GError *err = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO:GConfClient.get_list", + kwlist, &key, &py_type)) + return NULL; + + if (pyg_enum_get_value(GCONF_TYPE_VALUE_TYPE, py_type, (gint *)&lstype)) + return NULL; + + retlist = gconf_client_get_list(GCONF_CLIENT(self->obj), key, + lstype, &err); + if (pyg_error_check(&err)) { + return NULL; + } else if (retlist == NULL) { + return PyList_New(0); + } + + lslen = g_slist_length(retlist); + i = 0; + py_list = PyList_New(lslen); + for (ilist = retlist; ilist; ilist = ilist->next) { + PyObject *py_data; + data = ilist->data; + py_data = pygconf_parse_listvalue(lstype, data); + if (!py_data) { + g_slist_free(retlist); + return NULL; + } + PyList_SetItem(py_list, i, py_data); + i++; + if (lstype == GCONF_VALUE_SCHEMA) + gconf_schema_free(data); + else if(lstype == GCONF_VALUE_FLOAT || lstype == GCONF_VALUE_STRING) + g_free(data); + } + g_slist_free(retlist); + return py_list; +} + +%% +override gconf_client_set_list kwargs +static PyObject * +_wrap_gconf_client_set_list(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "key", "list_type", "list", NULL }; + char *key; + PyObject *py_type = NULL; + PyObject *py_list = NULL; + GSList *clist = NULL; + GSList *tmplist, *pointlist=NULL; + GConfValueType list_type; + int ret, i; + int retdata; /* Error flag. */ + GError *err = NULL; + + ret = 1; + retdata = 1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sOO:GConfClient.set_list", + kwlist, &key, &py_type, &py_list)) + return NULL; + if (!PyTuple_Check(py_list) && !PyList_Check(py_list)) { + PyErr_SetString(PyExc_TypeError, + "3rd argument should be a sequence type."); + return NULL; + } + + if (pyg_enum_get_value(GCONF_TYPE_VALUE_TYPE, py_type, (gint *)&list_type)) + return NULL; + + for (i = 0; i < PySequence_Size(py_list) && retdata; i++) { + gpointer data; + data = pygconf_parse_pygvalue(list_type, + PySequence_GetItem(py_list, i)); + if (data == NULL) { + retdata = 0; + break; + } + /* What to free the list later. */ + pointlist = g_slist_append(pointlist, data); + switch(list_type){ + case GCONF_VALUE_INT: + case GCONF_VALUE_BOOL: + clist = g_slist_append(clist, GINT_TO_POINTER(*(gint*)data)); + break; + case GCONF_VALUE_FLOAT: + clist = g_slist_append(clist, (gdouble*)data); + break; + case GCONF_VALUE_STRING: + clist = g_slist_append(clist, *(gchar**)data); + break; + case GCONF_VALUE_SCHEMA: + clist = g_slist_append(clist, *(GConfSchema**)data); + break; + default: + PyErr_SetString(PyExc_TypeError, "Unknown GConfValueType."); + retdata = 0; + break; + } + } + + if (retdata) + ret = gconf_client_set_list(GCONF_CLIENT(self->obj), key, list_type, + clist, &err); + + for (tmplist = pointlist; tmplist; tmplist = tmplist->next) { + g_free(tmplist->data); + } + g_slist_free(pointlist); + g_slist_free(clist); + + if (pyg_error_check(&err) || !retdata) + return NULL; + return PyInt_FromLong(ret); +} + +%% +override gconf_value_get_car args +static PyObject * +_wrap_gconf_value_get_car(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + GConfValue* vobj; + + vobj = gconf_value_get_car(pyg_boxed_get(self, GConfValue)); + return pyg_boxed_new(GCONF_TYPE_VALUE, vobj, TRUE, TRUE); +} + +%% +override gconf_value_get_cdr args +static PyObject * +_wrap_gconf_value_get_cdr(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + GConfValue* vobj; + + vobj = gconf_value_get_cdr(pyg_boxed_get(self, GConfValue)); + return pyg_boxed_new(GCONF_TYPE_VALUE, vobj, TRUE, TRUE); +} +%% +override gconf_value_get_list args +static PyObject * +_wrap_gconf_value_get_list(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + GConfValue *value; + PyObject *pylist; + GSList *values = NULL, *list; + int i = 0; + + value = pyg_boxed_get(self, GConfValue); + if (value->type != GCONF_VALUE_LIST) { + PyErr_SetString(PyExc_TypeError, "gconf value does not contain a list."); + return NULL; + } + values = gconf_value_get_list(value); + + pylist = PyTuple_New(g_slist_length(values)); + for (list = values; list; list = list->next) { + PyObject *pyvalue; + value = list->data; + pyvalue = pyg_boxed_new(GCONF_TYPE_VALUE, value, TRUE, TRUE); + + PyTuple_SetItem(pylist, i++, pyvalue); + } + + return pylist; +} +%% +override gconf_value_get_int noargs +static PyObject * +_wrap_gconf_value_get_int(PyObject *self) +{ + int ret; + GConfValue *value; + + value = pyg_boxed_get(self, GConfValue); + if (value->type != GCONF_VALUE_INT) { + PyErr_SetString(PyExc_TypeError, "gconf value does not contain an integer."); + return NULL; + } + ret = gconf_value_get_int(value); + return PyInt_FromLong(ret); +} +%% +override gconf_value_get_string noargs +static PyObject * +_wrap_gconf_value_get_string(PyObject *self) +{ + const gchar *ret; + GConfValue *value; + + value = pyg_boxed_get(self, GConfValue); + if (value->type != GCONF_VALUE_STRING) { + PyErr_SetString(PyExc_TypeError, "gconf value does not contain a string."); + return NULL; + } + ret = gconf_value_get_string(value); + if (ret) + return PyString_FromString(ret); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gconf_value_get_float noargs +static PyObject * +_wrap_gconf_value_get_float(PyObject *self) +{ + double ret; + GConfValue *value; + + value = pyg_boxed_get(self, GConfValue); + if (value->type != GCONF_VALUE_FLOAT) { + PyErr_SetString(PyExc_TypeError, "gconf value does not contain a float."); + return NULL; + } + ret = gconf_value_get_float(value); + return PyFloat_FromDouble(ret); +} +%% +override gconf_value_get_bool noargs +static PyObject * +_wrap_gconf_value_get_bool(PyObject *self) +{ + int ret; + PyObject *py_ret; + GConfValue *value; + + value = pyg_boxed_get(self, GConfValue); + if (value->type != GCONF_VALUE_BOOL) { + PyErr_SetString(PyExc_TypeError, "gconf value does not contain a boolean."); + return NULL; + } + ret = gconf_value_get_bool(value); + py_ret = ret ? Py_True : Py_False; + Py_INCREF(py_ret); + return py_ret; +} +%% +override gconf_value_set_list kwargs +static PyObject * +_wrap_gconf_value_set_list(PyObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "list", NULL }; + GSList *list; + PyObject *py_list; + int i, len; + GConfValue *value = pyg_boxed_get(self, GConfValue); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GConfValue.set_list", kwlist, + &PyList_Type, &py_list)) + return NULL; + if (value->type != GCONF_VALUE_LIST) { + PyErr_SetString(PyExc_TypeError, "gconf value type must be list."); + return NULL; + } + + len = PyList_Size(py_list); + for (i = 0, list = NULL; i < len; i++) { + PyObject *item = PyList_GET_ITEM(py_list, i); + if (!pyg_boxed_check(item, GCONF_TYPE_VALUE)) { + PyErr_SetString(PyExc_TypeError, "list elements must be of type gconf.Value"); + g_slist_free(list); + return NULL; + } + list = g_slist_append(list, pyg_boxed_get(item, GConfValue)); + } + gconf_value_set_list(value, list); + g_slist_free(list); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gconf_client_change_set_from_current +static PyObject * +_wrap_gconf_client_change_set_from_current(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "keys", NULL }; + PyObject *py_list; + const gchar **keys; + GError *err = NULL; + GConfChangeSet *ret; + int len, i; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GConfClient.change_set_from_current", + kwlist, &PyList_Type, &py_list)) + return NULL; + len = PyList_Size(py_list); + keys = g_new(const gchar *, len + 1); + for (i = 0; i < len; ++i) { + PyObject *item = PyList_GET_ITEM(py_list, i); + if (!PyString_Check(item)) { + g_free(keys); + PyErr_SetString(PyExc_TypeError, "list elements must be of type str"); + return NULL; + } + keys[i] = PyString_AsString(item); + } + keys[i] = NULL; + ret = gconf_client_change_set_from_currentv(GCONF_CLIENT(self->obj), keys, &err); + g_free(keys); + if (pyg_error_check(&err)) + return NULL; + /* pyg_boxed_new handles NULL checking */ + return pyg_boxed_new(GCONF_TYPE_CHANGE_SET, ret, TRUE, TRUE); +} +%% +override gconf_change_set_set_list kwargs +static PyObject * +_wrap_gconf_change_set_set_list(PyObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "key", "list_type", "list", NULL }; + char *key; + PyObject *py_list_type = NULL, *py_list; + GConfValueType list_type; + int i, len; + GSList *list; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sOO!:GConfChangeSet.set_list" + , kwlist, &key, &py_list_type, + &PyList_Type, &py_list)) + return NULL; + if (pyg_enum_get_value(GCONF_TYPE_VALUE_TYPE, py_list_type, (gint *)&list_type)) + return NULL; + + len = PyList_Size(py_list); + for (i = 0, list = NULL; i < len; i++) { + PyObject *item = PyList_GET_ITEM(py_list, i); + if (!pyg_boxed_check(item, GCONF_TYPE_VALUE)) { + PyErr_SetString(PyExc_TypeError, "list elements must be of type gconf.Value"); + g_slist_free(list); + return NULL; + } + list = g_slist_append(list, pyg_boxed_get(item, GConfValue)); + } + gconf_change_set_set_list(pyg_boxed_get(self, GConfChangeSet), key, list_type, list); + g_slist_free(list); + Py_INCREF(Py_None); + return Py_None; +} + +%% +define GConfClient.get_value kwargs + +static PyObject * +_wrap_g_conf_client_get_value(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "key", NULL }; + char *key; + GError *err = NULL; + GConfValue *value; + PyObject *py_ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:GConfClient.get_value", kwlist, &key)) + return NULL; + + value = gconf_client_get(GCONF_CLIENT(self->obj), key, &err); + + if (pyg_error_check(&err)) + return NULL; + + if (value == NULL) { + PyErr_Format(PyExc_ValueError, "gconf key %s has no value", key); + return NULL; + } + + switch (value->type) + { + case GCONF_VALUE_INVALID: + PyErr_SetString(PyExc_TypeError, "invalid value"); + py_ret = NULL; + break; + + case GCONF_VALUE_STRING: + py_ret = PyString_FromString(gconf_value_get_string(value)); + break; + case GCONF_VALUE_INT: + py_ret = PyInt_FromLong(gconf_value_get_int(value)); + break; + case GCONF_VALUE_FLOAT: + py_ret = PyFloat_FromDouble(gconf_value_get_float(value)); + break; + case GCONF_VALUE_BOOL: + py_ret = PyBool_FromLong(gconf_value_get_bool(value)); + break; + + case GCONF_VALUE_SCHEMA: + case GCONF_VALUE_LIST: + case GCONF_VALUE_PAIR: + PyErr_SetString(PyExc_TypeError, "value type not supported yet by this API"); + py_ret = NULL; + break; + default: + py_ret = NULL; + } + gconf_value_free(value); + return py_ret; +} + +%% +define GConfClient.set_value kwargs + +static PyObject * +_wrap_g_conf_client_set_value(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "key", "val", NULL }; + char *key; + PyObject *py_val; + GError *err = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs,"sO:GConfClient.set_value", kwlist, &key, &py_val)) + return NULL; + if (pyg_boxed_check(py_val, GCONF_TYPE_VALUE)) { + gconf_client_set(GCONF_CLIENT(self->obj), key, pyg_boxed_get(py_val, GConfValue), &err); + if (pyg_error_check(&err)) + return NULL; + } else { + if (PyBool_Check(py_val)) { + gconf_client_set_bool(GCONF_CLIENT(self->obj), key, PyInt_AsLong(py_val), &err); + } else if (PyInt_Check(py_val)) { + gconf_client_set_int(GCONF_CLIENT(self->obj), key, PyInt_AsLong(py_val), &err); + } else if (PyFloat_Check(py_val)) { + gconf_client_set_float(GCONF_CLIENT(self->obj), key, PyFloat_AsDouble(py_val), &err); + } else if (PyString_Check(py_val)) { + gconf_client_set_string(GCONF_CLIENT(self->obj), key, PyString_AsString(py_val), &err); + } else { + PyErr_SetString(PyExc_TypeError, "value type not supported yet by this API"); + return NULL; + } + if (pyg_error_check(&err)) + return NULL; + } + + Py_INCREF(Py_None); + return Py_None; +} + +%% +override gconf_value_new_from_string kwargs +static PyObject * +_wrap_gconf_value_new_from_string(PyObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "type", "str", NULL }; + PyObject *py_type = NULL; + char *str; + GConfValueType type; + GError *err = NULL; + GConfValue *ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Os:value_new_from_string", kwlist, &py_type, &str)) + return NULL; + if (pyg_enum_get_value(GCONF_TYPE_VALUE_TYPE, py_type, (gpointer)&type)) + return NULL; + + if (type == GCONF_VALUE_LIST || type == GCONF_VALUE_PAIR) { + PyErr_SetString(PyExc_ValueError, "GConf value types LIST and PAIR are not valid for this function"); + return NULL; + } + + ret = gconf_value_new_from_string(type, str, &err); + + if (pyg_error_check(&err)) + return NULL; + /* pyg_boxed_new handles NULL checking */ + return pyg_boxed_new(GCONF_TYPE_VALUE, ret, TRUE, TRUE); +} diff --git a/util/gconf/gconfmodule.c b/util/gconf/gconfmodule.c new file mode 100644 index 00000000..60273fbb --- /dev/null +++ b/util/gconf/gconfmodule.c @@ -0,0 +1,33 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* include this first, before NO_IMPORT_PYGOBJECT is defined */ +#include <pygobject.h> + +#include "gconf-types.h" + +void pygconf_register_classes (PyObject *d); +void pygconf_add_constants(PyObject *module, const gchar *strip_prefix); + +extern PyMethodDef pygconf_functions[]; +extern PyTypeObject PyGConfEngine_Type; + +DL_EXPORT(void) +initgconf (void) +{ + PyObject *m, *d; + + init_pygobject (); + + m = Py_InitModule ("gconf", pygconf_functions); + d = PyModule_GetDict (m); + + pygconf_register_classes (d); + pygconf_add_constants (m, "GCONF_"); + pygconf_register_engine_type (m); + + PyModule_AddObject(m, "Engine", (PyObject *) &PyGConfEngine_Type); +} diff --git a/util/gconf/wscript b/util/gconf/wscript new file mode 100644 index 00000000..442c6297 --- /dev/null +++ b/util/gconf/wscript @@ -0,0 +1,47 @@ +# -*- python -*- +# encoding: utf-8 + +import os +import Common + +def configure(conf): + conf.env.append_value('MODULES_AVAILABLE', 'gconf') + if 'gconf' in conf.env['ENABLE_MODULES'] or 'all' in conf.env['ENABLE_MODULES']: + if conf.check_pkg('gconf-2.0 >= 2.12 pygobject-2.0', + destvar='GCONF', mandatory=False): + conf.env.append_value('MODULES_TO_BUILD', 'gconf') + + +def codegen(bld, module): + cmd = bld.create_obj('command-output') + cmd.command = 'pygtk-codegen-2.0' + cmd.command_is_external = True + cmd.prio = 5 + cmd.argv = [ + '--py_ssize_t-clean', + '--load-types', cmd.input_file('gconf-arg-types.py'), + '--prefix', 'py'+module, + '--override', cmd.input_file("%s.override" % module), + cmd.input_file("%s.defs" % module), + ] + cmd.stdout = '%s.c' % module + return cmd + + +def build(bld): + + if 'gconf' in bld.env()['MODULES_TO_BUILD']: + codegen(bld, 'gconf') + pyext = bld.create_pyext() + pyext.source = 'gconfmodule.c gconf.c gconf-fixes.c gconf-types.c' + pyext.target = 'gconf' + pyext.uselib = 'GCONF' + pyext.includes = '.' + pyext.inst_var = 'PYTHONDIR' + pyext.inst_dir = 'gtk-2.0' + + Common.install_files('DATADIR', os.path.join('pygtk', '2.0', 'defs'), + ['gconf.defs']) + + Common.install_files('DATADIR', os.path.join('pygtk', '2.0', 'argtypes'), + 'gconf-arg-types.py') |