Browse files

Addin manager now inits & uninits addins correctly

Can be tested by using the DemoExtension, which will print to stdout
when that happens. The Core extensions (tools and effects) don't
actually have uninit methods implemented yet.
  • Loading branch information...
1 parent f5e92bd commit 7d580b51b01132c67ad0fc829d5349b3908c7f6e @robpvn robpvn committed May 29, 2012
Showing with 12 additions and 2 deletions.
  1. +12 −2 Pinta/MainWindow.cs
View
14 Pinta/MainWindow.cs
@@ -58,8 +58,8 @@ public MainWindow ()
AddinManager.Initialize ();
AddinManager.Registry.Update ();
- foreach (var extension in PintaCore.System.GetExtensions<IExtension> ())
- extension.Initialize ();
+ //Look out for any changes in extensions
+ AddinManager.AddExtensionNodeHandler (typeof (IExtension), OnExtensionChanged);
// Try to set the default tool to the PaintBrush
PintaCore.Tools.SetCurrentTool (Catalog.GetString ("Paintbrush"));
@@ -85,6 +85,16 @@ public MainWindow ()
PintaCore.Workspace.ActiveDocumentChanged += ActiveDocumentChanged;
}
+ // Called when an extension node is added or removed
+ private void OnExtensionChanged (object s, ExtensionNodeEventArgs args)
+ {
+ IExtension extension = (IExtension) args.ExtensionObject;
+ if (args.Change == ExtensionChange.Add)
+ extension.Initialize ();
+ else
+ extension.Uninitialize ();
+ }
+
#region GUI Construction
private void CreateWindow ()
{

0 comments on commit 7d580b5

Please sign in to comment.