[longomatch] Add menu option to dupicate tagged plays
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add menu option to dupicate tagged plays
- Date: Sat, 12 Oct 2013 13:36:31 +0000 (UTC)
commit 62c541d5b65d098e47ebd043e5b62261da328257
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed Oct 9 22:29:06 2013 +0200
Add menu option to dupicate tagged plays
LongoMatch.Core/Handlers/Handlers.cs | 2 ++
LongoMatch.Core/Interfaces/GUI/IMainWindow.cs | 1 +
.../Gui/Component/PlayersListTreeWidget.cs | 3 ++-
.../Gui/Component/PlaysListTreeWidget.cs | 8 ++++++++
.../Gui/Component/PlaysSelectionWidget.cs | 12 ++++++++++++
LongoMatch.GUI/Gui/MainWindow.cs | 11 +++++++++++
LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs | 13 ++++++++++++-
LongoMatch.GUI/gtk-gui/objects.xml | 3 +++
LongoMatch.Services/Services/EventsManager.cs | 11 +++++++++++
9 files changed, 62 insertions(+), 2 deletions(-)
---
diff --git a/LongoMatch.Core/Handlers/Handlers.cs b/LongoMatch.Core/Handlers/Handlers.cs
index e783d25..33fab57 100644
--- a/LongoMatch.Core/Handlers/Handlers.cs
+++ b/LongoMatch.Core/Handlers/Handlers.cs
@@ -47,6 +47,8 @@ namespace LongoMatch.Handlers
public delegate void TagPlayHandler(Play play);
/* Change the Play's category */
public delegate void PlayCategoryChangedHandler(Play play, Category cat);
+ /* DUplicate play */
+ public delegate void DuplicatePlayHandler (Play play);
/* Project Events */
public delegate void SaveProjectHandler(Project project, ProjectType projectType);
diff --git a/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs b/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
index c6bc27e..049aefb 100644
--- a/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
@@ -37,6 +37,7 @@ namespace LongoMatch.Interfaces.GUI
event PlaysDeletedHandler PlaysDeletedEvent;
event TimeNodeChangedHandler TimeNodeChanged;
event PlayCategoryChangedHandler PlayCategoryChanged;
+ event DuplicatePlayHandler DuplicatePlay;
/* Playlist */
event RenderPlaylistHandler RenderPlaylistEvent;
diff --git a/LongoMatch.GUI/Gui/Component/PlayersListTreeWidget.cs
b/LongoMatch.GUI/Gui/Component/PlayersListTreeWidget.cs
index d0523cc..b0c583a 100644
--- a/LongoMatch.GUI/Gui/Component/PlayersListTreeWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/PlayersListTreeWidget.cs
@@ -38,6 +38,7 @@ namespace LongoMatch.Gui.Component
public event PlayListNodeAddedHandler PlayListNodeAdded;
public event SnapshotSeriesHandler SnapshotSeriesEvent;
public event RenderPlaylistHandler RenderPlaylistEvent;
+ public event DuplicatePlayHandler DuplicatePlay;
public PlayersListTreeWidget()
{
@@ -47,7 +48,7 @@ namespace LongoMatch.Gui.Component
playerstreeview.PlayListNodeAdded += OnPlayListNodeAdded;
playerstreeview.SnapshotSeriesEvent += OnSnapshotSeriesEvent;
playerstreeview.NewRenderingJob += OnNewRenderingJob;
-
+ playerstreeview.DuplicatePlay += DuplicatePlay;
}
public Project Project {
diff --git a/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
b/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
index 2e540f4..2ef5f94 100644
--- a/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
@@ -46,6 +46,7 @@ namespace LongoMatch.Gui.Component
public event SnapshotSeriesHandler SnapshotSeriesEvent;
public event TagPlayHandler TagPlay;
public event RenderPlaylistHandler RenderPlaylist;
+ public event DuplicatePlayHandler DuplicatePlay;
ITemplatesService ts;
@@ -63,6 +64,7 @@ namespace LongoMatch.Gui.Component
treeview.PlayCategoryChanged += OnPlayCategoryChanged;
treeview.TagPlay += OnTagPlay;
treeview.NewRenderingJob += OnNewRenderingJob;
+ treeview.DuplicatePlay += OnDuplicatePlay;
}
public ITemplatesService TemplatesService
@@ -211,6 +213,12 @@ namespace LongoMatch.Gui.Component
PlayListNodeAdded(tNode);
}
+ protected virtual void OnDuplicatePlay (Play play)
+ {
+ if (DuplicatePlay != null)
+ DuplicatePlay (play);
+ }
+
protected virtual void OnPlayCategoryChanged(Play play, Category cat)
{
if(PlayCategoryChanged != null)
diff --git a/LongoMatch.GUI/Gui/Component/PlaysSelectionWidget.cs
b/LongoMatch.GUI/Gui/Component/PlaysSelectionWidget.cs
index ae04ccc..15baff7 100644
--- a/LongoMatch.GUI/Gui/Component/PlaysSelectionWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/PlaysSelectionWidget.cs
@@ -39,6 +39,7 @@ namespace LongoMatch.Gui.Component
public event SnapshotSeriesHandler SnapshotSeries;
public event RenderPlaylistHandler RenderPlaylist;
public event TagPlayHandler TagPlay;
+ public event DuplicatePlayHandler DuplicatePlay;
Project project;
PlaysFilter filter;
@@ -133,6 +134,11 @@ namespace LongoMatch.Gui.Component
localPlayersList.PlayListNodeAdded += EmitPlayListNodeAdded;
visitorPlayersList.PlayListNodeAdded += EmitPlayListNodeAdded;
+ /* Duplicate play */
+ playsList.DuplicatePlay += EmitDuplicatePlay;
+ localPlayersList.DuplicatePlay += EmitDuplicatePlay;
+ visitorPlayersList.DuplicatePlay += EmitDuplicatePlay;
+
/* Play name edited or Category name changed */
playsList.TimeNodeChanged += EmitTimeNodeChanged;
@@ -204,6 +210,12 @@ namespace LongoMatch.Gui.Component
UpdateTeamsModels();
}
+ private void EmitDuplicatePlay (Play play)
+ {
+ if (DuplicatePlay != null)
+ DuplicatePlay (play);
+ }
+
protected void OnCategoriesFiltersbuttonClicked (object sender, System.EventArgs e)
{
if (catfiltersbutton.Active) {
diff --git a/LongoMatch.GUI/Gui/MainWindow.cs b/LongoMatch.GUI/Gui/MainWindow.cs
index c73557e..7f1bf11 100644
--- a/LongoMatch.GUI/Gui/MainWindow.cs
+++ b/LongoMatch.GUI/Gui/MainWindow.cs
@@ -55,6 +55,7 @@ namespace LongoMatch.Gui
public event PlaysDeletedHandler PlaysDeletedEvent;
public event TimeNodeChangedHandler TimeNodeChanged;
public event PlayCategoryChangedHandler PlayCategoryChanged;
+ public event DuplicatePlayHandler DuplicatePlay;
/* Playlist */
public event RenderPlaylistHandler RenderPlaylistEvent;
@@ -287,6 +288,9 @@ namespace LongoMatch.Gui
/* Connect PlayListNodeAdded events */
playsSelection.PlayListNodeAdded += OnPlayListNodeAdded;
timeline.PlayListNodeAdded += OnPlayListNodeAdded;
+
+ /* Connect duplicate plays */
+ playsSelection.DuplicatePlay += EmitDuplicatePlay;
/* Connect tags events */
playsSelection.TagPlay += EmitTagPlay;
@@ -981,6 +985,13 @@ namespace LongoMatch.Gui
if (KeyPressed != null)
KeyPressed(sender, key, modifier);
}
+
+ void EmitDuplicatePlay (Play play)
+ {
+ if (DuplicatePlay != null)
+ DuplicatePlay (play);
+ }
+
#endregion
}
}
diff --git a/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs b/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs
index 57cf849..b6d5fcf 100644
--- a/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs
+++ b/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs
@@ -36,7 +36,8 @@ namespace LongoMatch.Gui.Component
{
// Plays menu
protected Menu menu, catMenu;
- protected MenuItem tag, delete, addPLN, deleteKeyFrame, snapshot, name, render, moveCat;
+ protected MenuItem tag, delete, addPLN, deleteKeyFrame, snapshot;
+ protected MenuItem name, render, moveCat, duplicate;
protected Gtk.CellRendererText nameCell;
protected Gtk.TreeViewColumn nameColumn;
@@ -56,6 +57,7 @@ namespace LongoMatch.Gui.Component
public event SnapshotSeriesHandler SnapshotSeriesEvent;
public event TagPlayHandler TagPlay;
public event EventHandler NewRenderingJob;
+ public event DuplicatePlayHandler DuplicatePlay;
public ListTreeViewBase()
{
@@ -163,6 +165,7 @@ namespace LongoMatch.Gui.Component
name = new MenuItem(Catalog.GetString("Edit name"));
tag = new MenuItem(Catalog.GetString("Edit tags"));
+ duplicate = new MenuItem(Catalog.GetString("Duplicate"));
delete = new MenuItem(Catalog.GetString("Delete"));
deleteKeyFrame = new MenuItem(Catalog.GetString("Delete key frame"));
addPLN = new MenuItem(Catalog.GetString("Add to playlist"));
@@ -175,6 +178,7 @@ namespace LongoMatch.Gui.Component
menu.Append(tag);
menu.Append(addPLN);
menu.Append(delete);
+ menu.Append(duplicate);
menu.Append(deleteKeyFrame);
menu.Append(render);
menu.Append(snapshot);
@@ -182,6 +186,7 @@ namespace LongoMatch.Gui.Component
name.Activated += OnEdit;
tag.Activated += OnTag;
+ duplicate.Activated += OnDuplicate;
addPLN.Activated += OnAdded;
delete.Activated += OnDeleted;
deleteKeyFrame.Activated += OnDeleteKeyFrame;
@@ -345,6 +350,12 @@ namespace LongoMatch.Gui.Component
}
}
+ void OnDuplicate (object sender, EventArgs e)
+ {
+ if (DuplicatePlay != null)
+ DuplicatePlay((Play)GetValueFromPath(Selection.GetSelectedRows()[0]));
+ }
+
protected virtual void OnEdit(object obj, EventArgs args) {
TreePath[] paths = Selection.GetSelectedRows();
diff --git a/LongoMatch.GUI/gtk-gui/objects.xml b/LongoMatch.GUI/gtk-gui/objects.xml
index 9b720d3..2ae1758 100644
--- a/LongoMatch.GUI/gtk-gui/objects.xml
+++ b/LongoMatch.GUI/gtk-gui/objects.xml
@@ -93,6 +93,7 @@
<signal name="PlayListNodeAdded" />
<signal name="SnapshotSeriesEvent" />
<signal name="RenderPlaylistEvent" />
+ <signal name="DuplicatePlay" />
</itemgroup>
</signals>
</object>
@@ -171,6 +172,7 @@
<signal name="SnapshotSeriesEvent" />
<signal name="TagPlay" />
<signal name="RenderPlaylist" />
+ <signal name="DuplicatePlay" />
</itemgroup>
</signals>
</object>
@@ -302,6 +304,7 @@
<signal name="RenderPlaylist" />
<signal name="TagPlay" />
<signal name="TimeNodeChanged" />
+ <signal name="DuplicatePlay" />
</itemgroup>
</signals>
</object>
diff --git a/LongoMatch.Services/Services/EventsManager.cs b/LongoMatch.Services/Services/EventsManager.cs
index 4d9acdc..6329a33 100644
--- a/LongoMatch.Services/Services/EventsManager.cs
+++ b/LongoMatch.Services/Services/EventsManager.cs
@@ -89,6 +89,7 @@ namespace LongoMatch.Services
mainWindow.PlaysDeletedEvent += OnPlaysDeleted;
mainWindow.PlaySelectedEvent += OnPlaySelected;
mainWindow.PlayCategoryChanged += OnPlayCategoryChanged;
+ mainWindow.DuplicatePlay += OnDuplicatePlay;
/* Connect playlist events */
mainWindow.PlayListNodeSelectedEvent += (tn) => {selectedTimeNode = tn;};
@@ -310,6 +311,16 @@ namespace LongoMatch.Services
filter.Update();
}
+ void OnDuplicatePlay (Play play)
+ {
+ Play copy = Cloner.Clone (play);
+ /* The category is also serialized and desarialized */
+ copy.Category = play.Category;
+ openedProject.AddPlay (copy);
+ mainWindow.AddPlay (copy);
+ filter.Update();
+ }
+
protected virtual void OnSegmentClosedEvent()
{
selectedTimeNode = null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]