[chronojump] EncoderOverview with inheritance on renamed gui/overview.cs
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] EncoderOverview with inheritance on renamed gui/overview.cs
- Date: Tue, 8 Oct 2019 10:30:42 +0000 (UTC)
commit ba24d0c4c9362afe8d5759fd44b26024ff3367a1
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Oct 8 12:29:52 2019 +0200
EncoderOverview with inheritance on renamed gui/overview.cs
glade/{encoder_overview.glade => overview.glade} | 4 +-
po/POTFILES.in | 4 +-
src/Makefile.am | 4 +-
src/gui/{encoderOverview.cs => overview.cs} | 136 +++++++++++++----------
4 files changed, 86 insertions(+), 62 deletions(-)
---
diff --git a/glade/encoder_overview.glade b/glade/overview.glade
similarity index 97%
rename from glade/encoder_overview.glade
rename to glade/overview.glade
index ab78a408..a3c581a8 100644
--- a/glade/encoder_overview.glade
+++ b/glade/overview.glade
@@ -2,12 +2,12 @@
<glade-interface>
<!-- interface-requires gtk+ 3.0 -->
<!-- interface-naming-policy toplevel-contextual -->
- <widget class="GtkWindow" id="encoder_overview_win">
+ <widget class="GtkWindow" id="overview_win">
<property name="width_request">650</property>
<property name="height_request">400</property>
<property name="can_focus">False</property>
<property name="border_width">10</property>
- <property name="title" translatable="yes">Encoder overview</property>
+ <property name="title" translatable="yes">Overview</property>
<property name="modal">True</property>
<property name="type_hint">dialog</property>
<signal name="delete_event" handler="on_delete_event" swapped="no"/>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6b6dedc0..aecd339c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -14,7 +14,6 @@ glade/dialog_server_stats.glade
glade/dialog_threshold.glade
glade/edit_event.glade
glade/encoder_configuration.glade
-glade/encoder_overview.glade
glade/error_window.glade
glade/evaluator_window.glade
glade/event_graph_configure.glade
@@ -22,6 +21,7 @@ glade/execute_auto.glade
glade/generic_window.glade
glade/jumps_runs_more.glade
glade/jump_type_add.glade
+glade/overview.glade
glade/person_multiple_infinite.glade
glade/person_recuperate.glade
glade/person_select_window.glade
@@ -63,7 +63,6 @@ src/gui/dialogThreshold.cs
src/gui/encoderConfiguration.cs
src/gui/encoder.cs
src/gui/encoderGraphObjects.cs
-src/gui/encoderOverview.cs
src/gui/encoderSelectRepetitions.cs
src/gui/encoderTreeviews.cs
src/gui/evaluator.cs
@@ -79,6 +78,7 @@ src/gui/jumpType.cs
src/gui/multiChronopic.cs
src/gui/old/chronojumpServerOld.cs
src/gui/old/queryServer.cs
+src/gui/overview.cs
src/gui/person.cs
src/gui/preferences.cs
src/gui/pulse.cs
diff --git a/src/Makefile.am b/src/Makefile.am
index 965441ca..72f975ea 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,7 +17,6 @@ SOURCES = \
gui/encoderTreeviews.cs\
gui/encoderConfiguration.cs\
gui/encoderSelectRepetitions.cs\
- gui/encoderOverview.cs\
gui/error.cs\
gui/eventExecute.cs\
gui/eventGraphConfigure.cs\
@@ -38,6 +37,7 @@ SOURCES = \
gui/reactionTime.cs\
gui/pulse.cs\
gui/multiChronopic.cs\
+ gui/overview.cs\
gui/person.cs\
gui/personSelect.cs\
gui/preferences.cs\
@@ -243,7 +243,6 @@ RESOURCES = \
../glade/dialog_threshold.glade \
../glade/edit_event.glade \
../glade/encoder_configuration.glade \
- ../glade/encoder_overview.glade \
../glade/error_window.glade \
../glade/evaluator_window.glade \
../glade/event_graph_configure.glade \
@@ -252,6 +251,7 @@ RESOURCES = \
../glade/force_sensor_exercise.glade \
../glade/jump_type_add.glade \
../glade/jumps_runs_more.glade \
+ ../glade/overview.glade \
../glade/person_multiple_infinite.glade \
../glade/person_recuperate.glade \
../glade/person_select_window.glade \
diff --git a/src/gui/encoderOverview.cs b/src/gui/overview.cs
similarity index 56%
rename from src/gui/encoderOverview.cs
rename to src/gui/overview.cs
index e3aadd17..454c5c90 100644
--- a/src/gui/encoderOverview.cs
+++ b/src/gui/overview.cs
@@ -15,92 +15,117 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Copyright (C) 2016-2017 Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2016-2019 Xavier de Blas <xaviblas gmail com>
*/
using System;
using System.Collections; //ArrayList
-//using System.Collections.Generic; //List<T>
using Gdk;
using Glade;
using Gtk;
using Mono.Unix;
-public class EncoderOverviewWindow
+public abstract class OverviewWindow
{
- static EncoderOverviewWindow EncoderOverviewWindowBox;
-
- [Widget] Gtk.Window encoder_overview_win;
- [Widget] Gtk.TreeView treeview_sets;
- [Widget] Gtk.TreeView treeview_reps;
+ [Widget] protected Gtk.Window overview_win;
+ [Widget] protected Gtk.TreeView treeview_sets;
+ [Widget] protected Gtk.TreeView treeview_reps;
- private enum treeviewType { SETS, REPS }
+ protected enum treeviewType { SETS, REPS }
+ protected int sessionID;
+ protected void initialize()
+ {
+ setTitle();
+ createTreeViews();
+ }
- public EncoderOverviewWindow(Gtk.Window parent, Constants.EncoderGI encoderGI, int sessionID)
+ protected virtual void setTitle()
{
- Glade.XML gladeXML;
- gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "encoder_overview.glade",
"encoder_overview_win", null);
+ overview_win.Title = getTitle();
+ }
+ protected abstract string getTitle();
- gladeXML.Autoconnect(this);
- encoder_overview_win.Parent = parent;
+ protected virtual void createTreeViews()
+ {
+ createAndFillTreeView(treeview_sets, treeviewType.SETS, selectData(treeviewType.SETS));
+ }
+ protected abstract ArrayList selectData(treeviewType type);
- if(encoderGI == Constants.EncoderGI.GRAVITATORY)
- encoder_overview_win.Title = Catalog.GetString("Encoder Overview") + " - " +
Catalog.GetString("Gravitatory");
- else if(encoderGI == Constants.EncoderGI.INERTIAL)
- encoder_overview_win.Title = Catalog.GetString("Encoder Overview") + " - " +
Catalog.GetString("Inertial");
- //put an icon to window
- UtilGtk.IconWindow(encoder_overview_win);
-
- createAndFillTreeView(treeview_sets, treeviewType.SETS, encoderGI,
- SqliteEncoder.SelectSessionOverviewSets(false, encoderGI, sessionID));
- createAndFillTreeView(treeview_reps, treeviewType.REPS, encoderGI,
- SqliteEncoder.SelectSessionOverviewReps(false, encoderGI, sessionID));
-
- /*
- createTreeView(treeview_sets, treeviewType.SETS, encoderGI);
- TreeStore storeSets = getStore(treeviewType.SETS, encoderGI);
- treeview_sets.Model = storeSets;
- ArrayList dataSets = SqliteEncoder.SelectSessionOverviewSets(false, encoderGI, sessionID);
-
- foreach (string [] line in dataSets)
- storeSets.AppendValues (line);
-
- createTreeView(treeview_reps, treeviewType.REPS, encoderGI);
- TreeStore storeReps = getStore(treeviewType.REPS, encoderGI);
- treeview_reps.Model = storeReps;
- ArrayList dataReps = SqliteEncoder.SelectSessionOverviewReps(false, encoderGI, sessionID);
-
- foreach (string [] line in dataReps)
- storeReps.AppendValues (line);
- */
- }
-
- private void createAndFillTreeView(Gtk.TreeView tv, treeviewType tvType, Constants.EncoderGI
encoderGI, ArrayList array)
+ protected void createAndFillTreeView(Gtk.TreeView tv, treeviewType tvType, ArrayList array)
{
- createTreeView(tv, tvType, encoderGI);
- TreeStore store = getStore(tvType, encoderGI);
+ createTreeView(tv, tvType);
+ TreeStore store = getStore(tvType);
tv.Model = store;
foreach (string [] line in array)
store.AppendValues (line);
}
+
+ protected abstract void createTreeView(Gtk.TreeView tv, treeviewType type);
+
+ protected abstract TreeStore getStore(treeviewType type);
+}
+
+public class EncoderOverviewWindow : OverviewWindow
+{
+ static EncoderOverviewWindow EncoderOverviewWindowBox;
+ private Constants.EncoderGI encoderGI;
+
+ public EncoderOverviewWindow(Gtk.Window parent)
+ {
+ Glade.XML gladeXML;
+ gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "overview.glade", "overview_win",
null);
+
+ gladeXML.Autoconnect(this);
+ overview_win.Parent = parent;
+
+ //put an icon to window
+ UtilGtk.IconWindow(overview_win);
+ }
+
static public EncoderOverviewWindow Show (Gtk.Window parent, Constants.EncoderGI encoderGI, int
sessionID)
{
if (EncoderOverviewWindowBox == null)
- EncoderOverviewWindowBox = new EncoderOverviewWindow (parent, encoderGI, sessionID);
+ EncoderOverviewWindowBox = new EncoderOverviewWindow (parent);
+
+ EncoderOverviewWindowBox.encoderGI = encoderGI;
+ EncoderOverviewWindowBox.sessionID = sessionID;
- EncoderOverviewWindowBox.encoder_overview_win.Show ();
+ EncoderOverviewWindowBox.initialize();
+
+ EncoderOverviewWindowBox.overview_win.Show ();
return EncoderOverviewWindowBox;
}
+ protected override string getTitle()
+ {
+ string title = Catalog.GetString("Encoder Overview") + " - " +
Catalog.GetString("Gravitatory");
+ if(encoderGI == Constants.EncoderGI.INERTIAL)
+ title = Catalog.GetString("Encoder Overview") + " - " + Catalog.GetString("Inertial");
+
+ return title;
+ }
+
+ protected override void createTreeViews()
+ {
+ createAndFillTreeView(treeview_sets, treeviewType.SETS, selectData(treeviewType.SETS));
+ createAndFillTreeView(treeview_reps, treeviewType.REPS, selectData(treeviewType.REPS));
+ }
+
+ protected override ArrayList selectData(treeviewType type)
+ {
+ if(type == treeviewType.SETS)
+ return SqliteEncoder.SelectSessionOverviewSets(false, encoderGI, sessionID);
+ else
+ return SqliteEncoder.SelectSessionOverviewReps(false, encoderGI, sessionID);
+ }
- private void createTreeView(
- Gtk.TreeView tv, treeviewType type, Constants.EncoderGI encoderGI)
+ protected override void createTreeView(Gtk.TreeView tv, treeviewType type)
{
tv.HeadersVisible=true;
int count = 0;
@@ -125,7 +150,7 @@ public class EncoderOverviewWindow
}
}
- private TreeStore getStore(treeviewType type, Constants.EncoderGI encoderGI)
+ protected override TreeStore getStore(treeviewType type)
{
TreeStore s;
if(type == treeviewType.SETS)
@@ -146,15 +171,14 @@ public class EncoderOverviewWindow
void on_button_close_clicked (object o, EventArgs args)
{
- EncoderOverviewWindowBox.encoder_overview_win.Hide();
+ EncoderOverviewWindowBox.overview_win.Hide();
EncoderOverviewWindowBox = null;
}
void on_delete_event (object o, DeleteEventArgs args)
{
- EncoderOverviewWindowBox.encoder_overview_win.Hide();
+ EncoderOverviewWindowBox.overview_win.Hide();
EncoderOverviewWindowBox = null;
}
}
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]