[chronojump] GenericWindow treeview no right button popup. Now use edit/del buttons
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] GenericWindow treeview no right button popup. Now use edit/del buttons
- Date: Mon, 16 Sep 2019 14:21:05 +0000 (UTC)
commit f71509c9eb4cc5cb565aa26aca6139575265ed48
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Sep 16 16:07:44 2019 +0200
GenericWindow treeview no right button popup. Now use edit/del buttons
glade/generic_window.glade | 60 +++++++++++++++++-
src/constants.cs | 2 +-
src/gui/encoder.cs | 6 +-
src/gui/encoderSelectRepetitions.cs | 6 +-
src/gui/forceSensor.cs | 4 +-
src/gui/genericWindow.cs | 121 ++++++++++++++++++------------------
6 files changed, 126 insertions(+), 73 deletions(-)
---
diff --git a/glade/generic_window.glade b/glade/generic_window.glade
index ccb7a272..ad391f6d 100644
--- a/glade/generic_window.glade
+++ b/glade/generic_window.glade
@@ -655,7 +655,7 @@
</packing>
</child>
<child>
- <widget class="GtkButton" id="hbox_combo_button">
+ <widget class="GtkButton" id="hbox_combo_button_apply">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -668,6 +668,20 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <widget class="GtkButton" id="hbox_combo_button_cancel">
+ <property name="label">Cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="on_hbox_combo_button_cancel_clicked" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -727,6 +741,48 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <widget class="GtkHBox" id="hbox_treeviewload_editdelete">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">16</property>
+ <child>
+ <widget class="GtkButton" id="button_treeviewload_row_edit">
+ <property name="label" translatable="yes">Edit</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <signal name="clicked" handler="on_edit_selected_clicked" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="button_treeviewload_row_delete">
+ <property name="label" translatable="yes">Delete</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <signal name="clicked" handler="on_delete_selected_clicked" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
<child>
<widget class="GtkButton" id="button_accept">
<property name="label">gtk-ok</property>
@@ -741,7 +797,7 @@
<property name="expand">True</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</widget>
diff --git a/src/constants.cs b/src/constants.cs
index dd168922..8b4812f5 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -1199,7 +1199,7 @@ public class Constants
}
public enum Encoder1RMMethod { NONWEIGHTED, WEIGHTED, WEIGHTED2, WEIGHTED3 }
- public enum ContextMenu { NONE, EDITDELETE, DELETE }
+ //public enum ContextMenu { NONE, EDITDELETE, DELETE }
//on glade/app1 using the same names
public const string ForceSensorLateralityBoth = "Both";
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 5c8ec999..236b9b31 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -1095,7 +1095,7 @@ public partial class ChronoJumpWindow
Catalog.GetString("If there is more than one value, top one will be used."),
bigArray);
- genericWin.SetTreeview(columnsString, false, dataPrint, new ArrayList(),
Constants.ContextMenu.DELETE, false);
+ genericWin.SetTreeview(columnsString, false, dataPrint, new ArrayList(),
GenericWindow.EditActions.DELETE, false);
genericWin.LabelSpinDouble2 = Catalog.GetString("Manually add");
genericWin.SetSpinDouble2Increments(0.1,1);
genericWin.SetSpinDouble2Range(0,5000);
@@ -1590,7 +1590,7 @@ public partial class ChronoJumpWindow
currentPerson.Name) + "\n" +
Catalog.GetString("If you want to edit or delete a row, right click on it."),
bigArray);
- genericWin.SetTreeview(columnsString, false, dataPrint, new ArrayList(),
Constants.ContextMenu.EDITDELETE, true);
+ genericWin.SetTreeview(columnsString, false, dataPrint, new ArrayList(),
GenericWindow.EditActions.EDITDELETE, true);
//find all persons in current session
ArrayList personsPre =
SqlitePersonSession.SelectCurrentSessionPersons(currentSession.UniqueID,
@@ -4744,7 +4744,7 @@ public partial class ChronoJumpWindow
"count", //not shown, unused
Catalog.GetString("Sets"), Catalog.GetString("Person"),
Catalog.GetString("Session"), Catalog.GetString("Date") },
- false, array, nonSensitiveRows, Constants.ContextMenu.NONE, false);
+ false, array, nonSensitiveRows, GenericWindow.EditActions.NONE,
false);
genericWin.ShowTextview();
genericWin.ShowTreeview();
diff --git a/src/gui/encoderSelectRepetitions.cs b/src/gui/encoderSelectRepetitions.cs
index 012bc5ff..c69564e4 100644
--- a/src/gui/encoderSelectRepetitions.cs
+++ b/src/gui/encoderSelectRepetitions.cs
@@ -257,7 +257,7 @@ public class EncoderSelectRepetitionsIndividualCurrentSession : EncoderSelectRep
Catalog.GetString("If you want to edit or delete a row, right click on it.")
+ "\n",
bigArray);
- genericWinESR.SetTreeview(columnsString, true, dataPrint, new ArrayList(),
Constants.ContextMenu.EDITDELETE, false);
+ genericWinESR.SetTreeview(columnsString, true, dataPrint, new ArrayList(),
GenericWindow.EditActions.EDITDELETE, false);
genericWinESR.ResetComboCheckBoxesOptions();
//genericWinESR.AddOptionsToComboCheckBoxesOptions(encoderExercisesNames);
@@ -513,7 +513,7 @@ public class EncoderSelectRepetitionsIndividualAllSessions : EncoderSelectRepeti
dataConverted.Add(encPS.ToStringArray(true));
}
- genericWinESR.SetTreeview(columnsString, true, dataConverted, nonSensitiveRows,
Constants.ContextMenu.NONE, false);
+ genericWinESR.SetTreeview(columnsString, true, dataConverted, nonSensitiveRows,
GenericWindow.EditActions.NONE, false);
genericWinESR.ResetComboCheckBoxesOptions();
genericWinESR.CreateComboCheckBoxes();
@@ -677,7 +677,7 @@ public class EncoderSelectRepetitionsGroupalCurrentSession : EncoderSelectRepeti
genericWinESR = GenericWindow.Show(Catalog.GetString("Persons compare"), false, //don't show
now
Catalog.GetString("Select persons to compare"), bigArray);
- genericWinESR.SetTreeview(columnsString, true, data, nonSensitiveRows,
Constants.ContextMenu.NONE, false);
+ genericWinESR.SetTreeview(columnsString, true, data, nonSensitiveRows,
GenericWindow.EditActions.NONE, false);
//select this person row
genericWinESR.SelectRowWithID(0, currentPerson.UniqueID);
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index e2ed790d..205e2895 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -1314,7 +1314,7 @@ LogB.Information(" re R ");
Catalog.GetString("If you want to edit or delete a row, right click on it.")
, bigArray);
- genericWin.SetTreeview(columnsString, false, dataPrint, new ArrayList(),
Constants.ContextMenu.EDITDELETE, true);
+ genericWin.SetTreeview(columnsString, false, dataPrint, new ArrayList(),
GenericWindow.EditActions.EDITDELETE, true);
//find all persons in current session
ArrayList personsPre =
SqlitePersonSession.SelectCurrentSessionPersons(currentSession.UniqueID,
@@ -2253,7 +2253,7 @@ LogB.Information(" re R ");
"count", //not shown, unused
Catalog.GetString("Sets"), Catalog.GetString("Person"),
Catalog.GetString("Session"), Catalog.GetString("Date") },
- false, array, nonSensitiveRows, Constants.ContextMenu.NONE, false);
+ false, array, nonSensitiveRows, GenericWindow.EditActions.NONE,
false);
genericWin.ShowTextview();
genericWin.ShowTreeview();
diff --git a/src/gui/genericWindow.cs b/src/gui/genericWindow.cs
index fb96e38d..4e9b8afb 100644
--- a/src/gui/genericWindow.cs
+++ b/src/gui/genericWindow.cs
@@ -60,7 +60,7 @@ public class GenericWindow
[Widget] Gtk.Label hbox_combo_label;
[Widget] Gtk.Box hbox_combo;
[Widget] Gtk.ComboBox combo;
- [Widget] Gtk.Button hbox_combo_button;
+ [Widget] Gtk.Button hbox_combo_button_apply;
[Widget] Gtk.Entry entry_edit_row;
[Widget] Gtk.Box hbox_all_none_selected;
@@ -79,6 +79,9 @@ public class GenericWindow
//treeview fake buttons
[Widget] Gtk.Button button_row_edit;
[Widget] Gtk.Button button_row_delete;
+
+ [Widget] Gtk.Button button_treeviewload_row_edit;
+ [Widget] Gtk.Button button_treeviewload_row_delete;
[Widget] Gtk.Box hbox_entry2;
[Widget] Gtk.Label label_entry2;
@@ -98,9 +101,10 @@ public class GenericWindow
static GenericWindow GenericWindowBox;
private TreeStore store;
- private Constants.ContextMenu genericWinContextMenu;
private bool textviewChanging = false;
+ public enum EditActions { NONE, EDITDELETE, DELETE }
+
//used to read data, see if it's ok, and print an error message.
//if all is ok, destroy it with HideAndNull()
public bool HideOnAccept;
@@ -210,6 +214,8 @@ public class GenericWindow
hbox_height_metric.Hide();
check1.Hide();
hbox_edit_row.Hide();
+ button_treeviewload_row_edit.Hide();
+ button_treeviewload_row_delete.Hide();
hbox_all_none_selected.Hide();
hbox_combo_all_none_selected.Hide();
hbuttonbox_middle.Hide();
@@ -532,7 +538,8 @@ public class GenericWindow
bool activateRowAcceptsWindow;
//data is an ArrayList of strings[], each string [] is a row, each of its strings is a column
public void SetTreeview(string [] columnsString, bool addCheckbox,
- ArrayList data, ArrayList myNonSensitiveRows, Constants.ContextMenu contextMenu,
+ ArrayList data, ArrayList myNonSensitiveRows,
+ EditActions editAction,
bool activateRowAcceptsWindow //this param makes button_accept the window if
'enter' on a row or double click
)
{
@@ -555,20 +562,24 @@ public class GenericWindow
}
LogB.Debug("aaaaaaaaaaaaaaaa2");
- genericWinContextMenu = contextMenu;
this.activateRowAcceptsWindow = activateRowAcceptsWindow;
- treeview.CursorChanged += on_treeview_cursor_changed;
- if(contextMenu == Constants.ContextMenu.EDITDELETE) {
+ if(editAction == EditActions.EDITDELETE)
+ {
+ button_treeviewload_row_edit.Sensitive = false;
+ button_treeviewload_row_edit.Visible = true;
+ button_treeviewload_row_delete.Sensitive = false;
+ button_treeviewload_row_delete.Visible = true;
button_row_edit = new Gtk.Button();
button_row_delete = new Gtk.Button();
- treeview.ButtonReleaseEvent -= on_treeview_button_release_event;
- treeview.ButtonReleaseEvent += on_treeview_button_release_event;
- } else if(contextMenu == Constants.ContextMenu.DELETE) {
+ } else if(editAction == EditActions.DELETE)
+ {
button_row_delete = new Gtk.Button();
- treeview.ButtonReleaseEvent -= on_treeview_button_release_event;
- treeview.ButtonReleaseEvent += on_treeview_button_release_event;
+ button_treeviewload_row_delete.Sensitive = false;
+ button_treeviewload_row_delete.Visible = true;
}
+
+ treeview.CursorChanged += on_treeview_cursor_changed;
}
public void SelectRowWithID(int colNum, int id)
@@ -636,10 +647,18 @@ public class GenericWindow
{
TreeIter iter = new TreeIter();
TreeModel myModel = treeview.Model;
- if (treeview.Selection.GetSelected (out myModel, out iter))
+ if (treeview.Selection.GetSelected (out myModel, out iter))
+ {
SetButtonAcceptSensitive(true);
+ button_treeviewload_row_edit.Sensitive = true;
+ button_treeviewload_row_delete.Sensitive = true;
+ }
else
+ {
SetButtonAcceptSensitive(false);
+ button_treeviewload_row_edit.Sensitive = false;
+ button_treeviewload_row_delete.Sensitive = false;
+ }
ShowEditRow(false);
}
@@ -772,59 +791,21 @@ public class GenericWindow
}
}
}
-
-
- private void on_treeview_button_release_event (object o, ButtonReleaseEventArgs args) {
- //TreeviewSelectedUniqueID = -1;
-
- Gdk.EventButton e = args.Event;
- Gtk.TreeView tv = (Gtk.TreeView) o;
- TreeModel model = treeview.Model;
- if (e.Button == 3) {
- TreeIter iter = new TreeIter();
- if (tv.Selection.GetSelected (out model, out iter)) {
- TreeviewSelectedUniqueID = Convert.ToInt32((string) store.GetValue (iter, 0));
- treeviewContextMenu();
- }
- }
- ShowEditRow(false);
- }
-
- Menu menuCtx;
- private void treeviewContextMenu() {
- menuCtx = new Menu ();
- Gtk.MenuItem myItem;
-
- if(genericWinContextMenu == Constants.ContextMenu.EDITDELETE) {
- myItem = new MenuItem ( Catalog.GetString("Edit selected") );
- myItem.Activated += on_edit_selected_clicked;
- menuCtx.Attach( myItem, 0, 1, 0, 1 );
-
- myItem = new MenuItem ( Catalog.GetString("Delete selected") );
- myItem.Activated += on_delete_selected_clicked;
- menuCtx.Attach( myItem, 0, 1, 1, 2 );
- }
- else if(genericWinContextMenu == Constants.ContextMenu.DELETE) {
- myItem = new MenuItem ( Catalog.GetString("Delete selected") );
- myItem.Activated += on_delete_selected_clicked;
- menuCtx.Attach( myItem, 0, 1, 0, 1 );
- } else {
- //don't show nothing if there are no options
- menuCtx.Popdown();
- return;
- }
-
- menuCtx.Popup();
- menuCtx.ShowAll();
- }
private void on_edit_selected_clicked (object o, EventArgs args)
{
TreeModel model;
TreeIter iter = new TreeIter();
- treeview.Selection.GetSelected (out model, out iter);
+ if(! treeview.Selection.GetSelected (out model, out iter))
+ return;
+
+ TreeviewSelectedUniqueID = Convert.ToInt32((string) store.GetValue (iter, 0));
+
entry_edit_row.Text = (string) model.GetValue (iter, commentColumn);
+ button_treeviewload_row_edit.Sensitive = false;
+ button_treeviewload_row_delete.Sensitive = false;
+
button_row_edit.Click();
}
@@ -839,6 +820,13 @@ public class GenericWindow
store.SetValue (iter, commentColumn, entry_edit_row.Text);
}
+ public void on_hbox_combo_button_cancel_clicked (object o, EventArgs args)
+ {
+ button_treeviewload_row_edit.Sensitive = true;
+ button_treeviewload_row_delete.Sensitive = true;
+ hbox_edit_row.Hide();
+ }
+
//this method is only used when try to delete an encoder/forceSensor exercise,
//and cannot because there are rows done with this exercise.
//Just unsensitive some stuff now in order to not be able to change them
@@ -856,7 +844,17 @@ public class GenericWindow
store = UtilGtk.RemoveRow(treeview, store);
}
- private void on_delete_selected_clicked (object o, EventArgs args) {
+ private void on_delete_selected_clicked (object o, EventArgs args)
+ {
+ TreeModel model;
+ TreeIter iter = new TreeIter();
+ if(! treeview.Selection.GetSelected (out model, out iter))
+ return;
+
+ TreeviewSelectedUniqueID = Convert.ToInt32((string) store.GetValue (iter, 0));
+ button_treeviewload_row_edit.Sensitive = false;
+ button_treeviewload_row_delete.Sensitive = false;
+
//activate button to manage on gui/encoder.cs in order to delete from SQL
button_row_delete.Click();
}
@@ -865,7 +863,6 @@ public class GenericWindow
public void Delete_row_accepted() {
//remove selected row from treeview
store = UtilGtk.RemoveRow(treeview, store);
- menuCtx.Popdown();
}
public void Row_add(string [] row) {
@@ -962,8 +959,8 @@ public class GenericWindow
}
public Button Button_row_edit_apply {
- set { hbox_combo_button = value; }
- get { return hbox_combo_button; }
+ set { hbox_combo_button_apply = value; }
+ get { return hbox_combo_button_apply; }
}
public int CommentColumn {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]