[chronojump] Better splashWin on start



commit 221c35b02b77d41055d1784bc38945bc591c5c3c
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jul 19 16:24:35 2017 +0200

    Better splashWin on start

 glade/app1.glade          |    7 +++-
 glade/splash_window.glade |   10 ++--
 src/chronojump.cs         |  103 +++++++--------------------------------------
 src/constants.cs          |   18 +++++---
 src/gui/chronojump.cs     |   30 +++++++++++--
 src/gui/splash.cs         |   43 +++++++-----------
 6 files changed, 81 insertions(+), 130 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 3416316..f77bfcb 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -3,7 +3,6 @@
   <!-- interface-requires gtk+ 3.0 -->
   <!-- interface-naming-policy toplevel-contextual -->
   <widget class="GtkWindow" id="app1">
-    <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Chronojump</property>
     <property name="default_width">800</property>
@@ -1346,6 +1345,9 @@
                                                             <placeholder/>
                                                             </child>
                                                             <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkLabel" 
id="label_start_selector_jumps">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -20970,6 +20972,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/glade/splash_window.glade b/glade/splash_window.glade
index 8a3cb18..b8b9482 100644
--- a/glade/splash_window.glade
+++ b/glade/splash_window.glade
@@ -5,8 +5,10 @@
   <widget class="GtkWindow" id="splash_window">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
+    <property name="type">popup</property>
     <property name="title">Chronojump</property>
     <property name="resizable">False</property>
+    <property name="modal">True</property>
     <property name="window_position">center-always</property>
     <property name="type_hint">splashscreen</property>
     <child>
@@ -57,15 +59,13 @@
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <child>
-                      <widget class="GtkButton" id="button_cancel">
-                        <property name="label">gtk-cancel</property>
-                        <property name="visible">True</property>
+                      <widget class="GtkButton" id="button_close">
+                        <property name="label">gtk-close</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
                         <property name="has_tooltip">True</property>
-                        <property name="tooltip" translatable="yes">Cancel connection with server</property>
                         <property name="use_stock">True</property>
-                        <signal name="clicked" handler="on_button_cancel_clicked" swapped="no"/>
+                        <signal name="clicked" handler="on_button_close_clicked" swapped="no"/>
                         <accelerator key="Escape" signal="clicked"/>
                       </widget>
                       <packing>
diff --git a/src/chronojump.cs b/src/chronojump.cs
index c20cc80..f458cae 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -201,8 +201,6 @@ public class ChronoJump
        new ChronoJump(args);
        }
 
-       bool createdSplashWin = false;
-
        public static string RelativeToPrefix(string relativePath) {
                return System.IO.Path.Combine(baseDirectory, relativePath);
        }
@@ -214,7 +212,6 @@ public class ChronoJump
 
                //start threading to show splash window
                SplashWindow.Show();
-               createdSplashWin = true;
 
                fakeSplashButton = new Gtk.Button();
                fakeSplashButton.Clicked += new EventHandler(on_splash_ended);
@@ -405,24 +402,6 @@ public class ChronoJump
 
                //connect to server to Ping
                versionAvailable = "";
-               /*
-               pingStart = false;
-               pingEnd = false;
-               
-               // disable server connection on start until server is not working on windows again 
-               bool connectServerAtStart = false;
-               if(connectServerAtStart) {
-                       thread = new Thread(new ThreadStart(findVersion));
-                       GLib.Idle.Add (new GLib.IdleHandler (PulseGTKPing));
-                       thread.Start(); 
-               
-                       //wait until pinging process start
-                       while(! pingStart) {
-                       }
-               }
-               else
-                       on_find_version_cancelled(new object(), new EventArgs());
-               */
                versionAvailable = Constants.ServerOffline;
        
 
@@ -510,40 +489,6 @@ public class ChronoJump
 
        }
 
-       private void findVersion() {
-               LogB.Debug("--1--");
-               //pingStart = true;
-
-               LogB.Debug("--2--");
-               //maybe other thread doesn't create at time the splash win
-               //then just wait
-               while(! createdSplashWin)
-                       ;
-               
-               LogB.Debug("--2.1--");
-                       
-               try {
-                       if(splashWin.FakeButtonCreated)
-                               LogB.Information("Created splashWin.FakeButton");
-                       else
-                               LogB.Warning("NOT Created splashWin.FakeButton, si es bloqueja, posar aquĆ­ un 
while (mentre no estigui creat)");
-
-                       splashWin.FakeButtonCancel.Clicked += new EventHandler(on_find_version_cancelled);
-
-                       LogB.Debug("--3--");
-               } catch {
-                       LogB.Warning("Problem with splash win");
-               }
-
-               versionAvailable = Server.Ping(true, progName, UtilAll.ReadVersion()); //doInsertion
-               
-               LogB.Debug("--4--");
-               LogB.Information(" version:  ", versionAvailable);
-               LogB.Debug("\n--5--");
-               //pingEnd = true;
-               LogB.Debug("--6--");
-       }
-               
        private void on_find_version_cancelled(object o, EventArgs args) {
                versionAvailable = Constants.ServerOffline;
                //pingEnd = true;
@@ -558,8 +503,9 @@ public class ChronoJump
                        if(chronojumpHasToExit)
                        {
                                if(quitNowCjTwoTimes) {
-                                       errorWin = ErrorWindow.Show(messageToShowOnBoot);
-                                       errorWin.Button_accept.Clicked += new 
EventHandler(on_message_boot_accepted_quit_not_deleting_runningfilename);
+                                       splashWin.UpdateLabel(messageToShowOnBoot);
+                                       splashWin.FakeButtonClose.Clicked += new 
EventHandler(on_message_boot_accepted_quit_not_deleting_runningfilename);
+                                       splashWin.ShowButtonClose();
                                } else {
                                        messageToShowOnBoot += "\n<b>" + 
string.Format(Catalog.GetString("Chronojump will exit now.")) + "</b>\n";
 
@@ -602,8 +548,15 @@ public class ChronoJump
                                //(eg from before installer to installjammer) maybe it will not find this 
runningFileName
                        }
                }
-               Log.End();
-               //Log.Delete();
+
+               if(splashWin != null)
+                       splashWin.Destroy();
+               else
+                       SplashWindow.Hide();
+
+               if(! quitNowCjTwoTimes)
+                       Log.End();
+
                Application.Quit();
        }
 
@@ -617,7 +570,7 @@ public class ChronoJump
                }
                LogB.SQL("all SQL done! starting Chronojump");
 
-               new ChronoJumpWindow(progVersion, progName, runningFileName);
+               new ChronoJumpWindow(progVersion, progName, runningFileName, splashWin);
        }
 
        private static void createBlankDB() {
@@ -649,9 +602,10 @@ public class ChronoJump
        /* splash window things 
         * --------------------*/
 
-       private void splashMessageChange(int messageInt) {
+       private void splashMessageChange(int messageInt)
+       {
               splashMessage = Catalog.GetString(Constants.SplashMessages[messageInt]);
-               needUpdateSplashMessage = true;
+              needUpdateSplashMessage = true;
        }
        
        protected bool PulseGTK ()
@@ -699,37 +653,12 @@ public class ChronoJump
        {
                LogB.Information("splash screen going to END");
                fakeSplashButton.Clicked -= new EventHandler(on_splash_ended);
-               if(splashWin != null)
-                       splashWin.Destroy();
-               else
-                       SplashWindow.Hide();
 
                LogB.Information("splash screen ENDED!");
 
                readMessageToStart();
        }
 
-       /*
-       protected bool PulseGTKPing ()
-       {
-               if(pulseGTKPingShouldEnd) {
-                       splashWin.CancelButtonShow(false);
-                       LogB.Information("ping going to END");
-                       return false;
-               }
-
-               if(splashShowButton)
-                       splashWin.CancelButtonShow(true); //show cancel button on splash win
-               else
-                       splashWin.CancelButtonShow(false);
-
-               Thread.Sleep (50);
-               LogB.Debug(" (PulseGTKPing:" + thread.ThreadState.ToString() + ") ");
-               if(thread.ThreadState == System.Threading.ThreadState.Stopped)
-                       pulseGTKPingShouldEnd = true;
-               return true;
-       }
-       */
        
        /* ---------------------
         * other support methods 
diff --git a/src/constants.cs b/src/constants.cs
index 2e04614..cdb5ad3 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -602,13 +602,17 @@ public class Constants
        };
 
        public static string [] SplashMessages = {
-               Catalog.GetString("Initializing"),              //0
-               Catalog.GetString("Checking database"),         //1
-               Catalog.GetString("Creating database"),         //2
-               Catalog.GetString("Making database backup"),    //3
-               Catalog.GetString("Updating database"),         //4
-               Catalog.GetString("Connecting to server"),      //5
-               Catalog.GetString("Preparing main Window"),     //6
+               "Initializing",                 //0
+               "Checking database",            //1
+               "Creating database",            //2
+               "Making database backup",       //3
+               "Updating database",            //4
+               "Connecting to server",         //5
+               "Preparing main Window",        //6
+               "Loading preferences",          //7
+               "Creating widgets",             //8
+               "Creating encoder widgets",     //9
+               "Starting main window",         //10
        };
        
        public static string DatabaseNotFound = Catalog.GetString("Error. Cannot find database.");
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 7dbd1c8..9b4391e 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -509,12 +509,11 @@ public partial class ChronoJumpWindow
        }
        
        
-       public ChronoJumpWindow(string progVersion, string progName, string runningFileName)
+       public ChronoJumpWindow(string progVersion, string progName, string runningFileName, SplashWindow 
splashWin)
        {
                this.progVersion = progVersion;
                this.progName = progName;
                this.runningFileName = runningFileName;
-               
 
                Glade.XML gxml;
                gxml = Glade.XML.FromAssembly (Util.GetGladePath() + "app1.glade", "app1", "chronojump");
@@ -543,11 +542,19 @@ public partial class ChronoJumpWindow
                //put videoOn as false before loading preferences to start always without the camera
                //this is good if camera produces crash
                SqlitePreferences.Update("videoOn", "False", false);
+
+               // ------ Loading preferences ------
+
+               splashWin.UpdateLabel(Catalog.GetString(Constants.SplashMessages[7]));
                
                //preferencesLoaded is a fix to a gtk#-net-windows-bug where radiobuttons raise signals
                //at initialization of chronojump and gives problems if this signals are raised while 
preferences are loading
                loadPreferences ();
                
+               // ------ Creating widgets ------
+
+               splashWin.UpdateLabel(Catalog.GetString(Constants.SplashMessages[8]));
+
                createTreeView_persons (treeview_persons);
 
                createTreeView_jumps (treeview_jumps);
@@ -620,14 +627,19 @@ public partial class ChronoJumpWindow
                threshold = new Threshold();
                cp2016 = new Chronopic2016();
 
+               // ------ Creating encoder widgets ------
+
+               splashWin.UpdateLabel(Catalog.GetString(Constants.SplashMessages[9]));
+
                encoderInitializeStuff();       
-               
+
+               LogB.Information("Calling configInitRead from gui / ChronojumpWindow");
                configInitRead();
 
                //presentationInit();
 
                videoCaptureInitialize();
-       
+
                string buildVersion = UtilAll.ReadVersionFromBuildInfo();
                label_version.Text = buildVersion;
                label_version_hidden.Text = buildVersion;
@@ -637,6 +649,9 @@ public partial class ChronoJumpWindow
                updatingRestTimes = true;
                GLib.Timeout.Add(1000, new GLib.TimeoutHandler(updateRestTimes)); //each s, better than 5s 
for don't have problems sorting data on treeview
 
+               // ------ Starting main window ------
+
+               splashWin.UpdateLabel(Catalog.GetString(Constants.SplashMessages[10]));
 
                /*
                 * start a ping in other thread
@@ -651,6 +666,13 @@ public partial class ChronoJumpWindow
                }
 
                testNewStuff();
+
+               if(splashWin != null)
+                       splashWin.Destroy();
+               else
+                       SplashWindow.Hide();
+
+               app1.Show();
        }
 
        private void testNewStuff()
diff --git a/src/gui/splash.cs b/src/gui/splash.cs
index e996b12..ccb993a 100644
--- a/src/gui/splash.cs
+++ b/src/gui/splash.cs
@@ -31,10 +31,9 @@ public class SplashWindow
        [Widget] Gtk.ProgressBar progressbarRate;
        [Widget] Gtk.ProgressBar progressbarSubRate;
        [Widget] Gtk.Label myLabel;
-       [Widget] Gtk.Button button_cancel;
+       [Widget] Gtk.Button button_close;
 
-       
-       public Gtk.Button fakeButtonCancel;
+       [Widget] Gtk.Button fakeButtonClose;
        public bool FakeButtonCreated = false;
        
        static SplashWindow SplashWindowBox;
@@ -48,10 +47,9 @@ public class SplashWindow
                //put an icon to window
                UtilGtk.IconWindow(splash_window);
 
-               fakeButtonCancel = new Gtk.Button();
+               FakeButtonClose = new Gtk.Button();
                FakeButtonCreated = true;
 
-               CancelButtonShow(false);
                hideAllProgressbars();
 
                //put logo image
@@ -105,31 +103,18 @@ public class SplashWindow
        public void UpdateLabel (string text) {
                myLabel.Text = text;
        }
-       
-       /* 
-        * cancel       
-        * for SPing
-        */
-       public void CancelButtonShow(bool show) {
-               if(show)
-                       button_cancel.Show();
-               else
-                       button_cancel.Hide();
-       }
-       
-       protected void on_button_cancel_clicked (object o, EventArgs args)
+
+       public void ShowButtonClose()
        {
-               fakeButtonCancel.Click();
+               button_close.Show();
        }
-       
-       public Button FakeButtonCancel 
+
+       protected void on_button_close_clicked (object o, EventArgs args)
        {
-               set { fakeButtonCancel = value; }
-               get { return fakeButtonCancel; }
+               fakeButtonClose.Click();
+               Hide();
        }
 
-                       
-
        public void Destroy () {
                //it seem on some machines (MacOSX) splash_window maybe is Destroyed previously because 
on_delete_event it's called
                //Destroy here if it has not been destroyed
@@ -162,5 +147,11 @@ public class SplashWindow
        private void on_delete_event (object o, DeleteEventArgs args) {
                splash_window.Destroy ();
        }
-}
 
+       public Button FakeButtonClose
+       {
+               set { fakeButtonClose = value; }
+               get { return fakeButtonClose; }
+       }
+
+}


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