[longomatch] Allow adding export addins to the GUI
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Allow adding export addins to the GUI
- Date: Sun, 18 Dec 2011 21:43:51 +0000 (UTC)
commit 8cf5c7522ab07ddd1a5fa1df183bb554f3b917bb
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Fri Dec 16 02:41:42 2011 +0100
Allow adding export addins to the GUI
LongoMatch.Addins/AddinsManager.cs | 7 +++-
.../ExtensionPoints/IExportProject.cs | 5 ++-
LongoMatch.Core/Interfaces/GUI/IMainWindow.cs | 1 +
LongoMatch.GUI/Gui/GUIToolkit.cs | 2 +-
LongoMatch.GUI/Gui/MainWindow.cs | 37 +++++++++++++++++--
LongoMatch/Main.cs | 1 +
6 files changed, 45 insertions(+), 8 deletions(-)
---
diff --git a/LongoMatch.Addins/AddinsManager.cs b/LongoMatch.Addins/AddinsManager.cs
index e1b214d..5b29e40 100644
--- a/LongoMatch.Addins/AddinsManager.cs
+++ b/LongoMatch.Addins/AddinsManager.cs
@@ -21,6 +21,8 @@ using Mono.Addins;
using LongoMatch;
using LongoMatch.Addins.ExtensionPoints;
+using LongoMatch.Interfaces.GUI;
+using LongoMatch.Store;
[assembly:AddinRoot ("LongoMatch", "1.0")]
@@ -41,8 +43,11 @@ namespace LongoMatch.Addins
}
}
- public void LoadExportProjectAddins() {
+ public void LoadExportProjectAddins(IMainWindow mainWindow) {
foreach (IExportProject exportProject in AddinManager.GetExtensionObjects<IExportProject> ()) {
+ mainWindow.AddExportEntry(exportProject.GetMenuEntryName(), exportProject.GetMenuEntryShortName(),
+ new Action<Project, string>(exportProject.ExportProject));
+
}
}
}
diff --git a/LongoMatch.Addins/ExtensionPoints/IExportProject.cs b/LongoMatch.Addins/ExtensionPoints/IExportProject.cs
index 6cbc3c7..cac3193 100644
--- a/LongoMatch.Addins/ExtensionPoints/IExportProject.cs
+++ b/LongoMatch.Addins/ExtensionPoints/IExportProject.cs
@@ -26,8 +26,9 @@ namespace LongoMatch.Addins.ExtensionPoints
[TypeExtensionPoint]
public interface IExportProject
{
- void AddMenuEntry(IMainWindow mainWindow);
- void ExportProject(Project project);
+ string GetMenuEntryName();
+ string GetMenuEntryShortName();
+ void ExportProject(Project project, string filename);
}
}
diff --git a/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs b/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
index a020798..418e8dc 100644
--- a/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
@@ -82,6 +82,7 @@ namespace LongoMatch.Interfaces.GUI
ICapturer Capturer{get;}
IPlaylistWidget Playlist{get;}
+ void AddExportEntry (string name, string shortName, Action<Project, string> exportAction);
}
}
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
index 1ba07d7..9d39b5c 100644
--- a/LongoMatch.GUI/Gui/GUIToolkit.cs
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -40,7 +40,7 @@ namespace LongoMatch.Gui
public GUIToolkit ()
{
- mainWindow = new MainWindow();
+ mainWindow = new MainWindow(this);
(mainWindow as MainWindow).Show();
}
diff --git a/LongoMatch.GUI/Gui/MainWindow.cs b/LongoMatch.GUI/Gui/MainWindow.cs
index ca0108e..6748523 100644
--- a/LongoMatch.GUI/Gui/MainWindow.cs
+++ b/LongoMatch.GUI/Gui/MainWindow.cs
@@ -89,17 +89,21 @@ namespace LongoMatch.Gui
private static Project openedProject;
private ProjectType projectType;
- private TimeNode selectedTimeNode;
+ private TimeNode selectedTimeNode;
+
TimeLineWidget timeline;
bool gameUnitsActionVisible;
GameUnitsTimelineWidget guTimeline;
+ IGUIToolkit guiToolKit;
#region Constructors
- public MainWindow() :
+ public MainWindow(IGUIToolkit guiToolkit) :
base("LongoMatch")
{
this.Build();
+ this.guiToolKit = guiToolkit;
+
projectType = ProjectType.None;
timeline = new TimeLineWidget();
@@ -192,6 +196,29 @@ namespace LongoMatch.Gui
gameunitstaggerwidget1.GameUnits = gameUnits;
}
+ public void AddExportEntry (string name, string shortName, Action<Project, string> exportAction) {
+ string filename;
+
+ MenuItem parent = (MenuItem) this.UIManager.GetWidget("/menubar1/ToolsAction/ExportProjectAction1");
+
+ MenuItem item = new MenuItem(name);
+ item.Activated += (sender, e) => {
+ filename = guiToolKit.SaveFile(Catalog.GetString("Output file"), null,
+ Config.HomeDir(), null, null);
+
+ if (filename == null)
+ return;
+
+ try {
+ exportAction(openedProject, filename);
+ guiToolKit.InfoMessage(Catalog.GetString("Project exported successfully"));
+ }catch (Exception ex) {
+ guiToolKit.ErrorMessage(Catalog.GetString("Error exporting project"));
+ Log.Exception(ex);}};
+ item.Show();
+ (parent.Submenu as Menu).Append(item);
+ }
+
#endregion
#region Private Methods
@@ -265,7 +292,7 @@ namespace LongoMatch.Gui
SaveProjectAction.Activated += (o, e) => {EmitSaveProject();};
CloseProjectAction.Activated += (o, e) => {PromptCloseProject();};
ImportProjectAction.Activated += (o, e) => {EmitImportProject();};
- ExportProjectToCSVFileAction.Activated += (o, e) => {EmitExportProject();};
+ ExportToProjectFileAction.Activated += (o, e) => {EmitExportProject();};
QuitAction.Activated += (o, e) => {CloseAndQuit();};
CategoriesTemplatesManagerAction.Activated += (o, e) => {EmitManageCategories();};
TeamsTemplatesManagerAction.Activated += (o, e) => {EmitManageTeams();};
@@ -286,6 +313,8 @@ namespace LongoMatch.Gui
visitorteamlabel.Text = desc.VisitorName;
localteamlabel.Text = desc.LocalName;
+ ExportProjectAction1.Sensitive = true;
+
if(projectType == ProjectType.FileProject) {
Title = System.IO.Path.GetFileNameWithoutExtension(desc.File.FilePath) +
" - " + Constants.SOFTWARE_NAME;
@@ -352,7 +381,7 @@ namespace LongoMatch.Gui
ManualTaggingViewAction.Sensitive = sensitive2;
GameUnitsViewAction.Sensitive = sensitive2 && gameUnitsActionVisible;
TimelineViewAction.Sensitive = sensitive2;
- ExportProjectToCSVFileAction.Sensitive = sensitive2;
+ ExportProjectAction1.Sensitive = sensitive2;
HideAllWidgetsAction.Sensitive=sensitive2;
}
diff --git a/LongoMatch/Main.cs b/LongoMatch/Main.cs
index e81a94d..13ebb93 100644
--- a/LongoMatch/Main.cs
+++ b/LongoMatch/Main.cs
@@ -60,6 +60,7 @@ namespace LongoMatch
manager.LoadConfigModifierAddins();
GUIToolkit guiToolkit = new GUIToolkit();
IMultimediaToolkit multimediaToolkit = new MultimediaFactory();
+ manager.LoadExportProjectAddins(guiToolkit.MainWindow);
Core.Start(guiToolkit, multimediaToolkit);
Application.Run();
} catch(Exception ex) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]