[chronojump] webcam devices on gui/preferences shown fullname (not code)



commit 7e51aac1233d5a80cce2e36de50a559c52ea2595
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Apr 8 17:57:50 2019 +0200

    webcam devices on gui/preferences shown fullname (not code)

 src/gui/preferences.cs     | 18 ++++++++++--------
 src/webcamFfmpegDevices.cs | 11 ++++++++++-
 2 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index e97699e5..289f2c98 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -195,6 +195,7 @@ public class PreferencesWindow
        const int ENCODERCAPTUREPAGE = 4;
        const int ENCODEROTHERPAGE = 5;
 
+       static private WebcamDeviceList wd_list;
 
        PreferencesWindow () {
                Glade.XML gladeXML;
@@ -295,8 +296,8 @@ public class PreferencesWindow
                        PreferencesWindowBox.radio_sound_systemsounds.Active = true;
                PreferencesWindowBox.label_test_sound_result.Text = "";
 
-               PreferencesWindowBox.createComboCamera(UtilMultimedia.GetVideoDevices(), 
preferences.videoDevice,
-                               preferences.videoDeviceResolution, preferences.videoDeviceFramerate);
+               wd_list = UtilMultimedia.GetVideoDevices();
+               PreferencesWindowBox.createComboCamera(preferences.videoDevice, 
preferences.videoDeviceResolution, preferences.videoDeviceFramerate);
 
        
 
@@ -590,7 +591,7 @@ public class PreferencesWindow
         * end of triggers stuff
         */
 
-       private void createComboCamera(WebcamDeviceList wd_list, string current, string resolution, string 
framerate)
+       private void createComboCamera(string current, string resolution, string framerate)
        {
                //videoDevice
 
@@ -606,8 +607,8 @@ public class PreferencesWindow
                        return;
                }
                
-               UtilGtk.ComboUpdate(combo_camera, wd_list.GetCodes());
-               //UtilGtk.ComboUpdate(combo_camera, wd_list.GetFullnames());
+               //UtilGtk.ComboUpdate(combo_camera, wd_list.GetCodes());
+               UtilGtk.ComboUpdate(combo_camera, wd_list.GetFullnames());
                hbox_combo_camera.PackStart(combo_camera, true, true, 0);
                hbox_combo_camera.ShowAll();
 
@@ -1497,9 +1498,10 @@ public class PreferencesWindow
 
                //camera stuff
 
-               if( preferences.videoDevice != UtilGtk.ComboGetActive(combo_camera) ) {
-                       SqlitePreferences.Update("videoDevice", UtilGtk.ComboGetActive(combo_camera), true);
-                       preferences.videoDevice = UtilGtk.ComboGetActive(combo_camera);
+               string cameraCode = wd_list.GetCodeOfFullname(UtilGtk.ComboGetActive(combo_camera));
+               if( cameraCode != "" && preferences.videoDevice != cameraCode ) {
+                       SqlitePreferences.Update("videoDevice", cameraCode, true);
+                       preferences.videoDevice = cameraCode;
                }
 
                if( preferences.videoDeviceResolution != UtilGtk.ComboGetActive(combo_camera_resolution) ) {
diff --git a/src/webcamFfmpegDevices.cs b/src/webcamFfmpegDevices.cs
index f974fb3e..ad395b82 100644
--- a/src/webcamFfmpegDevices.cs
+++ b/src/webcamFfmpegDevices.cs
@@ -104,6 +104,15 @@ public class WebcamDeviceList
 
                return l;
        }
+
+       public string GetCodeOfFullname(string fullname)
+       {
+               foreach(WebcamDevice wd in wd_list)
+                       if(wd.Fullname == fullname)
+                               return wd.Code;
+
+               return "";
+       }
 }
 
 public abstract class WebcamFfmpegGetDevices
@@ -144,7 +153,7 @@ public class WebcamFfmpegGetDevicesLinux : WebcamFfmpegGetDevices
                        //return "/dev/video0", "/dev/video1", ...
                        wd_list.Add(new WebcamDevice(
                                                prefix + file.Name,
-                                               prefix + file.Name + " default camera"));
+                                               prefix + file.Name + " (default camera)"));
 
                return wd_list;
        }


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