[pygtk] right way to share GOptionContext pointer from pygobject
Tristan Hill
stan at saticed.me.uk
Mon Nov 17 06:05:11 WST 2008
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 },
+ { "_get_context", (PyCFunction)pyg_option_get_context, METH_NOARGS },
{ NULL, NULL, 0 },
};
[1] http://bugzilla.gnome.org/show_bug.cgi?id=507174
More information about the pygtk
mailing list