[f-spot] Resolving MainWindow.Toplevel dependency of QueryWidget



commit 305846551a81addef08286d1bf5b78cf4598cf31
Author: Paul Werner Bou <paul purecodes org>
Date:   Sat May 15 11:53:38 2010 +0200

    Resolving MainWindow.Toplevel dependency of QueryWidget

 extensions/Exporters/ZipExport/ZipExport.cs        |    2 +-
 extensions/Misc/LightTable/LightTable.cs           |    2 +-
 extensions/Tools/DevelopInUFraw/DevelopInUFRaw.cs  |    8 +++---
 .../Tools/LiveWebGallery/GalleryRequestHandler.cs  |    4 +-
 extensions/Tools/MetaPixel/MetaPixel.cs            |   16 ++++++------
 extensions/Tools/PictureTile/PictureTile.cs        |   10 ++++----
 extensions/Tools/RawPlusJpeg/RawPlusJpeg.cs        |    4 +-
 .../Tools/RetroactiveRoll/RetroactiveRoll.cs       |    2 +-
 .../Tools/ScreensaverConfig/ScreensaverConfig.cs   |    4 +-
 extensions/Tools/SyncCatalog/SyncCatalog.cs        |    4 +-
 src/CameraFileSelectionDialog.cs                   |    4 +-
 src/Core/App.cs                                    |    2 +-
 src/Editors/Editor.cs                              |    4 +-
 src/Extensions/PhotoSelectionCondition.cs          |    6 ++--
 src/Extensions/PopupCommands.cs                    |   26 ++++++++++----------
 src/GroupSelector.cs                               |    4 +-
 src/ImportCommand.cs                               |    6 ++--
 src/Loupe.cs                                       |    4 +-
 src/MainWindow.cs                                  |   21 +++++++--------
 src/PhotoVersionCommands.cs                        |    2 +-
 src/QueryWidget.cs                                 |    2 -
 src/SelectionDataExtensions.cs                     |    4 +-
 src/TagPopup.cs                                    |   16 ++++++------
 src/TagQueryWidget.cs                              |    6 ++--
 src/TagSelectionWidget.cs                          |    4 +-
 src/Widgets/EditorPage.cs                          |    8 +++---
 src/Widgets/Filmstrip.cs                           |    4 +-
 src/Widgets/FindBar.cs                             |    2 +-
 src/Widgets/FolderTreeModel.cs                     |    2 +-
 src/Widgets/FolderTreeView.cs                      |    2 +-
 src/Widgets/InfoBox.cs                             |    4 +-
 src/Widgets/RatingMenuItem.cs                      |    4 +-
 src/Widgets/Sidebar.cs                             |    2 +-
 33 files changed, 96 insertions(+), 99 deletions(-)
---
diff --git a/extensions/Exporters/ZipExport/ZipExport.cs b/extensions/Exporters/ZipExport/ZipExport.cs
index 7d25d25..632faf1 100644
--- a/extensions/Exporters/ZipExport/ZipExport.cs
+++ b/extensions/Exporters/ZipExport/ZipExport.cs
@@ -42,7 +42,7 @@ namespace ZipExport {
 		public void Run (IBrowsableCollection p) {
 			Log.Information ("Executing ZipExport extension");
 			if (p.Count == 0) {
-				HigMessageDialog md = new HigMessageDialog (MainWindow.Toplevel.Window, DialogFlags.DestroyWithParent,
+				HigMessageDialog md = new HigMessageDialog (App.Instance.Organizer.Window, DialogFlags.DestroyWithParent,
 							  Gtk.MessageType.Error, ButtonsType.Ok,
 							  Catalog.GetString ("No selection available"),
 							  Catalog.GetString ("This tool requires an active selection. Please select one or more pictures and try again"));
diff --git a/extensions/Misc/LightTable/LightTable.cs b/extensions/Misc/LightTable/LightTable.cs
index 35430cf..9bed6b4 100644
--- a/extensions/Misc/LightTable/LightTable.cs
+++ b/extensions/Misc/LightTable/LightTable.cs
@@ -69,7 +69,7 @@ namespace LightTableExtension
 				photos = new List<MLPhoto> ();
 				selected_photos = new List<MLPhoto> ();
 
-				foreach (Photo p in MainWindow.Toplevel.SelectedPhotos ()) {
+				foreach (Photo p in App.Instance.Organizer.SelectedPhotos ()) {
 					MLPhoto p1 = new MLPhoto (p.DefaultVersionUri, this);
 					photos.Add (p1);
 				}
diff --git a/extensions/Tools/DevelopInUFraw/DevelopInUFRaw.cs b/extensions/Tools/DevelopInUFraw/DevelopInUFRaw.cs
index 97ad4da..a8c2bcf 100644
--- a/extensions/Tools/DevelopInUFraw/DevelopInUFRaw.cs
+++ b/extensions/Tools/DevelopInUFraw/DevelopInUFRaw.cs
@@ -29,7 +29,7 @@ namespace DevelopInUFRawExtension
 		{
 			Log.Information ("Executing DevelopInUFRaw extension");
 
-			foreach (Photo p in MainWindow.Toplevel.SelectedPhotos ()) {
+			foreach (Photo p in App.Instance.Organizer.SelectedPhotos ()) {
 				DevelopPhoto (p);
 			}
 		}
@@ -45,11 +45,11 @@ namespace DevelopInUFRawExtension
 		{
 			ProgressDialog pdialog = new ProgressDialog(Catalog.GetString ("Developing photos"),
 														ProgressDialog.CancelButtonType.Cancel,
-														MainWindow.Toplevel.SelectedPhotos ().Length,
-														MainWindow.Toplevel.Window);
+														App.Instance.Organizer.SelectedPhotos ().Length,
+														App.Instance.Organizer.Window);
 			Log.Information ("Executing DevelopInUFRaw extension in batch mode");
 
-			foreach (Photo p in MainWindow.Toplevel.SelectedPhotos ()) {
+			foreach (Photo p in App.Instance.Organizer.SelectedPhotos ()) {
 				bool cancelled = pdialog.Update(String.Format(Catalog.GetString ("Developing {0}"), p.Name));
 				if (cancelled) {
 					break;
diff --git a/extensions/Tools/LiveWebGallery/GalleryRequestHandler.cs b/extensions/Tools/LiveWebGallery/GalleryRequestHandler.cs
index 40f77d0..a288403 100644
--- a/extensions/Tools/LiveWebGallery/GalleryRequestHandler.cs
+++ b/extensions/Tools/LiveWebGallery/GalleryRequestHandler.cs
@@ -145,10 +145,10 @@ namespace LiveWebGalleryExtension
 			case QueryType.ByTag:
 				return App.Instance.Database.Photos.Query (new Tag[] {query_tag});
 			case QueryType.CurrentView:
-				return MainWindow.Toplevel.Query.Photos;
+				return App.Instance.Organizer.Query.Photos;
 			case QueryType.Selected:
 			default:
-				return MainWindow.Toplevel.SelectedPhotos ();
+				return App.Instance.Organizer.SelectedPhotos ();
 			}
 		}
 		
diff --git a/extensions/Tools/MetaPixel/MetaPixel.cs b/extensions/Tools/MetaPixel/MetaPixel.cs
index bbb2238..ffa1c4e 100644
--- a/extensions/Tools/MetaPixel/MetaPixel.cs
+++ b/extensions/Tools/MetaPixel/MetaPixel.cs
@@ -41,7 +41,7 @@ namespace MetaPixelExtension {
 
 		public void Run (object o, EventArgs e) {
 			Log.Information ("Executing MetaPixel extension");
-			if (MainWindow.Toplevel.SelectedPhotos ().Length == 0) {
+			if (App.Instance.Organizer.SelectedPhotos ().Length == 0) {
 				InfoDialog (Catalog.GetString ("No selection available"),
 					    Catalog.GetString ("This tool requires an active selection. Please select one or more pictures and try again"),
 					    Gtk.MessageType.Error);
@@ -78,7 +78,7 @@ namespace MetaPixelExtension {
 			metapixel_dialog.Modal = false;
 			metapixel_dialog.TransientFor = null;
 
-			miniatures_tags = new FSpot.Widgets.TagEntry (MainWindow.Toplevel.Database.Tags, false);
+			miniatures_tags = new FSpot.Widgets.TagEntry (App.Instance.Database.Tags, false);
 			miniatures_tags.UpdateFromTagNames (new string []{});
 			tagentry_box.Add (miniatures_tags);
 
@@ -98,7 +98,7 @@ namespace MetaPixelExtension {
 
 		void create_mosaics () {
 			//Prepare the query
-			Db db = MainWindow.Toplevel.Database;
+			Db db = App.Instance.Database;
 			FSpot.PhotoQuery mini_query = new FSpot.PhotoQuery (db.Photos);
 			Photo [] photos;
 
@@ -113,7 +113,7 @@ namespace MetaPixelExtension {
 				mini_query.Terms = FSpot.OrTerm.FromTags ((Tag []) taglist.ToArray (typeof (Tag)));
 				photos = mini_query.Photos;
 			} else {
-				photos = MainWindow.Toplevel.Query.Photos;
+				photos = App.Instance.Organizer.Query.Photos;
 			}
 
 			if (photos.Length == 0) {
@@ -179,11 +179,11 @@ namespace MetaPixelExtension {
 			progress_dialog = null;
 			progress_dialog = new ProgressDialog (Catalog.GetString ("Creating photomosaics"),
 							      ProgressDialog.CancelButtonType.Stop,
-							      MainWindow.Toplevel.SelectedPhotos ().Length, metapixel_dialog);
+							      App.Instance.Organizer.SelectedPhotos ().Length, metapixel_dialog);
 
 			//Now create the mosaics!
 			uint error_count = 0;
-			foreach (Photo p in MainWindow.Toplevel.SelectedPhotos ()) {
+			foreach (Photo p in App.Instance.Organizer.SelectedPhotos ()) {
 				if (progress_dialog.Update (String.Format (Catalog.GetString ("Processing \"{0}\""), p.Name))) {
 					progress_dialog.Destroy ();
 					DeleteTmp ();
@@ -232,7 +232,7 @@ namespace MetaPixelExtension {
 			string final_message = "Your mosaics have been generated as new versions of the pictures you selected";
 			if (error_count > 0)
 				final_message += String.Format (".\n{0} images out of {1} had errors",
-							error_count, MainWindow.Toplevel.SelectedPhotos ().Length);
+							error_count, App.Instance.Organizer.SelectedPhotos ().Length);
 			InfoDialog (Catalog.GetString ("PhotoMosaics generated!"),
 				    Catalog.GetString (final_message),
 				    (error_count == 0 ? Gtk.MessageType.Info : Gtk.MessageType.Warning));
@@ -287,7 +287,7 @@ namespace MetaPixelExtension {
 		}
 
 		private void InfoDialog (string title, string msg, Gtk.MessageType type) {
-			HigMessageDialog md = new HigMessageDialog (MainWindow.Toplevel.Window, DialogFlags.DestroyWithParent,
+			HigMessageDialog md = new HigMessageDialog (App.Instance.Organizer.Window, DialogFlags.DestroyWithParent,
 						  type, ButtonsType.Ok, title, msg);
 
 			md.Run ();
diff --git a/extensions/Tools/PictureTile/PictureTile.cs b/extensions/Tools/PictureTile/PictureTile.cs
index 8507be3..a4a3821 100644
--- a/extensions/Tools/PictureTile/PictureTile.cs
+++ b/extensions/Tools/PictureTile/PictureTile.cs
@@ -47,7 +47,7 @@ namespace PictureTileExtension {
 
 		public void Run (object o, EventArgs e) {
 			Log.Information ("Executing PictureTile extension");
-			if (MainWindow.Toplevel.SelectedPhotos ().Length == 0) {
+			if (App.Instance.Organizer.SelectedPhotos ().Length == 0) {
 				InfoDialog (Catalog.GetString ("No selection available"),
 					    Catalog.GetString ("This tool requires an active selection. Please select one or more pictures and try again"),
 					    Gtk.MessageType.Error);
@@ -109,14 +109,14 @@ namespace PictureTileExtension {
 			ProgressDialog progress_dialog = null;
 			progress_dialog = new ProgressDialog (Catalog.GetString ("Preparing selected pictures"),
 							      ProgressDialog.CancelButtonType.Stop,
-							      MainWindow.Toplevel.SelectedPhotos ().Length, picturetile_dialog);
+							      App.Instance.Organizer.SelectedPhotos ().Length, picturetile_dialog);
 
 			FilterSet filters = new FilterSet ();
 			filters.Add (new JpegFilter ());
 			filters.Add (new OrientationFilter ());
 			uint counter = 0;
 			ArrayList all_tags = new ArrayList ();
-			foreach (Photo p in MainWindow.Toplevel.SelectedPhotos ()) {
+			foreach (Photo p in App.Instance.Organizer.SelectedPhotos ()) {
 				if (progress_dialog.Update (String.Format (Catalog.GetString ("Processing \"{0}\""), p.Name))) {
 					progress_dialog.Destroy ();
 					DeleteTmp ();
@@ -195,7 +195,7 @@ namespace PictureTileExtension {
 			}
 
 			//Add the pic(s) to F-Spot!
-			Db db = MainWindow.Toplevel.Database;
+			Db db = App.Instance.Database;
 			ImportCommand command = new ImportCommand (null);
 			if (command.ImportFromPaths (db.Photos, photo_import_list, photo_tags) > 0) {
 				InfoDialog (Catalog.GetString ("PhotoWall generated!"),
@@ -243,7 +243,7 @@ namespace PictureTileExtension {
 		}
 
 		private void InfoDialog (string title, string msg, Gtk.MessageType type) {
-			HigMessageDialog md = new HigMessageDialog (MainWindow.Toplevel.Window, DialogFlags.DestroyWithParent,
+			HigMessageDialog md = new HigMessageDialog (App.Instance.Organizer.Window, DialogFlags.DestroyWithParent,
 						  type, ButtonsType.Ok, title, msg);
 
 			md.Run ();
diff --git a/extensions/Tools/RawPlusJpeg/RawPlusJpeg.cs b/extensions/Tools/RawPlusJpeg/RawPlusJpeg.cs
index e348a49..659c673 100644
--- a/extensions/Tools/RawPlusJpeg/RawPlusJpeg.cs
+++ b/extensions/Tools/RawPlusJpeg/RawPlusJpeg.cs
@@ -25,7 +25,7 @@ namespace RawPlusJpegExtension
 			Console.WriteLine ("EXECUTING RAW PLUS JPEG EXTENSION");
 
 			if (ResponseType.Ok != HigMessageDialog.RunHigConfirmation (
-				MainWindow.Toplevel.Window,
+				App.Instance.Organizer.Window,
 				DialogFlags.DestroyWithParent,
 				MessageType.Warning,
 				"Merge Raw+Jpegs",
@@ -62,7 +62,7 @@ namespace RawPlusJpegExtension
 			foreach (MergeRequest mr in merge_requests)
 				mr.Merge ();
 
-			MainWindow.Toplevel.UpdateQuery ();
+			App.Instance.Organizer.UpdateQuery ();
 		}
 
 		private static bool SamePlaceAndName (Photo p1, Photo p2)
diff --git a/extensions/Tools/RetroactiveRoll/RetroactiveRoll.cs b/extensions/Tools/RetroactiveRoll/RetroactiveRoll.cs
index 019713a..e184d00 100644
--- a/extensions/Tools/RetroactiveRoll/RetroactiveRoll.cs
+++ b/extensions/Tools/RetroactiveRoll/RetroactiveRoll.cs
@@ -21,7 +21,7 @@ namespace RetroactiveRoll
 	{
 		public void Run (object o, EventArgs e)
 		{
-			Photo[] photos = MainWindow.Toplevel.SelectedPhotos ();
+			Photo[] photos = App.Instance.Organizer.SelectedPhotos ();
 
 			if (photos.Length == 0) {
 				Console.WriteLine ("no photos selected, returning");
diff --git a/extensions/Tools/ScreensaverConfig/ScreensaverConfig.cs b/extensions/Tools/ScreensaverConfig/ScreensaverConfig.cs
index 8824ddf..3a3644d 100644
--- a/extensions/Tools/ScreensaverConfig/ScreensaverConfig.cs
+++ b/extensions/Tools/ScreensaverConfig/ScreensaverConfig.cs
@@ -61,7 +61,7 @@ namespace ScreensaverConfig
 					req.Width += 100;
 					args.Requisition = req;
 				};
-				TagMenu menu = new TagMenu (null, MainWindow.Toplevel.Database.Tags);
+				TagMenu menu = new TagMenu (null, App.Instance.Database.Tags);
 				menu.Populate (false);
 				menu.TagSelected += HandleTagSelected;
 				tag_button.Menu = menu;
@@ -88,7 +88,7 @@ namespace ScreensaverConfig
 					break;
 				case SCREENSAVER_TAG:
 					var screensaver_tag = Preferences.Get<int> (key);
-					Tag t = MainWindow.Toplevel.Database.Tags.GetTagById (screensaver_tag);
+					Tag t = App.Instance.Database.Tags.GetTagById (screensaver_tag);
 					if (screensaver_tag == 0 || t == null) {
 						all_radio.Active = true;
 						tag_button.Sensitive = false;
diff --git a/extensions/Tools/SyncCatalog/SyncCatalog.cs b/extensions/Tools/SyncCatalog/SyncCatalog.cs
index 45cc095..66030b4 100644
--- a/extensions/Tools/SyncCatalog/SyncCatalog.cs
+++ b/extensions/Tools/SyncCatalog/SyncCatalog.cs
@@ -46,7 +46,7 @@ namespace SyncCatalogExtension {
 			
 			RadioSelectedPhotos = new RadioButton ("Synchronize selected photos");
 			RadioEntireCatalog = new RadioButton (RadioSelectedPhotos, "Synchronize entire catalog");
-			if (MainWindow.Toplevel.SelectedPhotos ().Length > 0)
+			if (App.Instance.Organizer.SelectedPhotos ().Length > 0)
 				RadioSelectedPhotos.Active = true;
 			else
 				RadioEntireCatalog.Active = true;
@@ -78,7 +78,7 @@ namespace SyncCatalogExtension {
 					if (RadioEntireCatalog.Active)
 						photos = Core.Database.Photos.Query ();
 					else if (RadioSelectedPhotos.Active)
-						photos = MainWindow.Toplevel.SelectedPhotos ();
+						photos = App.Instance.Organizer.SelectedPhotos ();
 
 					this.Hide ();
 					foreach (Photo photo in photos) {
diff --git a/src/CameraFileSelectionDialog.cs b/src/CameraFileSelectionDialog.cs
index 491f0cc..d1a135e 100644
--- a/src/CameraFileSelectionDialog.cs
+++ b/src/CameraFileSelectionDialog.cs
@@ -96,7 +96,7 @@ namespace FSpot {
 		
 		private void CreateTagMenu ()
 		{
-			TagMenu tagmenu = new TagMenu (null, MainWindow.Toplevel.Database.Tags);
+			TagMenu tagmenu = new TagMenu (null, App.Instance.Database.Tags);
 			tagmenu.NewTagHandler = HandleNewTagSelected;
 			
 			tagmenu.Append (new MenuItem (Catalog.GetString ("Select Tag")));
@@ -116,7 +116,7 @@ namespace FSpot {
 
 		private void HandleNewTagSelected (object sender, EventArgs args)
 		{
-			Tag new_tag = MainWindow.Toplevel.CreateTag (Dialog, null);
+			Tag new_tag = App.Instance.Organizer.CreateTag (Dialog, null);
 			
 			if (new_tag != null) {
 				CreateTagMenu ();
diff --git a/src/Core/App.cs b/src/Core/App.cs
index c2207df..d82f4b6 100644
--- a/src/Core/App.cs
+++ b/src/Core/App.cs
@@ -221,7 +221,7 @@ namespace FSpot
 		void HandleShutdown ()
 		{
 			try {
-				MainWindow.Toplevel.Close ();
+				App.Instance.Organizer.Close ();
 			} catch {
 				System.Environment.Exit (0);
 			}
diff --git a/src/Editors/Editor.cs b/src/Editors/Editor.cs
index ef5a4db..86f82d2 100644
--- a/src/Editors/Editor.cs
+++ b/src/Editors/Editor.cs
@@ -205,7 +205,7 @@ namespace FSpot.Editors {
 			Pixbuf previewed = ProcessFast (preview, null);
 			State.PhotoImageView.Pixbuf = previewed;
 			State.PhotoImageView.ZoomFit (false);
-			MainWindow.Toplevel.InfoBox.UpdateHistogram (previewed);
+			App.Instance.Organizer.InfoBox.UpdateHistogram (previewed);
 
 			if (old_preview != null) {
 				old_preview.Dispose ();
@@ -238,7 +238,7 @@ namespace FSpot.Editors {
 				State.PhotoImageView.Pixbuf = original;
 				State.PhotoImageView.ZoomFit (false);
 
-				MainWindow.Toplevel.InfoBox.UpdateHistogram (null);
+				App.Instance.Organizer.InfoBox.UpdateHistogram (null);
 			}
 
 			Reset ();
diff --git a/src/Extensions/PhotoSelectionCondition.cs b/src/Extensions/PhotoSelectionCondition.cs
index 4ac1062..74848c1 100644
--- a/src/Extensions/PhotoSelectionCondition.cs
+++ b/src/Extensions/PhotoSelectionCondition.cs
@@ -23,13 +23,13 @@ namespace FSpot.Extensions
 	{
 		public PhotoSelectionCondition()
 		{
-			if (MainWindow.Toplevel != null)
-				MainWindow.Toplevel.Selection.Changed += delegate { NotifyChanged ();};
+			if (App.Instance.Organizer != null)
+				App.Instance.Organizer.Selection.Changed += delegate { NotifyChanged ();};
 		}
 
 		public override bool Evaluate (NodeElement conditionNode)
 		{
-			int count = MainWindow.Toplevel.Selection.Count;
+			int count = App.Instance.Organizer.Selection.Count;
 			string val = conditionNode.GetAttribute ("selection");
 			if (val.Length > 0) {
 				foreach (string selection in val.Split(',')) {
diff --git a/src/Extensions/PopupCommands.cs b/src/Extensions/PopupCommands.cs
index 787533b..2da7b79 100644
--- a/src/Extensions/PopupCommands.cs
+++ b/src/Extensions/PopupCommands.cs
@@ -18,7 +18,7 @@ namespace FSpot.Extensions
 	{
 		public void Run (object o, EventArgs e)
 		{
-			MainWindow.Toplevel.HandleCopy (o, e);
+			App.Instance.Organizer.HandleCopy (o, e);
 		}		
 	}
 
@@ -26,7 +26,7 @@ namespace FSpot.Extensions
 	{
 		public void Run (object o, EventArgs e)
 		{
-			MainWindow.Toplevel.HandleRotate270Command (o, e);
+			App.Instance.Organizer.HandleRotate270Command (o, e);
 		}
 	}
 
@@ -34,7 +34,7 @@ namespace FSpot.Extensions
 	{
 		public void Run (object o, EventArgs e)
 		{
-			MainWindow.Toplevel.HandleRotate90Command (o, e);
+			App.Instance.Organizer.HandleRotate90Command (o, e);
 		}
 	}
 
@@ -42,7 +42,7 @@ namespace FSpot.Extensions
 	{
 		public void Run (object o, EventArgs e)
 		{
-			MainWindow.Toplevel.HandleRemoveCommand (o, e);
+			App.Instance.Organizer.HandleRemoveCommand (o, e);
 		}
 	}
 
@@ -50,7 +50,7 @@ namespace FSpot.Extensions
 	{
 		public void Run (object o, EventArgs e)
 		{
-			MainWindow.Toplevel.HandleDeleteCommand (o, e);
+			App.Instance.Organizer.HandleDeleteCommand (o, e);
 		}
 	}
 
@@ -60,8 +60,8 @@ namespace FSpot.Extensions
 
 		public Gtk.Menu GetMenu ()
 		{
-			owm = new Widgets.OpenWithMenu (MainWindow.Toplevel.SelectedMimeTypes, "f-spot");
-			owm.ApplicationActivated += MainWindow.Toplevel.HandleOpenWith;
+			owm = new Widgets.OpenWithMenu (App.Instance.Organizer.SelectedMimeTypes, "f-spot");
+			owm.ApplicationActivated += App.Instance.Organizer.HandleOpenWith;
 			return (Gtk.Menu) owm;
 		}
 
@@ -78,9 +78,9 @@ namespace FSpot.Extensions
 
 		public Gtk.Menu GetMenu ()
 		{
-			tag_menu = new TagMenu (null, MainWindow.Toplevel.Database.Tags);
-			tag_menu.NewTagHandler += delegate { MainWindow.Toplevel.HandleCreateTagAndAttach (this, null); };
-			tag_menu.TagSelected += MainWindow.Toplevel.HandleAttachTagMenuSelected;
+			tag_menu = new TagMenu (null, App.Instance.Database.Tags);
+			tag_menu.NewTagHandler += delegate { App.Instance.Organizer.HandleCreateTagAndAttach (this, null); };
+			tag_menu.TagSelected += App.Instance.Organizer.HandleAttachTagMenuSelected;
 			return (Gtk.Menu) tag_menu;
 		}
 
@@ -96,13 +96,13 @@ namespace FSpot.Extensions
 		public Gtk.Menu GetMenu ()
 		{
 			PhotoTagMenu tag_menu = new PhotoTagMenu ();
-			tag_menu.TagSelected += MainWindow.Toplevel.HandleRemoveTagMenuSelected;
+			tag_menu.TagSelected += App.Instance.Organizer.HandleRemoveTagMenuSelected;
 			return (Gtk.Menu) tag_menu;
 		}
 
 		public void OnActivated (object o, EventArgs e)
 		{
-			MainWindow.Toplevel.HandleTagMenuActivate (o, e);
+			App.Instance.Organizer.HandleTagMenuActivate (o, e);
 		}
 	}
 
@@ -110,7 +110,7 @@ namespace FSpot.Extensions
 	{
 		public void Run (object o, EventArgs e)
 		{
-			MainWindow.Toplevel.HandleRatingMenuSelected ((o as Widgets.Rating).Value);
+			App.Instance.Organizer.HandleRatingMenuSelected ((o as Widgets.Rating).Value);
 		}
 	}
 }
diff --git a/src/GroupSelector.cs b/src/GroupSelector.cs
index fbaf8c9..7cc52ae 100644
--- a/src/GroupSelector.cs
+++ b/src/GroupSelector.cs
@@ -512,10 +512,10 @@ namespace FSpot {
 		{
 			Gtk.Menu order_menu = new Gtk.Menu();
 			
-			order_menu.Append (MainWindow.Toplevel.ReverseOrderAction.CreateMenuItem ());
+			order_menu.Append (App.Instance.Organizer.ReverseOrderAction.CreateMenuItem ());
 
 			GtkUtil.MakeMenuItem (order_menu, Catalog.GetString ("_Clear Date Range"), 
-						MainWindow.Toplevel.HandleClearDateRange);
+						App.Instance.Organizer.HandleClearDateRange);
 			
 			if (args != null)
 				order_menu.Popup (null, null, null, args.Button, args.Time);
diff --git a/src/ImportCommand.cs b/src/ImportCommand.cs
index 16e1d27..dd903c8 100644
--- a/src/ImportCommand.cs
+++ b/src/ImportCommand.cs
@@ -389,7 +389,7 @@ public class ImportCommand : GladeDialog
 				string port = "gphoto2:" + csource.Port;
 				this.Cancel ();
 				this.Dialog.Destroy ();
-				MainWindow.Toplevel.ImportCamera (port);
+				App.Instance.Organizer.ImportCamera (port);
 			}
 
 			idle_start.Start ();
@@ -641,7 +641,7 @@ public class ImportCommand : GladeDialog
 		photo_view.Pixbuf = GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 128, (Gtk.IconLookupFlags)0);
 		photo_view.ZoomFit (false);
 			
-		tag_entry = new FSpot.Widgets.TagEntry (MainWindow.Toplevel.Database.Tags, false);
+		tag_entry = new FSpot.Widgets.TagEntry (App.Instance.Database.Tags, false);
 		tag_entry.UpdateFromTagNames (new string []{});
 		tagentry_box.Add (tag_entry);
 
@@ -730,7 +730,7 @@ public class ImportCommand : GladeDialog
 			return;
 
 		tags_selected = new ArrayList ();
-		Db db = MainWindow.Toplevel.Database;	
+		Db db = App.Instance.Database;	
 		db.BeginTransaction ();
 		foreach (string tagname in new_tags) {
 			Tag t = db.Tags.GetTagByName (tagname);
diff --git a/src/Loupe.cs b/src/Loupe.cs
index af36848..b3e417e 100644
--- a/src/Loupe.cs
+++ b/src/Loupe.cs
@@ -438,7 +438,7 @@ namespace FSpot.Widgets {
 				break;
 			case Gdk.EventType.TwoButtonPress:
 				dragging = false;
-				MainWindow.Toplevel.HideLoupe ();
+				App.Instance.Organizer.HideLoupe ();
 				break;
 			}
 		}
@@ -457,7 +457,7 @@ namespace FSpot.Widgets {
 		{
 			switch (args.Event.Key) {
 			case Gdk.Key.v:
-				MainWindow.Toplevel.HideLoupe ();
+				App.Instance.Organizer.HideLoupe ();
 				args.RetVal = true;
 				break;
 			default:
diff --git a/src/MainWindow.cs b/src/MainWindow.cs
index f7455e3..4480624 100644
--- a/src/MainWindow.cs
+++ b/src/MainWindow.cs
@@ -33,7 +33,6 @@ namespace FSpot
 {
 	public class MainWindow
 	{
-		public static MainWindow Toplevel;
 		public Sidebar Sidebar { get; private set; }
 	
 		TagSelectionWidget tag_selection_widget;
@@ -218,11 +217,6 @@ namespace FSpot
 		public MainSelection Selection { get; private set; }
 		public InfoBox InfoBox { get; private set; }
 	
-		public MenuItem FindByTag {
-			get { return uimanager.GetWidget ("/ui/menubar1/find/find_by_tag") as MenuItem; }
-		}
-	
-	
 		//
 		// Constructor
 		//
@@ -270,9 +264,6 @@ namespace FSpot
 #endif
 			Database = db;
 	
-			if (Toplevel == null)
-				Toplevel = this;
-	
 			GtkBeans.Builder builder = new GtkBeans.Builder ("main_window.ui");
 			builder.Autoconnect (this);
 
@@ -434,6 +425,14 @@ namespace FSpot
 			query_widget.Logic.Changed += HandleQueryLogicChanged;
 			view_vbox.PackStart (query_widget, false, false, 0);
 			view_vbox.ReorderChild (query_widget, 2);
+			
+			MenuItem findByTag = uimanager.GetWidget ("/ui/menubar1/find/find_by_tag") as MenuItem;
+			query_widget.Hidden += delegate (object sender, EventArgs args) {
+				((Gtk.Label)findByTag.Child).TextWithMnemonic = Catalog.GetString ("Show _Find Bar");
+			};
+			query_widget.Shown += delegate (object sender, EventArgs args) {
+				((Gtk.Label)findByTag.Child).TextWithMnemonic = Catalog.GetString ("Hide _Find Bar");
+			};
 	
 			icon_view = new QueryView (query);
 			icon_view.ZoomChanged += HandleZoomChanged;
@@ -1586,7 +1585,7 @@ namespace FSpot
 	
 		public static void HandleHelp (object sender, EventArgs args)
 		{
-			GtkBeans.Global.ShowUri (Toplevel.Window.Screen, "ghelp:f-spot");
+			GtkBeans.Global.ShowUri (App.Instance.Organizer.Window.Screen, "ghelp:f-spot");
 		}
 	
 		public static void HandleAbout (object sender, EventArgs args)
@@ -2291,7 +2290,7 @@ namespace FSpot
 			System.Array.Sort (tags, new TagRemoveComparer ());
 		
 			//How many pictures are associated to these tags?
-			Db db = MainWindow.Toplevel.Database;
+			Db db = App.Instance.Database;
 			FSpot.PhotoQuery count_query = new FSpot.PhotoQuery(db.Photos);
 			count_query.Terms = FSpot.OrTerm.FromTags(tags);
 			int associated_photos = count_query.Count;
diff --git a/src/PhotoVersionCommands.cs b/src/PhotoVersionCommands.cs
index 0a10a68..ef1d27f 100644
--- a/src/PhotoVersionCommands.cs
+++ b/src/PhotoVersionCommands.cs
@@ -233,7 +233,7 @@ public class PhotoVersionCommands
 						Log.DebugException (e);
 					}
 				}
-				MainWindow.Toplevel.Database.Photos.Remove (photo);
+				App.Instance.Database.Photos.Remove (photo);
 			}
 			return true;
 		}
diff --git a/src/QueryWidget.cs b/src/QueryWidget.cs
index c77e5e5..271ea81 100644
--- a/src/QueryWidget.cs
+++ b/src/QueryWidget.cs
@@ -152,13 +152,11 @@ namespace FSpot {
 		public void ShowBar ()
 		{
 			Show ();
-			((Gtk.Label)MainWindow.Toplevel.FindByTag.Child).TextWithMnemonic = Catalog.GetString ("Hide _Find Bar");
 		}
 
 		public void HideBar ()
 		{
 			Hide ();
-			((Gtk.Label)MainWindow.Toplevel.FindByTag.Child).TextWithMnemonic = Catalog.GetString ("Show _Find Bar");
 		}
 
 		public void HandleChanged (IBrowsableCollection collection) 
diff --git a/src/SelectionDataExtensions.cs b/src/SelectionDataExtensions.cs
index d9d4634..83206cb 100644
--- a/src/SelectionDataExtensions.cs
+++ b/src/SelectionDataExtensions.cs
@@ -43,7 +43,7 @@ namespace FSpot
 			int size = sizeof (uint);
 			int length = selection_data.Length / size;
 			
-			PhotoStore photo_store = MainWindow.Toplevel.Database.Photos;
+			PhotoStore photo_store = App.Instance.Database.Photos;
 
 			Photo [] photos = new Photo [length];
 			
@@ -77,7 +77,7 @@ namespace FSpot
 			int size = sizeof (uint);
 			int length = selection_data.Length / size;
 			
-			TagStore tag_store = MainWindow.Toplevel.Database.Tags;
+			TagStore tag_store = App.Instance.Database.Tags;
 
 			Tag [] tags = new Tag [length];
 			
diff --git a/src/TagPopup.cs b/src/TagPopup.cs
index ab6bb5b..1d67cac 100644
--- a/src/TagPopup.cs
+++ b/src/TagPopup.cs
@@ -17,7 +17,7 @@ using FSpot.Utils;
 public class TagPopup {
 	public void Activate (Gdk.EventButton eb, Tag tag, Tag [] tags)
 	{
-		int photo_count = MainWindow.Toplevel.SelectedPhotos ().Length;
+		int photo_count = App.Instance.Organizer.SelectedPhotos ().Length;
 		int tags_count = tags.Length;
 
 		Gtk.Menu popup_menu = new Gtk.Menu ();
@@ -25,7 +25,7 @@ public class TagPopup {
 		GtkUtil.MakeMenuItem (popup_menu,
                 String.Format (Catalog.GetPluralString ("Find", "Find", tags.Length), tags.Length),
                 "gtk-add",
-                new EventHandler (MainWindow.Toplevel.HandleIncludeTag),
+                new EventHandler (App.Instance.Organizer.HandleIncludeTag),
                 true
         );
 
@@ -34,33 +34,33 @@ public class TagPopup {
 		GtkUtil.MakeMenuSeparator (popup_menu);
 		
 		GtkUtil.MakeMenuItem (popup_menu, Catalog.GetString ("Create New Tag..."), "tag-new",
-				      MainWindow.Toplevel.HandleCreateNewCategoryCommand, true);
+				      App.Instance.Organizer.HandleCreateNewCategoryCommand, true);
 
         GtkUtil.MakeMenuSeparator (popup_menu);
 		
 		GtkUtil.MakeMenuItem (popup_menu,
 			Catalog.GetString ("Edit Tag..."), "gtk-edit",
-			delegate { MainWindow.Toplevel.HandleEditSelectedTagWithTag (tag); }, tag != null && tags_count == 1);
+			delegate { App.Instance.Organizer.HandleEditSelectedTagWithTag (tag); }, tag != null && tags_count == 1);
 
 		GtkUtil.MakeMenuItem (popup_menu,
 			Catalog.GetPluralString ("Delete Tag", "Delete Tags", tags_count), "gtk-delete",
-			new EventHandler (MainWindow.Toplevel.HandleDeleteSelectedTagCommand), tag != null);
+			new EventHandler (App.Instance.Organizer.HandleDeleteSelectedTagCommand), tag != null);
 		
 		GtkUtil.MakeMenuSeparator (popup_menu);
 
 		GtkUtil.MakeMenuItem (popup_menu,
 				      Catalog.GetPluralString ("Attach Tag to Selection", "Attach Tags to Selection", tags_count), "gtk-add",
-				      new EventHandler (MainWindow.Toplevel.HandleAttachTagCommand), tag != null && photo_count > 0);
+				      new EventHandler (App.Instance.Organizer.HandleAttachTagCommand), tag != null && photo_count > 0);
 
 		GtkUtil.MakeMenuItem (popup_menu,
 				      Catalog.GetPluralString ("Remove Tag From Selection", "Remove Tags From Selection", tags_count), "gtk-remove",
-				      new EventHandler (MainWindow.Toplevel.HandleRemoveTagCommand), tag != null && photo_count > 0);
+				      new EventHandler (App.Instance.Organizer.HandleRemoveTagCommand), tag != null && photo_count > 0);
 
 		if (tags_count > 1 && tag != null) {
 			GtkUtil.MakeMenuSeparator (popup_menu);
 
 			GtkUtil.MakeMenuItem (popup_menu, Catalog.GetString ("Merge Tags"),
-					      new EventHandler (MainWindow.Toplevel.HandleMergeTagsCommand), true);
+					      new EventHandler (App.Instance.Organizer.HandleMergeTagsCommand), true);
 
 		}
 
diff --git a/src/TagQueryWidget.cs b/src/TagQueryWidget.cs
index 6ddddb4..a48f12d 100644
--- a/src/TagQueryWidget.cs
+++ b/src/TagQueryWidget.cs
@@ -24,7 +24,7 @@ namespace FSpot
 			//this.literal = literal;
 
 			/*MenuItem attach_item = new MenuItem (Catalog.GetString ("Find With"));
-			TagMenu attach_menu = new TagMenu (attach_item, MainWindow.Toplevel.Database.Tags);
+			TagMenu attach_menu = new TagMenu (attach_item, App.Instance.Database.Tags);
 			attach_menu.TagSelected += literal.HandleAttachTagCommand;
 			attach_item.ShowAll ();
 			popup_menu.Append (attach_item);*/
@@ -111,7 +111,7 @@ namespace FSpot
 				//Console.WriteLine ("root is not null and has terms");
 				Gtk.Menu m = new Gtk.Menu ();
 
-				Gtk.MenuItem all_item = GtkUtil.MakeMenuItem (m, Catalog.GetString ("All"), new EventHandler (MainWindow.Toplevel.HandleRequireTag));
+				Gtk.MenuItem all_item = GtkUtil.MakeMenuItem (m, Catalog.GetString ("All"), new EventHandler (App.Instance.Organizer.HandleRequireTag));
 				GtkUtil.MakeMenuSeparator (m);
 
 				int sensitive_items = 0;
@@ -122,7 +122,7 @@ namespace FSpot
 
 					string name = "_" + String.Join (", ", (string []) term_parts.ToArray (typeof(string)));
 
-					Gtk.MenuItem item = GtkUtil.MakeMenuItem (m, name, new EventHandler (MainWindow.Toplevel.HandleAddTagToTerm));
+					Gtk.MenuItem item = GtkUtil.MakeMenuItem (m, name, new EventHandler (App.Instance.Organizer.HandleAddTagToTerm));
 					item.Sensitive = !contains_tag;
 
 					if (!contains_tag)
diff --git a/src/TagSelectionWidget.cs b/src/TagSelectionWidget.cs
index eb3dbac..9f09a09 100644
--- a/src/TagSelectionWidget.cs
+++ b/src/TagSelectionWidget.cs
@@ -491,7 +491,7 @@ namespace FSpot {
 			// Check that the tag doesn't already exist
 			if (String.Compare (args.NewText, tag.Name, true) != 0 &&
 			    tag_store.GetTagByName (args.NewText) != null) {
-				HigMessageDialog md = new HigMessageDialog (MainWindow.Toplevel.Window,
+				HigMessageDialog md = new HigMessageDialog (App.Instance.Organizer.Window,
 					DialogFlags.DestroyWithParent, 
 					MessageType.Warning, ButtonsType.Ok, 
 					Catalog.GetString ("Error renaming tag"),
@@ -533,7 +533,7 @@ namespace FSpot {
 		public TagSelectionWidget (TagStore tag_store)
 			: base (new TreeStore (typeof(uint), typeof(string)))
 		{
-			database = MainWindow.Toplevel.Database;
+			database = App.Instance.Database;
 			
 			HeadersVisible = false;
 	
diff --git a/src/Widgets/EditorPage.cs b/src/Widgets/EditorPage.cs
index bb4664a..ee15799 100644
--- a/src/Widgets/EditorPage.cs
+++ b/src/Widgets/EditorPage.cs
@@ -87,7 +87,7 @@ namespace FSpot.Widgets {
 		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, App.Instance.Organizer.Window);
 		}
 
 		private void OnProcessingStep (int done) {
@@ -172,7 +172,7 @@ namespace FSpot.Widgets {
 		private bool SetupEditor (Editor editor) {
 			EditorState state = editor.CreateState ();
 
-			PhotoImageView photo_view = MainWindow.Toplevel.PhotoView.View;
+			PhotoImageView photo_view = App.Instance.Organizer.PhotoView.View;
 
 			if (Page.InPhotoView && photo_view != null) {
 				state.Selection = photo_view.Selection;
@@ -197,7 +197,7 @@ namespace FSpot.Widgets {
 				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 (App.Instance.Organizer.Window,
 										DialogFlags.DestroyWithParent,
 										Gtk.MessageType.Error, ButtonsType.Ok,
 										msg,
@@ -218,7 +218,7 @@ namespace FSpot.Widgets {
 				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 (App.Instance.Organizer.Window,
 									    DialogFlags.DestroyWithParent,
 									    Gtk.MessageType.Error, ButtonsType.Ok,
 									    msg,
diff --git a/src/Widgets/Filmstrip.cs b/src/Widgets/Filmstrip.cs
index 074c399..f6967cf 100644
--- a/src/Widgets/Filmstrip.cs
+++ b/src/Widgets/Filmstrip.cs
@@ -570,11 +570,11 @@ namespace FSpot.Widgets
 			Gtk.Menu placement_menu = new Gtk.Menu ();
 			GtkUtil.MakeCheckMenuItem (placement_menu, 
 							Mono.Unix.Catalog.GetString ("_Horizontal"), 
-							MainWindow.Toplevel.HandleFilmstripHorizontal, 
+							App.Instance.Organizer.HandleFilmstripHorizontal, 
 							true, Orientation == Orientation.Horizontal, true);
 			GtkUtil.MakeCheckMenuItem (placement_menu, 
 							Mono.Unix.Catalog.GetString ("_Vertical"), 
-							MainWindow.Toplevel.HandleFilmstripVertical, 
+							App.Instance.Organizer.HandleFilmstripVertical, 
 							true, Orientation == Orientation.Vertical, true);
 
 			if (args != null)
diff --git a/src/Widgets/FindBar.cs b/src/Widgets/FindBar.cs
index 13a4c20..31e2ade 100644
--- a/src/Widgets/FindBar.cs
+++ b/src/Widgets/FindBar.cs
@@ -269,7 +269,7 @@ namespace FSpot.Widgets {
 
 				is_negated = is_negated || negated;
 
-				tag = MainWindow.Toplevel.Database.Tags.GetTagByName (literal);
+				tag = App.Instance.Database.Tags.GetTagByName (literal);
 
 				// New OR term so we can match against both tag and text search
 				parent = new OrTerm(parent, null);
diff --git a/src/Widgets/FolderTreeModel.cs b/src/Widgets/FolderTreeModel.cs
index 17479d5..6b857ce 100644
--- a/src/Widgets/FolderTreeModel.cs
+++ b/src/Widgets/FolderTreeModel.cs
@@ -37,7 +37,7 @@ namespace FSpot.Widgets
 		public FolderTreeModel ()
 			: base (typeof (string), typeof (int), typeof (Uri))
 		{
-			database = MainWindow.Toplevel.Database;
+			database = App.Instance.Database;
 			database.Photos.ItemsChanged += HandlePhotoItemsChanged;
 			
 			UpdateFolderTree ();
diff --git a/src/Widgets/FolderTreeView.cs b/src/Widgets/FolderTreeView.cs
index f443574..bedc0eb 100644
--- a/src/Widgets/FolderTreeView.cs
+++ b/src/Widgets/FolderTreeView.cs
@@ -163,7 +163,7 @@ namespace FSpot.Widgets
 		
 		protected override void OnRowActivated (Gtk.TreePath path, Gtk.TreeViewColumn column)
 		{
-			MainWindow.Toplevel.SetFolderQuery (SelectedUris);	
+			App.Instance.Organizer.SetFolderQuery (SelectedUris);	
 		}
 
 	}
diff --git a/src/Widgets/InfoBox.cs b/src/Widgets/InfoBox.cs
index afac668..4595db2 100644
--- a/src/Widgets/InfoBox.cs
+++ b/src/Widgets/InfoBox.cs
@@ -144,7 +144,7 @@ namespace FSpot.Widgets
 
 		private void HandleRatingChanged (object o, EventArgs e)
 		{
-			MainWindow.Toplevel.HandleRatingMenuSelected ((o as Widgets.Rating).Value);
+			App.Instance.Organizer.HandleRatingMenuSelected ((o as Widgets.Rating).Value);
 	 	}
 	
 		private Label CreateRightAlignedLabel (string text)
@@ -747,7 +747,7 @@ namespace FSpot.Widgets
 	
 		public void HandleMainWindowViewModeChanged (object o, EventArgs args)
 		{
-			MainWindow.ModeType mode = MainWindow.Toplevel.ViewMode;
+			MainWindow.ModeType mode = App.Instance.Organizer.ViewMode;
 			if (mode == MainWindow.ModeType.IconView)
 				Context = ViewContext.Library;
 			else if (mode == MainWindow.ModeType.PhotoView)
diff --git a/src/Widgets/RatingMenuItem.cs b/src/Widgets/RatingMenuItem.cs
index 4d1c9f6..775e91f 100644
--- a/src/Widgets/RatingMenuItem.cs
+++ b/src/Widgets/RatingMenuItem.cs
@@ -60,8 +60,8 @@ namespace FSpot.Widgets
 				FSpot.Utils.Log.Debug ("PARENT IS FSVIEW");
 				FullScreenView fsview = parent as FullScreenView;
 				entry = new Rating ((int)fsview.View.Item.Current.Rating, true);
-			} else if (MainWindow.Toplevel.Selection.Count == 1)
-				entry = new Rating ((int)MainWindow.Toplevel.Selection[0].Rating, true);
+			} else if (App.Instance.Organizer.Selection.Count == 1)
+				entry = new Rating ((int)App.Instance.Organizer.Selection[0].Rating, true);
 			else
 				entry = new Rating (-1, true);
 			entry.Changed += OnEntryChanged;
diff --git a/src/Widgets/Sidebar.cs b/src/Widgets/Sidebar.cs
index 75b9ddc..5b4b6ac 100644
--- a/src/Widgets/Sidebar.cs
+++ b/src/Widgets/Sidebar.cs
@@ -190,7 +190,7 @@ namespace FSpot.Widgets
 
 		public void HandleMainWindowViewModeChanged (object o, EventArgs args)
 		{
-			MainWindow.ModeType mode = MainWindow.Toplevel.ViewMode;
+			MainWindow.ModeType mode = App.Instance.Organizer.ViewMode;
 			if (mode == MainWindow.ModeType.IconView) 
 				Context = ViewContext.Library;
 			else if (mode == MainWindow.ModeType.PhotoView)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]