[chronojump] Compujump better management of found/not found rfids and (re)opening dialogs
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Compujump better management of found/not found rfids and (re)opening dialogs
- Date: Sat, 8 Jul 2017 11:34:43 +0000 (UTC)
commit 17d99b225e9d0316f8fbd42262f9378cac7f4578
Author: Xavier de Blas <xaviblas gmail com>
Date: Sat Jul 8 13:33:42 2017 +0200
Compujump better management of found/not found rfids and (re)opening dialogs
src/RFID.cs | 12 ++++++++-
src/gui/dialogMessage.cs | 13 ++++++++--
src/gui/dialogPersonPopup.cs | 8 ++++++
src/gui/networks.cs | 53 ++++++++++++++++++++++++++++++-----------
4 files changed, 68 insertions(+), 18 deletions(-)
---
diff --git a/src/RFID.cs b/src/RFID.cs
index 9c040df..f2bc00a 100644
--- a/src/RFID.cs
+++ b/src/RFID.cs
@@ -31,6 +31,7 @@ public class RFID
private SerialPort port;
private string portName;
private Gtk.Button fakeButtonChange;
+ private Gtk.Button fakeButtonReopenDialog;
private Gtk.Button fakeButtonDisconnected;
public RFID(string portName)
@@ -38,6 +39,7 @@ public class RFID
this.portName = portName;
stop = false;
fakeButtonChange = new Button();
+ fakeButtonReopenDialog = new Button();
fakeButtonDisconnected = new Button();
}
@@ -101,10 +103,13 @@ public class RFID
handler(this, new EventArgs());
*/
lastRFID = str;
+ } else {
+ //Firing the event
+ fakeButtonReopenDialog.Click();
}
}
}
- Thread.Sleep(100);
+ Thread.Sleep(200);
}
LogB.Information("AT RFID.cs: STOPPED");
port.Close();
@@ -162,6 +167,11 @@ public class RFID
get { return fakeButtonChange; }
}
+ public Gtk.Button FakeButtonReopenDialog
+ {
+ get { return fakeButtonReopenDialog; }
+ }
+
public Gtk.Button FakeButtonDisconnected
{
get { return fakeButtonDisconnected; }
diff --git a/src/gui/dialogMessage.cs b/src/gui/dialogMessage.cs
index bd14430..7813152 100644
--- a/src/gui/dialogMessage.cs
+++ b/src/gui/dialogMessage.cs
@@ -32,6 +32,7 @@ public class DialogMessage
[Widget] Gtk.Image image_help;
[Widget] Gtk.Box hbox_stiffness_formula;
+ public bool Visible;
public DialogMessage (string title, Constants.MessageTypes type, string message)
{
@@ -57,7 +58,9 @@ public class DialogMessage
Glade.XML gladeXML;
gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "dialog_message.glade",
"dialog_message", "chronojump");
gladeXML.Autoconnect(this);
-
+
+ Visible = true;
+
//put an icon to window
UtilGtk.IconWindow(dialog_message);
@@ -93,11 +96,15 @@ public class DialogMessage
dialog_message.Show();
}
- public void on_close_button_clicked (object obj, EventArgs args) {
+ public void on_close_button_clicked (object obj, EventArgs args)
+ {
+ Visible = false;
dialog_message.Destroy ();
}
- private void on_delete_event (object o, DeleteEventArgs args) {
+ private void on_delete_event (object o, DeleteEventArgs args)
+ {
+ Visible = false;
dialog_message.Destroy ();
}
}
diff --git a/src/gui/dialogPersonPopup.cs b/src/gui/dialogPersonPopup.cs
index c060f2c..72a1127 100644
--- a/src/gui/dialogPersonPopup.cs
+++ b/src/gui/dialogPersonPopup.cs
@@ -45,6 +45,7 @@ public class DialogPersonPopup
private Task taskActive;
public Button Fake_button_start_task;
public Button Fake_button_person_logout;
+ public bool Visible;
public DialogPersonPopup (int personID, string name, string rfid, List<Task> tasks)
{
@@ -55,6 +56,8 @@ public class DialogPersonPopup
//put an icon to window
UtilGtk.IconWindow(dialog_person_popup);
+ Visible = true;
+
label_name.Text = "<b>" + name + "</b>";
label_name.UseMarkup = true;
label_rfid.Text = rfid;
@@ -220,11 +223,13 @@ public class DialogPersonPopup
public void on_button_close_clicked (object obj, EventArgs args)
{
+ Visible = false;
dialog_person_popup.Destroy ();
}
private void on_delete_event (object o, DeleteEventArgs args)
{
+ Visible = false;
dialog_person_popup.Destroy ();
}
@@ -232,7 +237,10 @@ public class DialogPersonPopup
public void DestroyDialog ()
{
LogB.Information("Destroying dialogPersonPopup");
+
+ Visible = false;
dialog_person_popup.Destroy ();
+
LogB.Information("Destroyed dialogPersonPopup");
}
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index dfdd765..0060a7b 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -84,6 +84,7 @@ public partial class ChronoJumpWindow
private static bool shouldShowRFIDDisconnected;
private static bool updatingRFIDGuiStuff;
private bool rfidProcessCancel;
+ private bool rfidIsDifferent;
DialogPersonPopup dialogPersonPopup;
@@ -145,6 +146,7 @@ public partial class ChronoJumpWindow
{
rfid = new RFID(chronopicRegister.GetRfidPortName());
rfid.FakeButtonChange.Clicked += new EventHandler(rfidChanged);
+ rfid.FakeButtonReopenDialog.Clicked += new EventHandler(rfidReopenDialog);
rfid.FakeButtonDisconnected.Clicked += new EventHandler(rfidDisconnected);
threadRFID = new Thread (new ThreadStart (RFIDStart));
@@ -168,14 +170,23 @@ public partial class ChronoJumpWindow
/*
* TODO: only if we are not in the middle of capture, or in cont mode without repetitions
*/
- if(rfid.Captured != capturedRFID && currentSession != null)
+ if(currentSession != null && rfid.Captured != capturedRFID)
{
LogB.Information("RFID changed to: " + rfid.Captured);
capturedRFID = rfid.Captured;
+ rfidIsDifferent = true;
shouldUpdateRFIDGui = true;
- } else
- LogB.Information("RFID doesn't change");
+ }
+ }
+
+ private void rfidReopenDialog(object sender, EventArgs e)
+ {
+ if(currentSession != null && rfid.Captured == capturedRFID)
+ {
+ rfidIsDifferent = false;
+ shouldUpdateRFIDGui = true;
+ }
}
private void rfidDisconnected(object sender, EventArgs e)
@@ -389,6 +400,7 @@ public partial class ChronoJumpWindow
label_rfid_encoder.Visible = false;
}
+ DialogMessage dialogMessageNotAtServer;
private bool pulseRFID ()
{
if(shouldShowRFIDDisconnected)
@@ -437,8 +449,13 @@ public partial class ChronoJumpWindow
Person pServer = json.GetPersonByRFID(capturedRFID);
if(pServer.UniqueID == -1) {
LogB.Information("Person NOT found on server!");
- new DialogMessage(Constants.MessageTypes.WARNING,
- "Aquesta pulsera o jugador no es troba identificada al
servidor"); //GTK
+ if(dialogMessageNotAtServer == null || ! dialogMessageNotAtServer.Visible)
+ {
+ dialogMessageNotAtServer = new
DialogMessage(Constants.MessageTypes.WARNING,
+ "Aquesta pulsera o jugador no es troba identificada
al servidor"); //GTK
+
+ compujumpPersonLogoutDo();
+ }
}
else {
LogB.Information("Person found on server!");
@@ -485,15 +502,18 @@ public partial class ChronoJumpWindow
}
else {
LogB.Information("RFID person exists locally!!");
- currentPerson = pLocal;
- insertAndAssignPersonSessionIfNeeded(json);
+ if(rfidIsDifferent || dialogPersonPopup == null || ! dialogPersonPopup.Visible)
+ {
+ currentPerson = pLocal;
+ insertAndAssignPersonSessionIfNeeded(json);
- personChanged(); //GTK
- label_person_change();
- pChangedShowTasks = true;
+ personChanged(); //GTK
+ label_person_change();
+ pChangedShowTasks = true;
+ }
}
- if(currentPersonWasNull)
+ if(currentPerson != null && currentPersonWasNull)
sensitiveGuiYesPerson();
if(pChangedShowTasks)
@@ -589,6 +609,9 @@ public partial class ChronoJumpWindow
if(dialogPersonPopup != null)
dialogPersonPopup.DestroyDialog();
+ if(dialogMessageNotAtServer != null && dialogMessageNotAtServer.Visible)
+ dialogMessageNotAtServer.on_close_button_clicked(new object(), new EventArgs());
+
dialogPersonPopup = new DialogPersonPopup(
currentPerson.UniqueID, currentPerson.Name, capturedRFID, tasks);
@@ -650,13 +673,15 @@ public partial class ChronoJumpWindow
}
private void compujumpPersonLogoutDo()
{
- dialogPersonPopup.Fake_button_person_logout.Clicked -= new
EventHandler(compujumpPersonLogout);
+ if(dialogPersonPopup != null)
+ {
+ dialogPersonPopup.Fake_button_person_logout.Clicked -= new
EventHandler(compujumpPersonLogout);
+ dialogPersonPopup.DestroyDialog();
+ }
currentPerson = null;
currentPersonSession = null;
sensitiveGuiNoPerson ();
-
- dialogPersonPopup.DestroyDialog();
}
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]