adding stuff to make the code extractor pick up examples
[platform/upstream/gstreamer.git] / docs / manual / gnome.xml
1 <chapter id="cha-gnome">
2   <title>Gnome integration</title>
3   <para> 
4     GStreamer is fairly easy to integrate with Gnome applications.
5     GStreamer uses libxml 2.0, GLib 2.0 and popt, as do all other
6     Gnome applications.
7     There are however some basic issues you need to address in your Gnome
8     applications.
9   </para>
10  
11   <sect1>
12     <title>Command line options</title>
13     <para>
14       Gnome applications call gnome_program_init () to parse command-line
15       options and initialize the necessary gnome modules.
16       GStreamer applications normally call gst_init (&amp;argc, &amp;argv) to
17       do the same for GStreamer.
18     </para>
19     <para>
20       Each of these two swallows the program options passed to the program,
21       so we need a different way to allow both Gnome and GStreamer to parse
22       the command-line options.  This is shown in the following example.
23     </para>  
24
25     <programlisting>
26 /* example-begin gnome.c */
27 #include &lt;gnome.h&gt;
28 #include &lt;gst/gst.h&gt;
29
30 int
31 main (int argc, char **argv)
32 {
33   struct poptOption options[] = {
34           { NULL, '\0', POPT_ARG_INCLUDE_TABLE, NULL, 0, "GStreamer", NULL },
35             POPT_TABLEEND
36         };
37   GnomeProgram *program;
38   poptContext context;
39   const gchar **argvn;
40
41   options[0].arg = (void *) gst_init_get_popt_table ();
42   if (! (program = gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
43                                        argc, argv,
44                                        GNOME_PARAM_POPT_TABLE, options,
45                                        NULL)))
46   g_error ("gnome_program_init failed");
47
48   g_object_get (program, "popt-context", &amp;context, NULL);
49   argvn = poptGetArgs (context);
50   if (!argvn) {
51     g_print ("Run this example with some arguments to see how it works.\n");
52     return 0;
53   }
54
55   while (*argvn) {
56     g_print ("argument: %s\n", *argvn);
57     ++argvn;
58   }
59
60   return 0;
61 }
62 /* example-end gnome.c */
63     </programlisting>
64     <para>
65       If you try out this program, you will see that when called with
66       --help, it will print out both GStreamer and Gnome help arguments.
67       All of the arguments that didn't belong to either end up in the
68       argvn pointer array.
69     </para>
70     <para>
71       FIXME: flesh this out more.  How do we get the GStreamer arguments
72       at the end ?
73   </sect1>
74 </chapter>