[longomatch] Allow tagging plays by team by default without need for subcategories



commit 60d65a966f2db70838ff4471e0288a18ece5ffef
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun Jan 15 23:36:44 2012 +0100

    Allow tagging plays by team by default without need for subcategories

 LongoMatch.Core/Store/Play.cs                      |    8 +-
 .../Store/Templates/CategoriesTemplate.cs          |    8 -
 LongoMatch.GUI/Gui/Component/TaggerWidget.cs       |   28 ++++
 LongoMatch.GUI/Gui/Dialog/TaggerDialog.cs          |   13 +-
 LongoMatch.GUI/Gui/GUIToolkit.cs                   |    3 +-
 .../LongoMatch.Gui.Component.TaggerWidget.cs       |   66 +++++++++-
 .../gtk-gui/LongoMatch.Gui.Dialog.TaggerDialog.cs  |    2 +
 LongoMatch.GUI/gtk-gui/gui.stetic                  |  136 +++++++++++++++-----
 8 files changed, 209 insertions(+), 55 deletions(-)
---
diff --git a/LongoMatch.Core/Store/Play.cs b/LongoMatch.Core/Store/Play.cs
index a3eae96..0e09b9c 100644
--- a/LongoMatch.Core/Store/Play.cs
+++ b/LongoMatch.Core/Store/Play.cs
@@ -160,10 +160,12 @@ namespace LongoMatch.Store
 				return StopFrame-StartFrame;
 			}
 		}
+		
+		public Team Team {
+			get;
+			set;
+		}
 
-		//// <summary>
-		/// Play's tags
-		/// </summary>
 		public StringTagStore Tags {
 			get;
 			set;
diff --git a/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs b/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
index ad49829..69c4e48 100644
--- a/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
+++ b/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
@@ -77,13 +77,6 @@ namespace LongoMatch.Store.Templates
 			Color c = Color.FromArgb(255, 0, 0);
 			HotKey h = new HotKey();
 			
-			team = new TeamSubCategory {
-				Name = Catalog.GetString("Team"),
-				AllowMultiple = false,
-				FastTag = true};
-			team.Add(Team.LOCAL);
-			team.Add(Team.VISITOR);
-			
 			localplayers = new PlayerSubCategory {
 				Name = Catalog.GetString("Local Team Players"),
 				AllowMultiple = true,
@@ -113,7 +106,6 @@ namespace LongoMatch.Store.Templates
 				HotKey = h,
 				Position = index-1,
 			};
-			cat.SubCategories.Add(team);
 			cat.SubCategories.Add(localplayers);
 			cat.SubCategories.Add(visitorplayers);
 			cat.SubCategories.Add(period);
diff --git a/LongoMatch.GUI/Gui/Component/TaggerWidget.cs b/LongoMatch.GUI/Gui/Component/TaggerWidget.cs
index ebe803a..200ecaa 100644
--- a/LongoMatch.GUI/Gui/Component/TaggerWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/TaggerWidget.cs
@@ -19,6 +19,8 @@
 using System;
 using System.Collections.Generic;
 using Gtk;
+
+using LongoMatch.Common;
 using LongoMatch.Store;
 using LongoMatch.Store.Templates;
 
@@ -29,11 +31,23 @@ namespace LongoMatch.Gui.Component
 	[System.ComponentModel.ToolboxItem(true)]
 	public partial class TaggerWidget : Gtk.Bin
 	{
+		Play play;
+		
 		public TaggerWidget()
 		{
 			this.Build();
 			table1.NColumns = 1;
 			table1.NRows = 1;
+			localcheckbutton.Toggled += OnCheckbuttonToggled;
+			visitorcheckbutton.Toggled += OnCheckbuttonToggled;
+		}
+		
+		public void SetData (Play play, string localTeam, string visitorTeam) {
+			this.play = play;
+			localcheckbutton.Label = localTeam;
+			visitorcheckbutton.Label = visitorTeam;
+			localcheckbutton.Active = play.Team == Team.LOCAL || play.Team == Team.BOTH;
+			visitorcheckbutton.Active = play.Team == Team.VISITOR || play.Team == Team.BOTH;
 		}
 		
 		public void AddSubCategory(TagSubCategory subcat, StringTagStore tags){
@@ -51,5 +65,19 @@ namespace LongoMatch.Gui.Component
 			table1.NRows ++;
 			tagger.Show();
 		}
+		
+		protected void OnCheckbuttonToggled (object sender, System.EventArgs e)
+		{
+			if (visitorcheckbutton.Active && localcheckbutton.Active) {
+				play.Team = Team.BOTH;
+			} else {
+				if (localcheckbutton.Active)
+					play.Team = Team.LOCAL;
+				else if (visitorcheckbutton.Active)
+					play.Team = Team.VISITOR;
+				else
+					play.Team = Team.NONE;
+			}
+		}
 	}
 }
\ No newline at end of file
diff --git a/LongoMatch.GUI/Gui/Dialog/TaggerDialog.cs b/LongoMatch.GUI/Gui/Dialog/TaggerDialog.cs
index 865737b..b1d4067 100644
--- a/LongoMatch.GUI/Gui/Dialog/TaggerDialog.cs
+++ b/LongoMatch.GUI/Gui/Dialog/TaggerDialog.cs
@@ -34,8 +34,7 @@ namespace LongoMatch.Gui.Dialog
 		private TeamTemplate localTeamTemplate;
 		private TeamTemplate visitorTeamTemplate;
 
-		public TaggerDialog(Category cat, StringTagStore tags, PlayersTagStore players, TeamsTagStore teams,
-		                    TeamTemplate localTeamTemplate, TeamTemplate visitorTeamTemplate)
+		public TaggerDialog(Play play, TeamTemplate localTeamTemplate, TeamTemplate visitorTeamTemplate)
 		{
 			this.Build();
 			
@@ -44,19 +43,21 @@ namespace LongoMatch.Gui.Dialog
 			this.localTeamTemplate = localTeamTemplate;
 			this.visitorTeamTemplate = visitorTeamTemplate;
 			
+			taggerwidget1.SetData(play, localTeamTemplate.TeamName, visitorTeamTemplate.TeamName);
+			
 			/* Iterate over all subcategories, adding a widget only for the FastTag ones */
-			foreach (var subcat in cat.SubCategories) {
+			foreach (var subcat in play.Category.SubCategories) {
 				if (!subcat.FastTag)
 					continue;
 				if (subcat is TagSubCategory) {
 					var tagcat = subcat as TagSubCategory;
-					AddTagSubcategory(tagcat, tags);
+					AddTagSubcategory(tagcat, play.Tags);
 				} else if (subcat is PlayerSubCategory) {
 					var tagcat = subcat as PlayerSubCategory;
-					AddPlayerSubcategory(tagcat, players);
+					AddPlayerSubcategory(tagcat, play.Players);
 				} else if (subcat is TeamSubCategory) {
 					var tagcat = subcat as TeamSubCategory;
-					AddTeamSubcategory(tagcat, teams,
+					AddTeamSubcategory(tagcat, play.Teams,
 					                   localTeamTemplate.TeamName,
 					                   visitorTeamTemplate.TeamName);
 				}
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
index da9af51..cc389ea 100644
--- a/LongoMatch.GUI/Gui/GUIToolkit.cs
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -140,8 +140,7 @@ namespace LongoMatch.Gui
 		}
 		
 		public void TagPlay (Play play, TeamTemplate local, TeamTemplate visitor) {
-			TaggerDialog tg = new TaggerDialog(play.Category, play.Tags, play.Players, play.Teams,
-			                                   local, visitor);
+			TaggerDialog tg = new TaggerDialog(play, local, visitor);
 			tg.TransientFor = mainWindow as Gtk.Window;
 			tg.Run();
 			tg.Destroy();
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.TaggerWidget.cs b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.TaggerWidget.cs
index 4120cb0..51a45c9 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.TaggerWidget.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.TaggerWidget.cs
@@ -5,6 +5,13 @@ namespace LongoMatch.Gui.Component
 	public partial class TaggerWidget
 	{
 		private global::Gtk.VBox vbox2;
+		private global::Gtk.VBox vbox3;
+		private global::Gtk.Frame frame1;
+		private global::Gtk.Alignment GtkAlignment;
+		private global::Gtk.HBox hbox1;
+		private global::Gtk.CheckButton localcheckbutton;
+		private global::Gtk.CheckButton visitorcheckbutton;
+		private global::Gtk.Label GtkLabel1;
 		private global::Gtk.Table table1;
         
 		protected virtual void Build ()
@@ -18,15 +25,64 @@ namespace LongoMatch.Gui.Component
 			this.vbox2.Name = "vbox2";
 			this.vbox2.Spacing = 6;
 			// Container child vbox2.Gtk.Box+BoxChild
+			this.vbox3 = new global::Gtk.VBox ();
+			this.vbox3.Name = "vbox3";
+			this.vbox3.Spacing = 6;
+			// Container child vbox3.Gtk.Box+BoxChild
+			this.frame1 = new global::Gtk.Frame ();
+			this.frame1.Name = "frame1";
+			this.frame1.ShadowType = ((global::Gtk.ShadowType)(0));
+			// Container child frame1.Gtk.Container+ContainerChild
+			this.GtkAlignment = new global::Gtk.Alignment (0F, 0F, 1F, 1F);
+			this.GtkAlignment.Name = "GtkAlignment";
+			this.GtkAlignment.LeftPadding = ((uint)(12));
+			// Container child GtkAlignment.Gtk.Container+ContainerChild
+			this.hbox1 = new global::Gtk.HBox ();
+			this.hbox1.Name = "hbox1";
+			this.hbox1.Spacing = 6;
+			// Container child hbox1.Gtk.Box+BoxChild
+			this.localcheckbutton = new global::Gtk.CheckButton ();
+			this.localcheckbutton.CanFocus = true;
+			this.localcheckbutton.Name = "localcheckbutton";
+			this.localcheckbutton.Label = "";
+			this.localcheckbutton.DrawIndicator = true;
+			this.localcheckbutton.UseUnderline = true;
+			this.hbox1.Add (this.localcheckbutton);
+			global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.localcheckbutton]));
+			w1.Position = 0;
+			// Container child hbox1.Gtk.Box+BoxChild
+			this.visitorcheckbutton = new global::Gtk.CheckButton ();
+			this.visitorcheckbutton.CanFocus = true;
+			this.visitorcheckbutton.Name = "visitorcheckbutton";
+			this.visitorcheckbutton.Label = "";
+			this.visitorcheckbutton.DrawIndicator = true;
+			this.visitorcheckbutton.UseUnderline = true;
+			this.hbox1.Add (this.visitorcheckbutton);
+			global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.visitorcheckbutton]));
+			w2.Position = 1;
+			this.GtkAlignment.Add (this.hbox1);
+			this.frame1.Add (this.GtkAlignment);
+			this.GtkLabel1 = new global::Gtk.Label ();
+			this.GtkLabel1.Name = "GtkLabel1";
+			this.GtkLabel1.LabelProp = global::Mono.Unix.Catalog.GetString ("<b>Team</b>");
+			this.GtkLabel1.UseMarkup = true;
+			this.frame1.LabelWidget = this.GtkLabel1;
+			this.vbox3.Add (this.frame1);
+			global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.frame1]));
+			w5.Position = 0;
+			w5.Expand = false;
+			w5.Fill = false;
+			// Container child vbox3.Gtk.Box+BoxChild
 			this.table1 = new global::Gtk.Table (((uint)(3)), ((uint)(3)), false);
 			this.table1.Name = "table1";
 			this.table1.RowSpacing = ((uint)(6));
 			this.table1.ColumnSpacing = ((uint)(6));
-			this.vbox2.Add (this.table1);
-			global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.table1]));
-			w1.Position = 0;
-			w1.Expand = false;
-			w1.Fill = false;
+			this.vbox3.Add (this.table1);
+			global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.table1]));
+			w6.Position = 1;
+			this.vbox2.Add (this.vbox3);
+			global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.vbox3]));
+			w7.Position = 0;
 			this.Add (this.vbox2);
 			if ((this.Child != null)) {
 				this.Child.ShowAll ();
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.TaggerDialog.cs b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.TaggerDialog.cs
index 15a4274..28f014b 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.TaggerDialog.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.TaggerDialog.cs
@@ -48,6 +48,8 @@ namespace LongoMatch.Gui.Dialog
 			this.hbox1.Add (this.tagsnotebook);
 			global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.tagsnotebook]));
 			w3.Position = 0;
+			w3.Expand = false;
+			w3.Fill = false;
 			// Container child hbox1.Gtk.Box+BoxChild
 			this.playersnotebook = new global::Gtk.Notebook ();
 			this.playersnotebook.CanFocus = true;
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index c6ce990..e6ba1f6 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -5216,45 +5216,117 @@ Show-&gt;&lt;b&gt; S&lt;/b&gt;
         <property name="MemberName" />
         <property name="Spacing">6</property>
         <child>
-          <widget class="Gtk.Table" id="table1">
+          <widget class="Gtk.VBox" id="vbox3">
             <property name="MemberName" />
-            <property name="NRows">3</property>
-            <property name="NColumns">3</property>
-            <property name="RowSpacing">6</property>
-            <property name="ColumnSpacing">6</property>
-            <child>
-              <placeholder />
-            </child>
-            <child>
-              <placeholder />
-            </child>
-            <child>
-              <placeholder />
-            </child>
-            <child>
-              <placeholder />
-            </child>
-            <child>
-              <placeholder />
-            </child>
-            <child>
-              <placeholder />
-            </child>
-            <child>
-              <placeholder />
-            </child>
+            <property name="Spacing">6</property>
             <child>
-              <placeholder />
+              <widget class="Gtk.Frame" id="frame1">
+                <property name="MemberName" />
+                <property name="ShadowType">None</property>
+                <child>
+                  <widget class="Gtk.Alignment" id="GtkAlignment">
+                    <property name="MemberName" />
+                    <property name="Xalign">0</property>
+                    <property name="Yalign">0</property>
+                    <property name="LeftPadding">12</property>
+                    <child>
+                      <widget class="Gtk.HBox" id="hbox1">
+                        <property name="MemberName" />
+                        <property name="Spacing">6</property>
+                        <child>
+                          <widget class="Gtk.CheckButton" id="localcheckbutton">
+                            <property name="MemberName" />
+                            <property name="CanFocus">True</property>
+                            <property name="Label" translatable="yes" />
+                            <property name="DrawIndicator">True</property>
+                            <property name="HasLabel">True</property>
+                            <property name="UseUnderline">True</property>
+                          </widget>
+                          <packing>
+                            <property name="Position">0</property>
+                            <property name="AutoSize">True</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="Gtk.CheckButton" id="visitorcheckbutton">
+                            <property name="MemberName" />
+                            <property name="CanFocus">True</property>
+                            <property name="Label" translatable="yes" />
+                            <property name="DrawIndicator">True</property>
+                            <property name="HasLabel">True</property>
+                            <property name="UseUnderline">True</property>
+                          </widget>
+                          <packing>
+                            <property name="Position">1</property>
+                            <property name="AutoSize">True</property>
+                          </packing>
+                        </child>
+                      </widget>
+                    </child>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="Gtk.Label" id="GtkLabel1">
+                    <property name="MemberName" />
+                    <property name="LabelProp" translatable="yes">&lt;b&gt;Team&lt;/b&gt;</property>
+                    <property name="UseMarkup">True</property>
+                  </widget>
+                  <packing>
+                    <property name="type">label_item</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="Position">0</property>
+                <property name="AutoSize">True</property>
+                <property name="Expand">False</property>
+                <property name="Fill">False</property>
+              </packing>
             </child>
             <child>
-              <placeholder />
+              <widget class="Gtk.Table" id="table1">
+                <property name="MemberName" />
+                <property name="NRows">3</property>
+                <property name="NColumns">3</property>
+                <property name="RowSpacing">6</property>
+                <property name="ColumnSpacing">6</property>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+              </widget>
+              <packing>
+                <property name="Position">1</property>
+                <property name="AutoSize">True</property>
+              </packing>
             </child>
           </widget>
           <packing>
             <property name="Position">0</property>
-            <property name="AutoSize">False</property>
-            <property name="Expand">False</property>
-            <property name="Fill">False</property>
+            <property name="AutoSize">True</property>
           </packing>
         </child>
       </widget>
@@ -5299,6 +5371,8 @@ Show-&gt;&lt;b&gt; S&lt;/b&gt;
               <packing>
                 <property name="Position">0</property>
                 <property name="AutoSize">True</property>
+                <property name="Expand">False</property>
+                <property name="Fill">False</property>
               </packing>
             </child>
             <child>



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