cheese r772 - in trunk: . data src
- From: dgsiegel svn gnome org
- To: svn-commits-list gnome org
- Subject: cheese r772 - in trunk: . data src
- Date: Thu, 19 Jun 2008 21:36:36 +0000 (UTC)
Author: dgsiegel
Date: Thu Jun 19 21:36:36 2008
New Revision: 772
URL: http://svn.gnome.org/viewvc/cheese?rev=772&view=rev
Log:
allow to choose the webcam using the preference dialog, fixes bug #522200, courtesy of Ryan Zeigler
Added:
trunk/src/cheese-prefs-webcam-combo.c
trunk/src/cheese-prefs-webcam-combo.h
Modified:
trunk/AUTHORS
trunk/ChangeLog
trunk/data/cheese-prefs.glade
trunk/data/cheese-prefs.ui
trunk/src/Makefile.am
trunk/src/cheese-prefs-dialog.c
trunk/src/cheese-prefs-dialog.h
trunk/src/cheese-webcam.c
trunk/src/cheese-webcam.h
trunk/src/cheese-window.c
Modified: trunk/AUTHORS
==============================================================================
--- trunk/AUTHORS (original)
+++ trunk/AUTHORS Thu Jun 19 21:36:36 2008
@@ -12,6 +12,7 @@
- Luca Ferretti <elle uca libero it>
- Mirco "MacSlow" MÃller <macslow bangang de>
- Patryk Zawadzki <patrys pld-linux org>
+ - Ryan Zeigler <zeiglerr gmail com>
- Sebastian Keller <sebastian-keller gmx de>
- Steve Magoun <steve magoun canonical com>
- Thomas Perl <thp perli ne>
Modified: trunk/data/cheese-prefs.glade
==============================================================================
--- trunk/data/cheese-prefs.glade (original)
+++ trunk/data/cheese-prefs.glade Thu Jun 19 21:36:36 2008
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.0 on Sat Apr 12 23:13:46 2008 -->
+<!--Generated with glade3 3.4.5 on Tue Jun 17 23:35:53 2008 -->
<glade-interface>
<widget class="GtkDialog" id="cheese_prefs_dialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -19,6 +19,34 @@
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
+ <widget class="GtkFrame" id="frame2">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <child>
+ <widget class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <widget class="GtkComboBox" id="webcam_combo_box">
+ <property name="visible">True</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Camera</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child>
<widget class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -49,6 +77,9 @@
</packing>
</child>
</widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
</widget>
<packing>
@@ -68,7 +99,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="no">gtk-close</property>
+ <property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
</widget>
Modified: trunk/data/cheese-prefs.ui
==============================================================================
--- trunk/data/cheese-prefs.ui (original)
+++ trunk/data/cheese-prefs.ui Thu Jun 19 21:36:36 2008
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!--Generated with glade3 3.4.0 on Sat Apr 12 23:13:46 2008 -->
+<!--Generated with glade3 3.4.5 on Tue Jun 17 23:35:53 2008 -->
<interface>
<object class="GtkDialog" id="cheese_prefs_dialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -18,6 +18,31 @@
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
+ <object class="GtkFrame" id="frame2">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkComboBox" id="webcam_combo_box">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Camera</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -45,6 +70,9 @@
</object>
</child>
</object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
<packing>
@@ -64,7 +92,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="no">gtk-close</property>
+ <property name="label">gtk-close</property>
<property name="use_stock">True</property>
</object>
</child>
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Thu Jun 19 21:36:36 2008
@@ -46,7 +46,9 @@
cheese-prefs-dialog.c \
cheese-prefs-dialog.h \
cheese-flash.h \
- cheese-flash.c
+ cheese-flash.c \
+ cheese-prefs-webcam-combo.c \
+ cheese-prefs-webcam-combo.h
cheese_LDADD = \
$(CHEESE_LIBS)
Modified: trunk/src/cheese-prefs-dialog.c
==============================================================================
--- trunk/src/cheese-prefs-dialog.c (original)
+++ trunk/src/cheese-prefs-dialog.c Thu Jun 19 21:36:36 2008
@@ -1,6 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: s; c-basic-offset: 2; tab-width: 2 -*- */
/*
* Copyright (C) 2008 James Liggett <jrliggett cox net>
+ * Copyright (C) 2008 daniel g. siegel <dgsiegel gmail com>
*
* Licensed under the GNU General Public License Version 2
*
@@ -24,6 +24,7 @@
{
GtkWidget *cheese_prefs_dialog;
GtkWidget *resolution_combo_box;
+ GtkWidget *webcam_combo_box;
GtkWidget *parent;
CheeseWebcam *webcam;
@@ -51,13 +52,14 @@
"cheese_prefs_dialog"));
prefs_dialog->resolution_combo_box = GTK_WIDGET (gtk_builder_get_object (builder,
"resolution_combo_box"));
-
+ prefs_dialog->webcam_combo_box = GTK_WIDGET (gtk_builder_get_object (builder,
+ "webcam_combo_box"));
gtk_window_set_transient_for (GTK_WINDOW (prefs_dialog->cheese_prefs_dialog),
GTK_WINDOW (prefs_dialog->parent));
}
static void
-on_resolution_changed (CheesePrefsWidget *widget, gpointer user_data)
+cheese_prefs_dialog_on_resolution_changed (CheesePrefsWidget *widget, gpointer user_data)
{
CheeseWebcam *webcam;
CheeseVideoFormat *current_format;
@@ -73,21 +75,52 @@
}
static void
+cheese_prefs_dialog_on_device_changed (CheesePrefsWidget *widget, CheesePrefsDialog *prefs_dialog)
+{
+ CheeseWebcam *webcam;
+ char *new_device_name;
+ char *old_device_name;
+
+ g_object_get (widget, "webcam", &webcam, NULL);
+ g_object_get (webcam, "device_name", &old_device_name, NULL);
+
+ new_device_name = cheese_prefs_webcam_combo_get_selected_webcam (CHEESE_PREFS_WEBCAM_COMBO (widget));
+ g_object_set (webcam, "device_name", new_device_name, NULL);
+ g_free (new_device_name);
+ if (!cheese_webcam_switch_webcam_device (webcam))
+ {
+ g_warning ("Couldn't change webcam device.");
+ /* Revert to default device */
+ g_object_set (webcam, "device_name", old_device_name, NULL);
+ }
+ cheese_prefs_dialog_widgets_synchronize (prefs_dialog->widgets);
+ g_free (old_device_name);
+}
+
+static void
cheese_prefs_dialog_setup_widgets (CheesePrefsDialog *prefs_dialog)
{
- CheesePrefsWidget *widget;
+ CheesePrefsWidget *resolution_widget;
+ CheesePrefsWidget *webcam_widget;
- widget = CHEESE_PREFS_WIDGET (cheese_prefs_resolution_combo_new (prefs_dialog->resolution_combo_box,
- prefs_dialog->webcam,
- "gconf_prop_x_resolution",
- "gconf_prop_y_resolution",
- 0, 0));
- g_signal_connect (G_OBJECT (widget), "changed",
- G_CALLBACK (on_resolution_changed),
+ resolution_widget = CHEESE_PREFS_WIDGET (cheese_prefs_resolution_combo_new (prefs_dialog->resolution_combo_box,
+ prefs_dialog->webcam,
+ "gconf_prop_x_resolution",
+ "gconf_prop_y_resolution",
+ 0, 0));
+ g_signal_connect (G_OBJECT (resolution_widget), "changed",
+ G_CALLBACK (cheese_prefs_dialog_on_resolution_changed),
NULL);
-
- cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, widget);
-
+ cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, resolution_widget);
+
+ webcam_widget = CHEESE_PREFS_WIDGET (cheese_prefs_webcam_combo_new (prefs_dialog->webcam_combo_box,
+ prefs_dialog->webcam,
+ "gconf_prop_webcam"));
+ g_signal_connect (G_OBJECT (webcam_widget), "changed",
+ G_CALLBACK (cheese_prefs_dialog_on_device_changed),
+ prefs_dialog);
+ cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, webcam_widget);
+
cheese_prefs_dialog_widgets_synchronize (prefs_dialog->widgets);
}
@@ -102,8 +135,7 @@
}
void
-cheese_prefs_dialog_run (GtkWidget *parent, CheeseGConf *gconf,
- CheeseWebcam *webcam)
+cheese_prefs_dialog_run (GtkWidget *parent, CheeseGConf *gconf, CheeseWebcam *webcam)
{
CheesePrefsDialog *prefs_dialog;
Modified: trunk/src/cheese-prefs-dialog.h
==============================================================================
--- trunk/src/cheese-prefs-dialog.h (original)
+++ trunk/src/cheese-prefs-dialog.h Thu Jun 19 21:36:36 2008
@@ -1,4 +1,3 @@
-/* -*- Mode: C; indent-tabs-mode: s; c-basic-offset: 2; tab-width: 2 -*- */
/*
* Copyright (C) 2008 James Liggett <jrliggett cox net>
*
@@ -28,8 +27,8 @@
#include "cheese-webcam.h"
#include "cheese-prefs-dialog-widgets.h"
#include "cheese-prefs-resolution-combo.h"
+#include "cheese-prefs-webcam-combo.h"
-void cheese_prefs_dialog_run (GtkWidget *parent, CheeseGConf *gconf,
- CheeseWebcam *webcam);
+void cheese_prefs_dialog_run (GtkWidget *parent, CheeseGConf *gconf, CheeseWebcam *webcam);
#endif /* _CHEESE_PREFS_DIALOG_H_ */
Added: trunk/src/cheese-prefs-webcam-combo.c
==============================================================================
--- (empty file)
+++ trunk/src/cheese-prefs-webcam-combo.c Thu Jun 19 21:36:36 2008
@@ -0,0 +1,283 @@
+/*
+ * Copyright (C) 2008 James Liggett <jrliggett cox net>
+ * Copyright (C) 2008 Ryan Zeigler <zeiglerr gmail com>
+ * Copyright (C) 2008 daniel g. siegel <dgsiegel gmail 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 <glib.h>
+
+#include "cheese-webcam.h"
+#include "cheese-prefs-widget.h"
+#include "cheese-prefs-webcam-combo.h"
+enum
+{
+ PRODUCT_NAME,
+ DEVICE_NAME,
+
+ NUM_COLS
+};
+
+enum
+{
+ PROP_0,
+ PROP_WEBCAM_DEVICE_KEY,
+ PROP_WEBCAM
+};
+
+typedef struct CheesePrefsWebcamComboPrivate
+{
+ gchar *webcam_device_key;
+ GtkListStore *list_store;
+ CheeseWebcam *webcam;
+ gboolean has_been_synchronized; /* Make sure we don't synchronize if client
+ * sets webcam on construction. */
+} CheesePrefsWebcamComboPrivate;
+
+#define CHEESE_PREFS_WEBCAM_COMBO_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_PREFS_WEBCAM_COMBO, \
+ CheesePrefsWebcamComboPrivate))
+
+G_DEFINE_TYPE (CheesePrefsWebcamCombo, cheese_prefs_webcam_combo, CHEESE_TYPE_PREFS_WIDGET);
+
+static void
+cheese_prefs_webcam_combo_init (CheesePrefsWebcamCombo *self)
+{
+ CheesePrefsWebcamComboPrivate *priv = CHEESE_PREFS_WEBCAM_COMBO_GET_PRIVATE (self);
+
+ priv->has_been_synchronized = FALSE;
+ priv->webcam = NULL;
+ priv->webcam_device_key = NULL;
+ priv->list_store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING);
+}
+
+static void
+cheese_prefs_webcam_combo_finalize (GObject *object)
+{
+ CheesePrefsWebcamCombo *self = CHEESE_PREFS_WEBCAM_COMBO (object);
+ CheesePrefsWebcamComboPrivate *priv = CHEESE_PREFS_WEBCAM_COMBO_GET_PRIVATE (self);
+
+ g_free (priv->webcam_device_key);
+ g_object_unref (priv->list_store);
+
+ G_OBJECT_CLASS (cheese_prefs_webcam_combo_parent_class)->finalize (object);
+}
+
+static void
+cheese_prefs_webcam_combo_selection_changed (GtkComboBox *combo_box, CheesePrefsWebcamCombo *self)
+{
+ CheesePrefsWebcamComboPrivate *priv = CHEESE_PREFS_WEBCAM_COMBO_GET_PRIVATE (self);
+ /* Put it into gconf */
+ char *new_device = cheese_prefs_webcam_combo_get_selected_webcam (self);
+ g_object_set (CHEESE_PREFS_WIDGET (self)->gconf, priv->webcam_device_key, new_device, NULL);
+ g_free (new_device);
+
+ cheese_prefs_widget_notify_changed (CHEESE_PREFS_WIDGET (self));
+}
+
+static void
+cheese_prefs_webcam_combo_synchronize (CheesePrefsWidget *prefs_widget)
+{
+ CheesePrefsWebcamCombo *self = CHEESE_PREFS_WEBCAM_COMBO (prefs_widget);
+ CheesePrefsWebcamComboPrivate *priv = CHEESE_PREFS_WEBCAM_COMBO_GET_PRIVATE (self);
+ GtkWidget *combo_box;
+ GArray *webcam_devices;
+ int selected_device_ind;
+ int num_devices;
+ CheeseWebcamDevice *selected_device;
+ char *product_name;
+ char *device_name;
+ CheeseWebcamDevice *device_ptr;
+ GtkTreeIter iter;
+ GtkTreeIter active_iter;
+ int i;
+
+ gboolean found_same_device = FALSE;
+
+ g_object_get (prefs_widget, "widget", &combo_box, NULL);
+ /* Disconnect to prevent a whole bunch of changed notifications */
+ g_signal_handlers_disconnect_by_func (combo_box, cheese_prefs_webcam_combo_selection_changed,
+ prefs_widget);
+
+ g_object_ref (priv->list_store);
+
+ gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), NULL);
+
+ webcam_devices = cheese_webcam_get_webcam_devices (priv->webcam);
+ selected_device_ind = cheese_webcam_get_selected_device (priv->webcam);
+ num_devices = cheese_webcam_get_num_webcam_devices (priv->webcam);
+
+ selected_device = &g_array_index (webcam_devices, CheeseWebcamDevice, selected_device_ind);
+
+ gtk_list_store_clear (priv->list_store);
+
+ for (i = 0; i < num_devices; i++)
+ {
+ device_ptr = &g_array_index (webcam_devices, CheeseWebcamDevice, i);
+ product_name = g_strdup_printf ("%s (%s)", device_ptr->product_name, device_ptr->video_device);
+ device_name = g_strdup (device_ptr->video_device);
+
+ gtk_list_store_append (priv->list_store, &iter);
+ gtk_list_store_set (priv->list_store, &iter, PRODUCT_NAME, product_name,
+ DEVICE_NAME, device_name,
+ -1);
+ g_free (product_name);
+ g_free (device_name);
+ if (device_ptr == selected_device)
+ {
+ active_iter = iter;
+ found_same_device = TRUE;
+ }
+ }
+
+ gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box),
+ GTK_TREE_MODEL (priv->list_store));
+
+ g_object_unref (priv->list_store);
+
+ if (found_same_device)
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &active_iter);
+ else
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
+
+ g_signal_connect (G_OBJECT (combo_box), "changed",
+ G_CALLBACK (cheese_prefs_webcam_combo_selection_changed),
+ self);
+
+ /* Set sensitive or not depending on whether or not there are webcam devices
+ available */
+ gtk_widget_set_sensitive (combo_box, num_devices > 0);
+
+ g_array_free (webcam_devices, TRUE);
+}
+
+static void
+cheese_prefs_webcam_combo_set_property (GObject *object, guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ CheesePrefsWebcamComboPrivate *priv = CHEESE_PREFS_WEBCAM_COMBO_GET_PRIVATE (object);
+ switch (prop_id)
+ {
+ case PROP_WEBCAM_DEVICE_KEY:
+ priv->webcam_device_key = g_value_dup_string (value);
+ break;
+ case PROP_WEBCAM:
+ priv->webcam = CHEESE_WEBCAM (g_value_get_object (value));
+ if (priv->has_been_synchronized)
+ cheese_prefs_webcam_combo_synchronize (CHEESE_PREFS_WIDGET (object));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+cheese_prefs_webcam_combo_get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ CheesePrefsWebcamComboPrivate *priv = CHEESE_PREFS_WEBCAM_COMBO_GET_PRIVATE (object);
+
+ g_return_if_fail (CHEESE_IS_PREFS_WEBCAM_COMBO (object));
+
+ switch (prop_id)
+ {
+ case PROP_WEBCAM_DEVICE_KEY:
+ g_value_set_string (value, priv->webcam_device_key);
+ break;
+ case PROP_WEBCAM:
+ g_value_set_object (value, priv->webcam);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+cheese_prefs_webcam_combo_class_init (CheesePrefsWebcamComboClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ CheesePrefsWidgetClass* parent_class = CHEESE_PREFS_WIDGET_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (CheesePrefsWebcamComboPrivate));
+
+ object_class->finalize = cheese_prefs_webcam_combo_finalize;
+ object_class->set_property = cheese_prefs_webcam_combo_set_property;
+ object_class->get_property = cheese_prefs_webcam_combo_get_property;
+ parent_class->synchronize = cheese_prefs_webcam_combo_synchronize;
+
+ g_object_class_install_property (object_class,
+ PROP_WEBCAM_DEVICE_KEY,
+ g_param_spec_string ("webcam_device_key",
+ "",
+ "Webcam device gconf key",
+ "",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_WEBCAM,
+ g_param_spec_object ("webcam",
+ "",
+ "Webcam object",
+ CHEESE_TYPE_WEBCAM,
+ G_PARAM_READWRITE));
+}
+
+
+CheesePrefsWebcamCombo *
+cheese_prefs_webcam_combo_new (GtkWidget *combo_box, CheeseWebcam *webcam,
+ const gchar *webcam_device_key)
+{
+ CheesePrefsWebcamCombo *self;
+ GtkCellRenderer *renderer;
+ CheesePrefsWebcamComboPrivate *priv;
+
+ self = g_object_new (CHEESE_TYPE_PREFS_WEBCAM_COMBO,
+ "widget", combo_box,
+ "webcam", webcam,
+ "webcam_device_key", webcam_device_key,
+ NULL);
+
+ priv = CHEESE_PREFS_WEBCAM_COMBO_GET_PRIVATE (self);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, FALSE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box), renderer, "text",
+ PRODUCT_NAME);
+ gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box),
+ GTK_TREE_MODEL (priv->list_store));
+
+ return self;
+}
+
+char *
+cheese_prefs_webcam_combo_get_selected_webcam (CheesePrefsWebcamCombo *webcam)
+{
+ CheesePrefsWebcamComboPrivate *priv = CHEESE_PREFS_WEBCAM_COMBO_GET_PRIVATE (webcam);
+ GtkTreeIter active_iter;
+ GtkWidget *combo_box;
+ char *device;
+
+ g_object_get (webcam, "widget", &combo_box, NULL);
+
+ gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &active_iter);
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->list_store), &active_iter, DEVICE_NAME, &device, -1);
+
+ return device;
+}
Added: trunk/src/cheese-prefs-webcam-combo.h
==============================================================================
--- (empty file)
+++ trunk/src/cheese-prefs-webcam-combo.h Thu Jun 19 21:36:36 2008
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2008 James Liggett <jrliggett cox net>
+ * Copyright (C) 2008 Ryan Zeigler <zeiglerr gmail 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_PREFS_WEBCAM_COMBO_H_
+#define _CHEESE_PREFS_WEBCAM_COMBO_H_
+
+#include <glib-object.h>
+#include "cheese-prefs-widget.h"
+#include "cheese-webcam.h"
+
+G_BEGIN_DECLS
+
+#define CHEESE_TYPE_PREFS_WEBCAM_COMBO (cheese_prefs_webcam_combo_get_type ())
+#define CHEESE_PREFS_WEBCAM_COMBO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHEESE_TYPE_PREFS_WEBCAM_COMBO, CheesePrefsWebcamCombo))
+#define CHEESE_PREFS_WEBCAM_COMBO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHEESE_TYPE_PREFS_WEBCAM_COMBO, CheesePrefsWebcamComboClass))
+#define CHEESE_IS_PREFS_WEBCAM_COMBO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHEESE_TYPE_PREFS_WEBCAM_COMBO))
+#define CHEESE_IS_PREFS_WEBCAM_COMBO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHEESE_TYPE_PREFS_WEBCAM_COMBO))
+#define CHEESE_PREFS_WEBCAM_COMBO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CHEESE_TYPE_PREFS_WEBCAM_COMBO, CheesePrefsWebcamComboClass))
+
+typedef struct _CheesePrefsWebcamComboClass CheesePrefsWebcamComboClass;
+typedef struct _CheesePrefsWebcamCombo CheesePrefsWebcamCombo;
+
+struct _CheesePrefsWebcamComboClass
+{
+ CheesePrefsWidgetClass parent_class;
+};
+
+struct _CheesePrefsWebcamCombo
+{
+ CheesePrefsWidget parent_instance;
+};
+
+GType cheese_prefs_webcam_combo_get_type (void) G_GNUC_CONST;
+
+CheesePrefsWebcamCombo * cheese_prefs_webcam_combo_new (GtkWidget *combo_box,
+ CheeseWebcam *webcam,
+ const gchar *webcam_device_key);
+
+char *cheese_prefs_webcam_combo_get_selected_webcam (CheesePrefsWebcamCombo *webcam);
+
+#endif /* _CHEESE_PREFS_WEBCAM_COMBO_H_ */
Modified: trunk/src/cheese-webcam.c
==============================================================================
--- trunk/src/cheese-webcam.c (original)
+++ trunk/src/cheese-webcam.c Thu Jun 19 21:36:36 2008
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2007,2008 Jaap Haitsma <jaap haitsma org>
* Copyright (C) 2007,2008 daniel g. siegel <dgsiegel gmail com>
+ * Copyright (C) 2008 Ryan Zeigler <zeiglerr gmail com>
*
* Licensed under the GNU General Public License Version 2
*
@@ -50,22 +51,11 @@
typedef struct
{
- char *video_device;
- char *gstreamer_src;
- char *product_name;
- int num_video_formats;
- GArray *video_formats;
-} CheeseWebcamDevice;
-
-
-typedef struct
-{
GtkWidget* video_window;
GstElement *pipeline;
GstBus *bus;
- /* We build the active pipeline by linking the appropriate pipelines listed
- below*/
+ /* We build the active pipeline by linking the appropriate pipelines listed below*/
GstElement *webcam_source_bin;
GstElement *video_display_bin;
GstElement *photo_save_bin;
@@ -965,6 +955,63 @@
return priv->num_webcam_devices;
}
+gboolean
+cheese_webcam_switch_webcam_device (CheeseWebcam *webcam)
+{
+ CheeseWebcamPrivate *priv = CHEESE_WEBCAM_GET_PRIVATE (webcam);
+ gboolean was_recording = FALSE;
+ gboolean pipeline_was_playing = FALSE;
+ gboolean disp_bin_created = FALSE;
+ gboolean disp_bin_added = FALSE;
+ gboolean disp_bin_linked = FALSE;
+ GError *error = NULL;
+
+ if (priv->is_recording)
+ {
+ cheese_webcam_stop_video_recording (webcam);
+ was_recording = TRUE;
+ }
+
+ if (priv->pipeline_is_playing)
+ {
+ cheese_webcam_stop (webcam);
+ pipeline_was_playing = TRUE;
+ }
+
+ gst_bin_remove (GST_BIN (priv->pipeline), priv->video_display_bin);
+
+ disp_bin_created = cheese_webcam_create_video_display_bin (webcam, &error);
+ if (!disp_bin_created)
+ {
+ return FALSE;
+ }
+ disp_bin_added = gst_bin_add (GST_BIN (priv->pipeline), priv->video_display_bin);
+ if (!disp_bin_added)
+ {
+ gst_object_sink (priv->video_display_bin);
+ return FALSE;
+ }
+
+ disp_bin_linked = gst_element_link (priv->video_display_bin, priv->photo_save_bin);
+ if (!disp_bin_linked)
+ {
+ gst_bin_remove (GST_BIN (priv->pipeline), priv->video_display_bin);
+ return FALSE;
+ }
+
+ if (pipeline_was_playing)
+ {
+ cheese_webcam_play (webcam);
+ }
+
+ /* if (was_recording)
+ {
+ Restart recording... ?
+ } */
+
+ return TRUE;
+}
+
void
cheese_webcam_play (CheeseWebcam *webcam)
{
@@ -1335,6 +1382,29 @@
}
+int
+cheese_webcam_get_selected_device (CheeseWebcam *webcam)
+{
+ CheeseWebcamPrivate *priv = CHEESE_WEBCAM_GET_PRIVATE (webcam);
+ return priv->selected_device;
+}
+
+GArray *
+cheese_webcam_get_webcam_devices (CheeseWebcam *webcam)
+{
+ GArray *devices_arr;
+ CheeseWebcamPrivate *priv = CHEESE_WEBCAM_GET_PRIVATE (webcam);
+
+ devices_arr = g_array_sized_new (FALSE,
+ TRUE,
+ sizeof(CheeseWebcamDevice),
+ priv->num_webcam_devices);
+ devices_arr = g_array_append_vals (devices_arr,
+ priv->webcam_devices,
+ priv->num_webcam_devices);
+ return devices_arr;
+}
+
GArray *
cheese_webcam_get_video_formats (CheeseWebcam *webcam)
{
@@ -1377,4 +1447,3 @@
return priv->current_format;
}
-
Modified: trunk/src/cheese-webcam.h
==============================================================================
--- trunk/src/cheese-webcam.h (original)
+++ trunk/src/cheese-webcam.h Thu Jun 19 21:36:36 2008
@@ -28,12 +28,12 @@
G_BEGIN_DECLS
-#define CHEESE_TYPE_WEBCAM (cheese_webcam_get_type ())
-#define CHEESE_WEBCAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CHEESE_TYPE_WEBCAM, CheeseWebcam))
-#define CHEESE_WEBCAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CHEESE_TYPE_WEBCAM, CheeseWebcamClass))
-#define CHEESE_IS_WEBCAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CHEESE_TYPE_WEBCAM))
-#define CHEESE_IS_WEBCAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CHEESE_TYPE_WEBCAM))
-#define CHEESE_WEBCAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CHEESE_TYPE_WEBCAM, CheeseWebcamClass))
+#define CHEESE_TYPE_WEBCAM (cheese_webcam_get_type ())
+#define CHEESE_WEBCAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CHEESE_TYPE_WEBCAM, CheeseWebcam))
+#define CHEESE_WEBCAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CHEESE_TYPE_WEBCAM, CheeseWebcamClass))
+#define CHEESE_IS_WEBCAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CHEESE_TYPE_WEBCAM))
+#define CHEESE_IS_WEBCAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CHEESE_TYPE_WEBCAM))
+#define CHEESE_WEBCAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CHEESE_TYPE_WEBCAM, CheeseWebcamClass))
typedef struct
{
@@ -50,6 +50,15 @@
CheeseFramerate *framerates;
} CheeseVideoFormat;
+typedef struct
+{
+ char *video_device;
+ char *gstreamer_src;
+ char *product_name;
+ int num_video_formats;
+ GArray *video_formats;
+} CheeseWebcamDevice;
+
typedef enum
{
CHEESE_WEBCAM_EFFECT_NO_EFFECT = (0),
@@ -80,24 +89,27 @@
} CheeseWebcamClass;
-GType cheese_webcam_get_type (void);
-CheeseWebcam *cheese_webcam_new (GtkWidget *video_window,
- char *webcam_device_name,
- int x_resolution,
- int y_resolution);
-void cheese_webcam_setup (CheeseWebcam *webcam, GError **error);
-void cheese_webcam_play (CheeseWebcam *webcam);
-void cheese_webcam_stop (CheeseWebcam *webcam);
-void cheese_webcam_set_effect (CheeseWebcam *webcam, CheeseWebcamEffect effect);
-void cheese_webcam_start_video_recording (CheeseWebcam *webcam, char *filename);
-void cheese_webcam_stop_video_recording (CheeseWebcam *webcam);
-void cheese_webcam_take_photo (CheeseWebcam *webcam, char *filename);
-gboolean cheese_webcam_has_webcam (CheeseWebcam *webcam);
-int cheese_webcam_get_num_webcam_devices (CheeseWebcam *webcam);
-GArray *cheese_webcam_get_video_formats (CheeseWebcam *webcam);
-void cheese_webcam_set_video_format (CheeseWebcam *webcam,
- CheeseVideoFormat *format);
+GType cheese_webcam_get_type (void);
+CheeseWebcam *cheese_webcam_new (GtkWidget *video_window,
+ char *webcam_device_name,
+ int x_resolution,
+ int y_resolution);
CheeseVideoFormat *cheese_webcam_get_current_video_format (CheeseWebcam *webcam);
+void cheese_webcam_setup (CheeseWebcam *webcam, GError **error);
+void cheese_webcam_play (CheeseWebcam *webcam);
+void cheese_webcam_stop (CheeseWebcam *webcam);
+void cheese_webcam_set_effect (CheeseWebcam *webcam, CheeseWebcamEffect effect);
+void cheese_webcam_start_video_recording (CheeseWebcam *webcam, char *filename);
+void cheese_webcam_stop_video_recording (CheeseWebcam *webcam);
+void cheese_webcam_take_photo (CheeseWebcam *webcam, char *filename);
+gboolean cheese_webcam_has_webcam (CheeseWebcam *webcam);
+int cheese_webcam_get_num_webcam_devices (CheeseWebcam *webcam);
+int cheese_webcam_get_selected_device (CheeseWebcam *webcam);
+GArray *cheese_webcam_get_webcam_devices (CheeseWebcam *webcam);
+gboolean cheese_webcam_switch_webcam_device (CheeseWebcam *webcam);
+GArray *cheese_webcam_get_video_formats (CheeseWebcam *webcam);
+void cheese_webcam_set_video_format (CheeseWebcam *webcam,
+ CheeseVideoFormat *format);
G_END_DECLS
#endif /* __CHEESE_WEBCAM_H__ */
Modified: trunk/src/cheese-window.c
==============================================================================
--- trunk/src/cheese-window.c (original)
+++ trunk/src/cheese-window.c Thu Jun 19 21:36:36 2008
@@ -1376,9 +1376,8 @@
GtkWidget *message_area;
GError *error;
-
g_object_get (cheese_window->gconf, "gconf_prop_x_resolution", &x_resolution,
- "gconf_prop_y_resolution", &y_resolution, NULL);
+ "gconf_prop_y_resolution", &y_resolution, "gconf_prop_webcam", &webcam_device, NULL);
gdk_threads_enter ();
cheese_window->webcam = cheese_webcam_new (cheese_window->screen,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]