=== modified file 'src/Editors/Editor.cs'
--- old/src/Editors/Editor.cs	2010-02-12 05:10:37 +0000
+++ new/src/Editors/Editor.cs	2010-02-12 05:57:10 +0000
@@ -18,6 +18,7 @@
 using Mono.Unix;
 
 using System;
+using System.IO;
 
 namespace FSpot.Editors {
 	[ExtensionNode ("Editor")]
@@ -61,6 +62,9 @@
 		public event ProcessingStepHandler ProcessingStep;
 		public event ProcessingFinishedHandler ProcessingFinished;
 
+		public PhotoImageView View { get; set; }
+		public Gtk.Window ParentWindow {get; set; }
+
 		// Contains the current selection, the items being edited, ...
 		private EditorState state;
 		public EditorState State {
@@ -96,7 +100,7 @@
 		}
 
 
-		protected void LoadPhoto (Photo photo, out Pixbuf photo_pixbuf, out Cms.Profile photo_profile) {
+		protected void LoadPhoto (IBrowsableItem photo, out Pixbuf photo_pixbuf, out Cms.Profile photo_profile) {
 			// FIXME: We might get this value from the PhotoImageView.
 			using (ImageFile img = ImageFile.Create (photo.DefaultVersionUri)) {
 				photo_pixbuf = img.Load ();
@@ -143,18 +147,29 @@
 			}
 
 			int done = 0;
-			foreach (Photo photo in State.Items) {
+			foreach (IBrowsableItem item in State.Items) {
 				Pixbuf input;
 				Cms.Profile input_profile;
-				LoadPhoto (photo, out input, out input_profile);
+				LoadPhoto (item, out input, out input_profile);
 
 				Pixbuf edited = Process (input, input_profile);
 				input.Dispose ();
 
-				bool create_version = photo.DefaultVersion.IsProtected;
-				photo.SaveVersion (edited, create_version);
-				photo.Changes.DataChanged = true;
-				Core.Database.Photos.Commit (photo);
+				if (item is Photo) {
+					var photo = item as Photo;
+					bool create_version = photo.DefaultVersion.IsProtected;
+					photo.SaveVersion (edited, create_version);
+					photo.Changes.DataChanged = true;
+					Core.Database.Photos.Commit (photo);
+				} else {
+					var pb = edited.Copy ();
+					using (ImageFile img = ImageFile.Create (item.DefaultVersionUri)) {
+						using (Stream stream = System.IO.File.OpenWrite (item.DefaultVersionUri.LocalPath)) {
+							img.Save (edited, stream);
+						}
+					}
+					State.PhotoImageView.Pixbuf = pb; 
+				}
 
 				done++;
 				if (ProcessingStep != null) {

=== modified file 'src/FSpot.addin.xml'
--- old/src/FSpot.addin.xml	2010-02-12 05:10:37 +0000
+++ new/src/FSpot.addin.xml	2010-02-12 05:49:25 +0000
@@ -61,8 +61,8 @@
 
 	<Extension path = "/FSpot/Sidebar">
 		<SidebarPage sidebar_page_type = "FSpot.Widgets.MetadataDisplayPage" />
+		<SidebarPage sidebar_page_type = "FSpot.Widgets.EditorPage" />
 		<Condition id="ViewMode" mode="library">
-			<SidebarPage sidebar_page_type = "FSpot.Widgets.EditorPage" />
 			<SidebarPage sidebar_page_type = "FSpot.Widgets.FolderTreePage" />
 		</Condition>
 	</Extension>

=== modified file 'src/SingleView.cs'
--- old/src/SingleView.cs	2010-02-12 05:10:37 +0000
+++ new/src/SingleView.cs	2010-02-12 05:50:32 +0000
@@ -127,9 +127,6 @@
 			info_vbox.Add (sidebar);
 			sidebar.AppendPage (directory_scrolled, Catalog.GetString ("Folder"), "gtk-directory");
 
-			AddinManager.AddExtensionNodeHandler ("/FSpot/Sidebar", OnSidebarExtensionChanged);
- 		
-			sidebar.Context = ViewContext.Single;
 
 			sidebar.CloseRequested += HandleHideSidePane;
 			sidebar.Show ();
@@ -149,6 +146,9 @@
 			
 			Window.ShowAll ();
 
+			AddinManager.AddExtensionNodeHandler ("/FSpot/Sidebar", OnSidebarExtensionChanged);	
+			sidebar.Context = ViewContext.Single;
+
 			zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
 		
 			LoadPreference (Preferences.VIEWER_SHOW_TOOLBAR);
@@ -189,8 +189,13 @@
 
 		private void OnSidebarExtensionChanged (object s, ExtensionNodeEventArgs args) {
 			// FIXME: No sidebar page removal yet!
-			if (args.Change == ExtensionChange.Add)
-				sidebar.AppendPage ((args.ExtensionNode as SidebarPageNode).GetSidebarPage ());
+			if (args.Change == ExtensionChange.Add) {
+				var page = (args.ExtensionNode as SidebarPageNode).GetSidebarPage ();
+Log.Debug ("OnSidebarExtensionAdded {0}  / {1} / {2}", page, image_view, window);
+				page.PhotoImageView = image_view;
+				page.ParentWindow = window;
+				sidebar.AppendPage (page);
+			}
 		}
 
 		void HandleExportActivated (object o, EventArgs e)

=== modified file 'src/Widgets/EditorPage.cs'
--- old/src/Widgets/EditorPage.cs	2010-02-12 05:10:37 +0000
+++ new/src/Widgets/EditorPage.cs	2010-02-12 05:50:32 +0000
@@ -23,7 +23,7 @@
 namespace FSpot.Widgets {
 	public class EditorPage : SidebarPage {
 		internal bool InPhotoView;
-		private readonly EditorPageWidget EditorPageWidget;
+		readonly EditorPageWidget EditorPageWidget;
 
 		public EditorPage () : base (new EditorPageWidget (),
 									   Catalog.GetString ("Edit"),
@@ -34,6 +34,16 @@
 			EditorPageWidget.Page = this;
 		}
 
+		public override PhotoImageView PhotoImageView {
+			get { return EditorPageWidget.PhotoImageView; }
+			set { EditorPageWidget.PhotoImageView = value; }
+		}
+
+		public override Gtk.Window ParentWindow {
+			get { return EditorPageWidget.ParentWindow; }
+			set { EditorPageWidget.ParentWindow = value ;}
+		}
+
 		protected override void AddedToSidebar () {
 			Sidebar.SelectionChanged += delegate (IBrowsableCollection collection) { EditorPageWidget.ShowTools (); };
 			Sidebar.ContextChanged += HandleContextChanged;
@@ -41,18 +51,22 @@
 
 		private void HandleContextChanged (object sender, EventArgs args)
 		{
-			InPhotoView = (Sidebar.Context == ViewContext.Edit);
+Log.Debug ("ContextChanged {0}", Sidebar.Context);
+			InPhotoView = (Sidebar.Context == ViewContext.Edit) || (Sidebar.Context == ViewContext.Single);
 			EditorPageWidget.ChangeButtonVisibility ();
 		}
 	}
 
 	public class EditorPageWidget : ScrolledWindow {
-		private VBox widgets;
-		private VButtonBox buttons;
-		private Widget active_editor;
-
-		private List<Editor> editors;
-		private Editor current_editor;
+		VBox widgets;
+		VButtonBox buttons;
+		Widget active_editor;
+
+		List<Editor> editors;
+		Editor current_editor;
+
+		public PhotoImageView PhotoImageView { get; set;}
+		public Gtk.Window ParentWindow { get; set; }
 
 		// Used to make buttons insensitive when selecting multiple images.
 		private Dictionary<Editor, Button> editor_buttons;
@@ -78,6 +92,8 @@
 				editor.ProcessingStarted += OnProcessingStarted;
 				editor.ProcessingStep += OnProcessingStep;
 				editor.ProcessingFinished += OnProcessingFinished;
+				editor.View = PhotoImageView;
+				editor.ParentWindow = ParentWindow;
 				editors.Add (editor);
 				PackButton (editor);
 			}
@@ -86,7 +102,7 @@
 		private ProgressDialog progress;
 
 		private void OnProcessingStarted (string name, int count) {
-			progress = new ProgressDialog (name, ProgressDialog.CancelButtonType.None, count, MainWindow.Toplevel.Window);
+			progress = new ProgressDialog (name, ProgressDialog.CancelButtonType.None, count, ParentWindow);
 		}
 
 		private void OnProcessingStep (int done) {
@@ -169,10 +185,13 @@
 		}
 
 		private bool SetupEditor (Editor editor) {
+Log.Debug ("");
+Log.Debug ("SetupEditor {0}", editor);
 			EditorState state = editor.CreateState ();
 
-			PhotoImageView photo_view = MainWindow.Toplevel.PhotoView.View;
-
+			PhotoImageView photo_view = PhotoImageView;
+Log.Debug ("PIV {0}", photo_view);
+Log.Debug ("InPhotoView {0}", Page.InPhotoView);
 			if (Page.InPhotoView && photo_view != null) {
 				state.Selection = photo_view.Selection;
 				state.PhotoImageView = photo_view;
@@ -196,7 +215,7 @@
 				string msg = Catalog.GetString ("No selection available");
 				string desc = Catalog.GetString ("This tool requires an active selection. Please select a region of the photo and try the operation again");
 
-				HigMessageDialog md = new HigMessageDialog (MainWindow.Toplevel.Window,
+				HigMessageDialog md = new HigMessageDialog (ParentWindow,
 										DialogFlags.DestroyWithParent,
 										Gtk.MessageType.Error, ButtonsType.Ok,
 										msg,
@@ -217,7 +236,7 @@
 				string desc = String.Format (Catalog.GetString ("Received exception \"{0}\". Note that you have to develop RAW files into JPEG before you can edit them."),
 							     e.Message);
 
-				HigMessageDialog md = new HigMessageDialog (MainWindow.Toplevel.Window,
+				HigMessageDialog md = new HigMessageDialog (ParentWindow,
 									    DialogFlags.DestroyWithParent,
 									    Gtk.MessageType.Error, ButtonsType.Ok,
 									    msg,

=== modified file 'src/Widgets/Sidebar.cs'
--- old/src/Widgets/Sidebar.cs	2010-02-12 05:10:37 +0000
+++ new/src/Widgets/Sidebar.cs	2010-02-12 05:50:32 +0000
@@ -110,6 +110,9 @@
 		// Can be overriden to get notified as soon as we're added to a sidebar.
 		protected virtual void AddedToSidebar () { }
 
+		public virtual PhotoImageView PhotoImageView { get; set; }
+		public virtual Gtk.Window ParentWindow { get; set; }
+
 		// Whether this page is currently visible
 		public bool IsActive {
 			get { return Sidebar.IsActive (this); }

