[chronojump] Chronopic device win can call to ArduinoDiscover for any of the unknown devices
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Chronopic device win can call to ArduinoDiscover for any of the unknown devices
- Date: Wed, 27 Apr 2022 15:23:44 +0000 (UTC)
commit 97b61d67f083dd9dd5dd49434a9b417ecada4831
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Apr 27 17:23:02 2022 +0200
Chronopic device win can call to ArduinoDiscover for any of the unknown devices
src/gui/chronopicRegister.cs | 52 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 51 insertions(+), 1 deletion(-)
---
diff --git a/src/gui/chronopicRegister.cs b/src/gui/chronopicRegister.cs
index 97a0f3623..f7f520543 100644
--- a/src/gui/chronopicRegister.cs
+++ b/src/gui/chronopicRegister.cs
@@ -15,7 +15,7 @@
* 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-2020 Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2016-2022 Xavier de Blas <xaviblas gmail com>
*/
using System;
@@ -216,6 +216,10 @@ public class ChronopicRegisterWindow
private List<Gtk.Button> list_buttons_left;
private List<Gtk.Button> list_buttons_right;
+ private List<Gtk.Button> list_discover_buttons;
+ private List<Gtk.Label> list_discover_labels;
+ private List<string> list_discover_ports;
+
private void createTable ()
{
int rows = listConnected.Count;
@@ -242,6 +246,10 @@ public class ChronopicRegisterWindow
list_labels_type = new List<Gtk.Label>();
list_buttons_right = new List<Gtk.Button>();
+ list_discover_buttons = new List<Gtk.Button>();
+ list_discover_labels = new List<Gtk.Label>();
+ list_discover_ports = new List<string>();
+
for (int count=1; count <= rows; count ++)
{
string deviceStr = listConnected[count -1].SerialNumber + "\n\n" +
listConnected[count -1].Port;
@@ -266,8 +274,21 @@ public class ChronopicRegisterWindow
hbox_type.PackStart(image, false, false, 1);
UtilGtk.ArrowEnum arrowEnum = UtilGtk.ArrowEnum.FORWARD;
+ Gtk.Button button_discover = null;
+ Gtk.Label label_discovered = null;
if(ChronopicRegisterPort.TypePrint(listConnected[count-1].Type) ==
ChronopicRegisterPort.TypePrint(ChronopicRegisterPort.Types.UNKNOWN))
+ {
arrowEnum = UtilGtk.ArrowEnum.FORWARD_EMPHASIS;
+
+ button_discover = new Gtk.Button("Discover"); //TODO: translate Discover.
+ button_discover.Clicked += new EventHandler(on_button_discover_clicked);
+ label_discovered = new Gtk.Label("");
+
+ list_discover_buttons.Add(button_discover);
+ list_discover_labels.Add(label_discovered);
+ list_discover_ports.Add(listConnected[count -1].Port);
+ }
+
Button button_right = UtilGtk.CreateArrowButton(ArrowType.Right, ShadowType.In, 50,
-1, arrowEnum);
button_right.CanFocus = false;
@@ -276,6 +297,12 @@ public class ChronopicRegisterWindow
button_right.Sensitive = (listConnected[count-1].Type !=
TypePixList.l[TypePixList.l.Count -1].Type);
hbox_type.PackStart(button_right, true, false, 1);
+ if(button_discover != null)
+ {
+ hbox_type.PackStart(button_discover, true, false, 1);
+ hbox_type.PackStart(label_discovered, true, false, 1);
+ }
+
Gtk.VBox vbox = new Gtk.VBox(false, 2);
vbox.Add(hbox_type);
@@ -467,6 +494,29 @@ public class ChronopicRegisterWindow
}
}
+ private void on_button_discover_clicked (object o, EventArgs args)
+ {
+ Button buttonClicked = o as Button;
+ if (o == null)
+ return;
+
+ int count = 0;
+ foreach(Gtk.Button button in list_discover_buttons)
+ {
+ if(button == buttonClicked)
+ {
+ LogB.Information("Calling discover at port: " + list_discover_ports[count]);
+
+ ArduinoDiscover ad = new ArduinoDiscover (list_discover_ports[count]);
+ ChronopicRegisterPort.Types crptype = ad.Discover ();
+
+ button.Visible = false;
+ (list_discover_labels[count]).Text = crptype.ToString();
+ }
+ count ++;
+ }
+ }
+
private void buttons_sensitivity(Gtk.Button left, Gtk.Button right, ChronopicRegisterPort.Types type)
{
left.Sensitive = (type != TypePixList.l[0].Type);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]