16 Nov 22:05
right way to share GOptionContext pointer from pygobject
From: Tristan Hill <stan <at> saticed.me.uk>
Subject: right way to share GOptionContext pointer from pygobject
Newsgroups: gmane.comp.gnome.gtk+.python
Date: 2008-11-16 21:05:11 GMT
Subject: right way to share GOptionContext pointer from pygobject
Newsgroups: gmane.comp.gnome.gtk+.python
Date: 2008-11-16 21:05:11 GMT
I've done a patch for gnome-python to add GOption support[1]. Using the existing GOptionContext wrapper in pygobject this is possible but access to the wrapped GOptionContext pointer is required to pass to gnome_program_init. I'd be grateful to know whether cobjects are a good way of doing this per http://bugzilla.gnome.org/attachment.cgi?id=117380&action=view - included inline here because it is quite short: --- glib/pygoptioncontext.c (revision 949) +++ glib/pygoptioncontext.c (working copy) @@ -281,6 +281,12 @@ return -1; } +static PyObject * +pyg_option_get_context(PyGOptionContext *self) +{ + return PyCObject_FromVoidPtr(self->context, NULL); +} + static PyMethodDef pyg_option_context_methods[] = { { "parse", (PyCFunction)pyg_option_context_parse, METH_VARARGS | METH_KEYWORDS }, { "set_help_enabled", (PyCFunction)pyg_option_context_set_help_enabled, METH_VARARGS | METH_KEYWORDS }, @@ -290,6 +296,7 @@ { "set_main_group", (PyCFunction)pyg_option_context_set_main_group, METH_VARARGS | METH_KEYWORDS }, { "get_main_group", (PyCFunction)pyg_option_context_get_main_group, METH_NOARGS }, { "add_group", (PyCFunction)pyg_option_context_add_group, METH_VARARGS | METH_KEYWORDS },(Continue reading)
RSS Feed