[chronojump] webcam preview on preferences gui



commit f791a738440340a06b4122ee116d8b2c8fa6124d
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Apr 8 18:54:19 2019 +0200

    webcam preview on preferences gui

 glade/preferences_win.glade | 67 +++++++++++++++++++++++++++++++++++++--------
 src/gui/preferences.cs      | 16 ++++++++++-
 2 files changed, 71 insertions(+), 12 deletions(-)
---
diff --git a/glade/preferences_win.glade b/glade/preferences_win.glade
index 1de8414a..c8197e6b 100644
--- a/glade/preferences_win.glade
+++ b/glade/preferences_win.glade
@@ -3409,17 +3409,6 @@ Other</property>
                         <property name="position">2</property>
                       </packing>
                     </child>
-                    <child>
-                      <widget class="GtkLabel" id="label_webcam_windows">
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">On Windows at least Windows 7 is 
required.</property>
-                      </widget>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">3</property>
-                      </packing>
-                    </child>
                     <child>
                       <widget class="GtkHBox" id="hbox_camera_resolution_framerate">
                         <property name="visible">True</property>
@@ -3501,6 +3490,62 @@ Other</property>
                             <property name="position">1</property>
                           </packing>
                         </child>
+                        <child>
+                          <widget class="GtkButton" id="button_video_preview">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="tooltip" translatable="yes">Preview video</property>
+                            <signal name="clicked" handler="on_button_video_preview_clicked" swapped="no"/>
+                            <child>
+                              <widget class="GtkHBox" id="hbox321">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">4</property>
+                                <child>
+                                  <widget class="GtkImage" id="image_video_preview">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="stock">gtk-missing-image</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkLabel" id="label392">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Preview</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </widget>
+                            </child>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                      </widget>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="label_webcam_windows">
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">On Windows at least Windows 7 is 
required.</property>
                       </widget>
                       <packing>
                         <property name="expand">True</property>
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 289f2c98..489e7f4a 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -152,6 +152,7 @@ public class PreferencesWindow
        [Widget] Gtk.ComboBox combo_camera_framerate;
        [Widget] Gtk.Label label_no_cameras;
        [Widget] Gtk.Label label_webcam_windows;
+       [Widget] Gtk.Image image_video_preview;
 
        //language tab
        [Widget] Gtk.Box hbox_combo_language;
@@ -242,6 +243,7 @@ public class PreferencesWindow
                PreferencesWindowBox.preferences = preferences;
 
                PreferencesWindowBox.createComboLanguage();
+               Pixbuf pixbuf;
 
                //appearence tab
                if(preferences.maximized == Preferences.MaximizedTypes.NO)
@@ -299,6 +301,8 @@ public class PreferencesWindow
                wd_list = UtilMultimedia.GetVideoDevices();
                PreferencesWindowBox.createComboCamera(preferences.videoDevice, 
preferences.videoDeviceResolution, preferences.videoDeviceFramerate);
 
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_photo_preview.png");
+               PreferencesWindowBox.image_video_preview.Pixbuf = pixbuf;
        
 
                string [] decs = {"1", "2", "3"};
@@ -377,7 +381,6 @@ public class PreferencesWindow
 
                //start of double contacts stuff ----
 
-               Pixbuf pixbuf;
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_run_simple.png");
                PreferencesWindowBox.image_races_simple.Pixbuf = pixbuf;
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_run_multiple.png");
@@ -683,6 +686,17 @@ public class PreferencesWindow
                Util.TestSound = false;
        }
 
+       private void on_button_video_preview_clicked (object o, EventArgs args)
+       {
+               string cameraCode = wd_list.GetCodeOfFullname(UtilGtk.ComboGetActive(combo_camera));
+               if(cameraCode == "")
+                       return;
+
+               Webcam webcamPlay = new WebcamFfmpeg (Webcam.Action.PLAYPREVIEW, UtilAll.GetOSEnum(),
+                               cameraCode, UtilGtk.ComboGetActive(combo_camera_resolution), 
UtilGtk.ComboGetActive(combo_camera_framerate));
+               Webcam.Result result = webcamPlay.PlayPreviewNoBackground ();
+       }
+
        // ---- end of multimedia stuff
 
        // ---- Language stuff


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