[cheese] add a command line option to specify camera file, fixes bug #614778



commit 2baf095b7746de4dbf1acaa8bd55cc02f948cc01
Author: daniel g. siegel <dgsiegel gnome org>
Date:   Mon Aug 9 01:01:52 2010 +0200

    add a command line option to specify camera file, fixes bug #614778
    
    the -d or --device option was added to specify a different
    device file. if the device file does not exist, or is not a
    valid v4l/v4l2 device it will be silently ignored

 src/cheese-main.vala   |    4 +++-
 src/cheese-window.vala |   12 +++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/cheese-main.vala b/src/cheese-main.vala
index 134cc4b..56fde6f 100644
--- a/src/cheese-main.vala
+++ b/src/cheese-main.vala
@@ -29,6 +29,7 @@ public class Cheese.Main
 {
   static bool       verbose;
   static bool       wide;
+  static string     device;
   static bool       version_only;
   static FileStream log_file;
 
@@ -37,6 +38,7 @@ public class Cheese.Main
   const OptionEntry[] options = {
     { "verbose", 'v', 0, OptionArg.NONE, ref verbose,      N_("Be verbose"),                          null},
     { "wide",    'w', 0, OptionArg.NONE, ref wide,         N_("Enable wide mode"),                    null},
+    { "device",  'd', 0, OptionArg.FILENAME, ref device,   N_("Device to use as a camera"),           N_("DEVICE")},
     { "version", 0,   0, OptionArg.NONE, ref version_only, N_("Output version information and exit"), null},
     { null}
   };
@@ -117,7 +119,7 @@ public class Cheese.Main
     main_window.setup_ui ();
     main_window.destroy.connect (Gtk.main_quit);
     main_window.show_all ();
-    main_window.setup_camera ();
+    main_window.setup_camera (device);
     Gtk.main ();
 
     return 0;
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index 83b3440..66f499b 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -1032,15 +1032,21 @@ public class Cheese.MainWindow : Gtk.Window
     toggle_camera_actions_sensitivities (false);
   }
 
-  public void setup_camera ()
+  public void setup_camera (string uri)
   {
+    string device;
+    if (uri.length > 0)
+      device = uri;
+    else
+      device = conf.gconf_prop_camera;
+
     camera = new Camera (video_preview,
-                         conf.gconf_prop_camera,
+                         device,
                          conf.gconf_prop_x_resolution,
                          conf.gconf_prop_y_resolution);
 
     try {
-      camera.setup (conf.gconf_prop_camera);
+      camera.setup (device);
     }
     catch (Error err)
     {



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