<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >GNOME integration</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="GStreamer Application Development Manual" HREF="index.html"><LINK REL="UP" TITLE="Appendices" HREF="part-appendices.html"><LINK REL="PREVIOUS" TITLE="GstEditor" HREF="section-components-gst-editor.html"><LINK REL="NEXT" TITLE="Quotes from the Developers" HREF="chapter-quotes.html"></HEAD ><BODY CLASS="chapter" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" ><SPAN CLASS="application" >GStreamer</SPAN > Application Development Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="section-components-gst-editor.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="chapter-quotes.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="chapter" ><H1 ><A NAME="chapter-gnome" ></A >Chapter 35. GNOME integration</H1 ><P > GStreamer is fairly easy to integrate with GNOME applications. GStreamer uses libxml 2.0, GLib 2.0 and popt, as do all other GNOME applications. There are however some basic issues you need to address in your GNOME applications. </P ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="AEN1260" >35.1. Command line options</A ></H1 ><P > GNOME applications call gnome_program_init () to parse command-line options and initialize the necessary gnome modules. GStreamer applications normally call gst_init (&argc, &argv) to do the same for GStreamer. </P ><P > Each of these two swallows the program options passed to the program, so we need a different way to allow both GNOME and GStreamer to parse the command-line options. This is shown in the following example. </P ><PRE CLASS="programlisting" > /* example-begin gnome.c */ #include <gnome.h> #include <gst/gst.h> int main (int argc, char **argv) { GstPoptOption options[] = { { NULL, '\0', POPT_ARG_INCLUDE_TABLE, NULL, 0, "GStreamer", NULL }, POPT_TABLEEND }; GnomeProgram *program; poptContext context; const gchar **argvn; GstElement *pipeline; GstElement *src, *sink; options[0].arg = (void *) gst_init_get_popt_table (); g_print ("Calling gnome_program_init with the GStreamer popt table\n"); /* gnome_program_init will initialize GStreamer now * as a side effect of having the GStreamer popt table passed. */ if (! (program = gnome_program_init ("my_package", "0.1", LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_POPT_TABLE, options, NULL))) g_error ("gnome_program_init failed"); g_print ("Getting gnome-program popt context\n"); g_object_get (program, "popt-context", &context, NULL); argvn = poptGetArgs (context); if (!argvn) { g_print ("Run this example with some arguments to see how it works.\n"); return 0; } g_print ("Printing rest of arguments\n"); while (*argvn) { g_print ("argument: %s\n", *argvn); ++argvn; } /* do some GStreamer things to show everything's initialized properly */ g_print ("Doing some GStreamer stuff to show that everything works\n"); pipeline = gst_pipeline_new ("pipeline"); src = gst_element_factory_make ("fakesrc", "src"); sink = gst_element_factory_make ("fakesink", "sink"); gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); gst_element_link (src, sink); gst_element_set_state (pipeline, GST_STATE_PLAYING); gst_bin_iterate (GST_BIN (pipeline)); gst_element_set_state (pipeline, GST_STATE_NULL); return 0; } /* example-end gnome.c */ </PRE ><P > If you try out this program, you will see that when called with --help, it will print out both GStreamer and GNOME help arguments. All of the arguments that didn't belong to either end up in the argvn pointer array. </P ><P > FIXME: flesh this out more. How do we get the GStreamer arguments at the end ? FIXME: add a GConf bit. </P ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="section-components-gst-editor.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="chapter-quotes.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >GstEditor</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="part-appendices.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Quotes from the Developers</TD ></TR ></TABLE ></DIV ></BODY ></HTML >