Blame SOURCES/0023-libcheese-Add-_init_with_args-init-function-variants.patch

ecdf9b
From e7b7314b5af40aaf9aa2a782a1fd025f2e08345e Mon Sep 17 00:00:00 2001
ecdf9b
From: Hans de Goede <hdegoede@redhat.com>
ecdf9b
Date: Wed, 12 Jun 2013 12:07:20 +0200
ecdf9b
Subject: [PATCH 23/35] libcheese: Add _init_with_args init function variants
ecdf9b
ecdf9b
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
ecdf9b
---
ecdf9b
 docs/reference/cheese-sections.txt |  2 ++
ecdf9b
 libcheese/cheese-gtk.c             | 57 ++++++++++++++++++++++++++++++++++++++
ecdf9b
 libcheese/cheese-gtk.h             |  5 ++++
ecdf9b
 libcheese/cheese-gtk.symbols       |  1 +
ecdf9b
 libcheese/cheese.c                 | 25 +++++++++++++++++
ecdf9b
 libcheese/cheese.h                 |  5 ++++
ecdf9b
 src/vapi/cheese-common.vapi        | 14 ++++++++++
ecdf9b
 7 files changed, 109 insertions(+)
ecdf9b
ecdf9b
diff --git a/docs/reference/cheese-sections.txt b/docs/reference/cheese-sections.txt
ecdf9b
index 81e835c..bed1e75 100644
ecdf9b
--- a/docs/reference/cheese-sections.txt
ecdf9b
+++ b/docs/reference/cheese-sections.txt
ecdf9b
@@ -2,12 +2,14 @@
ecdf9b
 <FILE>cheese-init</FILE>
ecdf9b
 <TITLE>Initializing libcheese</TITLE>
ecdf9b
 cheese_init
ecdf9b
+cheese_init_with_args
ecdf9b
 </SECTION>
ecdf9b
 
ecdf9b
 <SECTION>
ecdf9b
 <FILE>cheese-gtk-init</FILE>
ecdf9b
 <TITLE>Initializing libcheese-gtk</TITLE>
ecdf9b
 cheese_gtk_init
ecdf9b
+cheese_gtk_init_with_args
ecdf9b
 </SECTION>
ecdf9b
 
ecdf9b
 <SECTION>
ecdf9b
diff --git a/libcheese/cheese-gtk.c b/libcheese/cheese-gtk.c
ecdf9b
index f6f7715..008ebef 100644
ecdf9b
--- a/libcheese/cheese-gtk.c
ecdf9b
+++ b/libcheese/cheese-gtk.c
ecdf9b
@@ -18,6 +18,7 @@
ecdf9b
  */
ecdf9b
 
ecdf9b
 #include <gtk/gtk.h>
ecdf9b
+#include <gst/gst.h>
ecdf9b
 #ifdef GDK_WINDOWING_X11
ecdf9b
   #include <X11/Xlib.h>
ecdf9b
 #endif
ecdf9b
@@ -65,3 +66,59 @@ cheese_gtk_init (int *argc, char ***argv)
ecdf9b
 
ecdf9b
     return TRUE;
ecdf9b
 }
ecdf9b
+
ecdf9b
+/**
ecdf9b
+ * cheese_gtk_init_with_args:
ecdf9b
+ * @argc: pointer to the argument list count
ecdf9b
+ * @argv: pointer to the argument list vector
ecdf9b
+ * @parameter_string:  string which is displayed in the first line of --help
ecdf9b
+ * output, after programname [OPTION...]
ecdf9b
+ * @entries: a NULL-terminated array of GOptionEntries describing the options
ecdf9b
+ * of your program
ecdf9b
+ * @translation_domain: a translation domain to use for translating the
ecdf9b
+ * --help output for the options in entries with gettext(), or NULL
ecdf9b
+ * @error: a return location for errors
ecdf9b
+ *
ecdf9b
+ * Initialize libcheese-gtk, by initializing Clutter, GStreamer and GTK+. This
ecdf9b
+ * automatically calls cheese_init_with_args(), initializing libcheese.
ecdf9b
+ *
ecdf9b
+ * Returns: %TRUE if the initialization was successful, %FALSE otherwise
ecdf9b
+ */
ecdf9b
+gboolean
ecdf9b
+cheese_gtk_init_with_args (int *argc, char ***argv,
ecdf9b
+                           const char *parameter_string,
ecdf9b
+                           GOptionEntry *entries,
ecdf9b
+                           const char *translation_domain,
ecdf9b
+                           GError **error)
ecdf9b
+{
ecdf9b
+    GOptionContext *context;
ecdf9b
+    gboolean res;
ecdf9b
+
ecdf9b
+#ifdef GDK_WINDOWING_X11
ecdf9b
+    /* We can't call clutter_gst_init() before gtk_clutter_init(), so no
ecdf9b
+     * choice but to initialise X11 threading ourself */
ecdf9b
+    XInitThreads ();
ecdf9b
+#endif
ecdf9b
+
ecdf9b
+    /* We cannot simply call gtk_clutter_init_with_args() here, since that
ecdf9b
+     * will result in the commandline being parsed without gst support. */
ecdf9b
+    context = g_option_context_new (parameter_string);
ecdf9b
+    g_option_context_add_main_entries (context, entries, translation_domain);
ecdf9b
+    g_option_context_set_translation_domain (context, translation_domain);
ecdf9b
+    g_option_context_add_group (context, gst_init_get_option_group ());
ecdf9b
+    g_option_context_add_group (context, gtk_get_option_group (TRUE));
ecdf9b
+    g_option_context_add_group (context, cogl_get_option_group ());
ecdf9b
+    g_option_context_add_group (context,
ecdf9b
+        clutter_get_option_group_without_init ());
ecdf9b
+    g_option_context_add_group (context, gtk_clutter_get_option_group ());
ecdf9b
+
ecdf9b
+    res = g_option_context_parse (context, argc, argv, error);
ecdf9b
+
ecdf9b
+    g_option_context_free (context);
ecdf9b
+
ecdf9b
+    if (!res)
ecdf9b
+        return FALSE;
ecdf9b
+
ecdf9b
+    return cheese_init_with_args (argc, argv, parameter_string, entries,
ecdf9b
+                                  translation_domain, error);
ecdf9b
+}
ecdf9b
diff --git a/libcheese/cheese-gtk.h b/libcheese/cheese-gtk.h
ecdf9b
index 77640e2..1a4f1b8 100644
ecdf9b
--- a/libcheese/cheese-gtk.h
ecdf9b
+++ b/libcheese/cheese-gtk.h
ecdf9b
@@ -25,6 +25,11 @@
ecdf9b
 G_BEGIN_DECLS
ecdf9b
 
ecdf9b
 gboolean cheese_gtk_init (int *argc, char ***argv);
ecdf9b
+gboolean cheese_gtk_init_with_args (int *argc, char ***argv,
ecdf9b
+                                    const char *parameter_string,
ecdf9b
+                                    GOptionEntry *entries,
ecdf9b
+                                    const char *translation_domain,
ecdf9b
+                                    GError **error);
ecdf9b
 
ecdf9b
 G_END_DECLS
ecdf9b
 
ecdf9b
diff --git a/libcheese/cheese-gtk.symbols b/libcheese/cheese-gtk.symbols
ecdf9b
index fc43faf..a207c3d 100644
ecdf9b
--- a/libcheese/cheese-gtk.symbols
ecdf9b
+++ b/libcheese/cheese-gtk.symbols
ecdf9b
@@ -1,4 +1,5 @@
ecdf9b
 cheese_gtk_init
ecdf9b
+cheese_gtk_init_with_args
ecdf9b
 cheese_widget_get_type
ecdf9b
 cheese_widget_new
ecdf9b
 cheese_widget_get_camera
ecdf9b
diff --git a/libcheese/cheese.c b/libcheese/cheese.c
ecdf9b
index 0393562..fcab5a8 100644
ecdf9b
--- a/libcheese/cheese.c
ecdf9b
+++ b/libcheese/cheese.c
ecdf9b
@@ -52,3 +52,28 @@ cheese_init (int *argc, char ***argv)
ecdf9b
 
ecdf9b
     return TRUE;
ecdf9b
 }
ecdf9b
+
ecdf9b
+/**
ecdf9b
+ * cheese_init_with_args:
ecdf9b
+ * @argc: pointer to the argument list count
ecdf9b
+ * @argv: pointer to the argument list vector
ecdf9b
+ * @parameter_string:  string which is displayed in the first line of --help
ecdf9b
+ * output, after programname [OPTION...]
ecdf9b
+ * @entries: a NULL-terminated array of GOptionEntries describing the options
ecdf9b
+ * of your program
ecdf9b
+ * @translation_domain: a translation domain to use for translating the
ecdf9b
+ * --help output for the options in entries with gettext(), or NULL
ecdf9b
+ * @error: a return location for errors
ecdf9b
+ *
ecdf9b
+ * Initialize libcheese, by initializing Clutter and GStreamer.
ecdf9b
+ *
ecdf9b
+ * Returns: %TRUE if the initialization was successful, %FALSE otherwise
ecdf9b
+ */
ecdf9b
+gboolean
ecdf9b
+cheese_init_with_args (int *argc, char ***argv, const char *parameter_string,
ecdf9b
+                       GOptionEntry *entries, const char *translation_domain,
ecdf9b
+                       GError **error)
ecdf9b
+{
ecdf9b
+    return clutter_gst_init_with_args (argc, argv, parameter_string, entries,
ecdf9b
+                translation_domain, error) == CLUTTER_INIT_SUCCESS;
ecdf9b
+}
ecdf9b
diff --git a/libcheese/cheese.h b/libcheese/cheese.h
ecdf9b
index ec3239f..0f6e06c 100644
ecdf9b
--- a/libcheese/cheese.h
ecdf9b
+++ b/libcheese/cheese.h
ecdf9b
@@ -25,6 +25,11 @@
ecdf9b
 G_BEGIN_DECLS
ecdf9b
 
ecdf9b
 gboolean cheese_init (int *argc, char ***argv);
ecdf9b
+gboolean cheese_init_with_args (int *argc, char ***argv,
ecdf9b
+                                const char *parameter_string,
ecdf9b
+                                GOptionEntry *entries,
ecdf9b
+                                const char *translation_domain,
ecdf9b
+                                GError **error);
ecdf9b
 
ecdf9b
 G_END_DECLS
ecdf9b
 
ecdf9b
diff --git a/src/vapi/cheese-common.vapi b/src/vapi/cheese-common.vapi
ecdf9b
index 075b594..e4d4bec 100644
ecdf9b
--- a/src/vapi/cheese-common.vapi
ecdf9b
+++ b/src/vapi/cheese-common.vapi
ecdf9b
@@ -6,9 +6,23 @@ namespace Cheese
ecdf9b
   [CCode (cheader_filename = "cheese.h")]
ecdf9b
   public static bool init([CCode (array_length_pos = 0.9)] ref unowned string[] argv);
ecdf9b
 
ecdf9b
+  [CCode (cheader_filename = "cheese.h")]
ecdf9b
+  public static bool init_with_args(
ecdf9b
+    [CCode (array_length_pos = 0.9)] ref unowned string[] argv,
ecdf9b
+    string parameter_string,
ecdf9b
+    [CCode (array_length = false)] GLib.OptionEntry[] entries,
ecdf9b
+    string? translation_domain) throws GLib.OptionError;
ecdf9b
+
ecdf9b
   [CCode (cheader_filename = "cheese-gtk.h")]
ecdf9b
   public static bool gtk_init([CCode (array_length_pos = 0.9)] ref unowned string[] argv);
ecdf9b
 
ecdf9b
+  [CCode (cheader_filename = "cheese-gtk.h")]
ecdf9b
+  public static bool gtk_init_with_args(
ecdf9b
+    [CCode (array_length_pos = 0.9)] ref unowned string[] argv,
ecdf9b
+    string parameter_string,
ecdf9b
+    [CCode (array_length = false)] GLib.OptionEntry[] entries,
ecdf9b
+    string? translation_domain) throws GLib.OptionError;
ecdf9b
+
ecdf9b
   [CCode (cheader_filename = "cheese-effect.h")]
ecdf9b
   public class Effect : GLib.Object
ecdf9b
   {
ecdf9b
-- 
ecdf9b
1.8.2.1
ecdf9b