[longomatch] Add missing files in previous commit



commit 79f17b96b9f503e912aeb7110b40d7c17c7bd850
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue Jan 5 20:32:00 2010 +0100

    Add missing files in previous commit

 LongoMatch/Gui/Component/TagsTreeWidget.cs         |  204 ++++++++++++++++++
 LongoMatch/Gui/TreeView/TagsTreeView.cs            |  227 ++++++++++++++++++++
 .../LongoMatch.Gui.Component.TagsTreeWidget.cs     |  113 ++++++++++
 3 files changed, 544 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch/Gui/Component/TagsTreeWidget.cs b/LongoMatch/Gui/Component/TagsTreeWidget.cs
new file mode 100644
index 0000000..32ee454
--- /dev/null
+++ b/LongoMatch/Gui/Component/TagsTreeWidget.cs
@@ -0,0 +1,204 @@
+// TreeWidget.cs
+//
+//  Copyright(C) 20072009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//
+
+using System;
+using System.Collections.Generic;
+using Gtk;
+using Mono.Unix;
+using LongoMatch.DB;
+using LongoMatch.Handlers;
+using LongoMatch.TimeNodes;
+
+namespace LongoMatch.Gui.Component
+{
+
+
+	[System.ComponentModel.Category("LongoMatch")]
+	[System.ComponentModel.ToolboxItem(true)]
+	public partial class TagsTreeWidget : Gtk.Bin
+	{
+
+		public event TimeNodeSelectedHandler TimeNodeSelected;
+		public event TimeNodeChangedHandler TimeNodeChanged;
+		public event PlayListNodeAddedHandler PlayListNodeAdded;
+		public event SnapshotSeriesHandler SnapshotSeriesEvent;
+
+		private TreeModelFilter filter;
+		private ListStore model;
+		private List<Tag> filterTags;
+		private Project project;
+
+
+		public TagsTreeWidget()
+		{
+			this.Build();
+			filterTags = new List<Tag>();
+			model = new Gtk.ListStore(typeof(MediaTimeNode));			
+			filter = new Gtk.TreeModelFilter(model, null);
+			filter.VisibleFunc = new Gtk.TreeModelFilterVisibleFunc(FilterTree);
+			treeview.Model = filter;
+		}
+		
+		public void Clear(){
+			model.Clear();
+			filterTags.Clear();
+			filter.Refilter();
+		}
+
+		public void DeletePlay(MediaTimeNode play) {
+			if (project != null) {
+				TreeIter iter;
+				model.GetIterFirst(out iter);
+				while (model.IterIsValid(iter)) {
+					MediaTimeNode mtn = (MediaTimeNode) model.GetValue(iter,0);
+					if (mtn == play) {
+						model.Remove(ref iter);
+						break;
+					}
+					TreeIter prev = iter;
+					model.IterNext(ref iter);
+					if (prev.Equals(iter))
+						break;
+				}
+			}
+		}
+
+		public void AddPlay(MediaTimeNode play) {
+			model.AppendValues(play);
+			filter.Refilter();
+		}
+
+		public Project Project {
+			set {
+				project = value;
+				if (project != null) {
+					model.Clear();
+					foreach (List<MediaTimeNode> list in project.GetDataArray()){
+						foreach (MediaTimeNode tNode in list)
+							model.AppendValues(tNode);
+					}
+					FillCombobox();
+				}
+			}
+		}
+
+		public bool PlayListLoaded {
+			set {
+				treeview.PlayListLoaded=value;
+			}
+		}
+		
+		private void FillCombobox(){
+			(tagscombobox.Model as ListStore).Clear();
+			foreach (Tag tag in project.Tags)
+				tagscombobox.AppendText(tag.Text);
+		}
+		
+		private void AddFilterWidget(Tag tag){
+			HBox box;
+			Button b;
+			Label l;
+			
+			box = new HBox();
+			box.Name = tag.Text;
+			b = new Button();
+			b.Image =  new Image(Stetic.IconLoader.LoadIcon(this, "gtk-delete", Gtk.IconSize.Menu, 16));
+			b.Clicked += OnDeleteClicked;
+			l = new Label(tag.Text);
+			l.Justify = Justification.Left;
+			box.PackEnd(b,false,  false, 0);
+			box.PackStart(l,true, true, 0);
+			tagsvbox.PackEnd(box);
+			box.ShowAll();
+		}
+		
+		protected virtual void OnDeleteClicked (object o, System.EventArgs e){
+			Widget parent = (o as Widget).Parent;
+		    tagscombobox.AppendText(parent.Name);
+			filterTags.Remove(new Tag(parent.Name));
+			filter.Refilter();
+			tagsvbox.Remove(parent);
+		}
+			
+		protected virtual void OnAddFilter (object sender, System.EventArgs e)
+		{
+			string text = tagscombobox.ActiveText;
+			if (text == null || text == "")
+				return;
+			
+			Tag tag = new Tag(text);
+			if (!filterTags.Contains(tag)){
+				filterTags.Add(tag);
+				tagscombobox.RemoveText(tagscombobox.Active);
+				AddFilterWidget(tag);
+				filter.Refilter();
+			}
+		}
+
+		protected virtual void OnClearbuttonClicked (object sender, System.EventArgs e)
+		{
+			filterTags.Clear();
+			filter.Refilter();
+			foreach (Widget w in tagsvbox.Children)
+				tagsvbox.Remove(w);
+			FillCombobox();
+		}
+		
+		private bool FilterTree(Gtk.TreeModel model, Gtk.TreeIter iter)
+		{
+			MediaTimeNode tNode;
+			
+			if (filterTags.Count == 0)
+				return true;
+			
+			tNode = model.GetValue(iter, 0) as MediaTimeNode;
+
+			if (tNode == null)
+				return true;
+			foreach (Tag tag in tNode.Tags){
+				if (filterTags.Contains(tag))
+					return true;
+			}
+			return false;
+		}
+		
+		protected virtual void OnTimeNodeChanged(TimeNode tNode,object val) {
+			if (TimeNodeChanged != null)
+				TimeNodeChanged(tNode,val);
+		}
+
+		protected virtual void OnTimeNodeSelected(MediaTimeNode tNode) {
+			if (TimeNodeSelected != null)
+				TimeNodeSelected(tNode);
+		}
+
+		protected virtual void OnPlayListNodeAdded(MediaTimeNode tNode)
+		{
+			if (PlayListNodeAdded != null)
+				PlayListNodeAdded(tNode);
+		}
+
+		protected virtual void OnSnapshotSeriesEvent(LongoMatch.TimeNodes.MediaTimeNode tNode)
+		{
+			if (SnapshotSeriesEvent != null)
+				SnapshotSeriesEvent(tNode);
+		}
+	}
+}
\ No newline at end of file
diff --git a/LongoMatch/Gui/TreeView/TagsTreeView.cs b/LongoMatch/Gui/TreeView/TagsTreeView.cs
new file mode 100644
index 0000000..d4f398c
--- /dev/null
+++ b/LongoMatch/Gui/TreeView/TagsTreeView.cs
@@ -0,0 +1,227 @@
+// TreeWidgetPopup.cs
+//
+//  Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//
+
+using System;
+using System.Collections.Generic;
+using Gdk;
+using Gtk;
+using Mono.Unix;
+using LongoMatch.Handlers;
+using LongoMatch.TimeNodes;
+
+namespace LongoMatch.Gui.Component
+{
+
+
+	[System.ComponentModel.Category("LongoMatch")]
+	[System.ComponentModel.ToolboxItem(true)]
+	public class TagsTreeView : Gtk.TreeView
+	{
+
+		public event TimeNodeChangedHandler TimeNodeChanged;
+		public event TimeNodeSelectedHandler TimeNodeSelected;
+		public event PlayListNodeAddedHandler PlayListNodeAdded;
+		public event SnapshotSeriesHandler SnapshotSeriesEvent;
+
+		private Menu menu;
+		private MenuItem addPLN;
+		private MenuItem name;
+		private MenuItem snapshot;
+		private MenuItem deleteKeyFrame;
+		
+		private Gtk.CellRendererText nameCell;
+		private Gtk.TreeViewColumn nameColumn;
+		private bool editing;
+		
+
+		public TagsTreeView() {			
+			Selection.Mode = SelectionMode.Multiple;			
+			RowActivated += new RowActivatedHandler(OnTreeviewRowActivated);
+	
+			SetMenu();
+
+			nameColumn = new Gtk.TreeViewColumn();
+			nameColumn.Title = "Tag";
+			nameCell = new Gtk.CellRendererText();
+			nameCell.Edited += OnNameCellEdited;
+			Gtk.CellRendererPixbuf miniatureCell = new Gtk.CellRendererPixbuf();
+			nameColumn.PackStart(miniatureCell, true);
+			nameColumn.PackEnd(nameCell, true);
+
+			nameColumn.SetCellDataFunc(miniatureCell, new Gtk.TreeCellDataFunc(RenderMiniature));
+			nameColumn.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc(RenderName));
+
+			AppendColumn(nameColumn);
+		}
+
+		public bool PlayListLoaded {
+			set {
+				addPLN.Sensitive=value;
+			}
+		}		
+
+		private void SetMenu() {
+			menu = new Menu();
+
+			name = new MenuItem(Catalog.GetString("Edit"));
+			deleteKeyFrame = new MenuItem(Catalog.GetString("Delete key frame"));
+			snapshot = new MenuItem(Catalog.GetString("Export to PGN images"));
+			addPLN = new MenuItem(Catalog.GetString("Add to playlist"));
+			addPLN.Sensitive=false;
+
+			menu.Append(name);
+			menu.Append(deleteKeyFrame);
+			menu.Append(addPLN);
+			menu.Append(snapshot);
+
+			name.Activated += new EventHandler(OnEdit);
+			deleteKeyFrame.Activated += OnDeleteKeyFrame;
+			addPLN.Activated += new EventHandler(OnAdded);
+			snapshot.Activated += new EventHandler(OnSnapshot);
+			menu.ShowAll();
+		}
+
+		private MediaTimeNode GetValueFromPath(TreePath path){
+			Gtk.TreeIter iter;
+			Model.GetIter(out iter, path);
+			return Model.GetValue(iter,0) as MediaTimeNode;					
+		}	
+		
+		private void MultiSelectMenu (bool enabled){
+			name.Sensitive = !enabled;
+			snapshot.Sensitive = !enabled;
+		}
+		
+		private void RenderMiniature(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
+		{
+			MediaTimeNode tNode = model.GetValue(iter, 0) as MediaTimeNode;
+			(cell as Gtk.CellRendererPixbuf).Pixbuf = tNode.Miniature;
+		}
+
+		private void RenderName(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
+		{
+			MediaTimeNode tNode = (MediaTimeNode) model.GetValue(iter, 0);
+
+			//Handle special case in which we replace the text in the cell by the name of the TimeNode
+			//We need to check if we are editing and only change it for the path that's currently beeing edited
+
+			if (editing && Selection.IterIsSelected(iter))
+				(cell as Gtk.CellRendererText).Markup = tNode.Name;
+			else 
+				(cell as Gtk.CellRendererText).Markup = tNode.ToString();
+		}
+
+		private void OnNameCellEdited(object o, Gtk.EditedArgs args)
+		{
+			Gtk.TreeIter iter;
+			Model.GetIter(out iter, new Gtk.TreePath(args.Path));
+			MediaTimeNode tNode = Model.GetValue(iter,0) as MediaTimeNode;
+			tNode.Name = args.NewText;
+			editing = false;
+			nameCell.Editable=false;
+			if (TimeNodeChanged != null)
+				TimeNodeChanged(tNode,args.NewText);
+		}
+		
+		protected virtual void OnTreeviewRowActivated(object o, Gtk.RowActivatedArgs args)
+		{
+			Gtk.TreeIter iter;
+			Model.GetIter(out iter, args.Path);
+			MediaTimeNode tNode = Model.GetValue(iter, 0) as MediaTimeNode;
+
+			if (TimeNodeSelected != null)
+				TimeNodeSelected(tNode);
+		}
+
+		protected override bool OnButtonPressEvent(EventButton evnt)
+		{			
+			TreePath[] paths = Selection.GetSelectedRows();
+			
+			if ((evnt.Type == EventType.ButtonPress) && (evnt.Button == 3))
+			{
+				// We don't want to unselect the play when several
+				// plays are selected and we clik the right button
+				// For multiedition
+				if (paths.Length <= 1){
+					base.OnButtonPressEvent(evnt);
+					paths = Selection.GetSelectedRows();
+				}
+				
+				if (paths.Length == 1) {
+					MediaTimeNode selectedTimeNode = GetValueFromPath(paths[0]);
+					deleteKeyFrame.Sensitive = selectedTimeNode.KeyFrameDrawing != null;
+					MultiSelectMenu(false);
+					menu.Popup();
+				}
+				else if (paths.Length > 1){
+					MultiSelectMenu(true);
+					menu.Popup();								
+				}
+			}
+			else 
+				base.OnButtonPressEvent(evnt);
+			return true;
+		}		
+		
+		protected void OnDeleteKeyFrame(object obj, EventArgs args) {
+			MessageDialog md = new MessageDialog((Gtk.Window)Toplevel,
+			                                     DialogFlags.Modal,
+			                                     MessageType.Question,
+			                                     ButtonsType.YesNo,
+			                                     false,
+			                                     Catalog.GetString("Do you want to delete the key frame for this play?")
+			                                    );
+			if (md.Run() == (int)ResponseType.Yes){
+				TreePath[] paths = Selection.GetSelectedRows();
+				for (int i=0; i<paths.Length; i++){	
+					MediaTimeNode tNode = GetValueFromPath(paths[i]);
+					tNode.KeyFrameDrawing = null;
+				}
+				// Refresh the thumbnails
+				QueueDraw();
+			}
+			md.Destroy();
+		}
+
+		protected virtual void OnEdit(object obj, EventArgs args) {
+			TreePath[] paths = Selection.GetSelectedRows();
+			editing = true;
+			nameCell.Editable = true;
+			nameCell.Markup = GetValueFromPath(paths[0]).Name;
+			SetCursor(paths[0],  nameColumn, true);
+		}
+		
+		protected void OnAdded(object obj, EventArgs args) {
+			if (PlayListNodeAdded != null){
+				TreePath[] paths = Selection.GetSelectedRows();
+				for (int i=0; i<paths.Length; i++){	
+					MediaTimeNode tNode = GetValueFromPath(paths[i]);
+					PlayListNodeAdded(tNode);
+				}
+			}
+		}
+		
+		protected void OnSnapshot(object obj, EventArgs args) {
+			if (SnapshotSeriesEvent != null)
+				SnapshotSeriesEvent(GetValueFromPath(Selection.GetSelectedRows()[0]));
+		}			
+	}
+}
+
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.Component.TagsTreeWidget.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.Component.TagsTreeWidget.cs
new file mode 100644
index 0000000..210e1b0
--- /dev/null
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.Component.TagsTreeWidget.cs
@@ -0,0 +1,113 @@
+// ------------------------------------------------------------------------------
+//  <autogenerated>
+//      This code was generated by a tool.
+//      
+// 
+//      Changes to this file may cause incorrect behavior and will be lost if 
+//      the code is regenerated.
+//  </autogenerated>
+// ------------------------------------------------------------------------------
+
+namespace LongoMatch.Gui.Component {
+    
+    
+    public partial class TagsTreeWidget {
+        
+        private Gtk.VBox vbox1;
+        
+        private Gtk.ScrolledWindow GtkScrolledWindow;
+        
+        private LongoMatch.Gui.Component.TagsTreeView treeview;
+        
+        private Gtk.VBox tagsvbox;
+        
+        private Gtk.HBox hbox1;
+        
+        private Gtk.ComboBox tagscombobox;
+        
+        private Gtk.Button AddFilterButton;
+        
+        protected virtual void Build() {
+            Stetic.Gui.Initialize(this);
+            // Widget LongoMatch.Gui.Component.TagsTreeWidget
+            Stetic.BinContainer.Attach(this);
+            this.Name = "LongoMatch.Gui.Component.TagsTreeWidget";
+            // Container child LongoMatch.Gui.Component.TagsTreeWidget.Gtk.Container+ContainerChild
+            this.vbox1 = new Gtk.VBox();
+            this.vbox1.Name = "vbox1";
+            this.vbox1.Spacing = 6;
+            // Container child vbox1.Gtk.Box+BoxChild
+            this.GtkScrolledWindow = new Gtk.ScrolledWindow();
+            this.GtkScrolledWindow.Name = "GtkScrolledWindow";
+            this.GtkScrolledWindow.ShadowType = ((Gtk.ShadowType)(1));
+            // Container child GtkScrolledWindow.Gtk.Container+ContainerChild
+            this.treeview = new LongoMatch.Gui.Component.TagsTreeView();
+            this.treeview.CanFocus = true;
+            this.treeview.Name = "treeview";
+            this.GtkScrolledWindow.Add(this.treeview);
+            this.vbox1.Add(this.GtkScrolledWindow);
+            Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vbox1[this.GtkScrolledWindow]));
+            w2.Position = 0;
+            // Container child vbox1.Gtk.Box+BoxChild
+            this.tagsvbox = new Gtk.VBox();
+            this.tagsvbox.Name = "tagsvbox";
+            this.tagsvbox.Spacing = 6;
+            this.vbox1.Add(this.tagsvbox);
+            Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.vbox1[this.tagsvbox]));
+            w3.Position = 1;
+            w3.Expand = false;
+            w3.Fill = false;
+            // Container child vbox1.Gtk.Box+BoxChild
+            this.hbox1 = new Gtk.HBox();
+            this.hbox1.Name = "hbox1";
+            this.hbox1.Spacing = 6;
+            // Container child hbox1.Gtk.Box+BoxChild
+            this.tagscombobox = Gtk.ComboBox.NewText();
+            this.tagscombobox.Name = "tagscombobox";
+            this.hbox1.Add(this.tagscombobox);
+            Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.hbox1[this.tagscombobox]));
+            w4.Position = 0;
+            // Container child hbox1.Gtk.Box+BoxChild
+            this.AddFilterButton = new Gtk.Button();
+            this.AddFilterButton.CanFocus = true;
+            this.AddFilterButton.Name = "AddFilterButton";
+            this.AddFilterButton.UseUnderline = true;
+            // Container child AddFilterButton.Gtk.Container+ContainerChild
+            Gtk.Alignment w5 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
+            // Container child GtkAlignment.Gtk.Container+ContainerChild
+            Gtk.HBox w6 = new Gtk.HBox();
+            w6.Spacing = 2;
+            // Container child GtkHBox.Gtk.Container+ContainerChild
+            Gtk.Image w7 = new Gtk.Image();
+            w7.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-add", Gtk.IconSize.Menu, 16);
+            w6.Add(w7);
+            // Container child GtkHBox.Gtk.Container+ContainerChild
+            Gtk.Label w9 = new Gtk.Label();
+            w9.LabelProp = Mono.Unix.Catalog.GetString("Add Filter");
+            w9.UseUnderline = true;
+            w6.Add(w9);
+            w5.Add(w6);
+            this.AddFilterButton.Add(w5);
+            this.hbox1.Add(this.AddFilterButton);
+            Gtk.Box.BoxChild w13 = ((Gtk.Box.BoxChild)(this.hbox1[this.AddFilterButton]));
+            w13.Position = 1;
+            w13.Expand = false;
+            w13.Fill = false;
+            this.vbox1.Add(this.hbox1);
+            Gtk.Box.BoxChild w14 = ((Gtk.Box.BoxChild)(this.vbox1[this.hbox1]));
+            w14.Position = 2;
+            w14.Expand = false;
+            w14.Fill = false;
+            this.Add(this.vbox1);
+            if ((this.Child != null)) {
+                this.Child.ShowAll();
+            }
+            this.Hide();
+            this.treeview.TimeNodeChanged += new LongoMatch.Handlers.TimeNodeChangedHandler(this.OnTimeNodeChanged);
+            this.treeview.TimeNodeSelected += new LongoMatch.Handlers.TimeNodeSelectedHandler(this.OnTimeNodeSelected);
+            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);
+        }
+    }
+}



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