[cheese] Add init functions to libcheese and libcheese-gtk



commit 8d706290e186047ef5d189e7c7c61fcd1615b7ba
Author: David King <amigadave amigadave com>
Date:   Sat Jan 21 18:33:16 2012 +0000

    Add init functions to libcheese and libcheese-gtk
    
    Adding wrappers around clutter_gst_init() and clutter_gtk_init() reduces
    confusion for API users, as well as reducing link-time dependencies.
    
    Provides a clean fix for bug 668292 and bug 667884.

 Makefile.am                        |    6 +++-
 data/cheese-gtk.pc.in              |   10 ++----
 data/cheese.pc.in                  |    9 ++---
 docs/reference/cheese-docs.xml     |    2 +
 docs/reference/cheese-sections.txt |   12 +++++++
 libcheese/cheese-gtk.c             |   59 ++++++++++++++++++++++++++++++++++++
 libcheese/cheese-gtk.h             |   31 +++++++++++++++++++
 libcheese/cheese-gtk.symbols       |    1 +
 libcheese/cheese-widget.c          |    5 +--
 libcheese/cheese.c                 |   54 ++++++++++++++++++++++++++++++++
 libcheese/cheese.h                 |   31 +++++++++++++++++++
 11 files changed, 205 insertions(+), 15 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 9862b5d..30cd109 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -96,6 +96,7 @@ libcheese_gtk_la_SOURCES = \
 	libcheese/cheese-avatar-chooser.c \
 	libcheese/cheese-aspect-frame.c \
 	libcheese/cheese-flash.c \
+	libcheese/cheese-gtk.c \
 	libcheese/cheese-widget.c \
 	libcheese/um-crop-area.c
 
@@ -130,7 +131,8 @@ libcheese_la_SOURCES = \
 	libcheese/cheese-camera-device.c \
 	libcheese/cheese-camera-device-monitor.c \
 	libcheese/cheese-effect.c \
-	libcheese/cheese-fileutil.c
+	libcheese/cheese-fileutil.c \
+	libcheese/cheese.c
 
 noinst_libcheese_headers = \
 	libcheese/cheese-camera.h \
@@ -147,6 +149,8 @@ cheese_HEADERS = \
 	libcheese/cheese-camera-device.h \
 	libcheese/cheese-camera-device-monitor.h \
 	libcheese/cheese-effect.h \
+	libcheese/cheese-gtk.h \
+	libcheese/cheese.h \
 	libcheese/cheese-widget.h
 
 if HAVE_INTROSPECTION
diff --git a/data/cheese-gtk.pc.in b/data/cheese-gtk.pc.in
index f30c46d..d3d05ae 100644
--- a/data/cheese-gtk.pc.in
+++ b/data/cheese-gtk.pc.in
@@ -3,11 +3,9 @@ exec_prefix= exec_prefix@
 libdir= libdir@
 includedir= includedir@
 
-
-Name: cheese
-Description: Cheese Webcam widgets
-Version: @VERSION@
-Requires.private: gtk+-x11-3.0 gstreamer-0.10 gstreamer-plugins-base-0.10 libcanberra-gtk3
+Name: cheese-gtk
+Description: Cheese webcam widgets
+Version: @PACKAGE_VERSION@
+Requires.private: gtk+-x11-3.0 gstreamer-0.10 gstreamer-plugins-base-0.10 libcanberra-gtk3 clutter-gtk-1.0 cheese
 Libs: -L${libdir} -lcheese-gtk
 Cflags: -I${includedir}/cheese
-
diff --git a/data/cheese.pc.in b/data/cheese.pc.in
index c6e7048..a3a1fb8 100644
--- a/data/cheese.pc.in
+++ b/data/cheese.pc.in
@@ -3,11 +3,10 @@ exec_prefix= exec_prefix@
 libdir= libdir@
 includedir= includedir@
 
-
-Name: libcheese
-Description: Cheese Webcam
-Version: @VERSION@
-Requires.private: gstreamer-0.10 gstreamer-plugins-base-0.10
+Name: cheese
+Description: Cheese webcam utilities
+Version: @PACKAGE_VERSION@
+Requires.private: gstreamer-0.10 gstreamer-plugins-base-0.10 clutter-gst-1.0
 Requires: clutter-1.0
 Libs: -L${libdir} -lcheese
 Cflags: -I${includedir}/cheese
diff --git a/docs/reference/cheese-docs.xml b/docs/reference/cheese-docs.xml
index c4ce71f..6a33c8a 100644
--- a/docs/reference/cheese-docs.xml
+++ b/docs/reference/cheese-docs.xml
@@ -48,6 +48,7 @@
     libcheese provides video and photo capture functionality which does not
     require GTK+, such as enumerating video capture devices.
     </para>
+    <xi:include href="xml/cheese-init.xml"/>
     <xi:include href="xml/cheese-camera.xml"/>
     <xi:include href="xml/cheese-camera-device.xml"/>
     <xi:include href="xml/cheese-camera-device-monitor.xml"/>
@@ -61,6 +62,7 @@
     libcheese-gtk provides video and photo capture widgets for use in GTK+
     applications
     </para>
+    <xi:include href="xml/cheese-gtk-init.xml"/>
     <xi:include href="xml/cheese-avatar-chooser.xml"/>
     <xi:include href="xml/cheese-flash.xml"/>
     <xi:include href="xml/cheese-widget.xml"/>
diff --git a/docs/reference/cheese-sections.txt b/docs/reference/cheese-sections.txt
index 7a5b6a0..ba8c4f9 100644
--- a/docs/reference/cheese-sections.txt
+++ b/docs/reference/cheese-sections.txt
@@ -1,4 +1,16 @@
 <SECTION>
+<FILE>cheese-init</FILE>
+<TITLE>Initializing libcheese</TITLE>
+cheese_init
+</SECTION>
+
+<SECTION>
+<FILE>cheese-gtk-init</FILE>
+<TITLE>Initializing libcheese-gtk</TITLE>
+cheese_gtk_init
+</SECTION>
+
+<SECTION>
 <FILE>cheese-avatar-chooser</FILE>
 <TITLE>CheeseAvatarChooser</TITLE>
 CheeseAvatarChooser
diff --git a/libcheese/cheese-gtk.c b/libcheese/cheese-gtk.c
new file mode 100644
index 0000000..78d02c3
--- /dev/null
+++ b/libcheese/cheese-gtk.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright  2011 David King <amigadave amigadave com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <clutter-gtk/clutter-gtk.h>
+
+#include "cheese-gtk.h"
+#include "cheese.h"
+
+/**
+ * SECTION:cheese-gtk-init
+ * @short_description: Initialize libcheese-gtk
+ * @stability: Unstable
+ * @include: cheese/cheese-gtk.h
+ *
+ * Call cheese_gtk_init() to initialize libcheese-gtk.
+ */
+
+
+/**
+ * cheese_gtk_init:
+ * @argc: pointer to the argument list count
+ * @argv: pointer to the argument list vector
+ *
+ * Initialize libcheese-gtk, by initializing Clutter, GStreamer and GTK+. This
+ * automatically calls cheese_init(), initializing libcheese.
+ *
+ * Returns: %TRUE if the initialization was successful, %FALSE otherwise
+ */
+gboolean
+cheese_gtk_init (int *argc, char ***argv)
+{
+    ClutterInitError error;
+
+    error = gtk_clutter_init (argc, argv);
+
+    if (error != CLUTTER_INIT_SUCCESS)
+        return FALSE;
+
+    if (!cheese_init (argc, argv))
+        return FALSE;
+
+    return TRUE;
+}
diff --git a/libcheese/cheese-gtk.h b/libcheese/cheese-gtk.h
new file mode 100644
index 0000000..77640e2
--- /dev/null
+++ b/libcheese/cheese-gtk.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright  2011 David King <amigadave amigadave com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef CHEESE_GTK_H_
+#define CHEESE_GTK_H_
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gboolean cheese_gtk_init (int *argc, char ***argv);
+
+G_END_DECLS
+
+#endif /* CHEESE_GTK_H_ */
diff --git a/libcheese/cheese-gtk.symbols b/libcheese/cheese-gtk.symbols
index 6d4789b..fc43faf 100644
--- a/libcheese/cheese-gtk.symbols
+++ b/libcheese/cheese-gtk.symbols
@@ -1,3 +1,4 @@
+cheese_gtk_init
 cheese_widget_get_type
 cheese_widget_new
 cheese_widget_get_camera
diff --git a/libcheese/cheese-widget.c b/libcheese/cheese-widget.c
index 90bc7c6..5f2166b 100644
--- a/libcheese/cheese-widget.c
+++ b/libcheese/cheese-widget.c
@@ -387,9 +387,8 @@ cheese_widget_class_init (CheeseWidgetClass *klass)
 /**
  * cheese_widget_new:
  *
- * Creates a new #CheeseWidget. Make sure that you call gtk_clutter_init() and
- * clutter_gst_init(), and check for errors during initialization, before
- * calling this function.
+ * Creates a new #CheeseWidget. Make sure that you call cheese_gtk_init(), and
+ * check for errors during initialization, before calling this function.
  *
  * Returns: a new #CheeseWidget
  */
diff --git a/libcheese/cheese.c b/libcheese/cheese.c
new file mode 100644
index 0000000..0393562
--- /dev/null
+++ b/libcheese/cheese.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright  2011 David King <amigadave amigadave com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <clutter-gst/clutter-gst.h>
+
+#include "cheese.h"
+
+/**
+ * SECTION:cheese-init
+ * @short_description: Initialize libcheese
+ * @stability: Unstable
+ * @include: cheese/cheese.h
+ *
+ * Call cheese_init() to initialize libcheese.
+ */
+
+
+/**
+ * cheese_init:
+ * @argc: pointer to the argument list count
+ * @argv: pointer to the argument list vector
+ *
+ * Initialize libcheese, by initializing Clutter and GStreamer.
+ *
+ * Returns: %TRUE if the initialization was successful, %FALSE otherwise
+ */
+gboolean
+cheese_init (int *argc, char ***argv)
+{
+    ClutterInitError error;
+
+    error = clutter_gst_init (argc, argv);
+
+    if (error != CLUTTER_INIT_SUCCESS)
+        return FALSE;
+
+    return TRUE;
+}
diff --git a/libcheese/cheese.h b/libcheese/cheese.h
new file mode 100644
index 0000000..ec3239f
--- /dev/null
+++ b/libcheese/cheese.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright  2011 David King <amigadave amigadave com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef CHEESE_H_
+#define CHEESE_H_
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gboolean cheese_init (int *argc, char ***argv);
+
+G_END_DECLS
+
+#endif /* CHEESE_H_ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]