[chronojump] Bug fixed if no camera on start



commit d3fe87efaa57d8bd22146bfe0402b501bfadb6cb
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sun May 5 15:04:45 2013 +0200

    Bug fixed if no camera on start

 src/gui/chronojump.cs   |   21 ++++++++++++++-------
 src/gui/encoder.cs      |    2 +-
 src/gui/eventExecute.cs |    4 ++--
 src/gui/person.cs       |   14 ++++++++++----
 4 files changed, 27 insertions(+), 14 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 1104004..961e058 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2705,7 +2705,7 @@ public partial class ChronoJumpWindow
 
                videoDeviceNum = Convert.ToInt32(SqlitePreferences.Select("videoDevice"));
                if(checkbutton_video.Active) {
-                       videoCapturePrepare();
+                       videoCapturePrepare(false); //if error, show message
                }
 
                //change language works on windows. On Linux let's change the locale
@@ -2804,11 +2804,20 @@ public partial class ChronoJumpWindow
                
                hbox_video_capture.PackStart(capturer, true, true, 0);
                
-               videoCapturePrepare(); 
+               videoCapturePrepare(false); //if error, show message
        }
 
        int videoDeviceNum = 0; 
-       private void videoCapturePrepare() {
+       private void videoCapturePrepare(bool showErrorMessage) {
+               Log.WriteLine("videoCapturePPPPPPPPPPPPPPPPPrepare");
+               List<LongoMatch.Video.Utils.Device> devices = 
LongoMatch.Video.Utils.Device.ListVideoDevices();
+               if(devices.Count == 0) {
+                       if(showErrorMessage)
+                               new DialogMessage(Constants.MessageTypes.WARNING, Constants.CameraNotFound);
+                       return;
+               }
+
+
                CapturePropertiesStruct s = new CapturePropertiesStruct();
 
                s.OutputFile = Util.GetVideoTempFileName();
@@ -2819,8 +2828,6 @@ public partial class ChronoJumpWindow
                s.Width = 360;
                s.Height = 288;
                
-Log.WriteLine("videoCapturePPPPPPPPPPPPPPPPPrepare");
-               List<LongoMatch.Video.Utils.Device> devices = 
LongoMatch.Video.Utils.Device.ListVideoDevices();
                foreach(LongoMatch.Video.Utils.Device dev in devices){
                        Log.WriteLine(dev.ID.ToString());
                        Log.WriteLine(dev.IDProperty.ToString());
@@ -2868,7 +2875,7 @@ Log.WriteLine("videoCapturePPPPPPPPPPPPPPPPPrepare");
                
                changeVideoButtons(videoOn);
                
-               videoCapturePrepare();
+               videoCapturePrepare(true); //if error, show message
        }
 
        private void on_checkbutton_video_encoder_clicked(object o, EventArgs args) {
@@ -2886,7 +2893,7 @@ Log.WriteLine("videoCapturePPPPPPPPPPPPPPPPPrepare");
                
                changeVideoButtons(videoOn);
                
-               videoCapturePrepare();
+               videoCapturePrepare(true); //if error, show message
        }
 
        private void changeVolumeButton(bool myVolume) {
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 4e86f4f..09eebff 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -3287,7 +3287,7 @@ Log.WriteLine(str);
                                if(videoOn) {
                                        label_video_feedback_encoder.Text = "";
                                        capturer.ClickStop();
-                                       videoCapturePrepare();
+                                       videoCapturePrepare(false); //if error, show message
                                }
                        }
                        //save video will be later at encoderSaveSignalOrCurve, because there 
encoderSignalUniqueID will be known
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index 83df50a..aed3486 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -1833,7 +1833,7 @@ Log.WriteLine("Preparing reactive A");
                if(videoOn) {   
                        label_video_feedback.Text = "";
                        capturer.ClickStop();
-                       videoCapturePrepare();
+                       videoCapturePrepare(false); //if error, show message
                }
        }
        
@@ -1960,7 +1960,7 @@ Log.WriteLine("Preparing reactive A");
                        //it will be recorded on temp, but chronojump will move it to chronojump/multimedia 
folders
                        label_video_feedback.Text = "";
                        capturer.ClickStop();
-                       videoCapturePrepare();
+                       videoCapturePrepare(false); //if error, show message
                }
        }
        
diff --git a/src/gui/person.cs b/src/gui/person.cs
index 453bdab..933135a 100644
--- a/src/gui/person.cs
+++ b/src/gui/person.cs
@@ -990,15 +990,20 @@ public class PersonAddModifyWindow
        CapturerBin capturer;
        void on_button_take_photo_clicked (object o, EventArgs args) 
        {
+               List<LongoMatch.Video.Utils.Device> devices = 
LongoMatch.Video.Utils.Device.ListVideoDevices();
+               if(devices.Count == 0) {
+                       new DialogMessage(Constants.MessageTypes.WARNING, Constants.CameraNotFound);
+                       return;
+               }
+
                //deactivate camera to allow camera on edit person. videoOn will have same value to light 
checkbutton again later
                app1_checkbutton_video.Active = false;
 
                capturer = new CapturerBin();
                CapturePropertiesStruct s = new CapturePropertiesStruct();
 
-               List<LongoMatch.Video.Utils.Device> devices = 
LongoMatch.Video.Utils.Device.ListVideoDevices();
                s.DeviceID = devices[0].ID;
-               
+
                s.CaptureSourceType = CaptureSourceType.System;
 
                capturer.CaptureProperties = s;
@@ -1006,8 +1011,8 @@ public class PersonAddModifyWindow
                capturer.Visible=true;
                capturer.NewSnapshot += on_snapshot_done;
                capturer.NewSnapshotMini += on_snapshot_mini_done;
-               
-               capturerWindow = new Gtk.Window("Capturer");
+
+               capturerWindow = new Gtk.Window("Capturer");
                capturerWindow.Add(capturer);
                capturerWindow.Modal=true;
                capturerWindow.SetDefaultSize(400,400);
@@ -1017,6 +1022,7 @@ public class PersonAddModifyWindow
                capturerWindow.ShowAll();
                capturerWindow.Present();
                capturerWindow.DeleteEvent += delegate(object sender, DeleteEventArgs e) {capturer.Close(); 
capturer.Dispose(); person_win.Show(); };
+               
                capturer.Run();
        }
 


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