[longomatch] Allow rendering playlist directly from left bar



commit ff0032aac5d32cc275e516d9c2ff47f4af7d814f
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Sep 22 01:07:47 2011 +0200

    Allow rendering playlist directly from left bar

 LongoMatch/Common/GuiUtils.cs                   |   53 +++++++++++++++++++++++
 LongoMatch/Gui/Component/PlayListWidget.cs      |   19 +-------
 LongoMatch/Gui/Component/PlaysListTreeWidget.cs |   22 +++++++++
 LongoMatch/Gui/MainWindow.cs                    |    5 +-
 LongoMatch/Gui/TreeView/ListTreeViewBase.cs     |   16 ++++---
 LongoMatch/Gui/TreeView/PlaysTreeView.cs        |    2 +-
 LongoMatch/LongoMatch.mdp                       |    1 +
 LongoMatch/Makefile.am                          |    1 +
 LongoMatch/Store/PlayListPlay.cs                |   12 +++++
 LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs |    2 +-
 LongoMatch/gtk-gui/objects.xml                  |    4 ++
 11 files changed, 110 insertions(+), 27 deletions(-)
---
diff --git a/LongoMatch/Common/GuiUtils.cs b/LongoMatch/Common/GuiUtils.cs
new file mode 100644
index 0000000..b051f69
--- /dev/null
+++ b/LongoMatch/Common/GuiUtils.cs
@@ -0,0 +1,53 @@
+// 
+//  Copyright (C) 2011 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 Gtk;
+using Mono.Unix;
+
+using LongoMatch.Gui;
+using LongoMatch.Gui.Dialog;
+using LongoMatch.Playlist;
+using LongoMatch.Services.JobsManager;
+using LongoMatch.Store;
+
+namespace LongoMatch.Common
+{
+	public class GuiUtils
+	{
+		public static Job ConfigureRenderingJob (PlayList playlist, Gtk.Widget parent)
+		{
+			VideoEditionProperties vep;
+			Job job = null;
+			int response;
+
+			vep = new VideoEditionProperties();
+			vep.TransientFor = (Gtk.Window)parent.Toplevel;
+			response = vep.Run();
+			while(response == (int)ResponseType.Ok && vep.EncodingSettings.OutputFile == "") {
+				MessagePopup.PopupMessage(parent, MessageType.Warning,
+				                          Catalog.GetString("Please, select a video file."));
+				response=vep.Run();
+			}
+			if(response ==(int)ResponseType.Ok)
+				job = new Job(playlist, vep.EncodingSettings, vep.EnableAudio, vep.TitleOverlay);
+			vep.Destroy();
+			return job;
+		}
+	}
+}
+
diff --git a/LongoMatch/Gui/Component/PlayListWidget.cs b/LongoMatch/Gui/Component/PlayListWidget.cs
index a647b1d..b2cb816 100644
--- a/LongoMatch/Gui/Component/PlayListWidget.cs
+++ b/LongoMatch/Gui/Component/PlayListWidget.cs
@@ -241,8 +241,7 @@ namespace LongoMatch.Gui.Component
 
 		protected virtual void OnNewvideobuttonClicked(object sender, System.EventArgs e)
 		{
-			VideoEditionProperties vep;
-			int response;
+			Job job;
 
 			if(playList.Count == 0) {
 				MessagePopup.PopupMessage(this,MessageType.Warning,
@@ -250,21 +249,9 @@ namespace LongoMatch.Gui.Component
 				return;
 			}
 
-			vep = new VideoEditionProperties();
-			vep.TransientFor = (Gtk.Window)this.Toplevel;
-			response = vep.Run();
-			while(response == (int)ResponseType.Ok && vep.EncodingSettings.OutputFile == "") {
-				MessagePopup.PopupMessage(this, MessageType.Warning,
-				                          Catalog.GetString("Please, select a video file."));
-				response=vep.Run();
-			}
-			if(response ==(int)ResponseType.Ok) {
-				Job job = new Job(playList, vep.EncodingSettings, vep.EnableAudio, vep.TitleOverlay);
-				if (NewRenderingJob != null) {
+			job = GuiUtils.ConfigureRenderingJob(playList, this);
+			if (job != null && NewRenderingJob != null)
 					NewRenderingJob(job);
-				}
-			}
-			vep.Destroy();
 		}
 
 		protected virtual void OnApplyRate(PlayListPlay plNode) {
diff --git a/LongoMatch/Gui/Component/PlaysListTreeWidget.cs b/LongoMatch/Gui/Component/PlaysListTreeWidget.cs
index b8cd22d..8ec6f8f 100644
--- a/LongoMatch/Gui/Component/PlaysListTreeWidget.cs
+++ b/LongoMatch/Gui/Component/PlaysListTreeWidget.cs
@@ -26,7 +26,9 @@ using LongoMatch.DB;
 using LongoMatch.Gui.Dialog;
 using LongoMatch.Handlers;
 using LongoMatch.Store;
+using LongoMatch.Services.JobsManager;
 using LongoMatch.Common;
+using LongoMatch.Playlist;
 
 namespace LongoMatch.Gui.Component
 {
@@ -43,6 +45,7 @@ namespace LongoMatch.Gui.Component
 		public event PlayListNodeAddedHandler PlayListNodeAdded;
 		public event SnapshotSeriesHandler SnapshotSeriesEvent;
 		public event TagPlayHandler TagPlay;
+		public event JobHandler NewRenderingJob;
 
 		private Project project;
 
@@ -56,6 +59,7 @@ namespace LongoMatch.Gui.Component
 			treeview.SnapshotSeriesEvent += OnSnapshotSeriesEvent;
 			treeview.EditProperties += OnEditProperties;
 			treeview.TagPlay += OnTagPlay;
+			treeview.NewRenderingJob += OnNewRenderingJob;
 		}
 
 		public void RemovePlays(List<Play> plays) {
@@ -179,5 +183,23 @@ namespace LongoMatch.Gui.Component
 			if(TagPlay != null)
 				TagPlay(tNode);
 		}
+		
+		protected virtual void OnNewRenderingJob (object sender, EventArgs args)
+		{
+			Job job;
+			PlayList playlist = new PlayList();
+			TreePath[] paths = treeview.Selection.GetSelectedRows();
+
+			foreach(var path in paths) {
+				TreeIter iter;
+				
+				treeview.Model.GetIter(out iter, path);
+				playlist.Add(new PlayListPlay((Play)treeview.Model.GetValue(iter, 0),
+				                              project.Description.File, 1, true));
+			}
+			job = GuiUtils.ConfigureRenderingJob(playlist, this);
+			if (job != null && NewRenderingJob != null)
+					NewRenderingJob(job);
+		}
 	}
 }
diff --git a/LongoMatch/Gui/MainWindow.cs b/LongoMatch/Gui/MainWindow.cs
index e21eab9..9963a8d 100644
--- a/LongoMatch/Gui/MainWindow.cs
+++ b/LongoMatch/Gui/MainWindow.cs
@@ -99,9 +99,8 @@ namespace LongoMatch.Gui
 
 			videoRenderer = new RenderingJobsManager(renderingstatebar1);
 			renderingstatebar1.ManageJobs += OnManageJobs;
-			playlistwidget2.NewRenderingJob += delegate(Job job) {
-				videoRenderer.AddJob(job);
-			};
+			playlistwidget2.NewRenderingJob += delegate(Job job) {videoRenderer.AddJob(job);};
+			treewidget1.NewRenderingJob += delegate(Job job) {videoRenderer.AddJob(job);};
 			
 			buttonswidget1.Mode = TagMode.Predifined;
 
diff --git a/LongoMatch/Gui/TreeView/ListTreeViewBase.cs b/LongoMatch/Gui/TreeView/ListTreeViewBase.cs
index d4df36c..f04156e 100644
--- a/LongoMatch/Gui/TreeView/ListTreeViewBase.cs
+++ b/LongoMatch/Gui/TreeView/ListTreeViewBase.cs
@@ -33,12 +33,7 @@ namespace LongoMatch.Gui.Component
 	{
 		// Plays menu
 		protected Menu menu;
-		protected MenuItem tag;
-		protected MenuItem delete;
-		protected MenuItem addPLN;
-		protected MenuItem deleteKeyFrame;
-		protected MenuItem snapshot;
-		protected MenuItem name;
+		protected MenuItem tag, delete, addPLN, deleteKeyFrame, snapshot, name, render;
 
 		protected Gtk.CellRendererText nameCell;
 		protected Gtk.TreeViewColumn nameColumn;
@@ -51,6 +46,7 @@ namespace LongoMatch.Gui.Component
 		public event PlayListNodeAddedHandler PlayListNodeAdded;
 		public event SnapshotSeriesHandler SnapshotSeriesEvent;
 		public event TagPlayHandler TagPlay;
+		public event EventHandler NewRenderingJob;
 
 		public ListTreeViewBase()
 		{
@@ -113,6 +109,7 @@ namespace LongoMatch.Gui.Component
 			deleteKeyFrame = new MenuItem(Catalog.GetString("Delete key frame"));
 			addPLN = new MenuItem(Catalog.GetString("Add to playlist"));
 			addPLN.Sensitive=false;
+			render = new MenuItem(Catalog.GetString("Export to video file"));
 			snapshot = new MenuItem(Catalog.GetString("Export to PGN images"));
 
 			menu.Append(name);
@@ -120,6 +117,7 @@ namespace LongoMatch.Gui.Component
 			menu.Append(addPLN);
 			menu.Append(delete);
 			menu.Append(deleteKeyFrame);
+			menu.Append(render);
 			menu.Append(snapshot);
 
 			name.Activated += OnEdit;
@@ -127,6 +125,7 @@ namespace LongoMatch.Gui.Component
 			addPLN.Activated += OnAdded;
 			delete.Activated += OnDeleted;
 			deleteKeyFrame.Activated += OnDeleteKeyFrame;
+			render.Activated += OnRender;
 			snapshot.Activated += OnSnapshot;
 			menu.ShowAll();
 		}
@@ -309,6 +308,11 @@ namespace LongoMatch.Gui.Component
 			if(SnapshotSeriesEvent != null)
 				SnapshotSeriesEvent((Play)GetValueFromPath(Selection.GetSelectedRows()[0]));
 		}
+		
+		protected void OnRender(object obj, EventArgs args) {
+			if (NewRenderingJob != null)
+				NewRenderingJob(this, null);
+		}
 
 		protected abstract bool SelectFunction(TreeSelection selection, TreeModel model, TreePath path, bool selected);
 	}
diff --git a/LongoMatch/Gui/TreeView/PlaysTreeView.cs b/LongoMatch/Gui/TreeView/PlaysTreeView.cs
index c2e1767..0a7f326 100644
--- a/LongoMatch/Gui/TreeView/PlaysTreeView.cs
+++ b/LongoMatch/Gui/TreeView/PlaysTreeView.cs
@@ -38,7 +38,7 @@ namespace LongoMatch.Gui.Component
 		public event TimeNodeChangedHandler EditProperties;
 
 		//Categories menu
-		private Menu categoriesMenu;
+		Menu categoriesMenu;
 		private RadioAction sortByName, sortByStart, sortByStop, sortByDuration;
 
 		public PlaysTreeView() {
diff --git a/LongoMatch/LongoMatch.mdp b/LongoMatch/LongoMatch.mdp
index 7c5bff2..2f858ce 100644
--- a/LongoMatch/LongoMatch.mdp
+++ b/LongoMatch/LongoMatch.mdp
@@ -201,6 +201,7 @@
     <File subtype="Code" buildaction="Compile" name="Gui/TreeView/RenderingJobsTreeView.cs" />
     <File subtype="Code" buildaction="Compile" name="Gui/Dialog/RenderingJobsDialog.cs" />
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Dialog.RenderingJobsDialog.cs" />
+    <File subtype="Code" buildaction="Compile" name="Common/GuiUtils.cs" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
diff --git a/LongoMatch/Makefile.am b/LongoMatch/Makefile.am
index c3cf589..621e80c 100644
--- a/LongoMatch/Makefile.am
+++ b/LongoMatch/Makefile.am
@@ -11,6 +11,7 @@ SOURCES = \
 	Common/Constants.cs \
 	Common/Enums.cs \
 	Common/GStreamer.cs \
+	Common/GuiUtils.cs \
 	Common/Images.cs \
 	Common/Log.cs \
 	Common/ProjectUtils.cs \
diff --git a/LongoMatch/Store/PlayListPlay.cs b/LongoMatch/Store/PlayListPlay.cs
index 529e68b..480116e 100644
--- a/LongoMatch/Store/PlayListPlay.cs
+++ b/LongoMatch/Store/PlayListPlay.cs
@@ -37,6 +37,18 @@ namespace LongoMatch.Store
 		{
 			Valid = true;
 		}
+		
+		public PlayListPlay(Play play, PreviewMediaFile mediaFile, float rate, bool valid)
+		{
+			Name = play.Name;
+			Start = play.Start;
+			Stop = play.Stop;
+			Miniature = play.Miniature;
+			Drawings = play.Drawings;
+			MediaFile = mediaFile;
+			Rate = rate;
+			Valid = valid;
+		}
 		#endregion
 
 		#region Properties
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs
index e1dda90..374a93a 100644
--- a/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs
@@ -188,7 +188,7 @@ namespace LongoMatch.Gui
 			this.ImportProjectAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("_Import Project");
 			w1.Add (this.ImportProjectAction, "<Control>i");
 			this.ManualTaggingViewAction = new global::Gtk.RadioAction ("ManualTaggingViewAction", global::Mono.Unix.Catalog.GetString ("Manual tagging view"), null, null, 0);
-			this.ManualTaggingViewAction.Group = this.TimelineViewAction.Group;
+			this.ManualTaggingViewAction.Group = this.TaggingViewAction.Group;
 			this.ManualTaggingViewAction.Sensitive = false;
 			this.ManualTaggingViewAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Free Capture Mode");
 			w1.Add (this.ManualTaggingViewAction, "<Control>f");
diff --git a/LongoMatch/gtk-gui/objects.xml b/LongoMatch/gtk-gui/objects.xml
index 273ebff..b3149e1 100644
--- a/LongoMatch/gtk-gui/objects.xml
+++ b/LongoMatch/gtk-gui/objects.xml
@@ -118,6 +118,7 @@
         <signal name="PlayListNodeAdded" />
         <signal name="SnapshotSeriesEvent" />
         <signal name="TagPlay" />
+        <signal name="NewRenderingJob" />
       </itemgroup>
     </signals>
   </object>
@@ -135,6 +136,7 @@
         <signal name="PlayListNodeAdded" />
         <signal name="SnapshotSeriesEvent" />
         <signal name="TagPlay" />
+        <signal name="NewRenderingJob" />
       </itemgroup>
     </signals>
   </object>
@@ -153,6 +155,7 @@
         <signal name="SnapshotSeriesEvent" />
         <signal name="TagPlay" />
         <signal name="EditProperties" />
+        <signal name="NewRenderingJob" />
       </itemgroup>
     </signals>
   </object>
@@ -192,6 +195,7 @@
         <signal name="PlayListNodeAdded" />
         <signal name="SnapshotSeriesEvent" />
         <signal name="TagPlay" />
+        <signal name="NewRenderingJob" />
       </itemgroup>
     </signals>
   </object>



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