[chronojump] Encoder video play working



commit bcf0a458eb34871225d3152ba4c78cc11a933f2a
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Apr 19 17:47:20 2013 +0200

    Encoder video play working

 glade/chronojump.glade | 30 ++++++++++++++++++++++++++++--
 src/encoder.cs         | 16 +++++++++++++---
 src/gui/chronojump.cs  |  8 +++++---
 src/gui/encoder.cs     | 22 ++++++++++++++++++----
 4 files changed, 64 insertions(+), 12 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index eeb3ce1..376c1ab 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -12723,6 +12723,32 @@ on current Chronojump version.</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkButton" 
id="button_video_play_this_test_encoder">
+                                                            <property name="visible">True</property>
+                                                            <property name="sensitive">False</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <property name="has_tooltip">True</property>
+                                                            <property name="tooltip" translatable="yes">Play 
Video (v)</property>
+                                                            <property 
name="use_action_appearance">False</property>
+                                                            <signal name="clicked" 
handler="on_video_play_this_test_encoder_clicked" swapped="no"/>
+                                                            <accelerator key="v" signal="clicked"/>
+                                                            <child>
+                                                            <widget class="GtkImage" id="image2">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-media-play</property>
+                                                            <property name="icon-size">1</property>
+                                                            </widget>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" id="hbox85">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -12773,7 +12799,7 @@ on current Chronojump version.</property>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
-                                                            <property name="position">1</property>
+                                                            <property name="position">3</property>
                                                             </packing>
                                                             </child>
                                                             <child>
@@ -12797,7 +12823,7 @@ on current Chronojump version.</property>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">True</property>
-                                                            <property name="position">2</property>
+                                                            <property name="position">4</property>
                                                             </packing>
                                                             </child>
                                                             </widget>
diff --git a/src/encoder.cs b/src/encoder.cs
index 7cb39b6..2689fb1 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -319,10 +319,12 @@ public class EncoderSQL
                return str;
        }
 
-       public string [] ToStringArray (int count, bool checkboxes) {
-               int all = 7;
+       public string [] ToStringArray (int count, bool checkboxes, bool video) {
+               int all = 8;
                if(checkboxes)
-                       all = 8;
+                       all ++;
+               if(video)
+                       all++;
 
                string [] str = new String [all];
                int i=0;
@@ -336,6 +338,14 @@ public class EncoderSQL
                str[i++] = ecconLong;
                str[i++] = extraWeight;
                str[i++] = GetDate(true);
+               
+               if(video) {
+                       if(future2 != "")
+                               str[i++] = Catalog.GetString("Yes");
+                       else
+                               str[i++] = Catalog.GetString("No");
+               }
+
                str[i++] = description;
                return str;
        }
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index af73d02..88063d7 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -4584,11 +4584,11 @@ Console.WriteLine("X");
         */
 
        
-       private void playVideo(string fileName) {
+       private bool playVideo(string fileName) {
                if(File.Exists(fileName)) {
                        PlayerBin player = new PlayerBin();
                        player.Open(fileName);
-                       
+
                        //without these lines works also but has less functionalities (speed, go to ms)
                        Gtk.Window d = new Gtk.Window(Catalog.GetString("Playing video"));
                        d.Add(player);
@@ -4596,8 +4596,10 @@ Console.WriteLine("X");
                        d.SetDefaultSize(500,400);
                        d.ShowAll();
                        d.DeleteEvent += delegate(object sender, DeleteEventArgs e) {player.Close(); 
player.Dispose();};
-                       player.Play(); 
+                       player.Play();
+                       return true;    
                }
+               return false;   
        }
 
        private void on_video_play_this_test_clicked (object o, EventArgs args) {
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index c734756..eb309f6 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -41,6 +41,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Button button_encoder_capture_finish;
        [Widget] Gtk.Button button_encoder_recalculate;
        [Widget] Gtk.Button button_encoder_load_signal;
+       [Widget] Gtk.Button button_video_play_this_test_encoder;
        [Widget] Gtk.Viewport viewport_image_encoder_capture;
        [Widget] Gtk.Image image_encoder_bell;
        [Widget] Gtk.SpinButton spin_encoder_capture_time;
@@ -395,7 +396,7 @@ public partial class ChronoJumpWindow
                foreach(EncoderSQL es in data) {
                        checkboxes[count++] = es.future1;
                        Log.WriteLine(checkboxes[count-1]);
-                       dataPrint.Add(es.ToStringArray(count,true));
+                       dataPrint.Add(es.ToStringArray(count,true,false));
                }
        
                string [] columnsString = {
@@ -756,7 +757,7 @@ public partial class ChronoJumpWindow
                ArrayList dataPrint = new ArrayList();
                int count = 1;
                foreach(EncoderSQL es in data) 
-                       dataPrint.Add(es.ToStringArray(count++,false));
+                       dataPrint.Add(es.ToStringArray(count++,false,true));
                
                string [] columnsString = {
                        Catalog.GetString("ID"),
@@ -765,6 +766,7 @@ public partial class ChronoJumpWindow
                        Catalog.GetString("Contraction"),
                        Catalog.GetString("Extra weight"),
                        Catalog.GetString("Date"),
+                       Catalog.GetString("Video"),
                        Catalog.GetString("Comment")
                };
 
@@ -832,6 +834,7 @@ public partial class ChronoJumpWindow
                                entry_encoder_signal_comment.Text = es.description;
                                encoderTimeStamp = es.GetDate(false); 
                                encoderSignalUniqueID = es.uniqueID;
+                               button_video_play_this_test_encoder.Sensitive = (es.future2 != "");
                        }
                }
 
@@ -1275,6 +1278,7 @@ public partial class ChronoJumpWindow
                                encoderSignalUniqueID = myID;
                                feedback = Catalog.GetString("Signal saved");
                        
+                               button_video_play_this_test_encoder.Sensitive = false;
                                //move video    
                                if(videoOn) {
                                        if(Util.MoveTempVideo(currentSession.UniqueID, 
@@ -1286,9 +1290,11 @@ public partial class ChronoJumpWindow
                                                //need assign uniqueID to update and add the URL of video
                                                eSQL.uniqueID = encoderSignalUniqueID;
                                                SqliteEncoder.Update(false, eSQL);
-                                       } else
+                                               button_video_play_this_test_encoder.Sensitive = true;
+                                       } else {
                                                new DialogMessage(Constants.MessageTypes.WARNING, 
                                                                Catalog.GetString("Sorry, video cannot be 
stored."));
+                                       }
                                }
                        }
                }
@@ -2901,6 +2907,7 @@ Log.WriteLine(str);
                button_encoder_capture.Sensitive = Util.IntToBool(table[0]);
 
                button_encoder_recalculate.Sensitive = Util.IntToBool(table[1]);
+               
                button_encoder_load_signal.Sensitive = Util.IntToBool(table[2]);
                
                button_encoder_save_all_curves.Sensitive = Util.IntToBool(table[3]);
@@ -3103,6 +3110,7 @@ Log.WriteLine(str);
                                        capturer.ClickRec();
                                        label_video_feedback_encoder.Text = "Rec";
                                }
+                               button_video_play_this_test_encoder.Sensitive = false; 
 
                                encoderThreadCapture = new Thread(new ThreadStart(captureCsharp));
                                GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderCapture));
@@ -3351,5 +3359,11 @@ Log.WriteLine(str);
        }
        
        /* end of thread stuff */
-       
+
+       void on_video_play_this_test_encoder_clicked (object o, EventArgs args) {
+               if(! playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
+                                       Constants.TestTypes.ENCODER, Convert.ToInt32(encoderSignalUniqueID))))
+                       new DialogMessage(Constants.MessageTypes.WARNING, 
+                                       Catalog.GetString("Sorry, file not found"));
+       }
 }      


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