[chronojump] A session can be deleted from load session "window"



commit 9132e986d9445a7ea75d215ad9ec00ed935bd2ab
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Mar 18 17:16:14 2021 +0100

    A session can be deleted from load session "window"

 glade/app1.glade                      | 46 ++++++++++++++++++++++++++---------
 src/gui/app1/session/delete.cs        | 36 +++++++++++++++++++++------
 src/gui/app1/session/loadAndImport.cs | 20 +++++++++++++++
 src/gui/app1/session/main.cs          |  1 +
 4 files changed, 84 insertions(+), 19 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 696d47f4..e6eea6a1 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -24509,6 +24509,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -30592,6 +30595,18 @@ Concentric</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">6</property>
                                                             <child>
+                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="pack_type">end</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_capturing">
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">4</property>
@@ -30628,18 +30643,6 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="pack_type">end</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_no_capturing">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -39032,6 +39035,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -41120,6 +41126,7 @@ then click this button.</property>
                                                       <widget class="GtkHButtonBox" id="hbuttonbox18">
                                                         <property name="visible">True</property>
                                                         <property name="can_focus">False</property>
+                                                        <property name="spacing">60</property>
                                                         <property name="layout_style">start</property>
                                                         <child>
                                                           <widget class="GtkButton" id="app1s_button_edit">
@@ -41136,6 +41143,21 @@ then click this button.</property>
                                                             <property name="position">0</property>
                                                           </packing>
                                                         </child>
+                                                        <child>
+                                                          <widget class="GtkButton" id="app1s_button_delete">
+                                                            <property name="label" translatable="yes">Delete 
session</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="sensitive">False</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <signal name="clicked" 
handler="on_app1s_button_delete_clicked" swapped="no"/>
+                                                          </widget>
+                                                          <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                          </packing>
+                                                        </child>
                                                       </widget>
                                                       <packing>
                                                         <property name="expand">False</property>
diff --git a/src/gui/app1/session/delete.cs b/src/gui/app1/session/delete.cs
index 441e41aa..79c0301d 100644
--- a/src/gui/app1/session/delete.cs
+++ b/src/gui/app1/session/delete.cs
@@ -31,7 +31,19 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Label app1s_label_delete_done;
        [Widget] Gtk.Button app1s_button_delete_close;
 
+       private bool deleteSessionCalledFromLoad;
+       private Session tempDeletingSession;
+
+       //not called from load
        private void on_app1s_delete_session_confirm_start (object o, EventArgs args)
+       {
+               deleteSessionCalledFromLoad = false;
+               tempDeletingSession = currentSession;
+
+               on_app1s_delete_session_confirm_start_do ();
+       }
+
+       private void on_app1s_delete_session_confirm_start_do ()
        {
                //first show notebook tab in order to ensure the .Visible = true will work
                app1s_notebook.CurrentPage = app1s_PAGE_DELETE_CONFIRM;
@@ -45,7 +57,7 @@ public partial class ChronoJumpWindow
 
                app1s_button_delete_close.Visible = false;
 
-               if(currentSession.Name == Constants.SessionSimulatedName)
+               if(tempDeletingSession.Name == Constants.SessionSimulatedName)
                {
                        app1s_label_delete_cannot.Visible = true;
                        app1s_button_delete_close.Visible = true;
@@ -53,7 +65,7 @@ public partial class ChronoJumpWindow
                else {
                        app1s_vbox_delete_question.Visible = true;
 
-                       app1s_label_delete_session_confirm_name.Text = "<b>" + currentSession.Name + "</b>";
+                       app1s_label_delete_session_confirm_name.Text = "<b>" + tempDeletingSession.Name + 
"</b>";
                        app1s_label_delete_session_confirm_name.UseMarkup = true;
                        app1s_label_delete_session_confirm_name.Visible = true;
 
@@ -63,10 +75,10 @@ public partial class ChronoJumpWindow
        
        private void on_app1s_button_delete_accept_clicked (object o, EventArgs args) 
        {
-               string sessionUniqueID = currentSession.UniqueID.ToString ();
-               closeSession ();
+               if(currentSession.UniqueID == tempDeletingSession.UniqueID)
+                       closeSession ();
 
-               SqliteSession.DeleteAllStuff(sessionUniqueID);
+               SqliteSession.DeleteAllStuff(tempDeletingSession.UniqueID.ToString());
                
                app1s_vbox_delete_question.Visible = false;
                app1s_label_delete_session_confirm_name.Visible = false;
@@ -78,11 +90,21 @@ public partial class ChronoJumpWindow
 
        private void on_app1s_button_delete_cancel_clicked (object o, EventArgs args)
        {
-               app1s_notebook.CurrentPage = app1s_PAGE_MODES;
+               if(deleteSessionCalledFromLoad)
+                       app1s_notebook.CurrentPage = app1s_PAGE_SELECT_SESSION;
+               else
+                       app1s_notebook.CurrentPage = app1s_PAGE_MODES;
        }
 
        private void on_app1s_button_delete_close_clicked (object o, EventArgs args)
        {
-               app1s_notebook.CurrentPage = app1s_PAGE_MODES;
+               if(deleteSessionCalledFromLoad)
+               {
+                       app1s_notebook.CurrentPage = app1s_PAGE_SELECT_SESSION;
+
+                       //and reload the treeview:
+                       app1s_recreateTreeView("deleted a session coming from load session");
+               } else
+                       app1s_notebook.CurrentPage = app1s_PAGE_MODES;
        }
 }
diff --git a/src/gui/app1/session/loadAndImport.cs b/src/gui/app1/session/loadAndImport.cs
index a79b4946..29ba4741 100644
--- a/src/gui/app1/session/loadAndImport.cs
+++ b/src/gui/app1/session/loadAndImport.cs
@@ -540,10 +540,12 @@ public partial class ChronoJumpWindow
                        app1s_button_load.Sensitive = true;
                        app1s_button_import.Sensitive = true;
                        app1s_button_edit.Sensitive = true;
+                       app1s_button_delete.Sensitive = true;
                } else {
                        app1s_button_load.Sensitive = false;
                        app1s_button_import.Sensitive = false;
                        app1s_button_edit.Sensitive = false;
+                       app1s_button_delete.Sensitive = false;
                }
 
                app1s_button_manage_tags.Sensitive = (app1s_selected != "-1");
@@ -686,6 +688,24 @@ public partial class ChronoJumpWindow
                }
        }
 
+       private void on_app1s_button_delete_clicked (object o, EventArgs args)
+       {
+               Session s = SqliteSession.Select (app1s_selected);
+
+               //just care if for any reason the session cannot be found
+               if(s.UniqueID == -1)
+                       return;
+
+               if(s.Name == Constants.SessionSimulatedName)
+                       new DialogMessage(Constants.MessageTypes.INFO, Constants.SessionProtectedStr());
+               else {
+                       deleteSessionCalledFromLoad = true;
+                       tempDeletingSession = s;
+
+                       on_app1s_delete_session_confirm_start_do ();
+               }
+       }
+
        void app1s_on_button_cancel2_clicked (object o, EventArgs args)
        {
                menus_and_mode_sensitive(true);
diff --git a/src/gui/app1/session/main.cs b/src/gui/app1/session/main.cs
index 0a956a41..352fecd5 100644
--- a/src/gui/app1/session/main.cs
+++ b/src/gui/app1/session/main.cs
@@ -50,6 +50,7 @@ public partial class ChronoJumpWindow
        //notebook tab 2
        [Widget] Gtk.TreeView app1s_treeview_session_load;
        [Widget] Gtk.Button app1s_button_edit;
+       [Widget] Gtk.Button app1s_button_delete;
        [Widget] Gtk.Button app1s_button_load;
        [Widget] Gtk.Button app1s_button_import;
        [Widget] Gtk.Image app1s_image_import;


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