Add a new module, gstoption which allows you to fetch the

Original commit message from CVS:
2007-11-05  Johan Dahlin  <johan@gnome.org>

* gstoptionmodule.c:
* Makefile.am:
* configure.ac:
Add a new module, gstoption which allows you to fetch the
GOptionGroup from gstreamer without initializing and parsing
the command line arguments. Requires PyGObject 2.15.0
Fixes #425847

* examples/option-parser.py (main): Example
This commit is contained in:
Johan Dahlin 2007-11-08 10:51:07 +00:00
parent fbd4ea3772
commit 5b5311a64f
6 changed files with 133 additions and 1 deletions

View file

@ -1,3 +1,15 @@
2007-11-05 Johan Dahlin <johan@gnome.org>
* gstoptionmodule.c:
* Makefile.am:
* configure.ac:
Add a new module, gstoption which allows you to fetch the
GOptionGroup from gstreamer without initializing and parsing
the command line arguments. Requires PyGObject 2.15.0
Fixes #425847
* examples/option-parser.py (main): Example
2007-11-01 Johan Dahlin <johan@gnome.org>
* gst/gst.override:

View file

@ -1,12 +1,28 @@
SUBDIRS = codegen gst examples testsuite pkgconfig
win32 = $(shell cat $(top_srcdir)/win32/MANIFEST)
common_cflags = $(PYGOBJECT_CFLAGS) $(GST_CFLAGS) $(GST_OPTION_CFLAGS) -fno-strict-aliasing
common_libadd = $(GST_LIBS) $(GST_OPTION_LIBS)
common_ldflags = -module -avoid-version
debug:
echo $(win32)
ACLOCAL_AMFLAGS = -I common/m4
pyexec_LTLIBRARIES =
if HAVE_PYGOBJECT_2_16
pyexec_LTLIBRARIES += gstoption.la
endif
# GStreamer option bindings
gstoption_la_CFLAGS = $(common_cflags)
gstoption_la_LIBADD = $(common_libadd)
gstoption_la_LDFLAGS = $(common_ldflags) \
-export-symbols-regex "^(initgstoption|_PyGObject_API).*"
gstoption_la_SOURCES = gstoptionmodule.c
EXTRA_DIST = \
gstltihooks.py \
pygst.py.in \

2
common

@ -1 +1 @@
Subproject commit 34d7d649b972ea4915611a6ed88f01613bf32777
Subproject commit 423e2ea96b5f79281f4dd20d734bd968b3d95e89

View file

@ -323,6 +323,17 @@ PKG_CHECK_MODULES(PYGOBJECT_2_12, pygobject-2.0 >= 2.11.1,
[Defined if we have a 2.12 series pygobject])
], HAVE_PYGOBJECT_2_12="no")
dnl FIXME: check for a pygobject which exports pyg_option_group_new
PKG_CHECK_MODULES(PYGOBJECT_2_16, pygobject-2.0 >= 2.15.0,
[
HAVE_PYGOBJECT_2_16="yes"
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_PYGOBJECT_2_16, 1,
[Defined if we have a 2.16 series pygobject])
], HAVE_PYGOBJECT_2_16="no")
AM_CONDITIONAL(HAVE_PYGOBJECT_2_16, test x$HAVE_PYGOBJECT_2_16 != xno)
dnl define an ERROR_CFLAGS Makefile variable
AG_GST_SET_ERROR_CFLAGS($GST_CVS)

43
examples/option-parser.py Normal file
View file

@ -0,0 +1,43 @@
#!/usr/bin/env python
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
import sys
import pygtk
pygtk.require('2.0')
from gobject.option import OptionParser, OptionGroup
import pygst
pygst.require('0.10')
import gstoption
def main(args):
parser = OptionParser()
group = OptionGroup('flumotion', 'Flumotion options',
option_list=[])
group.add_option('-v', '--verbose',
action="store_true", dest="verbose",
help="be verbose")
group.add_option('', '--version',
action="store_true", dest="version",
default=False,
help="show version information")
parser.add_option_group(group)
parser.add_option_group(gstoption.get_group())
options, args = parser.parse_args(args)
if options.verbose:
print 'Verbose mode'
import gst
if options.version:
print sys.version, gst.version
if __name__ == '__main__':
sys.exit(main(sys.argv))

50
gstoptionmodule.c Normal file
View file

@ -0,0 +1,50 @@
/* -*- Mode: C; ; c-file-style: "k&r"; c-basic-offset: 4 -*- */
/* gst-python
* Copyright (C) 2007 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 <johan@gnome.org>
*/
#include <Python.h>
#include <pygobject.h>
#include <gst/gst.h>
static PyObject *
_wrap_gstoption_get_group (PyObject *self)
{
GOptionGroup *option_group;
option_group = gst_init_get_option_group();
return pyg_option_group_new(option_group);
}
static PyMethodDef pygstoption_functions[] = {
{ "get_group", (PyCFunction)_wrap_gstoption_get_group, METH_NOARGS, NULL },
{ NULL, NULL, 0, NULL }
};
DL_EXPORT(void)
initgstoption (void)
{
init_pygobject ();
if (!g_thread_supported ())
g_thread_init (NULL);
Py_InitModule ("gstoption", pygstoption_functions);
}