[longomatch/refactor] WIP
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/refactor] WIP
- Date: Fri, 4 Nov 2011 18:38:32 +0000 (UTC)
commit 33f146f3f4c8c515579116c3c3b95edfcbe07063
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Fri Nov 4 19:38:20 2011 +0100
WIP
LongoMatch.Core/Handlers/Handlers.cs | 1 +
LongoMatch.GUI/Gui/Dialog/NewProjectDialog.cs | 7 +++
LongoMatch.GUI/Gui/MainWindow.cs | 11 +++--
LongoMatch.GUI/LongoMatch.GUI.mdp | 16 ++++---
...LongoMatch.Gui.Dialog.ProjectSelectionDialog.cs | 4 +-
.../gtk-gui/LongoMatch.Gui.MainWindow.cs | 2 +-
LongoMatch.GUI/gtk-gui/gui.stetic | 5 +-
LongoMatch.GUI/gtk-gui/objects.xml | 28 ++++++------
LongoMatch.Services/Services/Core.cs | 26 +++++++---
LongoMatch.Services/Services/EventsManager.cs | 11 ++++-
LongoMatch.Services/Services/ProjectsManager.cs | 48 +++++++++++--------
11 files changed, 99 insertions(+), 60 deletions(-)
---
diff --git a/LongoMatch.Core/Handlers/Handlers.cs b/LongoMatch.Core/Handlers/Handlers.cs
index 543f4a3..cfa90d7 100644
--- a/LongoMatch.Core/Handlers/Handlers.cs
+++ b/LongoMatch.Core/Handlers/Handlers.cs
@@ -47,6 +47,7 @@ namespace LongoMatch.Handlers
/* Project Events */
public delegate void SaveProjectHandler(Project project, ProjectType projectType);
+ public delegate void OpenedProjectChangedHandler(Project project, ProjectType projectType);
public delegate void OpenProjectHandler();
public delegate void NewProjectHandler();
public delegate void ImportProjectHandler();
diff --git a/LongoMatch.GUI/Gui/Dialog/NewProjectDialog.cs b/LongoMatch.GUI/Gui/Dialog/NewProjectDialog.cs
index 1c3ad2d..ddbdd49 100644
--- a/LongoMatch.GUI/Gui/Dialog/NewProjectDialog.cs
+++ b/LongoMatch.GUI/Gui/Dialog/NewProjectDialog.cs
@@ -23,6 +23,7 @@ using LongoMatch.Common;
using LongoMatch.Store;
using LongoMatch.Video.Capturer;
using LongoMatch.Video.Utils;
+using LongoMatch.Interfaces;
namespace LongoMatch.Gui.Dialog
{
@@ -64,5 +65,11 @@ namespace LongoMatch.Gui.Dialog
return fdwidget.CaptureSettings;
}
}
+
+ public ITemplatesService TemplatesService {
+ set {
+ fdwidget.TemplatesService = value;
+ }
+ }
}
}
diff --git a/LongoMatch.GUI/Gui/MainWindow.cs b/LongoMatch.GUI/Gui/MainWindow.cs
index e1fa5f2..60949f9 100644
--- a/LongoMatch.GUI/Gui/MainWindow.cs
+++ b/LongoMatch.GUI/Gui/MainWindow.cs
@@ -174,6 +174,7 @@ namespace LongoMatch.Gui
buttonswidget.NewMarkEvent += EmitNewTag;;
buttonswidget.NewMarkStartEvent += EmitNewTagStart;
buttonswidget.NewMarkStopEvent += EmitNewTagStop;
+ timeline.NewMarkEvent += EmitNewTagAtFrame;
/* Connect TimeNodeChanged events */
playsList.TimeNodeChanged += EmitTimeNodeChanged;
@@ -216,9 +217,6 @@ namespace LongoMatch.Gui
visitorPlayersList.SnapshotSeriesEvent += EmitSnapshotSeries;
tagsList.SnapshotSeriesEvent += EmitSnapshotSeries;
- /* Connect timeline events */
- timeline.NewMarkEvent += EmitNewTagAtFrame;
-
playlist.NewRenderingJob += EmitNewJob;
playsList.NewRenderingJob += EmitNewJob;
@@ -268,7 +266,10 @@ namespace LongoMatch.Gui
capturer.Visible = true;
TaggingViewAction.Active = true;
}
-
+
+ openedProject = project;
+ this.projectType = projectType;
+
playsList.ProjectIsLive = isLive;
localPlayersList.ProjectIsLive = isLive;
visitorPlayersList.ProjectIsLive = isLive;
@@ -556,6 +557,8 @@ namespace LongoMatch.Gui
protected virtual void OnTimeNodeSelected(Play play)
{
rightvbox.Visible=true;
+ if (PlaySelectedEvent != null)
+ PlaySelectedEvent(play);
}
protected virtual void OnSegmentClosedEvent()
diff --git a/LongoMatch.GUI/LongoMatch.GUI.mdp b/LongoMatch.GUI/LongoMatch.GUI.mdp
index c7bb291..5051370 100644
--- a/LongoMatch.GUI/LongoMatch.GUI.mdp
+++ b/LongoMatch.GUI/LongoMatch.GUI.mdp
@@ -129,12 +129,14 @@
<File subtype="Directory" buildaction="Compile" name="." />
<File subtype="Directory" buildaction="Compile" name="." />
<File subtype="Code" buildaction="Compile" name="Gui/Dialog/About.cs" />
- <File subtype="Code" buildaction="Nothing" name="../images/longomatch.png" />
- <File subtype="Code" buildaction="Nothing" name="../images/stock_draw-circle-unfilled.png" />
- <File subtype="Code" buildaction="Nothing" name="../images/stock_draw-freeform-line.png" />
- <File subtype="Code" buildaction="Nothing" name="../images/stock_draw-line-45.png" />
- <File subtype="Code" buildaction="Nothing" name="../images/stock_draw-line-ends-with-arrow.png" />
- <File subtype="Code" buildaction="Nothing" name="../images/stock_draw-rectangle-unfilled.png" />
+ <File subtype="Code" buildaction="EmbedAsResource" name="../images/longomatch.png" />
+ <File subtype="Code" buildaction="EmbedAsResource" name="../images/stock_draw-circle-unfilled.png" />
+ <File subtype="Code" buildaction="EmbedAsResource" name="../images/stock_draw-freeform-line.png" />
+ <File subtype="Code" buildaction="EmbedAsResource" name="../images/stock_draw-line-45.png" />
+ <File subtype="Code" buildaction="EmbedAsResource" name="../images/stock_draw-line-ends-with-arrow.png" />
+ <File subtype="Code" buildaction="EmbedAsResource" name="../images/stock_draw-rectangle-unfilled.png" />
+ <File subtype="Code" buildaction="EmbedAsResource" name="../images/video.png" />
+ <File subtype="Code" buildaction="EmbedAsResource" name="../images/camera-video.png" />
</Contents>
<MonoDevelop.Autotools.MakefileInfo RelativeMakefileName="../CesarPlayer/Makefile.am" RelativeConfigureInPath="../">
<BuildFilesVar Name="FILES" />
@@ -160,4 +162,4 @@
<ProjectReference type="Gac" localcopy="True" refto="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</References>
<LanguageParameters ApplicationIcon="." CodePage="65001" ctype="CSharpProjectParameters" />
-</Project>
+</Project>
\ No newline at end of file
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.ProjectSelectionDialog.cs b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.ProjectSelectionDialog.cs
index b1b7511..152dc39 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.ProjectSelectionDialog.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.ProjectSelectionDialog.cs
@@ -162,8 +162,8 @@ namespace LongoMatch.Gui.Dialog
if ((this.Child != null)) {
this.Child.ShowAll ();
}
- this.DefaultWidth = 298;
- this.DefaultHeight = 179;
+ this.DefaultWidth = 332;
+ this.DefaultHeight = 183;
this.Show ();
}
}
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.MainWindow.cs b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.MainWindow.cs
index 414df01..976c774 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.MainWindow.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.MainWindow.cs
@@ -361,7 +361,7 @@ namespace LongoMatch.Gui
this.Child.ShowAll ();
}
this.DefaultWidth = 1259;
- this.DefaultHeight = 853;
+ this.DefaultHeight = 860;
this.leftbox.Hide ();
this.drawingtoolbox1.Hide ();
this.timeline.Hide ();
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index be766da..2745485 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -1559,7 +1559,7 @@
</widget>
</child>
</widget>
- <widget class="Gtk.Window" id="LongoMatch.Gui.MainWindow" design-size="1259 853">
+ <widget class="Gtk.Window" id="LongoMatch.Gui.MainWindow" design-size="1259 860">
<action-group name="Default">
<action id="FileAction">
<property name="Type">Action</property>
@@ -5592,7 +5592,7 @@ Show-><b> S</b>
</widget>
</child>
</widget>
- <widget class="Gtk.Dialog" id="LongoMatch.Gui.Dialog.ProjectSelectionDialog" design-size="298 179">
+ <widget class="Gtk.Dialog" id="LongoMatch.Gui.Dialog.ProjectSelectionDialog" design-size="332 183">
<property name="MemberName" />
<property name="Title" translatable="yes">New Project</property>
<property name="Icon">stock:longomatch Menu</property>
@@ -5620,6 +5620,7 @@ Show-><b> S</b>
<property name="MemberName" />
<property name="CanFocus">True</property>
<property name="Label" translatable="yes">New project using a video file</property>
+ <property name="Active">True</property>
<property name="DrawIndicator">True</property>
<property name="HasLabel">True</property>
<property name="UseUnderline">True</property>
diff --git a/LongoMatch.GUI/gtk-gui/objects.xml b/LongoMatch.GUI/gtk-gui/objects.xml
index 522585e..39d35ab 100644
--- a/LongoMatch.GUI/gtk-gui/objects.xml
+++ b/LongoMatch.GUI/gtk-gui/objects.xml
@@ -107,20 +107,6 @@
</itemgroup>
</signals>
</object>
- <object type="LongoMatch.Gui.Component.PlaysListTreeWidget" palette-category="LongoMatch" allow-children="false" base-type="Gtk.Bin">
- <itemgroups />
- <signals>
- <itemgroup label="PlaysListTreeWidget Signals">
- <signal name="TimeNodeSelected" />
- <signal name="TimeNodeChanged" />
- <signal name="TimeNodeDeleted" />
- <signal name="PlayListNodeAdded" />
- <signal name="SnapshotSeriesEvent" />
- <signal name="TagPlay" />
- <signal name="NewRenderingJob" />
- </itemgroup>
- </signals>
- </object>
<object type="LongoMatch.Gui.Component.PlayersTaggerWidget" palette-category="General" allow-children="false" base-type="Gtk.Bin">
<itemgroups />
<signals />
@@ -315,4 +301,18 @@
</itemgroup>
</signals>
</object>
+ <object type="LongoMatch.Gui.Component.PlaysListTreeWidget" palette-category="LongoMatch" allow-children="false" base-type="Gtk.Bin">
+ <itemgroups />
+ <signals>
+ <itemgroup label="PlaysListTreeWidget Signals">
+ <signal name="TimeNodeSelected" />
+ <signal name="TimeNodeChanged" />
+ <signal name="TimeNodeDeleted" />
+ <signal name="PlayListNodeAdded" />
+ <signal name="SnapshotSeriesEvent" />
+ <signal name="TagPlay" />
+ <signal name="NewRenderingJob" />
+ </itemgroup>
+ </signals>
+ </object>
</objects>
\ No newline at end of file
diff --git a/LongoMatch.Services/Services/Core.cs b/LongoMatch.Services/Services/Core.cs
index a0200f2..3c1a398 100644
--- a/LongoMatch.Services/Services/Core.cs
+++ b/LongoMatch.Services/Services/Core.cs
@@ -23,6 +23,7 @@ using Mono.Unix;
using LongoMatch.Gui;
using LongoMatch.DB;
using LongoMatch.Common;
+using LongoMatch.Store;
namespace LongoMatch.Services
{
@@ -30,6 +31,9 @@ namespace LongoMatch.Services
{
static DataBase db;
static TemplatesService ts;
+ static EventsManager eManager;
+ static HotKeysManager hkManager;
+ static MainWindow mainWindow;
public static void Init()
{
@@ -49,13 +53,12 @@ namespace LongoMatch.Services
}
public static void Start(MainWindow mainWindow) {
+ Core.mainWindow = mainWindow;
StartServices(mainWindow);
BindEvents(mainWindow);
}
public static void StartServices(MainWindow mainWindow){
- EventsManager eManager;
- HotKeysManager hkManager;
RenderingJobsManager videoRenderer;
ProjectsManager projectsManager;
@@ -71,18 +74,13 @@ namespace LongoMatch.Services
/* Start the hotkeys manager */
hkManager = new HotKeysManager();
hkManager.newMarkEvent += eManager.OnNewTag;
- mainWindow.KeyPressEvent += hkManager.KeyListener;
/* Start the rendering jobs manager */
videoRenderer = new RenderingJobsManager(mainWindow.RenderingStateBar);
mainWindow.NewJobEvent += (job) => {videoRenderer.AddJob(job);};
projectsManager = new ProjectsManager(mainWindow);
-
- /*
- OnProjectChange => hkManager.Categories=project.Categories;
-
- */
+ projectsManager.OpenedProjectChanged += OnOpenedProjectChanged;
}
public static void BindEvents(MainWindow mainWindow) {
@@ -124,6 +122,18 @@ namespace LongoMatch.Services
}
}
+ private static void OnOpenedProjectChanged (Project project, ProjectType projectType) {
+ if (project != null) {
+ hkManager.Categories=project.Categories;
+ mainWindow.KeyPressEvent -= hkManager.KeyListener;
+ } else {
+ mainWindow.KeyPressEvent += hkManager.KeyListener;
+ }
+
+ eManager.OpenedProject = project;
+ eManager.OpenedProjectType = projectType;
+ }
+
private static void SetupBaseDir() {
string home;
diff --git a/LongoMatch.Services/Services/EventsManager.cs b/LongoMatch.Services/Services/EventsManager.cs
index 93ad2c2..ba09be7 100644
--- a/LongoMatch.Services/Services/EventsManager.cs
+++ b/LongoMatch.Services/Services/EventsManager.cs
@@ -18,6 +18,7 @@
//
//
+using System;
using System.Collections.Generic;
using Gdk;
using Gtk;
@@ -86,8 +87,8 @@ namespace LongoMatch.Services
mainWindow.NewTagStopEvent += OnNewPlayStop;
mainWindow.NewTagAtFrameEvent += OnNewTagAtFrame;
mainWindow.TimeNodeChanged += OnTimeNodeChanged;
- mainWindow.PlaysDeletedEvent += OnPlaysDeleted;;
- mainWindow.PlaySelectedEvent += OnPlaySelected;;
+ mainWindow.PlaysDeletedEvent += OnPlaysDeleted;
+ mainWindow.PlaySelectedEvent += OnPlaySelected;
/* Connect playlist events */
mainWindow.PlayListNodeSelectedEvent += (tn) => {selectedTimeNode = tn;};
@@ -130,6 +131,8 @@ namespace LongoMatch.Services
private void AddNewPlay(Time start, Time stop, Category category) {
Pixbuf miniature;
+ Log.Debug(String.Format("New play created start:{0} stop:{1} category:{2}",
+ start, stop, category));
/* Get the current frame and get a thumbnail from it */
if(projectType == ProjectType.CaptureProject) {
if(!capturer.Capturing) {
@@ -173,12 +176,14 @@ namespace LongoMatch.Services
public virtual void OnNewPlayStart() {
startTime = new Time {MSeconds = (int)player.CurrentTime};
+ Log.Debug("New play start time: " + startTime);
}
public virtual void OnNewPlayStop(Category category) {
int diff;
Time stopTime = new Time {MSeconds = (int)player.CurrentTime};
+ Log.Debug("New play stop time: " + stopTime);
diff = stopTime.MSeconds - startTime.MSeconds;
if(diff < 0) {
@@ -207,6 +212,7 @@ namespace LongoMatch.Services
protected virtual void OnPlaySelected(Play play)
{
+ Log.Debug("Play selected: " + play);
selectedTimeNode = play;
player.SetStartStop(play.Start.MSeconds,play.Stop.MSeconds);
drawingManager.Play=play;
@@ -234,6 +240,7 @@ namespace LongoMatch.Services
protected virtual void OnPlaysDeleted(List<Play> plays)
{
+ Log.Debug(plays.Count + " plays deleted");
mainWindow.DeletePlays(plays);
openedProject.RemovePlays(plays);
diff --git a/LongoMatch.Services/Services/ProjectsManager.cs b/LongoMatch.Services/Services/ProjectsManager.cs
index cceceeb..e6d9d63 100644
--- a/LongoMatch.Services/Services/ProjectsManager.cs
+++ b/LongoMatch.Services/Services/ProjectsManager.cs
@@ -25,13 +25,14 @@ using Mono.Unix;
using LongoMatch.Common;
using LongoMatch.Gui;
using LongoMatch.Gui.Dialog;
+using LongoMatch.Handlers;
using LongoMatch.Store;
using LongoMatch.Store.Templates;
using LongoMatch.Video;
using LongoMatch.Video.Utils;
-using LongoMatch.Multimedia.Interfaces;
using LongoMatch.Video.Common;
using LongoMatch.Multimedia.Utils;
+using LongoMatch.Multimedia.Interfaces;
namespace LongoMatch.Services
{
@@ -39,11 +40,14 @@ namespace LongoMatch.Services
public class ProjectsManager
{
- Project openedProject;
+ public event OpenedProjectChangedHandler OpenedProjectChanged;
+
MainWindow mainWindow;
public ProjectsManager(MainWindow mainWindow) {
this.mainWindow = mainWindow;
+ Player = mainWindow.Player;
+ Capturer = mainWindow.Capturer;
ConnectSignals();
}
@@ -59,14 +63,10 @@ namespace LongoMatch.Services
}
public Project OpenedProject {
- set {
- openedProject = value;
- /* FIXME: Emit ProjectChanged */
- }
- get {
- return openedProject;
- }
+ set;
+ get;
}
+
public ProjectType OpenedProjectType {
set;
get;
@@ -82,8 +82,13 @@ namespace LongoMatch.Services
set;
}
- public void SaveCaptureProject(Project project) {
- MessageDialog md;
+ private void EmitProjectChanged() {
+ if (OpenedProjectChanged != null)
+ OpenedProjectChanged(OpenedProject, OpenedProjectType);
+ }
+
+ private void SaveCaptureProject(Project project) {
+ MessageDialog md;
string filePath = project.Description.File.FilePath;
Log.Debug ("Saving capture project: " + project);
@@ -116,7 +121,7 @@ namespace LongoMatch.Services
md.Destroy();
}
- public void SaveFakeLiveProject(Project project) {
+ private void SaveFakeLiveProject(Project project) {
int response;
MessageDialog md;
FileFilter filter;
@@ -150,7 +155,7 @@ namespace LongoMatch.Services
fChooser.Destroy();
}
- public void ImportProject() {
+ private void ImportProject() {
Project project;
bool isFake, exists;
int res;
@@ -251,7 +256,7 @@ namespace LongoMatch.Services
Catalog.GetString("Project successfully imported."));
}
- public void CreateNewProject(out Project project, out ProjectType projectType,
+ private void CreateNewProject(out Project project, out ProjectType projectType,
out CaptureSettings captureSettings) {
ProjectSelectionDialog psd;
NewProjectDialog npd;
@@ -272,7 +277,7 @@ namespace LongoMatch.Services
if(response != (int)ResponseType.Ok)
return;
projectType = psd.ProjectType;
-
+
if(projectType == ProjectType.CaptureProject) {
devices = VideoDevice.ListVideoDevices();
if(devices.Count == 0) {
@@ -287,9 +292,11 @@ namespace LongoMatch.Services
npd = new NewProjectDialog();
npd.TransientFor = mainWindow;
npd.Use = projectType;
+ npd.TemplatesService = Core.TemplatesService;
if(projectType == ProjectType.CaptureProject)
npd.Devices = devices;
response = npd.Run();
+
while(true) {
/* User cancelled: quit */
if(response != (int)ResponseType.Ok) {
@@ -322,7 +329,7 @@ namespace LongoMatch.Services
Core.DB.AddProject(project);
}
- public bool SetProject(Project project, ProjectType projectType, CaptureSettings props)
+ private bool SetProject(Project project, ProjectType projectType, CaptureSettings props)
{
if(OpenedProject != null)
CloseOpenedProject(true);
@@ -364,8 +371,8 @@ namespace LongoMatch.Services
OpenedProject = project;
OpenedProjectType = projectType;
mainWindow.SetProject(project, projectType, props);
+ EmitProjectChanged();
return true;
-
}
/*
@@ -395,7 +402,7 @@ namespace LongoMatch.Services
fChooser.Destroy();
}*/
- public void CreateThumbnails(Project project) {
+ private void CreateThumbnails(Project project) {
MultimediaFactory factory;
IFramesCapturer capturer;
BusyDialog dialog;
@@ -439,6 +446,7 @@ namespace LongoMatch.Services
OpenedProject.Clear();
OpenedProject = null;
OpenedProjectType = ProjectType.None;
+ EmitProjectChanged();
}
protected virtual void SaveProject(Project project, ProjectType projectType) {
@@ -447,7 +455,7 @@ namespace LongoMatch.Services
if(projectType == ProjectType.FileProject) {
try {
- Core.DB.UpdateProject(openedProject);
+ Core.DB.UpdateProject(project);
} catch(Exception e) {
Log.Exception(e);
}
@@ -504,7 +512,7 @@ namespace LongoMatch.Services
protected void OpenProjectsManager()
{
- Gui.Dialog.ProjectsManager pm = new Gui.Dialog.ProjectsManager(openedProject, Core.DB);
+ Gui.Dialog.ProjectsManager pm = new Gui.Dialog.ProjectsManager(OpenedProject, Core.DB);
pm.TransientFor = mainWindow;
pm.Show();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]