[chronojump] encoder: curves selection (50%)



commit f520585aaa089ad7f268eeb6da8c68a917e14970
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Jul 9 18:41:20 2012 +0200

    encoder: curves selection (50%)

 glade/chronojump.glade   |   42 +++++++++++++++-
 po/POTFILES.in           |    1 +
 src/constants.cs         |    4 +-
 src/gui/encoder.cs       |   17 +++++-
 src/gui/genericWindow.cs |  119 +++++++++++++++++++++++++++++++++++++++++++--
 src/gui/person.cs        |    2 +-
 6 files changed, 171 insertions(+), 14 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index b5b38ae..021ccf7 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -19658,6 +19658,44 @@ comments</property>
               </packing>
             </child>
             <child>
+              <widget class="GtkHBox" id="hbox_all_none_selected">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="spacing">10</property>
+                <child>
+                  <widget class="GtkLabel" id="label90">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Mark</property>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkHBox" id="hbox_combo_all_none_selected">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">6</property>
+              </packing>
+            </child>
+            <child>
               <widget class="GtkScrolledWindow" id="scrolled_window_textview">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -19672,7 +19710,7 @@ comments</property>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">6</property>
+                <property name="position">7</property>
               </packing>
             </child>
             <child>
@@ -19690,7 +19728,7 @@ comments</property>
               <packing>
                 <property name="expand">True</property>
                 <property name="fill">True</property>
-                <property name="position">7</property>
+                <property name="position">8</property>
               </packing>
             </child>
           </widget>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 58a2ee3..fdc07b9 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -27,6 +27,7 @@ src/gui/encoder.cs
 src/gui/evaluator.cs
 src/gui/event.cs
 src/gui/eventExecute.cs
+src/gui/genericWindow.cs
 src/gui/helpPorts.cs
 src/gui/jump.cs
 src/gui/jumpType.cs
diff --git a/src/constants.cs b/src/constants.cs
index c61b26b..b2780b8 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -531,9 +531,9 @@ public class Constants
 	//public static string LowerOrEqualThanCode = "<=";
 	public static string HigherOrEqualThanCode = ">=";
 
-	//height mentric contains 2 spins
+	//heightmetric contains 2 spins
 	public enum GenericWindowShow {
-		ENTRY, ENTRY2, ENTRY3, SPININT, SPINDOUBLE, HEIGHTMETRIC, TEXTVIEW, TREEVIEW
+		ENTRY, ENTRY2, ENTRY3, SPININT, SPINDOUBLE, HEIGHTMETRIC, COMBOALLNONESELECTED, TEXTVIEW, TREEVIEW
 	}
 	
 	public const string PrefVersionAvailable = "versionAvailable";
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 2264afb..2469e60 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -321,11 +321,22 @@ public partial class ChronoJumpWindow
 			Catalog.GetString("Comment")
 		};
 
+		ArrayList bigArray = new ArrayList();
+		ArrayList a1 = new ArrayList();
+		ArrayList a2 = new ArrayList();
+		
+		//0 is the widgget to show; 1 is the editable; 2 id default value
+		a1.Add(Constants.GenericWindowShow.COMBOALLNONESELECTED); a1.Add(true); a1.Add("ALL");
+		bigArray.Add(a1);
+		
+		a2.Add(Constants.GenericWindowShow.TREEVIEW); a2.Add(true); a2.Add("");
+		bigArray.Add(a2);
+		
 		genericWin = GenericWindow.Show(
 				string.Format(Catalog.GetString("Saved curves of athlete {0} on this session."), 
-					currentPerson.Name), Constants.GenericWindowShow.TREEVIEW);
+					currentPerson.Name), bigArray);
 
-		genericWin.SetTreeview(columnsString, dataPrint);
+		genericWin.SetTreeview(columnsString, true, dataPrint);
 		genericWin.ShowButtonCancel(false);
 		genericWin.SetButtonAcceptSensitive(true);
 
@@ -359,7 +370,7 @@ public partial class ChronoJumpWindow
 				string.Format(Catalog.GetString("Select signal of athlete {0} on this session."), 
 					currentPerson.Name), Constants.GenericWindowShow.TREEVIEW);
 
-		genericWin.SetTreeview(columnsString, dataPrint);
+		genericWin.SetTreeview(columnsString, false, dataPrint);
 		genericWin.SetButtonAcceptLabel(Catalog.GetString("Load"));
 		genericWin.SetButtonAcceptSensitive(false);
 		genericWin.Button_accept.Clicked += new EventHandler(on_encoder_load_signal_accepted);
diff --git a/src/gui/genericWindow.cs b/src/gui/genericWindow.cs
index a2eaacf..afecbd5 100644
--- a/src/gui/genericWindow.cs
+++ b/src/gui/genericWindow.cs
@@ -25,6 +25,7 @@ using Glade;
 using GLib; //for Value
 //using System.Text; //StringBuilder
 using System.Collections; //ArrayList
+using Mono.Unix;
 
 
 public class GenericWindow
@@ -42,6 +43,9 @@ public class GenericWindow
 
 	[Widget] Gtk.SpinButton spin_double;
 	[Widget] Gtk.Box hbox_height_metric;
+	[Widget] Gtk.Box hbox_all_none_selected;
+	[Widget] Gtk.Box hbox_combo_all_none_selected;
+	[Widget] Gtk.ComboBox combo_all_none_selected;
 	[Widget] Gtk.SpinButton spin_feet;
 	[Widget] Gtk.SpinButton spin_inches;
 	[Widget] Gtk.ScrolledWindow scrolled_window_textview;
@@ -126,6 +130,7 @@ public class GenericWindow
 		hbox_spin_int.Hide();
 		spin_double.Hide();
 		hbox_height_metric.Hide();
+		hbox_combo_all_none_selected.Hide();
 		scrolled_window_textview.Hide();
 		scrolled_window_treeview.Hide();
 	}
@@ -161,6 +166,14 @@ public class GenericWindow
 		else if(stuff == Constants.GenericWindowShow.HEIGHTMETRIC) {
 			hbox_height_metric.Show();
 		}
+		else if(stuff == Constants.GenericWindowShow.COMBOALLNONESELECTED) {
+			createComboAllNoneSelected();
+			combo_all_none_selected.Active = 
+				UtilGtk.ComboMakeActive(comboAllNoneSelectedOptions, Catalog.GetString("All"));
+			//markSelected(Catalog.GetString("All"));
+			//on_combo_all_none_selected_changed(new object(), new EventArgs());
+			hbox_combo_all_none_selected.Show();
+		}
 		else if(stuff == Constants.GenericWindowShow.TEXTVIEW) {
 			scrolled_window_textview.Show();
 		}
@@ -203,6 +216,57 @@ public class GenericWindow
 		spin_int.SetRange(min, max);
 	}
 	
+	protected static string [] comboAllNoneSelectedOptions = {
+		Catalog.GetString("All"),
+		Catalog.GetString("None"),
+		Catalog.GetString("Selected"),
+	};
+
+	protected void createComboAllNoneSelected() {
+		combo_all_none_selected = ComboBox.NewText ();
+		UtilGtk.ComboUpdate(combo_all_none_selected, comboAllNoneSelectedOptions, "");
+		
+		//combo_all_none_selected.DisableActivate ();
+		combo_all_none_selected.Changed += new EventHandler (on_combo_all_none_selected_changed);
+
+		hbox_combo_all_none_selected.PackStart(combo_all_none_selected, true, true, 0);
+		hbox_combo_all_none_selected.ShowAll();
+		combo_all_none_selected.Sensitive = true;
+	}
+	
+	protected void on_combo_all_none_selected_changed(object o, EventArgs args) {
+		string myText = UtilGtk.ComboGetActive(combo_all_none_selected);
+			
+		if (myText != "" & myText != Catalog.GetString("Selected")) {
+			try {
+				markSelected(myText);
+			} catch {
+				Log.WriteLine("Do later!!");
+			}
+		}
+	}
+	
+	protected void markSelected(string selected) {
+		Gtk.TreeIter iter;
+		bool okIter = store.GetIterFirst(out iter);
+		if(okIter) {
+			if(selected == Catalog.GetString("All")) {
+				do {
+					store.SetValue (iter, 0, true);
+				} while ( store.IterNext(ref iter) );
+			} else if(selected == Catalog.GetString("None")) {
+				do {
+					store.SetValue (iter, 0, false);
+				} while ( store.IterNext(ref iter) );
+			}
+		}
+			
+		//check if there are rows checked for having sensitive or not in recuperate button
+		//buttonRecuperateChangeSensitiveness();
+	}
+	
+	
+	
 	public void SetTextview(string str) {
 		TextBuffer tb = new TextBuffer (new TextTagTable());
 		tb.Text = str;
@@ -210,35 +274,45 @@ public class GenericWindow
 	}
 	
 	//data is an ArrayList of strings[], each string [] is a row, each of its strings is a column
-	public void SetTreeview(string [] columnsString, ArrayList data) 
+	public void SetTreeview(string [] columnsString, bool addCheckbox, ArrayList data) 
 	{
 		//adjust window to be bigger
 		generic_window.Resizable = true;
 		scrolled_window_treeview.WidthRequest = 550;
 		scrolled_window_treeview.HeightRequest = 250;
 
-		store = getStore(columnsString.Length); 
+		store = getStore(columnsString.Length, addCheckbox); 
 		treeview.Model = store;
-		prepareHeaders(columnsString);
+		prepareHeaders(columnsString, addCheckbox);
 		
+		if(addCheckbox)
+			createCheckboxes(treeview);
+
 		foreach (string [] line in data) 
 			store.AppendValues (line);
 		
 		treeview.CursorChanged += on_treeview_cursor_changed; 
 	}
 	
-	private TreeStore getStore (int columns)
+	private TreeStore getStore (int columns, bool addCheckbox)
 	{
+		if(addCheckbox)
+			columns++;
+
 		//prepares the TreeStore for required columns
 		Type [] types = new Type [columns];
+
 		for (int i=0; i < columns; i++) {
-			types[i] = typeof (string);
+			if(addCheckbox && i == 0)
+				types[0] = typeof (bool);
+			else
+				types[i] = typeof (string);
 		}
 		TreeStore myStore = new TreeStore(types);
 		return myStore;
 	}
 	
-	private void prepareHeaders(string [] columnsString) 
+	private void prepareHeaders(string [] columnsString, bool addCheckbox) 
 	{
 		treeviewRemoveColumns();
 		treeview.HeadersVisible=true;
@@ -278,6 +352,39 @@ public class GenericWindow
 			return 0;
 	}
 	
+	protected void createCheckboxes(TreeView tv) 
+	{
+		CellRendererToggle crt = new CellRendererToggle();
+		crt.Visible = true;
+		crt.Activatable = true;
+		crt.Active = true;
+		crt.Toggled += ItemToggled;
+
+		TreeViewColumn column = new TreeViewColumn ("", crt, "active", 0);
+		column.Clickable = true;
+		tv.InsertColumn (column, 0);
+	}
+
+	protected void ItemToggled(object o, ToggledArgs args) {
+		//Log.WriteLine("Toggled");
+
+		int column = 0;
+		TreeIter iter;
+		if (store.GetIter (out iter, new TreePath(args.Path))) 
+		{
+			bool val = (bool) store.GetValue (iter, column);
+			//Log.WriteLine (string.Format("toggled {0} with value {1}", args.Path, !val));
+
+			store.SetValue (iter, column, !val);
+		
+			combo_all_none_selected.Active = UtilGtk.ComboMakeActive(comboAllNoneSelectedOptions, Catalog.GetString("Selected"));
+
+			//check if there are rows checked for having sensitive or not
+			//buttonRecuperateChangeSensitiveness();
+		}
+	}
+
+	
 	public void SetButtonAcceptLabel(string str) {
 		button_accept.Label=str;
 	}
diff --git a/src/gui/person.cs b/src/gui/person.cs
index 8f977b4..83c075a 100644
--- a/src/gui/person.cs
+++ b/src/gui/person.cs
@@ -455,7 +455,7 @@ public class PersonsRecuperateFromOtherSessionWindow : PersonRecuperateWindow
 		buttonRecuperateChangeSensitiveness();
 	}
 	
-	
+
 	protected void createCheckboxes(TreeView tv) 
 	{
 		CellRendererToggle crt = new CellRendererToggle();



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