[chronojump] Encoder port sensitiveness better



commit a3ac5dfb4ead285b77113f09e992bc33445d4cca
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jan 30 01:30:34 2013 +0100

    Encoder port sensitiveness better

 src/gui/chronojump.cs |    6 ++++--
 src/gui/chronopic.cs  |   33 +++++++++------------------------
 src/gui/encoder.cs    |    2 +-
 src/util.cs           |    7 +++++++
 4 files changed, 21 insertions(+), 27 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index ae35f55..7a69ebd 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -3934,8 +3934,9 @@ Log.WriteLine("DDD 2");
 			cpd.Add(a);
 		}
 
-		chronopicWin = ChronopicWindow.Create(cpd, "", recreate, volumeOn);
+		chronopicWin = ChronopicWindow.Create(cpd, Util.GetDefaultPort(), recreate, volumeOn);
 		//chronopicWin.FakeButtonCancelled.Clicked += new EventHandler(on_chronopic_window_cancelled);
+Log.WriteLine("jjjjjjjjjjjjjjjjjjjjjjjjjjj");
 		chronopicLabels(0, recreate);
 	}
 
@@ -3979,9 +3980,10 @@ Log.WriteLine("DDD 2");
 	}
 
 	private void chronopicLabels(int cps, bool colorize) {
+Log.WriteLine("kkkkkkkkkkkkkkkkkkkkkkkkkkk");
 		string text = "<b>" + cps.ToString() + "</b>";
 		
-		if(chronopicWin.GetEncoderPort() != "") 
+		if(chronopicWin.GetEncoderPort() != Util.GetDefaultPort())
 			text += ", <b>enc</b>";
 			
 		label_connected_chronopics.Text = text;
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index e593b86..2acfc8c 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -347,11 +347,11 @@ Log.WriteLine("bbb");
 		//this reduces the callbacks of combo change
 		combo_windows_encoder.Sensitive = false;
 
-		if(encoderPort == "") {
-			UtilGtk.ComboUpdate(combo_windows_encoder, comboWindowsOptions, comboWindowsOptions[0]);
+		if(encoderPort == Util.GetDefaultPort()) {
+			UtilGtk.ComboUpdate(combo_windows_encoder, allWithDef, Constants.ChronopicDefaultPortWindows);
 			combo_windows_encoder.Changed += new EventHandler (on_combo_changed);
 		} else {
-			UtilGtk.ComboUpdate(combo_windows_encoder, comboWindowsOptions, encoderPort);
+			UtilGtk.ComboUpdate(combo_windows_encoder, allWithDef, encoderPort);
 			combo_windows_encoder.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, encoderPort);
 		}
 
@@ -402,13 +402,12 @@ Log.WriteLine("bbb");
 		//this reduces the callbacks of combo change
 		combo_linux_encoder.Sensitive = false;
 
-		if(encoderPort == "") {
-			UtilGtk.ComboUpdate(combo_linux_encoder, usbSerial, Constants.ChronopicDefaultPortLinux);
+		UtilGtk.ComboUpdate(combo_linux_encoder, allWithDef, encoderPort);
+
+		if(encoderPort == Util.GetDefaultPort())
 			combo_linux_encoder.Changed += new EventHandler (on_combo_changed);
-		} else {
-			UtilGtk.ComboUpdate(combo_linux_encoder, usbSerial, encoderPort);
-			combo_linux_encoder.Active = UtilGtk.ComboMakeActive(usbSerial, encoderPort);
-		}
+
+		combo_linux_encoder.Active = UtilGtk.ComboMakeActive(usbSerial, encoderPort);
 
 		combo_linux_encoder.Sensitive = true;
 	}
@@ -857,21 +856,7 @@ Log.WriteLine("bbb");
 	}
 
 	public string GetEncoderPort() {
-		if(Util.IsWindows()) {
-			string fullName = UtilGtk.ComboGetActive(combo_windows_encoder);
-			if(fullName.Length < 3)
-				return "COM1";
-			else {
-				//COM5
-				//int number = Convert.ToInt32(fullName.Substring(3));
-				//return (number -1).ToString(); //returns a "4", because eg: COM1 is port 0
-				
-				//with py2exe integration of serial, we need the portname
-				return fullName;
-			}
-		}
-		else
-			return UtilGtk.ComboGetActive(combo_linux_encoder);
+		return encoderPort;
 	}
 
 
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 1c8de4f..67838cb 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -170,7 +170,7 @@ public partial class ChronoJumpWindow
 	//TODO: garantir path windows	
 	void on_button_encoder_capture_clicked (object o, EventArgs args) 
 	{
-		if(chronopicWin.GetEncoderPort() == "") {
+		if(chronopicWin.GetEncoderPort() == Util.GetDefaultPort()) {
 			new DialogMessage(Constants.MessageTypes.WARNING, 
 					Catalog.GetString("Chronopic port is not configured."));
 			UtilGtk.ChronopicColors(viewport_chronopics, label_chronopics, label_connected_chronopics, false);
diff --git a/src/util.cs b/src/util.cs
index 1b9768e..8b5aa40 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1562,6 +1562,13 @@ public class Util
 		return detected;
 	}
 
+	public static string GetDefaultPort() {
+		if(Util.IsWindows())
+			return Constants.ChronopicDefaultPortWindows;
+		else
+			return Constants.ChronopicDefaultPortLinux;
+	}
+
 	/*
 	  tests:
 	  -1 simulated



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]