[longomatch/imports] WIP on imports



commit f7524ec8c9c8640b3d3f34df157ca571f5b1e2f8
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Oct 17 16:55:19 2012 +0200

    WIP on imports

 LongoMatch.Addins/AddinsManager.cs                 |    8 ++++-
 .../ExtensionPoints/IImportProject.cs              |   34 ++++++++++++++++++++
 LongoMatch.Addins/LongoMatch.Addins.mdp            |    1 +
 LongoMatch.Core/Interfaces/GUI/IMainWindow.cs      |    1 +
 LongoMatch.GUI/Gui/MainWindow.cs                   |   12 ++++++-
 .../gtk-gui/LongoMatch.Gui.MainWindow.cs           |   10 ++++--
 LongoMatch.GUI/gtk-gui/gui.stetic                  |    9 +++++-
 LongoMatch.mds                                     |    4 ++
 LongoMatch/Main.cs                                 |    1 +
 9 files changed, 74 insertions(+), 6 deletions(-)
---
diff --git a/LongoMatch.Addins/AddinsManager.cs b/LongoMatch.Addins/AddinsManager.cs
index 72f4eec..151be92 100644
--- a/LongoMatch.Addins/AddinsManager.cs
+++ b/LongoMatch.Addins/AddinsManager.cs
@@ -47,7 +47,13 @@ namespace LongoMatch.Addins
 			foreach (IExportProject exportProject in AddinManager.GetExtensionObjects<IExportProject> ()) {
 				mainWindow.AddExportEntry(exportProject.GetMenuEntryName(), exportProject.GetMenuEntryShortName(),
 					new Action<Project, IGUIToolkit>(exportProject.ExportProject));
-			
+			}
+		}
+		
+		public void LoadImportProjectAddins(IMainWindow mainWindow) {
+			foreach (IImportProject importProject in AddinManager.GetExtensionObjects<IImportProject> ()) {
+				mainWindow.AddImportEntry(importProject.GetMenuEntryName(), importProject.GetMenuEntryShortName(),
+					new Action<string, IGUIToolkit>(importProject.ImportProject));
 			}
 		}
 	}
diff --git a/LongoMatch.Addins/ExtensionPoints/IImportProject.cs b/LongoMatch.Addins/ExtensionPoints/IImportProject.cs
new file mode 100644
index 0000000..513f30a
--- /dev/null
+++ b/LongoMatch.Addins/ExtensionPoints/IImportProject.cs
@@ -0,0 +1,34 @@
+// 
+//  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 Mono.Addins;
+
+using LongoMatch.Store;
+using LongoMatch.Interfaces.GUI;
+
+namespace LongoMatch.Addins.ExtensionPoints
+{
+	[TypeExtensionPoint]
+	public interface IImportProject
+	{
+		string GetMenuEntryName();
+		string GetMenuEntryShortName();
+		void ImportProject(string filePath, IGUIToolkit guiToolkit);
+	}
+}
+
diff --git a/LongoMatch.Addins/LongoMatch.Addins.mdp b/LongoMatch.Addins/LongoMatch.Addins.mdp
index cc693da..fa6c26d 100644
--- a/LongoMatch.Addins/LongoMatch.Addins.mdp
+++ b/LongoMatch.Addins/LongoMatch.Addins.mdp
@@ -18,6 +18,7 @@
     <File subtype="Code" buildaction="Compile" name="ExtensionPoints/IConfigModifier.cs" />
     <File subtype="Code" buildaction="Compile" name="AddinsManager.cs" />
     <File subtype="Directory" buildaction="Compile" name="." />
+    <File subtype="Code" buildaction="Compile" name="ExtensionPoints/IImportProject.cs" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.6.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
diff --git a/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs b/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
index 827246a..37736da 100644
--- a/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
@@ -86,6 +86,7 @@ namespace LongoMatch.Interfaces.GUI
 		ITemplatesService TemplatesService{set;}
 		
 		void AddExportEntry (string name, string shortName, Action<Project, IGUIToolkit> exportAction);
+		void AddImportEntry (string name, string shortName, Action<string, IGUIToolkit> importAction);
 	}
 }
 
diff --git a/LongoMatch.GUI/Gui/MainWindow.cs b/LongoMatch.GUI/Gui/MainWindow.cs
index ee2ca57..5bb6bce 100644
--- a/LongoMatch.GUI/Gui/MainWindow.cs
+++ b/LongoMatch.GUI/Gui/MainWindow.cs
@@ -214,6 +214,14 @@ namespace LongoMatch.Gui
 			(parent.Submenu as Menu).Append(item);
 		}
 		
+		public void AddImportEntry (string name, string shortName, Action<string, IGUIToolkit> importAction) {
+			MenuItem parent = (MenuItem) this.UIManager.GetWidget("/menubar1/ToolsAction/ImportProjectAction1");
+			
+			MenuItem item = new MenuItem(name);
+			item.Activated += (sender, e) => (importAction(null, guiToolKit));
+			item.Show();
+			(parent.Submenu as Menu).Append(item);
+		}
 		#endregion
 		
 		#region Private Methods
@@ -275,7 +283,7 @@ namespace LongoMatch.Gui
 		private void ConnectMenuSignals() {
 			SaveProjectAction.Activated += (o, e) => {EmitSaveProject();};
 			CloseProjectAction.Activated += (o, e) => {PromptCloseProject();};
-			ImportProjectAction.Activated += (o, e) => {EmitImportProject();};
+		    ImportFromFileAction.Activated += (o, e) => {EmitImportProject();};
 			ExportToProjectFileAction.Activated += (o, e) => {EmitExportProject();};
 			QuitAction.Activated += (o, e) => {CloseAndQuit();};
 			CategoriesTemplatesManagerAction.Activated += (o, e) => {EmitManageCategories();};
@@ -866,6 +874,8 @@ namespace LongoMatch.Gui
 			if (KeyPressed != null)
 				KeyPressed(sender, key, modifier);
 		}
+
+
 		#endregion
 	}
 }
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.MainWindow.cs b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.MainWindow.cs
index b5e19ba..a7fe305 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.MainWindow.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.MainWindow.cs
@@ -34,6 +34,7 @@ namespace LongoMatch.Gui
 		private global::Gtk.Action Action;
 		private global::Gtk.Action ExportToProjectFileAction;
 		private global::Gtk.Action dialogInfoAction;
+		private global::Gtk.Action ImportFromFileAction;
 		private global::Gtk.VBox vbox1;
 		private global::Gtk.VBox menubox;
 		private global::Gtk.MenuBar menubar1;
@@ -136,12 +137,12 @@ 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");
 			this.GameUnitsViewAction = new global::Gtk.RadioAction ("GameUnitsViewAction", global::Mono.Unix.Catalog.GetString ("Game units view"), null, null, 0);
-			this.GameUnitsViewAction.Group = this.TimelineViewAction.Group;
+			this.GameUnitsViewAction.Group = this.TaggingViewAction.Group;
 			this.GameUnitsViewAction.Sensitive = false;
 			this.GameUnitsViewAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Game units view");
 			w1.Add (this.GameUnitsViewAction, null);
@@ -160,6 +161,9 @@ namespace LongoMatch.Gui
 			this.dialogInfoAction = new global::Gtk.Action ("dialogInfoAction", global::Mono.Unix.Catalog.GetString ("Shortcuts"), null, "gtk-dialog-info");
 			this.dialogInfoAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Shortcuts");
 			w1.Add (this.dialogInfoAction, null);
+			this.ImportFromFileAction = new global::Gtk.Action ("ImportFromFileAction", global::Mono.Unix.Catalog.GetString ("Import from file"), null, null);
+			this.ImportFromFileAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Import from file");
+			w1.Add (this.ImportFromFileAction, null);
 			this.UIManager.InsertActionGroup (w1, 0);
 			this.AddAccelGroup (this.UIManager.AccelGroup);
 			this.Name = "LongoMatch.Gui.MainWindow";
@@ -176,7 +180,7 @@ namespace LongoMatch.Gui
 			this.menubox.Name = "menubox";
 			this.menubox.Spacing = 6;
 			// Container child menubox.Gtk.Box+BoxChild
-			this.UIManager.AddUiFromString ("<ui><menubar name='menubar1'><menu name='FileAction' action='FileAction'><menuitem name='NewPojectAction' action='NewPojectAction'/><menuitem name='openAction' action='openAction'/><menuitem name='SaveProjectAction' action='SaveProjectAction'/><menuitem name='CloseProjectAction' action='CloseProjectAction'/><separator/><menuitem name='ImportProjectAction' action='ImportProjectAction'/><separator/><menuitem name='QuitAction' action='QuitAction'/></menu><menu name='ToolsAction' action='ToolsAction'><menuitem name='ProjectsManagerAction' action='ProjectsManagerAction'/><menuitem name='CategoriesTemplatesManagerAction' action='CategoriesTemplatesManagerAction'/><menuitem name='TeamsTemplatesManagerAction' action='TeamsTemplatesManagerAction'/><menu name='ExportProjectAction1' action='ExportProjectAction1'><menuitem name='ExportToProjectFileAction' action='ExportToProjectFileAction'/></menu></menu><menu name='ViewAction' action='ViewAction'><me
 nuitem name='FullScreenAction' action='FullScreenAction'/><menuitem name='HideAllWidgetsAction' action='HideAllWidgetsAction'/><separator/><menuitem name='PlaylistAction' action='PlaylistAction'/><separator/><menuitem name='TaggingViewAction' action='TaggingViewAction'/><menuitem name='ManualTaggingViewAction' action='ManualTaggingViewAction'/><menuitem name='TimelineViewAction' action='TimelineViewAction'/><menuitem name='GameUnitsViewAction' action='GameUnitsViewAction'/></menu><menu name='HelpAction' action='HelpAction'><menuitem name='AboutAction' action='AboutAction'/><menuitem name='HelpAction1' action='HelpAction1'/><menuitem name='dialogInfoAction' action='dialogInfoAction'/></menu></menubar></ui>");
+			this.UIManager.AddUiFromString ("<ui><menubar name='menubar1'><menu name='FileAction' action='FileAction'><menuitem name='NewPojectAction' action='NewPojectAction'/><menuitem name='openAction' action='openAction'/><menuitem name='SaveProjectAction' action='SaveProjectAction'/><menuitem name='CloseProjectAction' action='CloseProjectAction'/><separator/><menu name='ImportProjectAction' action='ImportProjectAction'><menuitem name='ImportFromFileAction' action='ImportFromFileAction'/></menu><separator/><menuitem name='QuitAction' action='QuitAction'/></menu><menu name='ToolsAction' action='ToolsAction'><menuitem name='ProjectsManagerAction' action='ProjectsManagerAction'/><menuitem name='CategoriesTemplatesManagerAction' action='CategoriesTemplatesManagerAction'/><menuitem name='TeamsTemplatesManagerAction' action='TeamsTemplatesManagerAction'/><menu name='ExportProjectAction1' action='ExportProjectAction1'><menuitem name='ExportToProjectFileAction' action='ExportToProjectFil
 eAction'/></menu></menu><menu name='ViewAction' action='ViewAction'><menuitem name='FullScreenAction' action='FullScreenAction'/><menuitem name='HideAllWidgetsAction' action='HideAllWidgetsAction'/><separator/><menuitem name='PlaylistAction' action='PlaylistAction'/><separator/><menuitem name='TaggingViewAction' action='TaggingViewAction'/><menuitem name='ManualTaggingViewAction' action='ManualTaggingViewAction'/><menuitem name='TimelineViewAction' action='TimelineViewAction'/><menuitem name='GameUnitsViewAction' action='GameUnitsViewAction'/></menu><menu name='HelpAction' action='HelpAction'><menuitem name='AboutAction' action='AboutAction'/><menuitem name='HelpAction1' action='HelpAction1'/><menuitem name='dialogInfoAction' action='dialogInfoAction'/></menu></menubar></ui>");
 			this.menubar1 = ((global::Gtk.MenuBar)(this.UIManager.GetWidget ("/menubar1")));
 			this.menubar1.Name = "menubar1";
 			this.menubox.Add (this.menubar1);
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index 7c36656..b828607 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -1804,6 +1804,11 @@
         <property name="StockId">gtk-dialog-info</property>
         <signal name="Activated" handler="OnDialogInfoActionActivated" />
       </action>
+      <action id="ImportFromFileAction">
+        <property name="Type">Action</property>
+        <property name="Label" translatable="yes">Import from file</property>
+        <property name="ShortLabel" translatable="yes">Import from file</property>
+      </action>
     </action-group>
     <property name="MemberName" />
     <property name="Title" translatable="yes">LongoMatch</property>
@@ -1828,7 +1833,9 @@
                     <node type="Menuitem" action="SaveProjectAction" />
                     <node type="Menuitem" action="CloseProjectAction" />
                     <node type="Separator" />
-                    <node type="Menuitem" action="ImportProjectAction" />
+                    <node type="Menu" action="ImportProjectAction">
+                      <node type="Menuitem" action="ImportFromFileAction" />
+                    </node>
                     <node type="Separator" />
                     <node type="Menuitem" action="QuitAction" />
                   </node>
diff --git a/LongoMatch.mds b/LongoMatch.mds
index 26745c4..492e82e 100644
--- a/LongoMatch.mds
+++ b/LongoMatch.mds
@@ -27,6 +27,7 @@
       <Entry build="True" name="LongoMatch.GUI.Multimedia" configuration="Debug" />
       <Entry build="True" name="LongoMatch.Addins" configuration="Debug" />
       <Entry build="True" name="LongoMatch.Addins.COE" configuration="Debug" />
+      <Entry build="True" name="LongoMatch.Plugins" configuration="Debug" />
     </Configuration>
     <Configuration name="Release" ctype="CombineConfiguration">
       <Entry build="True" name="LongoMatch.GUI" configuration="Release" />
@@ -38,6 +39,7 @@
       <Entry build="True" name="LongoMatch.GUI.Multimedia" configuration="Release" />
       <Entry build="True" name="LongoMatch.Addins" configuration="Release" />
       <Entry build="True" name="LongoMatch.Addins.COE" configuration="Release" />
+      <Entry build="True" name="LongoMatch.Plugins" configuration="Release" />
     </Configuration>
   </Configurations>
   <StartMode startupentry="LongoMatchGtk" single="True">
@@ -50,6 +52,7 @@
     <Execute type="None" entry="LongoMatch.GUI.Multimedia" />
     <Execute type="None" entry="LongoMatch.Addins" />
     <Execute type="None" entry="LongoMatch.Addins.COE" />
+    <Execute type="None" entry="LongoMatch.Plugins" />
   </StartMode>
   <Entries>
     <Entry filename="LongoMatch.GUI/LongoMatch.GUI.mdp" />
@@ -61,5 +64,6 @@
     <Entry filename="LongoMatch.GUI.Multimedia/LongoMatch.GUI.Multimedia.mdp" />
     <Entry filename="LongoMatch.Addins/LongoMatch.Addins.mdp" />
     <Entry filename="LongoMatch.Addins.COE/LongoMatch.Addins.COE.mdp" />
+    <Entry filename="LongoMatch.Plugins/LongoMatch.Plugins.mdp" />
   </Entries>
 </Combine>
\ No newline at end of file
diff --git a/LongoMatch/Main.cs b/LongoMatch/Main.cs
index 80b0a23..48a6c23 100644
--- a/LongoMatch/Main.cs
+++ b/LongoMatch/Main.cs
@@ -63,6 +63,7 @@ namespace LongoMatch
 			    GUIToolkit guiToolkit = new GUIToolkit(version);
 			    IMultimediaToolkit multimediaToolkit = new MultimediaFactory();
 			    manager.LoadExportProjectAddins(guiToolkit.MainWindow);
+			    manager.LoadImportProjectAddins(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]