cheese r777 - in trunk: . src
- From: jhaitsma svn gnome org
- To: svn-commits-list gnome org
- Subject: cheese r777 - in trunk: . src
- Date: Mon, 23 Jun 2008 19:12:51 +0000 (UTC)
Author: jhaitsma
Date: Mon Jun 23 19:12:50 2008
New Revision: 777
URL: http://svn.gnome.org/viewvc/cheese?rev=777&view=rev
Log:
Make hal-device-id command line option work Fixes bug #498023. Patch by zeiglerr at gmail dot com
Modified:
trunk/ChangeLog
trunk/src/cheese-prefs-webcam-combo.c
trunk/src/cheese-webcam.c
trunk/src/cheese-webcam.h
trunk/src/cheese-window.c
trunk/src/cheese-window.h
trunk/src/cheese.c
Modified: trunk/src/cheese-prefs-webcam-combo.c
==============================================================================
--- trunk/src/cheese-prefs-webcam-combo.c (original)
+++ trunk/src/cheese-prefs-webcam-combo.c Mon Jun 23 19:12:50 2008
@@ -19,6 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <string.h>
#include <glib.h>
#include "cheese-webcam.h"
@@ -99,6 +100,7 @@
int selected_device_ind;
int num_devices;
CheeseWebcamDevice *selected_device;
+ char *gconf_device_name;
char *product_name;
char *device_name;
CheeseWebcamDevice *device_ptr;
@@ -118,11 +120,21 @@
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);
+ selected_device_ind = cheese_webcam_get_selected_device_index (priv->webcam);
num_devices = cheese_webcam_get_num_webcam_devices (priv->webcam);
selected_device = &g_array_index (webcam_devices, CheeseWebcamDevice, selected_device_ind);
+ /* If the selected device is not the same device as the one in gconf, the
+ selected device isn't available or was set by --hal-device. Set it now.
+ Not sure if this is desired behavior */
+ g_object_get (prefs_widget->gconf, priv->webcam_device_key, &gconf_device_name, NULL);
+ if (strcmp(selected_device->video_device, gconf_device_name) != 0)
+ {
+ g_object_set(prefs_widget->gconf, priv->webcam_device_key, selected_device->video_device, NULL);
+ }
+ g_free(gconf_device_name);
+
gtk_list_store_clear (priv->list_store);
for (i = 0; i < num_devices; i++)
Modified: trunk/src/cheese-webcam.c
==============================================================================
--- trunk/src/cheese-webcam.c (original)
+++ trunk/src/cheese-webcam.c Mon Jun 23 19:12:50 2008
@@ -299,6 +299,7 @@
{
priv->webcam_devices[i].num_video_formats = 0;
priv->webcam_devices[i].video_formats = g_array_new (FALSE, FALSE, sizeof (CheeseVideoFormat));
+ priv->webcam_devices[i].hal_udi = g_strdup (udis[i]);
}
for (i = 0; i < priv->num_webcam_devices; i++)
@@ -1165,6 +1166,7 @@
g_free (g_array_index (priv->webcam_devices[i].video_formats, CheeseVideoFormat, j).framerates);
g_free (g_array_index (priv->webcam_devices[i].video_formats, CheeseVideoFormat, j).mimetype);
}
+ g_free (priv->webcam_devices[i].hal_udi);
g_array_free (priv->webcam_devices[i].video_formats, TRUE);
}
g_free (priv->webcam_devices);
@@ -1335,13 +1337,19 @@
}
void
-cheese_webcam_setup (CheeseWebcam *webcam, GError **error)
+cheese_webcam_setup (CheeseWebcam *webcam, char *hal_dev_udi, GError **error)
{
CheeseWebcamPrivate* priv = CHEESE_WEBCAM_GET_PRIVATE (webcam);
gboolean ok = TRUE;
GError *tmp_error = NULL;
cheese_webcam_detect_webcam_devices (webcam);
+
+ if (hal_dev_udi != NULL)
+ {
+ cheese_webcam_set_device_by_dev_udi (webcam, hal_dev_udi);
+ }
+
cheese_webcam_create_video_display_bin (webcam, &tmp_error);
if (tmp_error != NULL)
{
@@ -1382,7 +1390,7 @@
}
int
-cheese_webcam_get_selected_device (CheeseWebcam *webcam)
+cheese_webcam_get_selected_device_index (CheeseWebcam *webcam)
{
CheeseWebcamPrivate *priv = CHEESE_WEBCAM_GET_PRIVATE (webcam);
return priv->selected_device;
@@ -1404,6 +1412,27 @@
return devices_arr;
}
+void
+cheese_webcam_set_device_by_dev_file (CheeseWebcam *webcam, char *file)
+{
+ g_object_set(webcam, "device_name", file, NULL);
+}
+
+void
+cheese_webcam_set_device_by_dev_udi (CheeseWebcam *webcam, char *udi)
+{
+ CheeseWebcamPrivate *priv = CHEESE_WEBCAM_GET_PRIVATE (webcam);
+ int i;
+ for (i = 0; i < priv->num_webcam_devices; i++)
+ {
+ if (strcmp(priv->webcam_devices[i].hal_udi, udi) == 0)
+ {
+ g_object_set(webcam, "device_name", priv->webcam_devices[i].video_device, NULL);
+ break;
+ }
+ }
+}
+
GArray *
cheese_webcam_get_video_formats (CheeseWebcam *webcam)
{
Modified: trunk/src/cheese-webcam.h
==============================================================================
--- trunk/src/cheese-webcam.h (original)
+++ trunk/src/cheese-webcam.h Mon Jun 23 19:12:50 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
*
@@ -53,6 +54,7 @@
typedef struct
{
char *video_device;
+ char *hal_udi;
char *gstreamer_src;
char *product_name;
int num_video_formats;
@@ -95,7 +97,7 @@
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_setup (CheeseWebcam *webcam, char *udi, GError **error);
void cheese_webcam_play (CheeseWebcam *webcam);
void cheese_webcam_stop (CheeseWebcam *webcam);
void cheese_webcam_set_effect (CheeseWebcam *webcam, CheeseWebcamEffect effect);
@@ -104,8 +106,10 @@
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);
+int cheese_webcam_get_selected_device_index (CheeseWebcam *webcam);
GArray *cheese_webcam_get_webcam_devices (CheeseWebcam *webcam);
+void cheese_webcam_set_device_by_dev_file (CheeseWebcam *webcam, char *file);
+void cheese_webcam_set_device_by_dev_udi (CheeseWebcam *webcam, char *udi);
gboolean cheese_webcam_switch_webcam_device (CheeseWebcam *webcam);
GArray *cheese_webcam_get_video_formats (CheeseWebcam *webcam);
void cheese_webcam_set_video_format (CheeseWebcam *webcam,
Modified: trunk/src/cheese-window.c
==============================================================================
--- trunk/src/cheese-window.c (original)
+++ trunk/src/cheese-window.c Mon Jun 23 19:12:50 2008
@@ -2,6 +2,7 @@
* Copyright (C) 2007,2008 daniel g. siegel <dgsiegel gmail com>
* Copyright (C) 2007,2008 Jaap Haitsma <jaap haitsma org>
* Copyright (C) 2008 Patryk Zawadzki <patrys pld-linux org>
+ * Copyright (C) 2008 Ryan Zeigler <zeiglerr gmail com>
*
* Licensed under the GNU General Public License Version 2
*
@@ -63,6 +64,8 @@
{
gboolean recording;
+ /* UDI device requested on the command line */
+ char *startup_hal_dev_udi;
char *video_filename;
char *photo_filename;
@@ -1387,8 +1390,7 @@
g_free (webcam_device);
error = NULL;
- cheese_webcam_setup (cheese_window->webcam, &error);
-
+ cheese_webcam_setup (cheese_window->webcam, cheese_window->startup_hal_dev_udi, &error);
if (error != NULL)
{
GtkWidget *dialog;
@@ -1441,12 +1443,13 @@
}
void
-cheese_window_init ()
+cheese_window_init (char *hal_dev_udi)
{
CheeseWindow *cheese_window;
cheese_window = g_new0 (CheeseWindow, 1);
+ cheese_window->startup_hal_dev_udi = hal_dev_udi;
cheese_window->gconf = cheese_gconf_new ();
cheese_window->audio_play_counter = 0;
cheese_window->rand = g_rand_new ();
Modified: trunk/src/cheese-window.h
==============================================================================
--- trunk/src/cheese-window.h (original)
+++ trunk/src/cheese-window.h Mon Jun 23 19:12:50 2008
@@ -23,6 +23,6 @@
#include <gtk/gtk.h>
-void cheese_window_init (void);
+void cheese_window_init (char *hal_dev_udi);
#endif /* __CHEESE_WINDOW_H__ */
Modified: trunk/src/cheese.c
==============================================================================
--- trunk/src/cheese.c (original)
+++ trunk/src/cheese.c Mon Jun 23 19:12:50 2008
@@ -111,7 +111,7 @@
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
APPNAME_DATA_DIR G_DIR_SEPARATOR_S "icons");
- cheese_window_init ();
+ cheese_window_init (CheeseOptions.hal_device_id);
gdk_threads_enter ();
gtk_main ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]