[chronojump] RunEncoder export widgets/thread/export working ok
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] RunEncoder export widgets/thread/export working ok
- Date: Wed, 3 Mar 2021 14:54:18 +0000 (UTC)
commit d512d405ab6333ba0a05d926ba4043da90b114e1
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Mar 3 15:53:40 2021 +0100
RunEncoder export widgets/thread/export working ok
glade/app1.glade | 7 +++--
r-scripts/maximumIsometricForce.R | 2 +-
r-scripts/sprintEncoder.R | 4 +++
src/forceSensor.cs | 10 +++----
src/gui/app1/icons.cs | 2 ++
src/gui/app1/runEncoderAnalyze.cs | 28 +++++++++++++++++++-
src/runEncoder.cs | 56 ++++++++++++++++++++++++++++-----------
7 files changed, 85 insertions(+), 24 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 7187d687..c9cfd46a 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -26563,7 +26563,7 @@ Concentric</property>
<property name="border_width">2</property>
<property name="spacing">2</property>
<child>
- <widget class="GtkHBox" id="hbox253">
+ <widget class="GtkHBox" id="hbox_run_encoder_top">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">20</property>
@@ -27309,8 +27309,10 @@ Concentric</property>
<widget class="GtkCheckButton"
id="check_run_encoder_export_images">
<property name="label"
translatable="yes">Include images</property>
<property name="visible">True</property>
+ <property name="sensitive">False</property>
<property name="can_focus">True</property>
<property
name="receives_default">False</property>
+ <property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
@@ -27431,8 +27433,9 @@ Concentric</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked"
handler="on_button_run_encoder_export_cancel_clicked" swapped="no"/>
<child>
- <widget class="GtkImage"
id="image_run_encoder_cancel">
+ <widget class="GtkImage"
id="image_run_encoder_export_cancel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property
name="stock">gtk-missing-image</property>
diff --git a/r-scripts/maximumIsometricForce.R b/r-scripts/maximumIsometricForce.R
index b89fbed3..bc4a5d1f 100644
--- a/r-scripts/maximumIsometricForce.R
+++ b/r-scripts/maximumIsometricForce.R
@@ -1248,7 +1248,7 @@ start <- function(op)
progressFilename = paste(progressFolder, "/", i, sep="")
file.create(progressFilename)
- print("done")
+ print("done")
}
#3) write the file
diff --git a/r-scripts/sprintEncoder.R b/r-scripts/sprintEncoder.R
index e40bebbe..21f3c4e0 100644
--- a/r-scripts/sprintEncoder.R
+++ b/r-scripts/sprintEncoder.R
@@ -785,6 +785,10 @@ start <- function(op)
dataFiles$device[i], dataFiles$title[i], dataFiles$datetime[i],
op$startAccel)
endGraph()
+
+ progressFilename = paste(progressFolder, "/", i, sep="")
+ file.create(progressFilename)
+ print("done")
}
}
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 7df09d43..597da5f4 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -2642,6 +2642,11 @@ public class ForceSensorExport
{
this.exportURL = exportURL;
+ //create progressbar and graph files dirs or delete their contents
+ createOrEmptyDir(Util.GetForceSensorTempProgressDir());
+ createOrEmptyDir(Util.GetForceSensorTempGraphsDir());
+ createOrEmptyDir(Util.GetForceSensorTempGraphsABDir());
+
cancel = false;
noData = false;
cannotCopy = false;
@@ -2649,11 +2654,6 @@ public class ForceSensorExport
messageToProgressbar = "";
notebook.CurrentPage = 1;
- //create progressbar and graph files dirs or delete their contents
- createOrEmptyDir(Util.GetForceSensorTempProgressDir());
- createOrEmptyDir(Util.GetForceSensorTempGraphsDir());
- createOrEmptyDir(Util.GetForceSensorTempGraphsABDir());
-
thread = new Thread (new ThreadStart (forceSensorExportDo));
GLib.Idle.Add (new GLib.IdleHandler (pulseForceSensorExportGTK));
thread.Start();
diff --git a/src/gui/app1/icons.cs b/src/gui/app1/icons.cs
index ac071ae8..5d948416 100644
--- a/src/gui/app1/icons.cs
+++ b/src/gui/app1/icons.cs
@@ -207,6 +207,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Image image_run_encoder_analyze_load;
[Widget] Gtk.Image image_run_encoder_analyze_image_save_graph;
[Widget] Gtk.Image image_run_encoder_analyze_image_save_disk;
+ [Widget] Gtk.Image image_run_encoder_export_cancel;
//video play icons
[Widget] Gtk.Image image_video_play_this_test_contacts;
@@ -705,6 +706,7 @@ public partial class ChronoJumpWindow
pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_cancel.png");
image_encoder_analyze_cancel.Pixbuf = pixbuf;
image_force_sensor_export_cancel.Pixbuf = pixbuf;
+ image_run_encoder_export_cancel.Pixbuf = pixbuf;
//zoom icons, done like this because there's one zoom icon created ad-hoc,
//and is not nice that the other are different for an user theme change
diff --git a/src/gui/app1/runEncoderAnalyze.cs b/src/gui/app1/runEncoderAnalyze.cs
index f8a91070..2d02bf33 100644
--- a/src/gui/app1/runEncoderAnalyze.cs
+++ b/src/gui/app1/runEncoderAnalyze.cs
@@ -45,9 +45,12 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Image image_run_encoder_analyze_individual_current_set;
[Widget] Gtk.Image image_run_encoder_analyze_individual_current_session;
[Widget] Gtk.Image image_run_encoder_analyze_groupal_current_session;
+
+ [Widget] Gtk.HBox hbox_run_encoder_top;
[Widget] Gtk.HBox hbox_run_encoder_analyze_top_modes;
//export
+ [Widget] Gtk.Notebook notebook_run_encoder_export;
[Widget] Gtk.Label label_run_encoder_export_data;
[Widget] Gtk.CheckButton check_run_encoder_export_images;
[Widget] Gtk.ProgressBar progressbar_run_encoder_export;
@@ -310,8 +313,14 @@ public partial class ChronoJumpWindow
RunEncoderExport runEncoderExport;
private void button_run_encoder_export_session (int personID)
{
+ runEncoderButtonsSensitive(false);
+ hbox_run_encoder_top.Sensitive = false;
+
runEncoderExport = new RunEncoderExport (
- true, //includeImages //TODO
+ notebook_run_encoder_export,
+ progressbar_run_encoder_export,
+ label_run_encoder_export_result,
+ check_run_encoder_export_images.Active,
UtilAll.IsWindows(),
personID,
currentSession.UniqueID,
@@ -325,9 +334,26 @@ public partial class ChronoJumpWindow
preferences.CSVExportDecimalSeparatorChar //decimalIsPointAtExport
(write)
);
+ runEncoderExport.Button_done.Clicked -= new EventHandler(run_encoder_export_done);
+ runEncoderExport.Button_done.Clicked += new EventHandler(run_encoder_export_done);
+
//runEncoderExport.Start(selectedFileName); //file or folder
runEncoderExport.Start("runEncoderExport.csv"); //file or folder
//TODO: continue with cancel stuff, ...
}
+
+ private void on_button_run_encoder_export_cancel_clicked (object o, EventArgs args)
+ {
+ runEncoderExport.Cancel();
+ }
+
+ private void run_encoder_export_done (object o, EventArgs args)
+ {
+ runEncoderExport.Button_done.Clicked -= new EventHandler(run_encoder_export_done);
+
+ runEncoderButtonsSensitive(true);
+ hbox_run_encoder_top.Sensitive = true;
+ }
+
}
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index 19f320b9..e5e7aedb 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -415,11 +415,9 @@ public class RunEncoderExport
public Gtk.Button Button_done;
//passed variables
- /*
private Gtk.Notebook notebook;
private Gtk.ProgressBar progressbar;
private Gtk.Label labelResult;
- */
private bool includeImages;
private string exportURL; //folder or .csv depending on includeImages
private bool isWindows;
@@ -448,9 +446,9 @@ public class RunEncoderExport
//constructor
public RunEncoderExport (
-// Gtk.Notebook notebook,
-// Gtk.ProgressBar progressbar,
-// Gtk.Label labelResult,
+ Gtk.Notebook notebook,
+ Gtk.ProgressBar progressbar,
+ Gtk.Label labelResult,
bool includeImages,
bool isWindows,
int personID,
@@ -462,9 +460,9 @@ public class RunEncoderExport
char exportDecimalSeparator
)
{
-// this.notebook = notebook;
-// this.progressbar = progressbar;
-// this.labelResult = labelResult;
+ this.notebook = notebook;
+ this.progressbar = progressbar;
+ this.labelResult = labelResult;
this.includeImages = includeImages;
this.isWindows = isWindows;
this.personID = personID;
@@ -486,16 +484,16 @@ public class RunEncoderExport
{
this.exportURL = exportURL;
+ //create progressbar and graph files dirs or delete their contents
+ createOrEmptyDir(Util.GetRunEncoderTempProgressDir());
+ createOrEmptyDir(Util.GetRunEncoderTempGraphsDir());
+
cancel = false;
noData = false;
cannotCopy = false;
-// progressbar.Fraction = 0;
+ progressbar.Fraction = 0;
messageToProgressbar = "";
-// notebook.CurrentPage = 1;
-
- //create progressbar and graph files dirs or delete their contents
- createOrEmptyDir(Util.GetRunEncoderTempProgressDir());
- createOrEmptyDir(Util.GetRunEncoderTempGraphsDir());
+ notebook.CurrentPage = 1;
thread = new Thread (new ThreadStart (runEncoderExportDo));
GLib.Idle.Add (new GLib.IdleHandler (pulseRunEncoderExportGTK));
@@ -522,14 +520,42 @@ public class RunEncoderExport
{
if(! thread.IsAlive || cancel)
{
+ if(cancel)
+ LogB.Information("pulseRunEncoderExportGTK cancelled");
+
LogB.Information("pulseRunEncoderExportGTK ending here");
LogB.ThreadEnded();
- //Button_done.Click();
+ progressbar.Fraction = 1;
+ notebook.CurrentPage = 0;
+
+ if(cancel)
+ labelResult.Text = Catalog.GetString("Cancelled.");
+ else if (noData)
+ labelResult.Text = Catalog.GetString("Missing data.");
+ else if (cannotCopy)
+ labelResult.Text = string.Format(Catalog.GetString("Cannot copy to {0} "),
exportURL);
+ else
+ labelResult.Text = string.Format(Catalog.GetString("Exported to {0}"),
exportURL);// +
+ //Constants.GetSpreadsheetString(CSVExportDecimalSeparator)
+ //);
+ Button_done.Click();
return false;
}
+ DirectoryInfo dirInfo = new DirectoryInfo(Util.GetRunEncoderTempProgressDir());
+ //LogB.Information(string.Format("pulse files: {0}", dirInfo.GetFiles().Length));
+
+ int files = dirInfo.GetFiles().Length;
+ if(files == 0) {
+ progressbar.Text = messageToProgressbar;
+ progressbar.Pulse();
+ } else {
+ progressbar.Text = string.Format(Catalog.GetString("Exporting {0}/{1}"), files,
re_l.Count);
+ progressbar.Fraction = UtilAll.DivideSafeFraction(files, re_l.Count);
+ }
+
Thread.Sleep (100);
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]