From b77038b9f2e39859edb6aa97b99bb6a6280f59af Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sat, 4 Oct 2003 22:49:37 +0000 Subject: [PATCH] app.py --help works, whee ! Original commit message from CVS: app.py --help works, whee ! --- ChangeLog | 5 +++++ gst/gstmodule.c | 31 ++++++++++++++++++++++++++++++- gst/gstreamermodule.c | 31 ++++++++++++++++++++++++++++++- gstreamer/gstmodule.c | 31 ++++++++++++++++++++++++++++++- gstreamer/gstreamermodule.c | 31 ++++++++++++++++++++++++++++++- 5 files changed, 125 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33851e16c8..1aecadaa4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-10-05 Thomas Vander Stichele + + * gstreamer/gstreamermodule.c: (init_gstreamer): + use gst_init_check () with argc and argv (see pygtk) + 2003-10-04 Thomas Vander Stichele * Makefile.am: add testsuite dir diff --git a/gst/gstmodule.c b/gst/gstmodule.c index cf3fb65548..b89331fc54 100644 --- a/gst/gstmodule.c +++ b/gst/gstmodule.c @@ -37,9 +37,38 @@ DL_EXPORT(void) init_gstreamer (void) { PyObject *m, *d; + PyObject *av; + int argc, i; + char **argv; init_pygobject (); - gst_init(NULL,NULL); + + /* pull in arguments */ + av = PySys_GetObject ("argv"); + if (av != NULL) { + argc = PyList_Size (av); + argv = g_new (char *, argc); + for (i = 0; i < argc; i++) + argv[i] = g_strdup (PyString_AsString (PyList_GetItem (av, i))); + } else { + argc = 0; + argv = NULL; + } + + if (!gst_init_check (&argc, &argv)) { + if (argv != NULL) { + for (i = 0; i < argc; i++) + g_free (argv[i]); + g_free (argv); + } + PyErr_SetString (PyExc_RuntimeError, "can't initialize module gstreamer"); + } + if (argv != NULL) { + PySys_SetArgv (argc, argv); + for (i = 0; i < argc; i++) + g_free (argv[i]); + g_free (argv); + } m = Py_InitModule ("_gstreamer", pygstreamer_functions); d = PyModule_GetDict (m); diff --git a/gst/gstreamermodule.c b/gst/gstreamermodule.c index cf3fb65548..b89331fc54 100644 --- a/gst/gstreamermodule.c +++ b/gst/gstreamermodule.c @@ -37,9 +37,38 @@ DL_EXPORT(void) init_gstreamer (void) { PyObject *m, *d; + PyObject *av; + int argc, i; + char **argv; init_pygobject (); - gst_init(NULL,NULL); + + /* pull in arguments */ + av = PySys_GetObject ("argv"); + if (av != NULL) { + argc = PyList_Size (av); + argv = g_new (char *, argc); + for (i = 0; i < argc; i++) + argv[i] = g_strdup (PyString_AsString (PyList_GetItem (av, i))); + } else { + argc = 0; + argv = NULL; + } + + if (!gst_init_check (&argc, &argv)) { + if (argv != NULL) { + for (i = 0; i < argc; i++) + g_free (argv[i]); + g_free (argv); + } + PyErr_SetString (PyExc_RuntimeError, "can't initialize module gstreamer"); + } + if (argv != NULL) { + PySys_SetArgv (argc, argv); + for (i = 0; i < argc; i++) + g_free (argv[i]); + g_free (argv); + } m = Py_InitModule ("_gstreamer", pygstreamer_functions); d = PyModule_GetDict (m); diff --git a/gstreamer/gstmodule.c b/gstreamer/gstmodule.c index cf3fb65548..b89331fc54 100644 --- a/gstreamer/gstmodule.c +++ b/gstreamer/gstmodule.c @@ -37,9 +37,38 @@ DL_EXPORT(void) init_gstreamer (void) { PyObject *m, *d; + PyObject *av; + int argc, i; + char **argv; init_pygobject (); - gst_init(NULL,NULL); + + /* pull in arguments */ + av = PySys_GetObject ("argv"); + if (av != NULL) { + argc = PyList_Size (av); + argv = g_new (char *, argc); + for (i = 0; i < argc; i++) + argv[i] = g_strdup (PyString_AsString (PyList_GetItem (av, i))); + } else { + argc = 0; + argv = NULL; + } + + if (!gst_init_check (&argc, &argv)) { + if (argv != NULL) { + for (i = 0; i < argc; i++) + g_free (argv[i]); + g_free (argv); + } + PyErr_SetString (PyExc_RuntimeError, "can't initialize module gstreamer"); + } + if (argv != NULL) { + PySys_SetArgv (argc, argv); + for (i = 0; i < argc; i++) + g_free (argv[i]); + g_free (argv); + } m = Py_InitModule ("_gstreamer", pygstreamer_functions); d = PyModule_GetDict (m); diff --git a/gstreamer/gstreamermodule.c b/gstreamer/gstreamermodule.c index cf3fb65548..b89331fc54 100644 --- a/gstreamer/gstreamermodule.c +++ b/gstreamer/gstreamermodule.c @@ -37,9 +37,38 @@ DL_EXPORT(void) init_gstreamer (void) { PyObject *m, *d; + PyObject *av; + int argc, i; + char **argv; init_pygobject (); - gst_init(NULL,NULL); + + /* pull in arguments */ + av = PySys_GetObject ("argv"); + if (av != NULL) { + argc = PyList_Size (av); + argv = g_new (char *, argc); + for (i = 0; i < argc; i++) + argv[i] = g_strdup (PyString_AsString (PyList_GetItem (av, i))); + } else { + argc = 0; + argv = NULL; + } + + if (!gst_init_check (&argc, &argv)) { + if (argv != NULL) { + for (i = 0; i < argc; i++) + g_free (argv[i]); + g_free (argv); + } + PyErr_SetString (PyExc_RuntimeError, "can't initialize module gstreamer"); + } + if (argv != NULL) { + PySys_SetArgv (argc, argv); + for (i = 0; i < argc; i++) + g_free (argv[i]); + g_free (argv); + } m = Py_InitModule ("_gstreamer", pygstreamer_functions); d = PyModule_GetDict (m);