[longomatch] Add 'AND'/'OR' option to the tags filter



commit ed34e0fa632bdd84293fe679f8934f3e38646752
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Jun 16 01:52:41 2010 +0200

    Add 'AND'/'OR' option to the tags filter

 LongoMatch/Gui/Component/TagsTreeWidget.cs         |   39 +++++++++++++++++---
 .../LongoMatch.Gui.Component.TagsTreeWidget.cs     |   20 ++++++++++
 LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs    |    2 +-
 LongoMatch/gtk-gui/gui.stetic                      |   26 +++++++++++++-
 LongoMatch/gtk-gui/objects.xml                     |   22 ++++++------
 5 files changed, 91 insertions(+), 18 deletions(-)
---
diff --git a/LongoMatch/Gui/Component/TagsTreeWidget.cs b/LongoMatch/Gui/Component/TagsTreeWidget.cs
index 9354cfe..bbf611b 100644
--- a/LongoMatch/Gui/Component/TagsTreeWidget.cs
+++ b/LongoMatch/Gui/Component/TagsTreeWidget.cs
@@ -1,4 +1,4 @@
-// TreeWidget.cs
+// TreeWidget.cs
 //
 //  Copyright(C) 20072009 Andoni Morales Alastruey
 //
@@ -28,6 +28,10 @@ using LongoMatch.TimeNodes;
 
 namespace LongoMatch.Gui.Component
 {
+	public enum FilterType {
+		OR = 0,
+		AND = 1
+	}
 
 
 	[System.ComponentModel.Category("LongoMatch")]
@@ -44,6 +48,9 @@ namespace LongoMatch.Gui.Component
 		private ListStore model;
 		private List<Tag> filterTags;
 		private Project project;
+		private FilterType filterType;
+		private const string orFilter =  "'OR' Filter";
+		private const string andFilter = "'AND' Filter";
 
 
 		public TagsTreeWidget()
@@ -54,6 +61,11 @@ namespace LongoMatch.Gui.Component
 			filter = new Gtk.TreeModelFilter(model, null);
 			filter.VisibleFunc = new Gtk.TreeModelFilterVisibleFunc(FilterTree);
 			treeview.Model = filter;
+			filtercombobox.InsertText ((int)FilterType.OR, Catalog.GetString(orFilter));
+			filtercombobox.InsertText ((int)FilterType.AND, Catalog.GetString(andFilter));
+			filtercombobox.Active = 0;
+			filterType = FilterType.OR;
+			
 		}
 		
 		public void Clear(){
@@ -178,11 +190,20 @@ namespace LongoMatch.Gui.Component
 
 			if (tNode == null)
 				return true;
-			foreach (Tag tag in tNode.Tags){
-				if (filterTags.Contains(tag))
-					return true;
+
+			if (filterType == FilterType.OR){
+				foreach (Tag tag in filterTags){
+					if (tNode.Tags.Contains(tag))
+						return true;
+				}
+				return false;
+			} else {
+				foreach (Tag tag in filterTags){
+					if (! tNode.Tags.Contains(tag))
+						return false;
+				}
+				return true;
 			}
-			return false;
 		}
 		
 		protected virtual void OnTimeNodeChanged(TimeNode tNode,object val) {
@@ -206,5 +227,13 @@ namespace LongoMatch.Gui.Component
 			if (SnapshotSeriesEvent != null)
 				SnapshotSeriesEvent(tNode);
 		}
+		
+		protected virtual void OnFiltercomboboxChanged (object sender, System.EventArgs e)
+		{
+			filterType = (FilterType) filtercombobox.Active;
+			filter.Refilter();
+		}
+		
+		
 	}
 }
\ No newline at end of file
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.Component.TagsTreeWidget.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.Component.TagsTreeWidget.cs
index 210e1b0..512b7ce 100644
--- a/LongoMatch/gtk-gui/LongoMatch.Gui.Component.TagsTreeWidget.cs
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.Component.TagsTreeWidget.cs
@@ -27,6 +27,10 @@ namespace LongoMatch.Gui.Component {
         
         private Gtk.Button AddFilterButton;
         
+        private Gtk.HBox hbox2;
+        
+        private Gtk.ComboBox filtercombobox;
+        
         protected virtual void Build() {
             Stetic.Gui.Initialize(this);
             // Widget LongoMatch.Gui.Component.TagsTreeWidget
@@ -98,6 +102,21 @@ namespace LongoMatch.Gui.Component {
             w14.Position = 2;
             w14.Expand = false;
             w14.Fill = false;
+            // Container child vbox1.Gtk.Box+BoxChild
+            this.hbox2 = new Gtk.HBox();
+            this.hbox2.Name = "hbox2";
+            this.hbox2.Spacing = 6;
+            // Container child hbox2.Gtk.Box+BoxChild
+            this.filtercombobox = Gtk.ComboBox.NewText();
+            this.filtercombobox.Name = "filtercombobox";
+            this.hbox2.Add(this.filtercombobox);
+            Gtk.Box.BoxChild w15 = ((Gtk.Box.BoxChild)(this.hbox2[this.filtercombobox]));
+            w15.Position = 0;
+            this.vbox1.Add(this.hbox2);
+            Gtk.Box.BoxChild w16 = ((Gtk.Box.BoxChild)(this.vbox1[this.hbox2]));
+            w16.Position = 3;
+            w16.Expand = false;
+            w16.Fill = false;
             this.Add(this.vbox1);
             if ((this.Child != null)) {
                 this.Child.ShowAll();
@@ -108,6 +127,7 @@ namespace LongoMatch.Gui.Component {
             this.treeview.PlayListNodeAdded += new LongoMatch.Handlers.PlayListNodeAddedHandler(this.OnPlayListNodeAdded);
             this.treeview.SnapshotSeriesEvent += new LongoMatch.Handlers.SnapshotSeriesHandler(this.OnSnapshotSeriesEvent);
             this.AddFilterButton.Clicked += new System.EventHandler(this.OnAddFilter);
+            this.filtercombobox.Changed += new System.EventHandler(this.OnFiltercomboboxChanged);
         }
     }
 }
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs
index 26d3adf..fbceab2 100644
--- a/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs
@@ -195,7 +195,7 @@ namespace LongoMatch.Gui {
             this.ImportProjectAction.ShortLabel = Mono.Unix.Catalog.GetString("_Import Project");
             w1.Add(this.ImportProjectAction, "<Control>i");
             this.FreeCaptureModeAction = new Gtk.RadioAction("FreeCaptureModeAction", Mono.Unix.Catalog.GetString("Free Capture Mode"), null, null, 0);
-            this.FreeCaptureModeAction.Group = this.AnalyzeModeAction.Group;
+            this.FreeCaptureModeAction.Group = this.CaptureModeAction.Group;
             this.FreeCaptureModeAction.Sensitive = false;
             this.FreeCaptureModeAction.ShortLabel = Mono.Unix.Catalog.GetString("Free Capture Mode");
             w1.Add(this.FreeCaptureModeAction, null);
diff --git a/LongoMatch/gtk-gui/gui.stetic b/LongoMatch/gtk-gui/gui.stetic
index 14887e3..0a2a122 100644
--- a/LongoMatch/gtk-gui/gui.stetic
+++ b/LongoMatch/gtk-gui/gui.stetic
@@ -5312,7 +5312,7 @@ Show-&gt;&lt;b&gt; S&lt;/b&gt;
       </widget>
     </child>
   </widget>
-  <widget class="Gtk.Bin" id="LongoMatch.Gui.Component.TaggerWidget" design-size="377 181">
+  <widget class="Gtk.Bin" id="LongoMatch.Gui.Component.TaggerWidget" design-size="377 196">
     <property name="MemberName" />
     <property name="Visible">False</property>
     <child>
@@ -5571,6 +5571,30 @@ You can add new tags using the text entry and clicking "Add Tag"</property>
             <property name="Fill">False</property>
           </packing>
         </child>
+        <child>
+          <widget class="Gtk.HBox" id="hbox2">
+            <property name="MemberName" />
+            <property name="Spacing">6</property>
+            <child>
+              <widget class="Gtk.ComboBox" id="filtercombobox">
+                <property name="MemberName" />
+                <property name="IsTextCombo">True</property>
+                <property name="Items" translatable="yes" />
+                <signal name="Changed" handler="OnFiltercomboboxChanged" />
+              </widget>
+              <packing>
+                <property name="Position">0</property>
+                <property name="AutoSize">False</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="Position">3</property>
+            <property name="AutoSize">True</property>
+            <property name="Expand">False</property>
+            <property name="Fill">False</property>
+          </packing>
+        </child>
       </widget>
     </child>
   </widget>
diff --git a/LongoMatch/gtk-gui/objects.xml b/LongoMatch/gtk-gui/objects.xml
index dac8514..8436ebc 100644
--- a/LongoMatch/gtk-gui/objects.xml
+++ b/LongoMatch/gtk-gui/objects.xml
@@ -195,17 +195,6 @@
       </itemgroup>
     </signals>
   </object>
-  <object type="LongoMatch.Gui.Component.TagsTreeWidget" palette-category="LongoMatch" allow-children="false" base-type="Gtk.Bin">
-    <itemgroups />
-    <signals>
-      <itemgroup label="TagsTreeWidget Signals">
-        <signal name="TimeNodeSelected" />
-        <signal name="TimeNodeChanged" />
-        <signal name="PlayListNodeAdded" />
-        <signal name="SnapshotSeriesEvent" />
-      </itemgroup>
-    </signals>
-  </object>
   <object type="LongoMatch.Gui.Component.ButtonsWidget" palette-category="LongoMatch" allow-children="false" base-type="Gtk.Bin">
     <itemgroups />
     <signals>
@@ -273,4 +262,15 @@
     </itemgroups>
     <signals />
   </object>
+  <object type="LongoMatch.Gui.Component.TagsTreeWidget" palette-category="LongoMatch" allow-children="false" base-type="Gtk.Bin">
+    <itemgroups />
+    <signals>
+      <itemgroup label="TagsTreeWidget Signals">
+        <signal name="TimeNodeSelected" />
+        <signal name="TimeNodeChanged" />
+        <signal name="PlayListNodeAdded" />
+        <signal name="SnapshotSeriesEvent" />
+      </itemgroup>
+    </signals>
+  </object>
 </objects>
\ No newline at end of file



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