[chronojump] Any session can be edited from load session view
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Any session can be edited from load session view
- Date: Wed, 10 Mar 2021 16:13:32 +0000 (UTC)
commit deb140c22b3dd8233c37c4014c41d9a905b40876
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Mar 10 16:12:47 2021 +0100
Any session can be edited from load session view
glade/app1.glade | 66 ++++++++++++----
src/gui/app1/chronojump.cs | 6 +-
src/gui/app1/session/addEdit.cs | 130 ++++++++++++++++++++-----------
src/gui/app1/session/loadAndImport.cs | 22 ++++++
src/gui/app1/session/main.cs | 1 +
src/gui/app1/session/tagSessionSelect.cs | 10 +--
6 files changed, 165 insertions(+), 70 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index d78ed352..691a07cf 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -23839,6 +23839,9 @@ Concentric</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -29922,6 +29925,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>
@@ -29958,18 +29973,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>
@@ -38344,6 +38347,9 @@ then click this button.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -40427,12 +40433,40 @@ then click this button.</property>
<widget class="GtkHBox" id="hbox125">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">12</property>
+ <property name="spacing">90</property>
+ <child>
+ <widget class="GtkHButtonBox" id="hbuttonbox18">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">start</property>
+ <child>
+ <widget class="GtkButton" id="app1s_button_edit">
+ <property name="label" translatable="yes">Edit
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_edit_clicked" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
<widget class="GtkHButtonBox"
id="app1s_hbuttonbox_page2_load">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="layout_style">spread</property>
+ <property name="spacing">60</property>
+ <property name="layout_style">end</property>
<child>
<widget class="GtkButton" id="app1s_button_cancel">
<property name="visible">True</property>
@@ -40493,7 +40527,7 @@ then click this button.</property>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -40546,7 +40580,7 @@ then click this button.</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</widget>
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 6bc9e9cc..58ea4b20 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -2479,7 +2479,7 @@ public partial class ChronoJumpWindow
LogB.Information("new session");
app1s_notebook_sup_entered_from = notebook_sup.CurrentPage;
notebook_sup.CurrentPage = Convert.ToInt32(notebook_sup_pages.SESSION);
- sessionAddEditShow (true);
+ sessionAddEditShow (App1saeModes.ADDSESSION);
}
private void setApp1Title(string sessionName, Constants.Menuitem_modes mode)
@@ -2586,7 +2586,9 @@ public partial class ChronoJumpWindow
new DialogMessage(Constants.MessageTypes.INFO, Constants.SessionProtectedStr());
else {
notebook_sup.CurrentPage = Convert.ToInt32(notebook_sup_pages.SESSION);
- sessionAddEditShow (false);
+
+ sessionAddEditUseSession (currentSession);
+ sessionAddEditShow (App1saeModes.EDITCURRENTSESSION);
}
}
diff --git a/src/gui/app1/session/addEdit.cs b/src/gui/app1/session/addEdit.cs
index f5b8a123..86cce560 100644
--- a/src/gui/app1/session/addEdit.cs
+++ b/src/gui/app1/session/addEdit.cs
@@ -46,17 +46,28 @@ public partial class ChronoJumpWindow
string [] app1sae_speciallitiesTranslated;
string [] app1sae_levels;
- bool app1sae_addSession;
+ //EDITOTHERSESSION is used when a session is edit from load session widgets
+ //a session that is not currentSession
+ public enum App1saeModes { ADDSESSION, EDITCURRENTSESSION, EDITOTHERSESSION};
+ App1saeModes app1sae_mode;
+ private Session tempEditingSession;
+
bool app1sae_combosCreated = false;
GenericWindow app1sae_genericWin;
-
- private void sessionAddEditShow (bool addSession)
+
+ private void sessionAddEditUseSession (Session s)
{
+ tempEditingSession = s;
+ }
+
+ private void sessionAddEditShow (App1saeModes mode)
+ {
+ LogB.Information("sessionAddEditShow, " + mode.ToString());
app1s_notebook.CurrentPage = app1s_PAGE_ADD_EDIT;
app1sae_notebook_add_edit.CurrentPage = 0;
- app1sae_addSession = addSession;
+ app1sae_mode = mode;
if(! app1sae_combosCreated)
{
@@ -80,7 +91,7 @@ public partial class ChronoJumpWindow
tbtags.Text = "";
app1sae_textview_tags.Buffer = tbtags;
- if(addSession) {
+ if(app1sae_mode == App1saeModes.ADDSESSION) {
hbox_session_add.Visible = true;
hbox_session_more_edit.Visible = false;
app1sae_dateTime = DateTime.Today;
@@ -100,39 +111,43 @@ public partial class ChronoJumpWindow
app1sae_button_accept.Sensitive = false;
} else {
+ //just a precaution
+ if(tempEditingSession == null)
+ return;
+
hbox_session_add.Visible = false;
hbox_session_more_edit.Visible = true;
- app1sae_dateTime = currentSession.Date;
+ app1sae_dateTime = tempEditingSession.Date;
- app1sae_entry_name.Text = currentSession.Name;
- app1sae_entry_place.Text = currentSession.Place;
+ app1sae_entry_name.Text = tempEditingSession.Name;
+ app1sae_entry_place.Text = tempEditingSession.Place;
- app1sae_label_date.Text = currentSession.DateLong;
+ app1sae_label_date.Text = tempEditingSession.DateLong;
TextBuffer tb = new TextBuffer (new TextTagTable());
- tb.Text = currentSession.Comments;
+ tb.Text = tempEditingSession.Comments;
app1sae_textview_comments.Buffer = tb;
- tbtags.Text = TagSession.GetActiveTagNamesOfThisSession(currentSession.UniqueID);
+ tbtags.Text = TagSession.GetActiveTagNamesOfThisSession(tempEditingSession.UniqueID);
app1sae_textview_tags.Buffer = tbtags;
}
//app1sae_labelUpdate();
app1sae_radios_changed();
- if(! addSession)
- app1sae_showSportStuffWithLoadedData();
+ if(app1sae_mode != App1saeModes.ADDSESSION)
+ app1sae_editSession_showSportStuffWithLoadedData();
}
- void app1sae_showSportStuffWithLoadedData()
+ void app1sae_editSession_showSportStuffWithLoadedData()
{
- LogB.Information(string.Format("{0}-{1}-{2}", currentSession.PersonsSportID,
currentSession.PersonsSpeciallityID, currentSession.PersonsPractice));
+ LogB.Information(string.Format("{0}-{1}-{2}", tempEditingSession.PersonsSportID,
tempEditingSession.PersonsSpeciallityID, tempEditingSession.PersonsPractice));
- if(currentSession.PersonsSportID != Constants.SportUndefinedID)
+ if(tempEditingSession.PersonsSportID != Constants.SportUndefinedID)
{
app1sae_radiobutton_same_sport.Active = true;
- Sport mySport = SqliteSport.Select(false, currentSession.PersonsSportID);
+ Sport mySport = SqliteSport.Select(false, tempEditingSession.PersonsSportID);
app1sae_combo_sports.Active = UtilGtk.ComboMakeActive(app1sae_sportsTranslated,
mySport.ToString());
app1sae_hbox_sports.Visible = true;
@@ -142,10 +157,10 @@ public partial class ChronoJumpWindow
app1sae_createComboSpeciallities(mySport.UniqueID);
app1sae_speciallity_row_show(true);
- if(currentSession.PersonsSpeciallityID != Constants.SpeciallityUndefinedID) {
+ if(tempEditingSession.PersonsSpeciallityID !=
Constants.SpeciallityUndefinedID) {
app1sae_radiobutton_same_speciallity.Active = true;
app1sae_combo_speciallities.Active =
UtilGtk.ComboMakeActive(app1sae_speciallitiesTranslated,
- SqliteSpeciallity.Select(false,
currentSession.PersonsSpeciallityID));
+ SqliteSpeciallity.Select(false,
tempEditingSession.PersonsSpeciallityID));
} else
app1sae_combo_speciallities.Active =
@@ -153,17 +168,17 @@ public partial class ChronoJumpWindow
Catalog.GetString(Constants.SpeciallityUndefined));
}
- if(currentSession.PersonsSportID != Constants.SportNoneID)
+ if(tempEditingSession.PersonsSportID != Constants.SportNoneID)
{
app1sae_combo_levels.Destroy();
app1sae_createComboLevels();
app1sae_level_row_show(true);
- if(currentSession.PersonsPractice != Constants.LevelUndefinedID) {
+ if(tempEditingSession.PersonsPractice != Constants.LevelUndefinedID) {
app1sae_radiobutton_same_level.Active = true;
app1sae_combo_levels.Active = UtilGtk.ComboMakeActive(app1sae_levels,
- currentSession.PersonsPractice + ":" +
- Util.FindLevelName(currentSession.PersonsPractice));
+ tempEditingSession.PersonsPractice + ":" +
+
Util.FindLevelName(tempEditingSession.PersonsPractice));
} else
app1sae_combo_levels.Active =
@@ -534,24 +549,32 @@ public partial class ChronoJumpWindow
void app1sae_on_button_cancel_clicked (object o, EventArgs args)
{
- if(app1sae_addSession)
+ if(app1sae_mode == App1saeModes.ADDSESSION)
notebook_supSetOldPage();
- else
+ else if(app1sae_mode == App1saeModes.EDITCURRENTSESSION)
app1s_notebook.CurrentPage = app1s_PAGE_MODES;
+ else { //(app1sae_mode == App1saeModes.EDITOTHERSESSION)
+ app1s_notebook.CurrentPage = app1s_PAGE_SELECT_SESSION;
+
+ //maybe tags have been created while editing:
+ createComboSessionLoadTags (false);
+ //and reload the treeview:
+ app1s_recreateTreeView("Cancelled an edit session from load session");
+ }
}
private void on_app1sae_button_select_tags_clicked (object o, EventArgs args)
{
- //just be cautious
- if(currentSession == null)
+ //just be cautious, but if we are not editing, this is not needed
+ if(app1sae_mode != App1saeModes.ADDSESSION && tempEditingSession == null)
return;
tagSessionSelect = new TagSessionSelect();
- if(app1sae_addSession)
+ if(app1sae_mode == App1saeModes.ADDSESSION)
tagSessionSelect.PassVariables(true, -1, "", preferences.askDeletion);
else
- tagSessionSelect.PassVariables(false, currentSession.UniqueID, "",
preferences.askDeletion);
+ tagSessionSelect.PassVariables(false, tempEditingSession.UniqueID, "",
preferences.askDeletion);
tagSessionSelect.FakeButtonDone.Clicked -= new
EventHandler(on_select_tags_clicked_done_addEdit);
tagSessionSelect.FakeButtonDone.Clicked += new
EventHandler(on_select_tags_clicked_done_addEdit);
@@ -565,10 +588,10 @@ public partial class ChronoJumpWindow
TextBuffer tbtags = new TextBuffer (new TextTagTable());
tbtags.Text = "";
- if(app1sae_addSession)
+ if(app1sae_mode == App1saeModes.ADDSESSION)
tbtags.Text = tagSessionSelect.TagsListStringForAddSession;
else
- tbtags.Text = TagSession.GetActiveTagNamesOfThisSession(currentSession.UniqueID);
+ tbtags.Text = TagSession.GetActiveTagNamesOfThisSession(tempEditingSession.UniqueID);
app1sae_textview_tags.Buffer = tbtags;
}
@@ -640,7 +663,7 @@ public partial class ChronoJumpWindow
LogB.Information("app1sae_on_button_accept_clicked 1");
bool sessionNameExists = Sqlite.Exists (false, Constants.SessionTable, name);
- if(sessionNameExists && app1sae_addSession)
+ if(sessionNameExists && app1sae_mode == App1saeModes.ADDSESSION)
{
//if we try to add a new session with same name ...
LogB.Information("app1sae_on_button_accept_clicked add existing ...");
@@ -648,7 +671,7 @@ public partial class ChronoJumpWindow
ErrorWindow.Show(myString);
LogB.Information("app1sae_on_button_accept_clicked add existing done!");
}
- else if( sessionNameExists && ! app1sae_addSession && (currentSession == null || name !=
currentSession.Name) )
+ else if( sessionNameExists && app1sae_mode != App1saeModes.ADDSESSION && (tempEditingSession
== null || name != tempEditingSession.Name) )
{
//if we edit a session but we changed name and it matches another existing session ...
LogB.Information("app1sae_on_button_accept_clicked edit existing not me ...");
@@ -684,7 +707,7 @@ public partial class ChronoJumpWindow
string comments =
Util.RemoveTildeAndColon(Util.MakeValidSQL(app1sae_textview_comments.Buffer.Text));
LogB.Information("app1sae_on_button_accept_clicked 8");
- if(app1sae_addSession)
+ if(app1sae_mode == App1saeModes.ADDSESSION)
{
LogB.Information("app1sae_on_button_accept_clicked 9");
currentSession = new Session (name, place,
@@ -707,24 +730,37 @@ public partial class ChronoJumpWindow
} else
{
LogB.Information("app1sae_on_button_accept_clicked D");
- currentSession.Name = name;
- currentSession.Place = place;
- currentSession.Date = app1sae_dateTime;
- currentSession.PersonsSportID = sportID;
- currentSession.PersonsSpeciallityID = speciallityID;
- currentSession.PersonsPractice = levelID;
- currentSession.Comments = comments;
+ tempEditingSession.Name = name;
+ tempEditingSession.Place = place;
+ tempEditingSession.Date = app1sae_dateTime;
+ tempEditingSession.PersonsSportID = sportID;
+ tempEditingSession.PersonsSpeciallityID = speciallityID;
+ tempEditingSession.PersonsPractice = levelID;
+ tempEditingSession.Comments = comments;
LogB.Information("app1sae_on_button_accept_clicked E");
- SqliteSession.Update(currentSession.UniqueID, currentSession.Name,
- currentSession.Place, currentSession.Date,
+ SqliteSession.Update(tempEditingSession.UniqueID, tempEditingSession.Name,
+ tempEditingSession.Place, tempEditingSession.Date,
sportID, speciallityID, levelID,
- currentSession.Comments);
+ tempEditingSession.Comments);
LogB.Information("app1sae_on_button_accept_clicked F");
- on_edit_session_accepted ();
- LogB.Information("app1sae_on_button_accept_clicked G");
- app1s_notebook.CurrentPage = app1s_PAGE_MODES;
+ if(app1sae_mode == App1saeModes.EDITCURRENTSESSION)
+ {
+ currentSession = tempEditingSession;
+ on_edit_session_accepted ();
+
+ LogB.Information("app1sae_on_button_accept_clicked G");
+ app1s_notebook.CurrentPage = app1s_PAGE_MODES;
+ } else {//(app1sae_mode == App1saeModes.EDITOTHERSESSION)
+ app1s_notebook.CurrentPage = app1s_PAGE_SELECT_SESSION;
+
+ //maybe tags have been created while editing:
+ createComboSessionLoadTags (false);
+ //and reload the treeview:
+ app1s_recreateTreeView("Accepted an edit session from load session");
+ }
+
LogB.Information("app1sae_on_button_accept_clicked H");
}
LogB.Information("app1sae_on_button_accept_clicked I");
diff --git a/src/gui/app1/session/loadAndImport.cs b/src/gui/app1/session/loadAndImport.cs
index 71419354..6510ddab 100644
--- a/src/gui/app1/session/loadAndImport.cs
+++ b/src/gui/app1/session/loadAndImport.cs
@@ -483,9 +483,11 @@ public partial class ChronoJumpWindow
app1s_selected = (string)model.GetValue (iter, 0);
app1s_button_load.Sensitive = true;
app1s_button_import.Sensitive = true;
+ app1s_button_edit.Sensitive = true;
} else {
app1s_button_load.Sensitive = false;
app1s_button_import.Sensitive = false;
+ app1s_button_edit.Sensitive = false;
}
app1s_button_manage_tags.Sensitive = (app1s_selected != "-1");
@@ -604,6 +606,26 @@ public partial class ChronoJumpWindow
}
// ---- notebook page 2 (load sesion) buttons ----
+
+ private void on_app1s_button_edit_clicked (object o, EventArgs args)
+ {
+ /*
+ *
+ * hi ha dos opcions, o fem load de la sessió aquell, fem el edit i tornem després:
+ * o cridem al sessionAddEdit amb opcio de edit des de fora
+ * i allà treiem totes les refs a currentSession, i que usi algo temp
+
+ */
+ Session s = SqliteSession.Select (app1s_selected);
+
+ if(s.Name == Constants.SessionSimulatedName)
+ new DialogMessage(Constants.MessageTypes.INFO, Constants.SessionProtectedStr());
+ else {
+ sessionAddEditUseSession (s);
+ sessionAddEditShow (App1saeModes.EDITOTHERSESSION);
+ }
+ }
+
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 e00b478d..0a956a41 100644
--- a/src/gui/app1/session/main.cs
+++ b/src/gui/app1/session/main.cs
@@ -49,6 +49,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_load;
[Widget] Gtk.Button app1s_button_import;
[Widget] Gtk.Image app1s_image_import;
diff --git a/src/gui/app1/session/tagSessionSelect.cs b/src/gui/app1/session/tagSessionSelect.cs
index f89aa77b..9edd11aa 100644
--- a/src/gui/app1/session/tagSessionSelect.cs
+++ b/src/gui/app1/session/tagSessionSelect.cs
@@ -32,7 +32,7 @@ public class TagSessionSelect
{
//passed variables
private bool addSession;
- private int currentSessionID;
+ private int sessionID;
private string sessionName;
private bool askDeletion;
@@ -47,10 +47,10 @@ public class TagSessionSelect
public Gtk.Button FakeButtonDone;
- public void PassVariables(bool addSession, int currentSessionID, string sessionName, bool askDeletion)
+ public void PassVariables(bool addSession, int sessionID, string sessionName, bool askDeletion)
{
this.addSession = addSession;
- this.currentSessionID = currentSessionID;
+ this.sessionID = sessionID;
this.sessionName = sessionName;
this.askDeletion = askDeletion;
@@ -90,7 +90,7 @@ public class TagSessionSelect
if(addSession)
tagsActiveThisSession_list = new List<TagSession>();
else
- tagsActiveThisSession_list = SqliteSessionTagSession.SelectTagsOfASession(false,
currentSessionID);
+ tagsActiveThisSession_list = SqliteSessionTagSession.SelectTagsOfASession(false,
sessionID);
}
private void createBigArray()
@@ -220,7 +220,7 @@ public class TagSessionSelect
count ++;
}
} else
- SQLUpdateTransaction(currentSessionID);
+ SQLUpdateTransaction(sessionID);
FakeButtonDone.Click();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]