Example #1
0
            public ScreensaverConfigDialog() : base(Assembly.GetExecutingAssembly(), "ScreensaverConfigDialog.ui", "screensaver-config-dialog")
            {
                delay_adjustment = new Adjustment(default_delay, 1.0, 20.0, .5, 5, 0);
                LoadPreference(SCREENSAVER_DELAY);
                delay_scale.Adjustment         = delay_adjustment;
                delay_adjustment.ValueChanged += HandleDelayChanged;

                tag_button = new MenuButton();
                tag_button.SizeRequested += delegate(object sender, SizeRequestedArgs args) {
                    var req = args.Requisition;
                    req.Width       += 100;
                    args.Requisition = req;
                };
                TagMenu menu = new TagMenu(null, App.Instance.Database.Tags);

                menu.Populate(false);
                menu.TagSelected += HandleTagSelected;
                tag_button.Menu   = menu;
                tag_button.ShowAll();
                table.Attach(tag_button, 2, 3, 1, 2);
                LoadPreference(SCREENSAVER_TAG);
                all_radio.Toggled += HandleTagRadioToggled;

                do_button.Clicked += HandleUseFSpot;
            }
 public void OnActivated(object o, EventArgs e)
 {
     if (tag_menu != null)
     {
         tag_menu.Populate();
     }
 }
Example #3
0
        public PreferenceDialog() : base("main_preferences")
        {
            LoadPreference(Preferences.METADATA_EMBED_IN_IMAGE);
            LoadPreference(Preferences.SCREENSAVER_TAG);
            LoadPreference(Preferences.GNOME_SCREENSAVER_THEME);
            if (!Global.CustomPhotoDirectory)
            {
                photosdir_chooser.CurrentFolderChanged += HandlePhotosdirChanged;
                photosdir_chooser.SetCurrentFolder(Global.PhotoDirectory);
            }
            else
            {
                photosdir_chooser.SetCurrentFolder(Global.PhotoDirectory);
                photosdir_chooser.Sensitive = false;
            }

            Gtk.CellRendererText name_cell = new Gtk.CellRendererText();
            Gtk.CellRendererText desc_cell = new Gtk.CellRendererText();

            display_combo.Model = new ProfileList();
            display_combo.PackStart(desc_cell, false);
            display_combo.PackStart(name_cell, true);
            display_combo.SetCellDataFunc(name_cell, new CellLayoutDataFunc(ProfileList.ProfileNameDataFunc));
            display_combo.SetCellDataFunc(desc_cell, new CellLayoutDataFunc(ProfileList.ProfileDescriptionDataFunc));
            display_combo.Changed += HandleDisplayChanged;

            destination_combo.Model = new ProfileList();
            destination_combo.PackStart(desc_cell, false);
            destination_combo.PackStart(name_cell, true);
            destination_combo.SetCellDataFunc(name_cell, new CellLayoutDataFunc(ProfileList.ProfileNameDataFunc));
            destination_combo.SetCellDataFunc(desc_cell, new CellLayoutDataFunc(ProfileList.ProfileDescriptionDataFunc));
            destination_combo.Changed += HandleDisplayChanged;

            Tag     t       = MainWindow.Toplevel.Database.Tags.GetTagById(screensaver_tag);
            TagMenu tagmenu = new TagMenu(null, MainWindow.Toplevel.Database.Tags);

            tagmenu.Populate(true);
            tag_option.Menu = tagmenu;

            int history = tagmenu.GetPosition(t);

            if (history >= 0)
            {
                tag_option.SetHistory((uint)history);
            }

            tagmenu.TagSelected          += HandleTagMenuSelected;
            set_saver_button.Clicked     += HandleUseFSpot;
            screensaverall_radio.Toggled += ToggleTagRadio;

            Preferences.SettingChanged += OnPreferencesChanged;
            this.Dialog.Destroyed      += HandleDestroyed;
        }
Example #4
0
        void ShowTagMenuFor(Widget widget, TagMenu.TagSelectedHandler handler)
        {
            TagMenu tag_menu = new TagMenu(null, App.Instance.Database.Tags);

            tag_menu.TagSelected += handler;
            tag_menu.Populate();
            int x, y;

            GetPosition(out x, out y);
            x += widget.Allocation.X; y += widget.Allocation.Y;
            tag_menu.Popup(null, null, delegate(Menu menu, out int x_, out int y_, out bool push_in) { x_ = x; y_ = y; push_in = true; }, 0, 0);
        }
        private void CreateTagMenu()
        {
            TagMenu tagmenu = new TagMenu(null, MainWindow.Toplevel.Database.Tags);

            tagmenu.NewTagHandler = HandleNewTagSelected;

            tagmenu.Append(new MenuItem(Catalog.GetString("Select Tag")));

            tagmenu.Populate(true);

            tagmenu.TagSelected += HandleTagMenuSelected;

            tagmenu.ShowAll();
            tag_option_menu.Menu = tagmenu;
        }
		public PreferenceDialog () : base ("main_preferences")
		{
			LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);
			LoadPreference (Preferences.SCREENSAVER_TAG);
			LoadPreference (Preferences.GNOME_SCREENSAVER_THEME);
			if (!Global.CustomPhotoDirectory) {
				photosdir_chooser.CurrentFolderChanged += HandlePhotosdirChanged;
				photosdir_chooser.SetCurrentFolder (Global.PhotoDirectory);
			} else {
				photosdir_chooser.SetCurrentFolder(Global.PhotoDirectory);
				photosdir_chooser.Sensitive = false;
			}

			Gtk.CellRendererText name_cell = new Gtk.CellRendererText ();
			Gtk.CellRendererText desc_cell = new Gtk.CellRendererText ();
			
			display_combo.Model = new ProfileList ();
			display_combo.PackStart (desc_cell, false);
			display_combo.PackStart (name_cell, true);
			display_combo.SetCellDataFunc (name_cell, new CellLayoutDataFunc (ProfileList.ProfileNameDataFunc));
			display_combo.SetCellDataFunc (desc_cell, new CellLayoutDataFunc (ProfileList.ProfileDescriptionDataFunc));
			display_combo.Changed += HandleDisplayChanged;

			destination_combo.Model = new ProfileList ();
			destination_combo.PackStart (desc_cell, false);
			destination_combo.PackStart (name_cell, true);
			destination_combo.SetCellDataFunc (name_cell, new CellLayoutDataFunc (ProfileList.ProfileNameDataFunc));
			destination_combo.SetCellDataFunc (desc_cell, new CellLayoutDataFunc (ProfileList.ProfileDescriptionDataFunc));
			destination_combo.Changed += HandleDisplayChanged;

			Tag t = MainWindow.Toplevel.Database.Tags.GetTagById (screensaver_tag);
			TagMenu tagmenu = new TagMenu (null, MainWindow.Toplevel.Database.Tags);
	
			tagmenu.Populate (true);
			tag_option.Menu = tagmenu;

			int history = tagmenu.GetPosition (t);
			if (history >= 0)
				tag_option.SetHistory ((uint)history);

			tagmenu.TagSelected += HandleTagMenuSelected;
			set_saver_button.Clicked += HandleUseFSpot;
			screensaverall_radio.Toggled += ToggleTagRadio;

			Preferences.SettingChanged += OnPreferencesChanged;
			this.Dialog.Destroyed += HandleDestroyed;
		}
Example #7
0
            public ScreensaverConfigDialog()
                : base(Assembly.GetExecutingAssembly (), "ScreensaverConfigDialog.ui", "screensaver-config-dialog")
            {
                delay_adjustment = new Adjustment (default_delay, 1.0, 20.0, .5, 5, 0);
                LoadPreference (SCREENSAVER_DELAY);
                delay_scale.Adjustment = delay_adjustment;
                delay_adjustment.ValueChanged += HandleDelayChanged;

                tag_button = new MenuButton ();
                tag_button.SizeRequested += delegate (object sender, SizeRequestedArgs args) {
                    var req = args.Requisition;
                    req.Width += 100;
                    args.Requisition = req;
                };
                TagMenu menu = new TagMenu (null, App.Instance.Database.Tags);
                menu.Populate (false);
                menu.TagSelected += HandleTagSelected;
                tag_button.Menu = menu;
                tag_button.ShowAll ();
                table.Attach (tag_button, 2, 3, 1, 2);
                LoadPreference (SCREENSAVER_TAG);
                all_radio.Toggled += HandleTagRadioToggled;

                do_button.Clicked += HandleUseFSpot;
            }
Example #8
0
 void ShowTagMenuFor(Widget widget, TagMenu.TagSelectedHandler handler)
 {
     TagMenu tag_menu = new TagMenu (null, App.Instance.Database.Tags);
     tag_menu.TagSelected += handler;
     tag_menu.Populate ();
     int x, y;
     GetPosition (out x, out y);
     x += widget.Allocation.X; y += widget.Allocation.Y;
     tag_menu.Popup (null, null, delegate (Menu menu, out int x_, out int y_, out bool push_in) {x_ = x; y_ = y; push_in = true;}, 0, 0);
 }
        public PreferenceDialog() : base("main_preferences")
        {
            tag_button = new MenuButton();
            LoadPreference(Preferences.METADATA_EMBED_IN_IMAGE);
            LoadPreference(Preferences.COLOR_MANAGEMENT_ENABLED);
            LoadPreference(Preferences.COLOR_MANAGEMENT_USE_X_PROFILE);
            LoadPreference(Preferences.SCREENSAVER_TAG);
            LoadPreference(Preferences.GNOME_SCREENSAVER_THEME);
            if (Global.PhotoDirectory == Preferences.Get <string> (Preferences.STORAGE_PATH))
            {
                photosdir_chooser.CurrentFolderChanged += HandlePhotosdirChanged;
                photosdir_chooser.SetCurrentFolder(Global.PhotoDirectory);
            }
            else
            {
                photosdir_chooser.SetCurrentFolder(Global.PhotoDirectory);
                photosdir_chooser.Sensitive = false;
            }

            Gtk.CellRendererText name_cell = new Gtk.CellRendererText();
            Gtk.CellRendererText desc_cell = new Gtk.CellRendererText();

            use_x_profile_check.Sensitive = colormanagement_check.Active;

            display_combo.Sensitive = colormanagement_check.Active;
            display_combo.Model     = new ProfileList();
            display_combo.PackStart(desc_cell, false);
            display_combo.PackStart(name_cell, true);
            display_combo.SetCellDataFunc(name_cell, new CellLayoutDataFunc(ProfileList.ProfileNameDataFunc));
            //FIXME
            int it_ = 0;

            foreach (Cms.Profile profile in FSpot.ColorManagement.Profiles)
            {
                if (profile.ProductName == Preferences.Get <string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE))
                {
                    display_combo.Active = it_;
                }
                it_++;
            }

            display_combo.Changed += HandleDisplayChanged;

            destination_combo.Sensitive = colormanagement_check.Active;
            destination_combo.Model     = new ProfileList();
            destination_combo.PackStart(desc_cell, false);
            destination_combo.PackStart(name_cell, true);
            destination_combo.SetCellDataFunc(name_cell, new CellLayoutDataFunc(ProfileList.ProfileNameDataFunc));
            destination_combo.Changed += HandleDestinationChanged;
            //FIXME
            it_ = 0;
            foreach (Cms.Profile profile in FSpot.ColorManagement.Profiles)
            {
                if (profile.ProductName == Preferences.Get <string> (Preferences.COLOR_MANAGEMENT_OUTPUT_PROFILE))
                {
                    destination_combo.Active = it_;
                }
                it_++;
            }

            TagMenu tagmenu = new TagMenu(null, MainWindow.Toplevel.Database.Tags);

            tagmenu.Populate(false);

            tag_button.Menu = tagmenu;
            tag_button.ShowAll();
            tagselectionhbox.Add(tag_button);

            tagmenu.TagSelected          += HandleTagMenuSelected;
            set_saver_button.Clicked     += HandleUseFSpot;
            screensaverall_radio.Toggled += ToggleTagRadio;

            themenone_radio.Toggled += ToggleThemeRadio;
            themelist_combo          = ComboBox.NewText();
            theme_list = new Dictionary <string, string> ();
            string gtkrc = Path.Combine("gtk-2.0", "gtkrc");

            string [] search = { Path.Combine(Global.HomeDirectory, ".themes"), "/usr/share/themes" };
            foreach (string path in search)
            {
                if (Directory.Exists(path))
                {
                    foreach (string dir in Directory.GetDirectories(path))
                    {
                        if (File.Exists(Path.Combine(dir, gtkrc)) && !theme_list.ContainsKey(Path.GetFileName(dir)))
                        {
                            theme_list.Add(Path.GetFileName(dir), Path.Combine(dir, gtkrc));
                        }
                    }
                }
            }

            string active_theme = Preferences.Get <string> (Preferences.GTK_RC);
            int    it           = 0;

            foreach (string theme in theme_list.Keys)
            {
                themelist_combo.AppendText(Path.GetFileName(theme));
                if (active_theme.Contains(Path.DirectorySeparatorChar + Path.GetFileName(theme) + Path.DirectorySeparatorChar))
                {
                    themelist_combo.Active = it;
                }
                it++;
            }

            theme_table.Attach(themelist_combo, 2, 3, 0, 1);
            themelist_combo.Changed += HandleThemeComboChanged;
            themelist_combo.Show();
            theme_filechooser.Visible = themefile_label.Visible = FSpot.Utils.Log.Debugging;

            themelist_combo.Sensitive = theme_filechooser.Sensitive = themecustom_radio.Active;
            if (File.Exists(active_theme))
            {
                theme_filechooser.SetFilename(Preferences.Get <string> (Preferences.GTK_RC));
            }
            theme_filechooser.SelectionChanged += HandleThemeFileActivated;
            themecustom_radio.Active            = (active_theme != String.Empty);

#if GTK_2_12_2
            restartlabel.Visible = false;
#endif

#if DEBUGTHEMES
            refreshtheme_button = true;
#endif

            Preferences.SettingChanged += OnPreferencesChanged;
            this.Dialog.Destroyed      += HandleDestroyed;
        }
		private void CreateTagMenu ()
		{
			TagMenu tagmenu = new TagMenu (null, MainWindow.Toplevel.Database.Tags);
			tagmenu.NewTagHandler = HandleNewTagSelected;
			
			tagmenu.Append (new MenuItem (Catalog.GetString ("Select Tag")));
			
			tagmenu.Populate (true);
			
			tagmenu.TagSelected += HandleTagMenuSelected;
			
			tagmenu.ShowAll ();
			tag_option_menu.Menu = tagmenu;
		}
	//
	// Constructor
	//
	public MainWindow (Db db)
	{
		this.db = db;

		if (Toplevel == null)
			Toplevel = this;

		Glade.XML gui = new Glade.XML (null, "f-spot.glade", "main_window", "f-spot");
		gui.Autoconnect (this);

		LoadPreference (Preferences.MAIN_WINDOW_WIDTH);
		LoadPreference (Preferences.MAIN_WINDOW_X);
		LoadPreference (Preferences.MAIN_WINDOW_MAXIMIZED);
		main_window.ShowAll ();

		LoadPreference (Preferences.SIDEBAR_POSITION);
		LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);

		LoadPreference (Preferences.COLOR_MANAGEMENT_ENABLED);
 		LoadPreference (Preferences.COLOR_MANAGEMENT_USE_X_PROFILE);
 		FSpot.ColorManagement.LoadSettings();
	
#if GTK_2_10
		pagesetup_menu_item.Activated += HandlePageSetupActivated;
#else
		pagesetup_menu_item.Visible = false;
#endif
		toolbar = new Gtk.Toolbar ();
		toolbar_vbox.PackStart (toolbar);

		ToolButton import_button = GtkUtil.ToolButtonFromTheme ("gtk-add", Catalog.GetString ("Import"), false);
		import_button.Clicked += HandleImportCommand;
		import_button.SetTooltip (ToolTips, Catalog.GetString ("Import new images"), null);
		toolbar.Insert (import_button, -1);
	
		toolbar.Insert (new SeparatorToolItem (), -1);

		ToolButton rl_button = GtkUtil.ToolButtonFromTheme ("object-rotate-left", Catalog.GetString ("Rotate Left"), true);
		rl_button.Clicked += HandleRotate270Command;
		toolbar.Insert (rl_button, -1);

		ToolButton rr_button = GtkUtil.ToolButtonFromTheme ("object-rotate-right", Catalog.GetString ("Rotate Right"), true);
		rr_button.Clicked += HandleRotate90Command;
		toolbar.Insert (rr_button, -1);

		toolbar.Insert (new SeparatorToolItem (), -1);

		browse_button = new ToggleToolButton ();
		browse_button.Label = Catalog.GetString ("Browse");
		browse_button.IconName = "mode-browse";
		browse_button.IsImportant = true;
		browse_button.Toggled += HandleToggleViewBrowse;
		browse_button.SetTooltip (ToolTips, Catalog.GetString ("Browse many photos simultaneously"), null);
		toolbar.Insert (browse_button, -1);

		edit_button = new ToggleToolButton ();
		edit_button.Label = Catalog.GetString ("Edit Image");
		edit_button.IconName = "mode-image-edit";
		edit_button.IsImportant = true;
		edit_button.Toggled += HandleToggleViewPhoto;
		edit_button.SetTooltip (ToolTips, Catalog.GetString ("View and edit a photo"), null);
		toolbar.Insert (edit_button, -1);

		toolbar.Insert (new SeparatorToolItem (), -1);

		ToolButton fs_button = GtkUtil.ToolButtonFromTheme ("view-fullscreen", Catalog.GetString ("Fullscreen"), true);
		fs_button.Clicked += HandleViewFullscreen;
		fs_button.SetTooltip (ToolTips, Catalog.GetString ("View photos fullscreen"), null);
		toolbar.Insert (fs_button, -1);

		ToolButton ss_button = GtkUtil.ToolButtonFromTheme ("media-playback-start", Catalog.GetString ("Slideshow"), true);
		ss_button.Clicked += HandleViewSlideShow;
		ss_button.SetTooltip (ToolTips, Catalog.GetString ("View photos in a slideshow"), null);
		toolbar.Insert (ss_button, -1);

		SeparatorToolItem white_space = new SeparatorToolItem ();
		white_space.Draw = false;
		white_space.Expand = true;
		toolbar.Insert (white_space, -1);

		ToolItem label_item = new ToolItem ();
		count_label = new Label (String.Empty);
		label_item.Child = count_label;
		toolbar.Insert (label_item, -1);

		display_previous_button = new ToolButton (Stock.GoBack);
		toolbar.Insert (display_previous_button, -1);
		display_previous_button.SetTooltip (ToolTips, Catalog.GetString ("Previous photo"), String.Empty);
		display_previous_button.Clicked += new EventHandler (HandleDisplayPreviousButtonClicked);

		display_next_button = new ToolButton (Stock.GoForward);
		toolbar.Insert (display_next_button, -1);
		display_next_button.SetTooltip (ToolTips, Catalog.GetString ("Next photo"), String.Empty);
		display_next_button.Clicked += new EventHandler (HandleDisplayNextButtonClicked);

		sidebar = new Sidebar ();
		ViewModeChanged += sidebar.HandleMainWindowViewModeChanged;
		sidebar_vbox.Add (sidebar);

		tag_selection_scrolled = new ScrolledWindow ();
		tag_selection_scrolled.ShadowType = ShadowType.In;
		
		tag_selection_widget = new TagSelectionWidget (db.Tags);
		tag_selection_scrolled.Add (tag_selection_widget);

		sidebar.AppendPage (tag_selection_scrolled, Catalog.GetString ("Tags"), "tag");

		AddinManager.AddExtensionNodeHandler ("/FSpot/Sidebar", OnSidebarExtensionChanged);

		sidebar.Context = ViewContext.Library;
 		
		sidebar.CloseRequested += HideSidebar;
		sidebar.Show ();

		info_box = new InfoBox ();
		ViewModeChanged += info_box.HandleMainWindowViewModeChanged;
		info_box.VersionIdChanged += delegate (InfoBox box, uint version_id) { UpdateForVersionIdChange (version_id);};
		sidebar_vbox.PackEnd (info_box, false, false, 0);

		info_box.Context = ViewContext.Library;
		
		tag_selection_widget.Selection.Changed += HandleTagSelectionChanged;
		tag_selection_widget.DragDataGet += HandleTagSelectionDragDataGet;
		tag_selection_widget.DragDrop += HandleTagSelectionDragDrop;
		tag_selection_widget.DragBegin += HandleTagSelectionDragBegin;
		tag_selection_widget.KeyPressEvent += HandleTagSelectionKeyPress;
		Gtk.Drag.SourceSet (tag_selection_widget, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    tag_target_table, DragAction.Copy | DragAction.Move);

		tag_selection_widget.DragDataReceived += HandleTagSelectionDragDataReceived;
		tag_selection_widget.DragMotion += HandleTagSelectionDragMotion;
		Gtk.Drag.DestSet (tag_selection_widget, DestDefaults.All, tag_dest_target_table, 
				  DragAction.Copy | DragAction.Move ); 

		tag_selection_widget.ButtonPressEvent += HandleTagSelectionButtonPressEvent;
		tag_selection_widget.PopupMenu += HandleTagSelectionPopupMenu;
		tag_selection_widget.RowActivated += HandleTagSelectionRowActivated;
		
		LoadPreference (Preferences.TAG_ICON_SIZE);
		
		try {
			query = new FSpot.PhotoQuery (db.Photos);
		} catch (System.Exception e) {
			//FIXME assume any exception here is due to a corrupt db and handle that.
			new RepairDbDialog (e, db.Repair (), main_window);
			query = new FSpot.PhotoQuery (db.Photos);
		}

		UpdateStatusLabel ();
		query.Changed += HandleQueryChanged;

		db.Photos.ItemsChanged += HandleDbItemsChanged;
		db.Tags.ItemsChanged += HandleTagsChanged;
		db.Tags.ItemsAdded += HandleTagsChanged;
		db.Tags.ItemsRemoved += HandleTagsChanged;
#if SHOW_CALENDAR
		FSpot.SimpleCalendar cal = new FSpot.SimpleCalendar (query);
		cal.DaySelected += HandleCalendarDaySelected;
		left_vbox.PackStart (cal, false, true, 0);
#endif

		group_selector = new FSpot.GroupSelector ();
		group_selector.Adaptor = new FSpot.TimeAdaptor (query, Preferences.Get<bool> (Preferences.GROUP_ADAPTOR_ORDER_ASC));

		group_selector.ShowAll ();
		
		if (zoom_scale != null) {
			zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
		}

		view_vbox.PackStart (group_selector, false, false, 0);
		view_vbox.ReorderChild (group_selector, 0);

		find_bar = new FindBar (query, tag_selection_widget.Model);
		view_vbox.PackStart (find_bar, false, false, 0);
		view_vbox.ReorderChild (find_bar, 1);
		main_window.KeyPressEvent += HandleKeyPressEvent;
		
		query_widget = new FSpot.QueryWidget (query, db, tag_selection_widget);
		query_widget.Logic.Changed += HandleQueryLogicChanged;
		view_vbox.PackStart (query_widget, false, false, 0);
		view_vbox.ReorderChild (query_widget, 2);

		icon_view = new QueryView (query);
		icon_view.ZoomChanged += HandleZoomChanged;
		LoadPreference (Preferences.ZOOM);
		LoadPreference (Preferences.SHOW_TAGS);
		LoadPreference (Preferences.SHOW_DATES);
		LoadPreference (Preferences.SHOW_RATINGS);
		icon_view_scrolled.Add (icon_view);
		icon_view.DoubleClicked += HandleDoubleClicked;
		icon_view.Vadjustment.ValueChanged += HandleIconViewScroll;
		icon_view.GrabFocus ();

		new FSpot.PreviewPopup (icon_view);

		Gtk.Drag.SourceSet (icon_view, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    icon_source_target_table, DragAction.Copy | DragAction.Move);
		
		icon_view.DragBegin += HandleIconViewDragBegin;
		icon_view.DragDataGet += HandleIconViewDragDataGet;

		TagMenu tag_menu = new TagMenu (null, Database.Tags);
		tag_menu.NewTagHandler += delegate { HandleCreateTagAndAttach (this, null); };
		tag_menu.TagSelected += HandleAttachTagMenuSelected;
		tag_menu.Populate();
		attach_tag.Submenu = tag_menu;
		
		PhotoTagMenu pmenu = new PhotoTagMenu ();
		pmenu.TagSelected += HandleRemoveTagMenuSelected;
		remove_tag.Submenu = pmenu;
		
		Gtk.Drag.DestSet (icon_view, DestDefaults.All, icon_dest_target_table, 
				  DragAction.Copy | DragAction.Move); 

		//		icon_view.DragLeave += new DragLeaveHandler (HandleIconViewDragLeave);
		icon_view.DragMotion += HandleIconViewDragMotion;
		icon_view.DragDrop += HandleIconViewDragDrop;
		icon_view.DragDataReceived += HandleIconViewDragDataReceived;
		icon_view.KeyPressEvent += HandleIconViewKeyPressEvent;

		photo_view = new PhotoView (query);
		photo_box.Add (photo_view);

		photo_view.DoubleClicked += HandleDoubleClicked;
		photo_view.KeyPressEvent += HandlePhotoViewKeyPressEvent;
		photo_view.UpdateStarted += HandlePhotoViewUpdateStarted;
		photo_view.UpdateFinished += HandlePhotoViewUpdateFinished;

		photo_view.View.ZoomChanged += HandleZoomChanged;

		// Tag typing: focus the tag entry if the user starts typing a tag
		icon_view.KeyPressEvent += HandlePossibleTagTyping;
		photo_view.KeyPressEvent += HandlePossibleTagTyping;
		tag_entry = new TagEntry (db.Tags);
		tag_entry.KeyPressEvent += HandleTagEntryKeyPressEvent;
		tag_entry.TagsAttached += HandleTagEntryTagsAttached;
		tag_entry.TagsRemoved += HandleTagEntryRemoveTags;
		tag_entry.Activated += HandleTagEntryActivate;
		tag_entry_container.Add (tag_entry);

		Gtk.Drag.DestSet (photo_view, DestDefaults.All, tag_target_table, 
				  DragAction.Copy | DragAction.Move); 

		photo_view.DragMotion += HandlePhotoViewDragMotion;
		photo_view.DragDrop += HandlePhotoViewDragDrop;
		photo_view.DragDataReceived += HandlePhotoViewDragDataReceived;

		view_notebook.SwitchPage += HandleViewNotebookSwitchPage;
		group_selector.Adaptor.GlassSet += HandleAdaptorGlassSet;
		group_selector.Adaptor.Changed += HandleAdaptorChanged;
		LoadPreference (Preferences.GROUP_ADAPTOR);
		LoadPreference (Preferences.GROUP_ADAPTOR_ORDER_ASC);

		this.selection = new MainSelection (this);
		this.selection.Changed += HandleSelectionChanged;
		this.selection.ItemsChanged += HandleSelectionItemsChanged;
		this.selection.Changed += sidebar.HandleSelectionChanged;
		this.selection.ItemsChanged += sidebar.HandleSelectionItemsChanged;

		Mono.Addins.AddinManager.ExtensionChanged += PopulateExtendableMenus;
		PopulateExtendableMenus (null, null);

		UpdateMenus ();

		main_window.ShowAll ();

		tagbar.Hide ();
		find_bar.Hide ();

		UpdateFindByTagMenu ();

		LoadPreference (Preferences.SHOW_TOOLBAR);
		LoadPreference (Preferences.SHOW_SIDEBAR);
		LoadPreference (Preferences.SHOW_TIMELINE);
		LoadPreference (Preferences.SHOW_FILMSTRIP);

		LoadPreference (Preferences.GNOME_MAILTO_ENABLED);
		
		Preferences.SettingChanged += OnPreferencesChanged;

		main_window.DeleteEvent += HandleDeleteEvent;
		
		query_widget.HandleChanged (query);
		query_widget.Hide ();

		// When the icon_view is loaded, set it's initial scroll position
		icon_view.SizeAllocated += HandleIconViewReady;

		export.Activated += HandleExportActivated;
		UpdateToolbar ();

		Banshee.Kernel.Scheduler.Resume ();
	}
Example #12
0
		//
		// Constructor
		//
		public MainWindow (Db db)
		{
			foreach (ServiceNode service in AddinManager.GetExtensionNodes ("/FSpot/Services")) {
				try {
					service.Initialize ();
					service.Start ();
				} catch (Exception e) {
					Log.WarningFormat ("Something went wrong while starting the {0} extension.", service.Id);
					Log.DebugException (e);
				}
			}

			Database = db;

			GtkBeans.Builder builder = new GtkBeans.Builder ("main_window.ui");
			builder.Autoconnect (this);

			//Set the global DefaultColormap. Allows transparency according
			//to the theme (work on murrine engine)
			Gdk.Colormap colormap = ((Widget)main_window).Screen.RgbaColormap;
			if (colormap == null) {
				Log.Debug ("Your screen doesn't support alpha channels!");
				colormap = ((Widget)main_window).Screen.RgbColormap;
			}
			Gtk.Widget.DefaultColormap = colormap;

			LoadPreference (Preferences.MAIN_WINDOW_WIDTH);
			LoadPreference (Preferences.MAIN_WINDOW_X);
			LoadPreference (Preferences.MAIN_WINDOW_MAXIMIZED);
			main_window.ShowAll ();

			LoadPreference (Preferences.SIDEBAR_POSITION);
			LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);

			pagesetup_menu_item.Activated += HandlePageSetupActivated;

			toolbar = new Gtk.Toolbar ();
			toolbar_vbox.PackStart (toolbar);

			ToolButton import_button = GtkUtil.ToolButtonFromTheme ("gtk-add", Catalog.GetString ("Import Photos…"), true);
			import_button.Clicked += (o, args) => StartImport (null);
			import_button.TooltipText = Catalog.GetString ("Import new photos");
			toolbar.Insert (import_button, -1);

			toolbar.Insert (new SeparatorToolItem (), -1);

			rl_button = GtkUtil.ToolButtonFromTheme ("object-rotate-left", Catalog.GetString ("Rotate Left"), false);
			rl_button.Clicked += HandleRotate270Command;
			toolbar.Insert (rl_button, -1);

			rr_button = GtkUtil.ToolButtonFromTheme ("object-rotate-right", Catalog.GetString ("Rotate Right"), false);
			rr_button.Clicked += HandleRotate90Command;
			toolbar.Insert (rr_button, -1);

			toolbar.Insert (new SeparatorToolItem (), -1);

			browse_button = new ToggleToolButton ();
			browse_button.Label = Catalog.GetString ("Browsing");
			browse_button.IconName = "mode-browse";
			browse_button.IsImportant = true;
			browse_button.Toggled += HandleToggleViewBrowse;
			browse_button.TooltipText = Catalog.GetString ("Browse your photo library");
			toolbar.Insert (browse_button, -1);

			edit_button = new ToggleToolButton ();
			edit_button.Label = Catalog.GetString ("Editing");
			edit_button.IconName = "mode-image-edit";
			edit_button.IsImportant = true;
			edit_button.Toggled += HandleToggleViewPhoto;
			edit_button.TooltipText = Catalog.GetString ("Edit your photos");
			toolbar.Insert (edit_button, -1);

			toolbar.Insert (new SeparatorToolItem (), -1);

			ToolButton fs_button = GtkUtil.ToolButtonFromTheme ("view-fullscreen", Catalog.GetString ("Fullscreen"), false);
			fs_button.Clicked += HandleViewFullscreen;
			fs_button.TooltipText = Catalog.GetString ("View photos fullscreen");
			toolbar.Insert (fs_button, -1);

			ToolButton ss_button = GtkUtil.ToolButtonFromTheme ("media-playback-start", Catalog.GetString ("Slideshow"), false);
			ss_button.Clicked += HandleViewSlideShow;
			ss_button.TooltipText = Catalog.GetString ("View photos in a slideshow");
			toolbar.Insert (ss_button, -1);

			SeparatorToolItem white_space = new SeparatorToolItem ();
			white_space.Draw = false;
			white_space.Expand = true;
			toolbar.Insert (white_space, -1);

			ToolItem label_item = new ToolItem ();
			count_label = new Label (String.Empty);
			label_item.Child = count_label;
			toolbar.Insert (label_item, -1);

			display_previous_button = new ToolButton (Stock.GoBack);
			toolbar.Insert (display_previous_button, -1);
			display_previous_button.TooltipText = Catalog.GetString ("Previous photo");
			display_previous_button.Clicked += new EventHandler (HandleDisplayPreviousButtonClicked);

			display_next_button = new ToolButton (Stock.GoForward);
			toolbar.Insert (display_next_button, -1);
			display_next_button.TooltipText = Catalog.GetString ("Next photo");
			display_next_button.Clicked += new EventHandler (HandleDisplayNextButtonClicked);

			Sidebar = new Sidebar ();
			ViewModeChanged += Sidebar.HandleMainWindowViewModeChanged;
			sidebar_vbox.Add (Sidebar);

			tag_selection_scrolled = new Gtk.ScrolledWindow ();
			tag_selection_scrolled.ShadowType = ShadowType.In;

			tag_selection_widget = new TagSelectionWidget (Database.Tags);
			tag_selection_scrolled.Add (tag_selection_widget);

			Sidebar.AppendPage (tag_selection_scrolled, Catalog.GetString ("Tags"), "tag");

			AddinManager.AddExtensionNodeHandler ("/FSpot/Sidebar", OnSidebarExtensionChanged);

			Sidebar.Context = ViewContext.Library;

			Sidebar.CloseRequested += HideSidebar;
			Sidebar.Show ();

			InfoBox = new InfoBox ();
			ViewModeChanged += InfoBox.HandleMainWindowViewModeChanged;
			InfoBox.VersionChanged += delegate (InfoBox box, IPhotoVersion version) {
				UpdateForVersionChange (version);
			};
			sidebar_vbox.PackEnd (InfoBox, false, false, 0);

			InfoBox.Context = ViewContext.Library;

			tag_selection_widget.Selection.Changed += HandleTagSelectionChanged;
			tag_selection_widget.KeyPressEvent += HandleTagSelectionKeyPress;
			tag_selection_widget.ButtonPressEvent += HandleTagSelectionButtonPressEvent;
			tag_selection_widget.PopupMenu += HandleTagSelectionPopupMenu;
			tag_selection_widget.RowActivated += HandleTagSelectionRowActivated;

			LoadPreference (Preferences.TAG_ICON_SIZE);

			try {
				query = new PhotoQuery (Database.Photos);
			} catch (System.Exception e) {
				//FIXME assume any exception here is due to a corrupt db and handle that.
				new RepairDbDialog (e, Database.Repair (), main_window);
				query = new PhotoQuery (Database.Photos);
			}

			UpdateStatusLabel ();
			query.Changed += HandleQueryChanged;

			Database.Photos.ItemsChanged += HandleDbItemsChanged;
			Database.Tags.ItemsChanged += HandleTagsChanged;
			Database.Tags.ItemsAdded += HandleTagsChanged;
			Database.Tags.ItemsRemoved += HandleTagsChanged;

			group_selector = new GroupSelector ();
			group_selector.Adaptor = new TimeAdaptor (query, Preferences.Get<bool> (Preferences.GROUP_ADAPTOR_ORDER_ASC));

			group_selector.ShowAll ();

			if (zoom_scale != null) {
				zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
			}

			view_vbox.PackStart (group_selector, false, false, 0);
			view_vbox.ReorderChild (group_selector, 0);

			find_bar = new FindBar (query, tag_selection_widget.Model);
			view_vbox.PackStart (find_bar, false, false, 0);
			view_vbox.ReorderChild (find_bar, 1);
			main_window.KeyPressEvent += HandleKeyPressEvent;

			query_widget = new QueryWidget (query, Database);
			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 {
				((Gtk.Label)findByTag.Child).TextWithMnemonic = Catalog.GetString ("Show _Find Bar");
			};
			query_widget.Shown += delegate {
				((Gtk.Label)findByTag.Child).TextWithMnemonic = Catalog.GetString ("Hide _Find Bar");
			};

			icon_view = new QueryView (query);
			icon_view.ZoomChanged += HandleZoomChanged;
			LoadPreference (Preferences.ZOOM);
			LoadPreference (Preferences.SHOW_TAGS);
			LoadPreference (Preferences.SHOW_DATES);
			LoadPreference (Preferences.SHOW_RATINGS);
			icon_view_scrolled.Add (icon_view);
			icon_view.DoubleClicked += HandleDoubleClicked;
			icon_view.Vadjustment.ValueChanged += HandleIconViewScroll;
			icon_view.GrabFocus ();

			preview_popup = new PreviewPopup (icon_view);

			icon_view.DragBegin += HandleIconViewDragBegin;
			icon_view.DragEnd += HandleIconViewDragEnd;
			icon_view.DragDataGet += HandleIconViewDragDataGet;
			icon_view.DragMotion += HandleIconViewDragMotion;
			icon_view.DragDrop += HandleIconViewDragDrop;
			// StartDrag is fired by IconView
			icon_view.StartDrag += HandleIconViewStartDrag;

			TagMenu tag_menu = new TagMenu (null, Database.Tags);
			tag_menu.NewTagHandler += delegate {
				HandleCreateTagAndAttach (this, null);
			};
			tag_menu.TagSelected += HandleAttachTagMenuSelected;
			tag_menu.Populate ();
			(uimanager.GetWidget ("/ui/menubar1/edit2/attach_tag") as MenuItem).Submenu = tag_menu;

			PhotoTagMenu pmenu = new PhotoTagMenu ();
			pmenu.TagSelected += HandleRemoveTagMenuSelected;
			(uimanager.GetWidget ("/ui/menubar1/edit2/remove_tag") as MenuItem).Submenu = pmenu;

			Gtk.Drag.DestSet (icon_view, DestDefaults.All, (TargetEntry[])iconDestTargetList,
				DragAction.Copy | DragAction.Move);

			icon_view.DragDataReceived += HandleIconViewDragDataReceived;
			icon_view.KeyPressEvent += HandleIconViewKeyPressEvent;

			photo_view = new PhotoView (query);
			photo_box.Add (photo_view);

			photo_view.DoubleClicked += HandleDoubleClicked;
			photo_view.KeyPressEvent += HandlePhotoViewKeyPressEvent;
			photo_view.UpdateStarted += HandlePhotoViewUpdateStarted;
			photo_view.UpdateFinished += HandlePhotoViewUpdateFinished;

			photo_view.View.ZoomChanged += HandleZoomChanged;

			// Tag typing: focus the tag entry if the user starts typing a tag
			icon_view.KeyPressEvent += HandlePossibleTagTyping;
			photo_view.KeyPressEvent += HandlePossibleTagTyping;
			tag_entry = new TagEntry (Database.Tags);
			tag_entry.KeyPressEvent += HandleTagEntryKeyPressEvent;
			tag_entry.TagsAttached += HandleTagEntryTagsAttached;
			tag_entry.TagsRemoved += HandleTagEntryRemoveTags;
			tag_entry.Activated += HandleTagEntryActivate;
			tag_entry_container.Add (tag_entry);

			Gtk.Drag.DestSet (photo_view, DestDefaults.All, tag_target_table,
				DragAction.Copy | DragAction.Move);

			photo_view.DragMotion += HandlePhotoViewDragMotion;
			photo_view.DragDrop += HandlePhotoViewDragDrop;
			photo_view.DragDataReceived += HandlePhotoViewDragDataReceived;

			view_notebook.SwitchPage += HandleViewNotebookSwitchPage;
			group_selector.Adaptor.GlassSet += HandleAdaptorGlassSet;
			group_selector.Adaptor.Changed += HandleAdaptorChanged;
			LoadPreference (Preferences.GROUP_ADAPTOR_ORDER_ASC);
			LoadPreference (Preferences.FILMSTRIP_ORIENTATION);

			Selection = new MainSelection (this);
			Selection.Changed += HandleSelectionChanged;
			Selection.ItemsChanged += HandleSelectionItemsChanged;
			Selection.Changed += Sidebar.HandleSelectionChanged;
			Selection.ItemsChanged += Sidebar.HandleSelectionItemsChanged;

			AddinManager.ExtensionChanged += PopulateExtendableMenus;
			PopulateExtendableMenus (null, null);

			UpdateMenus ();

			main_window.ShowAll ();

			tagbar.Hide ();
			find_bar.Hide ();

			UpdateFindByTagMenu ();

			LoadPreference (Preferences.SHOW_TOOLBAR);
			LoadPreference (Preferences.SHOW_SIDEBAR);
			LoadPreference (Preferences.SHOW_TIMELINE);
			LoadPreference (Preferences.SHOW_FILMSTRIP);

			LoadPreference (Preferences.GNOME_MAILTO_ENABLED);

			Preferences.SettingChanged += OnPreferencesChanged;

			main_window.DeleteEvent += HandleDeleteEvent;

			// When the icon_view is loaded, set it's initial scroll position
			icon_view.SizeAllocated += HandleIconViewReady;

			export.Activated += HandleExportActivated;
			UpdateToolbar ();

			(uimanager.GetWidget ("/ui/menubar1/file1/close1") as MenuItem).Hide ();

			Banshee.Kernel.Scheduler.Resume ();
		}
Example #13
0
        //
        // Constructor
        //
        public MainWindow(Db db)
        {
            foreach (ServiceNode service in AddinManager.GetExtensionNodes ("/FSpot/Services")) {
                try {
                    service.Initialize ();
                    service.Start ();
                } catch (Exception e) {
                    Log.Warning ("Something went wrong while starting the {0} extension.", service.Id);
                    Log.DebugException (e);
                }
            }

            #if GSD_2_24
            Log.Information ("Hack for gnome-settings-daemon engaged");
            int max_age, max_size;
            if (Preferences.TryGet<int> (Preferences.GSD_THUMBS_MAX_AGE, out max_age)) {
                if (max_age < 0)
                    Log.Debug ("maximum_age check already disabled, good");
                else if (max_age == 0)
                    Log.Warning ("maximum_age is 0 (tin-hat mode), not overriding");
                else if (max_age < 180) {
                    Log.Debug ("Setting maximum_age to a saner value");
                    Preferences.Set (Preferences.GSD_THUMBS_MAX_AGE, 180);
                }
            }

            if (Preferences.TryGet<int> (Preferences.GSD_THUMBS_MAX_SIZE, out max_size)) {
                int count = App.Instance.Database.Photos.Count ("photos");
                // average thumbs are taking 70K, so this will push the threshold
                //if f-spot takes more than 70% of the thumbs space
                int size = count / 10;
                if (max_size < 0)
                    Log.Debug ("maximum_size check already disabled, good");
                else if (max_size == 0)
                    Log.Warning ("maximum_size is 0 (tin-hat mode), not overriding");
                else if (max_size < size) {
                    Log.Debug ("Setting maximum_size to a saner value ({0}MB), according to your db size", size);
                    Preferences.Set (Preferences.GSD_THUMBS_MAX_SIZE, size);
                }
            }

            #endif
            Database = db;

            if (Toplevel == null)
                Toplevel = this;

            GtkBeans.Builder builder = new GtkBeans.Builder ("main_window.ui");
            builder.Autoconnect (this);

            //Set the global DefaultColormap. Allows transparency according
            //to the theme (work on murrine engine)
            Gdk.Colormap colormap = ((Widget)main_window).Screen.RgbaColormap;
            if (colormap == null) {
                Log.Debug ("Your screen doesn't support alpha channels!");
                colormap = ((Widget)main_window).Screen.RgbColormap;
            }
            Gtk.Widget.DefaultColormap = colormap;

            LoadPreference (Preferences.MAIN_WINDOW_WIDTH);
            LoadPreference (Preferences.MAIN_WINDOW_X);
            LoadPreference (Preferences.MAIN_WINDOW_MAXIMIZED);
            main_window.ShowAll ();

            LoadPreference (Preferences.SIDEBAR_POSITION);
            LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);

            pagesetup_menu_item.Activated += HandlePageSetupActivated;

            toolbar = new Gtk.Toolbar ();
            toolbar_vbox.PackStart (toolbar);

            ToolButton import_button = GtkUtil.ToolButtonFromTheme ("gtk-add", Catalog.GetString ("Import"), true);
            import_button.Clicked += HandleImportCommand;
            import_button.SetTooltip (ToolTips, Catalog.GetString ("Import new images"), null);
            toolbar.Insert (import_button, -1);

            toolbar.Insert (new SeparatorToolItem (), -1);

            rl_button = GtkUtil.ToolButtonFromTheme ("object-rotate-left", Catalog.GetString ("Rotate Left"), false);
            rl_button.Clicked += HandleRotate270Command;
            toolbar.Insert (rl_button, -1);

            rr_button = GtkUtil.ToolButtonFromTheme ("object-rotate-right", Catalog.GetString ("Rotate Right"), false);
            rr_button.Clicked += HandleRotate90Command;
            toolbar.Insert (rr_button, -1);

            toolbar.Insert (new SeparatorToolItem (), -1);

            browse_button = new ToggleToolButton ();
            browse_button.Label = Catalog.GetString ("Browse");
            browse_button.IconName = "mode-browse";
            browse_button.IsImportant = true;
            browse_button.Toggled += HandleToggleViewBrowse;
            browse_button.SetTooltip (ToolTips, Catalog.GetString ("Browse many photos simultaneously"), null);
            toolbar.Insert (browse_button, -1);

            edit_button = new ToggleToolButton ();
            edit_button.Label = Catalog.GetString ("Edit Image");
            edit_button.IconName = "mode-image-edit";
            edit_button.IsImportant = true;
            edit_button.Toggled += HandleToggleViewPhoto;
            edit_button.SetTooltip (ToolTips, Catalog.GetString ("View and edit a photo"), null);
            toolbar.Insert (edit_button, -1);

            toolbar.Insert (new SeparatorToolItem (), -1);

            ToolButton fs_button = GtkUtil.ToolButtonFromTheme ("view-fullscreen", Catalog.GetString ("Fullscreen"), false);
            fs_button.Clicked += HandleViewFullscreen;
            fs_button.SetTooltip (ToolTips, Catalog.GetString ("View photos fullscreen"), null);
            toolbar.Insert (fs_button, -1);

            ToolButton ss_button = GtkUtil.ToolButtonFromTheme ("media-playback-start", Catalog.GetString ("Slideshow"), false);
            ss_button.Clicked += HandleViewSlideShow;
            ss_button.SetTooltip (ToolTips, Catalog.GetString ("View photos in a slideshow"), null);
            toolbar.Insert (ss_button, -1);

            SeparatorToolItem white_space = new SeparatorToolItem ();
            white_space.Draw = false;
            white_space.Expand = true;
            toolbar.Insert (white_space, -1);

            ToolItem label_item = new ToolItem ();
            count_label = new Label (String.Empty);
            label_item.Child = count_label;
            toolbar.Insert (label_item, -1);

            display_previous_button = new ToolButton (Stock.GoBack);
            toolbar.Insert (display_previous_button, -1);
            display_previous_button.SetTooltip (ToolTips, Catalog.GetString ("Previous photo"), String.Empty);
            display_previous_button.Clicked += new EventHandler (HandleDisplayPreviousButtonClicked);

            display_next_button = new ToolButton (Stock.GoForward);
            toolbar.Insert (display_next_button, -1);
            display_next_button.SetTooltip (ToolTips, Catalog.GetString ("Next photo"), String.Empty);
            display_next_button.Clicked += new EventHandler (HandleDisplayNextButtonClicked);

            Sidebar = new Sidebar ();
            ViewModeChanged += Sidebar.HandleMainWindowViewModeChanged;
            sidebar_vbox.Add (Sidebar);

            tag_selection_scrolled = new ScrolledWindow ();
            tag_selection_scrolled.ShadowType = ShadowType.In;

            tag_selection_widget = new TagSelectionWidget (Database.Tags);
            tag_selection_scrolled.Add (tag_selection_widget);

            Sidebar.AppendPage (tag_selection_scrolled, Catalog.GetString ("Tags"), "tag");

            AddinManager.AddExtensionNodeHandler ("/FSpot/Sidebar", OnSidebarExtensionChanged);

            Sidebar.Context = ViewContext.Library;

            Sidebar.CloseRequested += HideSidebar;
            Sidebar.Show ();

            InfoBox = new InfoBox ();
            ViewModeChanged += InfoBox.HandleMainWindowViewModeChanged;
            InfoBox.VersionIdChanged += delegate (InfoBox box, uint version_id) { UpdateForVersionIdChange (version_id);};
            sidebar_vbox.PackEnd (InfoBox, false, false, 0);

            InfoBox.Context = ViewContext.Library;

            tag_selection_widget.Selection.Changed += HandleTagSelectionChanged;
            tag_selection_widget.KeyPressEvent += HandleTagSelectionKeyPress;
            tag_selection_widget.ButtonPressEvent += HandleTagSelectionButtonPressEvent;
            tag_selection_widget.PopupMenu += HandleTagSelectionPopupMenu;
            tag_selection_widget.RowActivated += HandleTagSelectionRowActivated;

            LoadPreference (Preferences.TAG_ICON_SIZE);

            try {
                query = new FSpot.PhotoQuery (Database.Photos);
            } catch (System.Exception e) {
                //FIXME assume any exception here is due to a corrupt db and handle that.
                new RepairDbDialog (e, Database.Repair (), main_window);
                query = new FSpot.PhotoQuery (Database.Photos);
            }

            UpdateStatusLabel ();
            query.Changed += HandleQueryChanged;

            Database.Photos.ItemsChanged += HandleDbItemsChanged;
            Database.Tags.ItemsChanged += HandleTagsChanged;
            Database.Tags.ItemsAdded += HandleTagsChanged;
            Database.Tags.ItemsRemoved += HandleTagsChanged;
            #if SHOW_CALENDAR
            FSpot.SimpleCalendar cal = new FSpot.SimpleCalendar (query);
            cal.DaySelected += HandleCalendarDaySelected;
            left_vbox.PackStart (cal, false, true, 0);
            #endif

            group_selector = new FSpot.GroupSelector ();
            group_selector.Adaptor = new FSpot.TimeAdaptor (query, Preferences.Get<bool> (Preferences.GROUP_ADAPTOR_ORDER_ASC));

            group_selector.ShowAll ();

            if (zoom_scale != null) {
                zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
            }

            view_vbox.PackStart (group_selector, false, false, 0);
            view_vbox.ReorderChild (group_selector, 0);

            find_bar = new FindBar (query, tag_selection_widget.Model);
            view_vbox.PackStart (find_bar, false, false, 0);
            view_vbox.ReorderChild (find_bar, 1);
            main_window.KeyPressEvent += HandleKeyPressEvent;

            query_widget = new FSpot.QueryWidget (query, Database);
            query_widget.Logic.Changed += HandleQueryLogicChanged;
            view_vbox.PackStart (query_widget, false, false, 0);
            view_vbox.ReorderChild (query_widget, 2);

            icon_view = new QueryView (query);
            icon_view.ZoomChanged += HandleZoomChanged;
            LoadPreference (Preferences.ZOOM);
            LoadPreference (Preferences.SHOW_TAGS);
            LoadPreference (Preferences.SHOW_DATES);
            LoadPreference (Preferences.SHOW_RATINGS);
            icon_view_scrolled.Add (icon_view);
            icon_view.DoubleClicked += HandleDoubleClicked;
            icon_view.Vadjustment.ValueChanged += HandleIconViewScroll;
            icon_view.GrabFocus ();

            new FSpot.PreviewPopup (icon_view);

            Gtk.Drag.SourceSet (icon_view, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
                        icon_source_target_table, DragAction.Copy | DragAction.Move);

            icon_view.DragBegin += HandleIconViewDragBegin;
            icon_view.DragDataGet += HandleIconViewDragDataGet;

            TagMenu tag_menu = new TagMenu (null, Database.Tags);
            tag_menu.NewTagHandler += delegate { HandleCreateTagAndAttach (this, null); };
            tag_menu.TagSelected += HandleAttachTagMenuSelected;
            tag_menu.Populate();
            (uimanager.GetWidget("/ui/menubar1/edit2/attach_tag") as MenuItem).Submenu = tag_menu;

            PhotoTagMenu pmenu = new PhotoTagMenu ();
            pmenu.TagSelected += HandleRemoveTagMenuSelected;
            (uimanager.GetWidget("/ui/menubar1/edit2/remove_tag") as MenuItem).Submenu = pmenu;

            Gtk.Drag.DestSet (icon_view, DestDefaults.All, icon_dest_target_table,
                      DragAction.Copy | DragAction.Move);

            //		icon_view.DragLeave += new DragLeaveHandler (HandleIconViewDragLeave);
            icon_view.DragMotion += HandleIconViewDragMotion;
            icon_view.DragDrop += HandleIconViewDragDrop;
            icon_view.DragDataReceived += HandleIconViewDragDataReceived;
            icon_view.KeyPressEvent += HandleIconViewKeyPressEvent;

            photo_view = new PhotoView (query);
            photo_box.Add (photo_view);

            photo_view.DoubleClicked += HandleDoubleClicked;
            photo_view.KeyPressEvent += HandlePhotoViewKeyPressEvent;
            photo_view.UpdateStarted += HandlePhotoViewUpdateStarted;
            photo_view.UpdateFinished += HandlePhotoViewUpdateFinished;

            photo_view.View.ZoomChanged += HandleZoomChanged;

            // Tag typing: focus the tag entry if the user starts typing a tag
            icon_view.KeyPressEvent += HandlePossibleTagTyping;
            photo_view.KeyPressEvent += HandlePossibleTagTyping;
            tag_entry = new TagEntry (Database.Tags);
            tag_entry.KeyPressEvent += HandleTagEntryKeyPressEvent;
            tag_entry.TagsAttached += HandleTagEntryTagsAttached;
            tag_entry.TagsRemoved += HandleTagEntryRemoveTags;
            tag_entry.Activated += HandleTagEntryActivate;
            tag_entry_container.Add (tag_entry);

            Gtk.Drag.DestSet (photo_view, DestDefaults.All, tag_target_table,
                      DragAction.Copy | DragAction.Move);

            photo_view.DragMotion += HandlePhotoViewDragMotion;
            photo_view.DragDrop += HandlePhotoViewDragDrop;
            photo_view.DragDataReceived += HandlePhotoViewDragDataReceived;

            view_notebook.SwitchPage += HandleViewNotebookSwitchPage;
            group_selector.Adaptor.GlassSet += HandleAdaptorGlassSet;
            group_selector.Adaptor.Changed += HandleAdaptorChanged;
            LoadPreference (Preferences.GROUP_ADAPTOR_ORDER_ASC);
            LoadPreference (Preferences.FILMSTRIP_ORIENTATION);

            Selection = new MainSelection (this);
            Selection.Changed += HandleSelectionChanged;
            Selection.ItemsChanged += HandleSelectionItemsChanged;
            Selection.Changed += Sidebar.HandleSelectionChanged;
            Selection.ItemsChanged += Sidebar.HandleSelectionItemsChanged;

            Mono.Addins.AddinManager.ExtensionChanged += PopulateExtendableMenus;
            PopulateExtendableMenus (null, null);

            UpdateMenus ();

            main_window.ShowAll ();

            tagbar.Hide ();
            find_bar.Hide ();

            UpdateFindByTagMenu ();

            LoadPreference (Preferences.SHOW_TOOLBAR);
            LoadPreference (Preferences.SHOW_SIDEBAR);
            LoadPreference (Preferences.SHOW_TIMELINE);
            LoadPreference (Preferences.SHOW_FILMSTRIP);

            LoadPreference (Preferences.GNOME_MAILTO_ENABLED);

            Preferences.SettingChanged += OnPreferencesChanged;

            main_window.DeleteEvent += HandleDeleteEvent;

            query_widget.HandleChanged (query);
            query_widget.Close ();

            // When the icon_view is loaded, set it's initial scroll position
            icon_view.SizeAllocated += HandleIconViewReady;

            export.Activated += HandleExportActivated;
            UpdateToolbar ();

            (uimanager.GetWidget("/ui/menubar1/file1/close1") as MenuItem).Hide ();

            Banshee.Kernel.Scheduler.Resume ();
        }
		public PreferenceDialog () : base ("main_preferences")
		{
			tag_button = new MenuButton ();
			LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);
			LoadPreference (Preferences.COLOR_MANAGEMENT_ENABLED);
			LoadPreference (Preferences.COLOR_MANAGEMENT_USE_X_PROFILE);
			LoadPreference (Preferences.SCREENSAVER_TAG);
			LoadPreference (Preferences.GNOME_SCREENSAVER_THEME);
			if (Global.PhotoDirectory == Preferences.Get<string> (Preferences.STORAGE_PATH)) {
				photosdir_chooser.CurrentFolderChanged += HandlePhotosdirChanged;
				photosdir_chooser.SetCurrentFolder (Global.PhotoDirectory);
			} else {
				photosdir_chooser.SetCurrentFolder(Global.PhotoDirectory);
				photosdir_chooser.Sensitive = false;
			}

			Gtk.CellRendererText name_cell = new Gtk.CellRendererText ();
			Gtk.CellRendererText desc_cell = new Gtk.CellRendererText ();
			
			use_x_profile_check.Sensitive = colormanagement_check.Active;
			
			display_combo.Sensitive = colormanagement_check.Active;
			display_combo.Model = new ProfileList ();                                                                                    
			display_combo.PackStart (desc_cell, false);
			display_combo.PackStart (name_cell, true);
			display_combo.SetCellDataFunc (name_cell, new CellLayoutDataFunc (ProfileList.ProfileNameDataFunc));
			//FIXME
			int it_ = 0;
			foreach (Cms.Profile profile in FSpot.ColorManagement.Profiles) {
				if (profile.ProductName == Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE))
					display_combo.Active = it_;
				it_++;
			}

			display_combo.Changed += HandleDisplayChanged;

			destination_combo.Sensitive = colormanagement_check.Active;
			destination_combo.Model = new ProfileList ();
			destination_combo.PackStart (desc_cell, false);
			destination_combo.PackStart (name_cell, true);
			destination_combo.SetCellDataFunc (name_cell, new CellLayoutDataFunc (ProfileList.ProfileNameDataFunc));
			destination_combo.Changed += HandleDestinationChanged;
			//FIXME
			it_ = 0;
			foreach (Cms.Profile profile in FSpot.ColorManagement.Profiles) {
				if (profile.ProductName ==  Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_OUTPUT_PROFILE))
					destination_combo.Active = it_;
				it_++;
			}

			TagMenu tagmenu = new TagMenu (null, MainWindow.Toplevel.Database.Tags);
	
			tagmenu.Populate (false);

			tag_button.Menu = tagmenu;
			tag_button.ShowAll ();
			tagselectionhbox.Add (tag_button);

			tagmenu.TagSelected += HandleTagMenuSelected;
			set_saver_button.Clicked += HandleUseFSpot;
			screensaverall_radio.Toggled += ToggleTagRadio;

			themenone_radio.Toggled += ToggleThemeRadio;
			themelist_combo = ComboBox.NewText ();
			theme_list = new Dictionary<string, string> ();
			string gtkrc = Path.Combine ("gtk-2.0", "gtkrc");
			string [] search = {Path.Combine (Global.HomeDirectory, ".themes"), "/usr/share/themes"};
			foreach (string path in search)
				if (Directory.Exists (path)) 
					foreach (string dir in Directory.GetDirectories (path))
						if (File.Exists (Path.Combine (dir, gtkrc)) && !theme_list.ContainsKey (Path.GetFileName (dir)))
							theme_list.Add (Path.GetFileName (dir), Path.Combine (dir, gtkrc));
			
			string active_theme = Preferences.Get<string> (Preferences.GTK_RC);
			int it = 0;
			foreach (string theme in theme_list.Keys) {
				themelist_combo.AppendText (Path.GetFileName (theme));
				if (active_theme.Contains (Path.DirectorySeparatorChar + Path.GetFileName (theme) + Path.DirectorySeparatorChar))
					themelist_combo.Active = it;
				it ++;
			}
			
			theme_table.Attach (themelist_combo, 2, 3, 0, 1);
			themelist_combo.Changed += HandleThemeComboChanged;
			themelist_combo.Show ();
			theme_filechooser.Visible = themefile_label.Visible = FSpot.Utils.Log.Debugging;

			themelist_combo.Sensitive = theme_filechooser.Sensitive = themecustom_radio.Active; 
			if (File.Exists (active_theme))
				theme_filechooser.SetFilename (Preferences.Get<string> (Preferences.GTK_RC));
			theme_filechooser.SelectionChanged += HandleThemeFileActivated;
			themecustom_radio.Active = (active_theme != String.Empty);	

#if GTK_2_12_2
			restartlabel.Visible = false;
#endif

#if DEBUGTHEMES
			refreshtheme_button = true;
#endif

			Preferences.SettingChanged += OnPreferencesChanged;
			this.Dialog.Destroyed += HandleDestroyed;
		}