[longomatch] Allow editing categories with the project loaded



commit cbd877fa3ae3f6d19b7ecec4077f6ef7a803ce4d
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Aug 24 23:29:30 2011 +0200

    Allow editing categories with the project loaded

 LongoMatch/Gui/Component/PlaysListTreeWidget.cs |    7 +++++++
 LongoMatch/Gui/TreeView/ListTreeViewBase.cs     |    5 +++++
 LongoMatch/Gui/TreeView/PlaysTreeView.cs        |   12 +++++++++---
 3 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/LongoMatch/Gui/Component/PlaysListTreeWidget.cs b/LongoMatch/Gui/Component/PlaysListTreeWidget.cs
index 059285b..9bac540 100644
--- a/LongoMatch/Gui/Component/PlaysListTreeWidget.cs
+++ b/LongoMatch/Gui/Component/PlaysListTreeWidget.cs
@@ -23,6 +23,7 @@ using System.Collections.Generic;
 using Gtk;
 using Mono.Unix;
 using LongoMatch.DB;
+using LongoMatch.Gui.Dialog;
 using LongoMatch.Handlers;
 using LongoMatch.Store;
 using LongoMatch.Common;
@@ -136,6 +137,12 @@ namespace LongoMatch.Gui.Component
 		}
 
 		protected virtual void OnTimeNodeChanged(TimeNode tNode,object val) {
+			if (tNode is Category) {
+				EditCategoryDialog dialog = new EditCategoryDialog();
+				dialog.Category = tNode as Category; 
+				dialog.Run();
+				dialog.Destroy();
+			}
 			if(TimeNodeChanged != null)
 				TimeNodeChanged(tNode,val);
 		}
diff --git a/LongoMatch/Gui/TreeView/ListTreeViewBase.cs b/LongoMatch/Gui/TreeView/ListTreeViewBase.cs
index dddb728..d4df36c 100644
--- a/LongoMatch/Gui/TreeView/ListTreeViewBase.cs
+++ b/LongoMatch/Gui/TreeView/ListTreeViewBase.cs
@@ -142,6 +142,11 @@ namespace LongoMatch.Gui.Component
 			Model.GetIter(out iter, path);
 			return Model.GetValue(iter,0);
 		}
+		
+		protected void EmitTimeNodeChanged(TimeNode tNode) {
+			if (TimeNodeChanged != null)
+				TimeNodeChanged(tNode, tNode.Name);
+		}
 
 		protected void RenderMiniature(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
 		{
diff --git a/LongoMatch/Gui/TreeView/PlaysTreeView.cs b/LongoMatch/Gui/TreeView/PlaysTreeView.cs
index 879380e..7baa1c4 100644
--- a/LongoMatch/Gui/TreeView/PlaysTreeView.cs
+++ b/LongoMatch/Gui/TreeView/PlaysTreeView.cs
@@ -21,6 +21,7 @@
 using Gdk;
 using Gtk;
 using LongoMatch.Common;
+using LongoMatch.Gui.Dialog;
 using LongoMatch.Store;
 using System;
 
@@ -33,7 +34,6 @@ namespace LongoMatch.Gui.Component
 	public class PlaysTreeView : ListTreeViewBase
 	{
 
-
 		//Categories menu
 		private Menu categoriesMenu;
 		private RadioAction sortByName, sortByStart, sortByStop, sortByDuration;
@@ -56,7 +56,7 @@ namespace LongoMatch.Gui.Component
 		}
 
 		private void SetCategoriesMenu() {
-			Gtk.Action edit, sortMenu;
+			Gtk.Action edit, editProp, sortMenu;
 			UIManager manager;
 			ActionGroup g;
 
@@ -69,6 +69,7 @@ namespace LongoMatch.Gui.Component
 			sortByStart = new Gtk.RadioAction("SortByStartAction", Mono.Unix.Catalog.GetString("Sort by start time"), null, null, 2);
 			sortByStop = new Gtk.RadioAction("SortByStopAction", Mono.Unix.Catalog.GetString("Sort by stop time"), null, null, 3);
 			sortByDuration = new Gtk.RadioAction("SortByDurationAction", Mono.Unix.Catalog.GetString("Sort by duration"), null, null, 3);
+			editProp = new Gtk.Action("EditPropAction", Mono.Unix.Catalog.GetString("Edit properties"), null, "gtk-edit");
 
 			sortByName.Group = new GLib.SList(System.IntPtr.Zero);
 			sortByStart.Group = sortByName.Group;
@@ -82,6 +83,7 @@ namespace LongoMatch.Gui.Component
 			g.Add(sortByStart, null);
 			g.Add(sortByStop, null);
 			g.Add(sortByDuration, null);
+			g.Add(editProp, null);
 
 			manager.InsertActionGroup(g,0);
 
@@ -94,6 +96,7 @@ namespace LongoMatch.Gui.Component
 			                        "      <menuitem action='SortByStopAction'/>"+
 			                        "      <menuitem action='SortByDurationAction'/>"+
 			                        "    </menu>"+
+			                        "    <menuitem action='EditPropAction'/>"+
 			                        "  </popup>"+
 			                        "</ui>");
 
@@ -104,6 +107,9 @@ namespace LongoMatch.Gui.Component
 			sortByStart.Activated += OnSortActivated;
 			sortByStop.Activated += OnSortActivated;
 			sortByDuration.Activated += OnSortActivated;
+			editProp.Activated += delegate(object sender, EventArgs e) {
+				EmitTimeNodeChanged(GetValueFromPath(Selection.GetSelectedRows()[0]) as Category);
+			};
 		}
 
 		private void SetupSortMenu(SortMethodType sortMethod) {
@@ -169,7 +175,7 @@ namespace LongoMatch.Gui.Component
 				return 0;
 			}
 		}
-
+		
 		private void OnSortActivated(object o, EventArgs args) {
 			Category category;
 			RadioAction sender;



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