Ejemplo n.º 1
0
        public SmugMugAccountDialog(Gtk.Window parent, SmugMugAccount account)
        {
            builder = new GtkBeans.Builder (null, "smugmug_add_dialog.ui", null);
            builder.Autoconnect (this);

            Dialog.Modal = false;
            Dialog.TransientFor = parent;
            Dialog.DefaultResponse = Gtk.ResponseType.Ok;

            this.account = account;

            password_entry.ActivatesDefault = true;
            username_entry.ActivatesDefault = true;

            if (account != null) {
                password_entry.Text = account.Password;
                username_entry.Text = account.Username;
                add_button.Label = Gtk.Stock.Ok;
                Dialog.Response += HandleEditResponse;
            }

            if (remove_button != null)
                remove_button.Visible = account != null;

            this.Dialog.Show ();

            password_entry.Changed += HandleChanged;
            username_entry.Changed += HandleChanged;
            HandleChanged (null, null);
        }
Ejemplo n.º 2
0
        public AccountDialog(Gtk.Window parent, GalleryAccount account, bool show_error)
        {
            var builder = new GtkBeans.Builder (null, "gallery_add_dialog.ui", null);
            builder.Autoconnect (this);
            add_dialog = new Gtk.Dialog (builder.GetRawObject ("gallery_add_dialog"));
            add_dialog.Modal = false;
            add_dialog.TransientFor = parent;
            add_dialog.DefaultResponse = Gtk.ResponseType.Ok;

            this.account = account;

            status_area.Visible = show_error;

            if (account != null) {
                gallery_entry.Text = account.Name;
                url_entry.Text = account.Url;
                password_entry.Text = account.Password;
                username_entry.Text = account.Username;
                add_button.Label = Gtk.Stock.Ok;
                add_dialog.Response += HandleEditResponse;
            }

            if (remove_button != null)
                remove_button.Visible = account != null;

            add_dialog.Show ();

            gallery_entry.Changed += HandleChanged;
            url_entry.Changed += HandleChanged;
            password_entry.Changed += HandleChanged;
            username_entry.Changed += HandleChanged;
            HandleChanged (null, null);
        }
Ejemplo n.º 3
0
        public PickFolderDialog(Gtk.Dialog parent, string folder)
        {
            var builder = new GtkBeans.Builder (null, "pickfolder_dialog.ui", null);
            builder.Autoconnect (this);

            Log.Debug ("new pickfolder");
            pickfolder_dialog.Modal = false;
            pickfolder_dialog.TransientFor = parent;

            pickfolder_chooser.LocalOnly = false;

            pickfolder_label.Text = String.Format (Catalog.GetString ("<big>The database refers to files contained in the <b>{0}</b> folder.\n Please select that folder so I can do the mapping.</big>"), folder);
            pickfolder_label.UseMarkup = true;
        }
Ejemplo n.º 4
0
        public GoogleAddAlbum(GoogleExport export, Mono.Google.Picasa.PicasaWeb picasa)
        {
            builder = new GtkBeans.Builder (null, "google_add_album_dialog.ui", null);
            builder.Autoconnect (this);

            this.export = export;
            this.picasa = picasa;

            Dialog.Response += HandleAddResponse;

            description_entry.Changed += HandleChanged;
            title_entry.Changed += HandleChanged;
            HandleChanged (null, null);
        }
Ejemplo n.º 5
0
        public MergeDbDialog(MergeDb parent)
        {
            this.parent = parent;

            var builder = new GtkBeans.Builder (null, "mergedb_dialog.ui", null);
            builder.Autoconnect (this);
            mergedb_dialog.Modal = false;
            mergedb_dialog.TransientFor = null;

            db_filechooser.LocalOnly = false;
            db_filechooser.FileSet += OnFileSet;

            newrolls_radio.Toggled += HandleRollsChanged;
            allrolls_radio.Toggled += HandleRollsChanged;
            singleroll_radio.Toggled += HandleRollsChanged;
        }
Ejemplo n.º 6
0
        public SmugMugAddAlbum(SmugMugExport export, SmugMugApi smugmug)
        {
            builder = new GtkBeans.Builder (null, "smugmug_add_album_dialog.ui", null);
            builder.Autoconnect (this);

            this.export = export;
            this.smugmug = smugmug;

            this.category_store = new ListStore (typeof(int), typeof(string));
            CellRendererText display_cell = new CellRendererText();
            category_combo.PackStart (display_cell, true);
            category_combo.SetCellDataFunc (display_cell, new CellLayoutDataFunc (CategoryDataFunc));
            this.category_combo.Model = category_store;
            PopulateCategoryCombo ();

            Dialog.Response += HandleAddResponse;

            title_entry.Changed += HandleChanged;
            HandleChanged (null, null);
        }
Ejemplo n.º 7
0
        public GalleryAddAlbum(GalleryExport export, Gallery gallery)
        {
            var builder = new GtkBeans.Builder (null, "gallery_add_album_dialog.ui", null);
            builder.Autoconnect (this);
            add_album_dialog = new Gtk.Dialog (builder.GetRawObject ("gallery_add_album_dialog"));
            add_album_dialog.Modal = true;

            album_optionmenu = new Gtk.ComboBox ();
            (name_entry.Parent as Gtk.Table).Attach (album_optionmenu, 1, 2, 1, 2);
            album_optionmenu.Show ();

            this.export = export;
            this.gallery = gallery;
            PopulateAlbums ();

            add_album_dialog.Response += HandleAddResponse;

            name_entry.Changed += HandleChanged;
            description_entry.Changed += HandleChanged;
            title_entry.Changed += HandleChanged;
            HandleChanged (null, null);
        }
Ejemplo n.º 8
0
        public AccountDialog(Gtk.Window parent, GalleryAccount account, bool show_error)
        {
            var builder = new GtkBeans.Builder(null, "gallery_add_dialog.ui", null);

            builder.Autoconnect(this);
            add_dialog                 = new Gtk.Dialog(builder.GetRawObject("gallery_add_dialog"));
            add_dialog.Modal           = false;
            add_dialog.TransientFor    = parent;
            add_dialog.DefaultResponse = Gtk.ResponseType.Ok;

            this.account = account;

            status_area.Visible = show_error;

            if (account != null)
            {
                gallery_entry.Text   = account.Name;
                url_entry.Text       = account.Url;
                password_entry.Text  = account.Password;
                username_entry.Text  = account.Username;
                add_button.Label     = Gtk.Stock.Ok;
                add_dialog.Response += HandleEditResponse;
            }

            if (remove_button != null)
            {
                remove_button.Visible = account != null;
            }

            add_dialog.Show();

            gallery_entry.Changed  += HandleChanged;
            url_entry.Changed      += HandleChanged;
            password_entry.Changed += HandleChanged;
            username_entry.Changed += HandleChanged;
            HandleChanged(null, null);
        }
Ejemplo n.º 9
0
        public GoogleAccountDialog(Gtk.Window parent, GoogleAccount account, bool show_error, CaptchaException captcha_exception)
        {
            builder = new GtkBeans.Builder (null, "google_add_dialog.ui", null);
            builder.Autoconnect (this);
            Dialog.Modal = false;
            Dialog.TransientFor = parent;
            Dialog.DefaultResponse = Gtk.ResponseType.Ok;

            this.account = account;

            bool show_captcha = (captcha_exception != null);
            status_area.Visible = show_error;
            locked_area.Visible = show_captcha;
            captcha_label.Visible = show_captcha;
            captcha_entry.Visible = show_captcha;
            captcha_image.Visible = show_captcha;

            password_entry.ActivatesDefault = true;
            username_entry.ActivatesDefault = true;

            if (show_captcha) {
                try {
                    using  (var img = ImageFile.Create(new SafeUri(captcha_exception.CaptchaUrl, true))) {
                        captcha_image.Pixbuf = img.Load();
                        token = captcha_exception.Token;
                    }
                } catch (Exception) {}
            }

            if (account != null) {
                password_entry.Text = account.Password;
                username_entry.Text = account.Username;
                add_button.Label = Gtk.Stock.Ok;
                Dialog.Response += HandleEditResponse;
            }

            if (remove_button != null)
                remove_button.Visible = account != null;

            this.Dialog.Show ();

            password_entry.Changed += HandleChanged;
            username_entry.Changed += HandleChanged;
            HandleChanged (null, null);
        }
Ejemplo n.º 10
0
 private void CreateDialog()
 {
     builder = new GtkBeans.Builder(null, "ChangePhotoPath.ui", null);
     builder.Autoconnect(this);
 }
Ejemplo n.º 11
0
        public SingleView(SafeUri [] uris)
        {
            this.uri = uris [0];
            Log.Debug ("uri: " + this.uri);

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

            LoadPreference (Preferences.VIEWER_WIDTH);
            LoadPreference (Preferences.VIEWER_MAXIMIZED);

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

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

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

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

            ToolButton fs_button = GtkUtil.ToolButtonFromTheme ("view-fullscreen", Catalog.GetString ("Fullscreen"), true);
            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"), true);
            ss_button.Clicked += HandleViewSlideshow;
            ss_button.TooltipText = Catalog.GetString ("View photos in a slideshow");
            toolbar.Insert (ss_button, -1);

            collection = new UriCollection (uris);

            TargetList targetList = new TargetList();
            targetList.AddTextTargets((uint)DragDropTargets.TargetType.PlainText);
            targetList.AddUriTargets((uint)DragDropTargets.TargetType.UriList);

            directory_view = new SelectionCollectionGridView (collection);
            directory_view.Selection.Changed += HandleSelectionChanged;
            directory_view.DragDataReceived += HandleDragDataReceived;
            Gtk.Drag.DestSet (directory_view, DestDefaults.All, (TargetEntry[])targetList,
                    DragAction.Copy | DragAction.Move);
            directory_view.DisplayTags = false;
            directory_view.DisplayDates = false;
            directory_view.DisplayRatings = false;

            directory_scrolled = new ScrolledWindow();
            directory_scrolled.Add (directory_view);

            sidebar = new Sidebar ();

            info_vbox.Add (sidebar);
            sidebar.AppendPage (directory_scrolled, Catalog.GetString ("Folder"), "gtk-directory");

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

            sidebar.Context = ViewContext.Single;

            sidebar.CloseRequested += HandleHideSidePane;
            sidebar.Show ();

            ThumbnailLoader.Default.OnPixbufLoaded += delegate { directory_view.QueueDraw (); };

            image_view = new PhotoImageView (collection);
            GtkUtil.ModifyColors (image_view);
            GtkUtil.ModifyColors (image_scrolled);
            image_view.ZoomChanged += HandleZoomChanged;
            image_view.Item.Changed += HandleItemChanged;
            image_view.ButtonPressEvent += HandleImageViewButtonPressEvent;
            image_view.DragDataReceived += HandleDragDataReceived;
            Gtk.Drag.DestSet (image_view, DestDefaults.All, (TargetEntry[])targetList,
                    DragAction.Copy | DragAction.Move);
            image_scrolled.Add (image_view);

            Window.ShowAll ();

            zoom_scale.ValueChanged += HandleZoomScaleValueChanged;

            LoadPreference (Preferences.VIEWER_SHOW_TOOLBAR);
            LoadPreference (Preferences.VIEWER_INTERPOLATION);
            LoadPreference (Preferences.VIEWER_TRANSPARENCY);
            LoadPreference (Preferences.VIEWER_TRANS_COLOR);

            ShowSidebar = collection.Count > 1;

            LoadPreference (Preferences.VIEWER_SHOW_FILENAMES);

            Preferences.SettingChanged += OnPreferencesChanged;
            Window.DeleteEvent += HandleDeleteEvent;

            collection.Changed += HandleCollectionChanged;

            // wrap the methods to fit to the delegate
            image_view.Item.Changed += delegate (object sender, BrowsablePointerChangedEventArgs old) {
                    BrowsablePointer pointer = sender as BrowsablePointer;
                    if (pointer == null)
                        return;
                    IPhoto [] item = {pointer.Current};
                    sidebar.HandleSelectionChanged (new PhotoList (item));
            };

            image_view.Item.Collection.ItemsChanged += sidebar.HandleSelectionItemsChanged;

            UpdateStatusLabel ();

            if (collection.Count > 0)
                directory_view.Selection.Add (0);

            export.Submenu = (Mono.Addins.AddinManager.GetExtensionNode ("/FSpot/Menus/Exports") as FSpot.Extensions.SubmenuNode).GetMenuItem (this).Submenu;
            export.Submenu.ShowAll ();
            export.Activated += HandleExportActivated ;
        }
Ejemplo n.º 12
0
        void BuildUI()
        {
            bool show_toolbar;

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

            show_toolbar = Preferences.Get <bool> (Preferences.ToolbarShowKey) == true && low_res == false;

            // Toolbar creation
            toolbar = new Widgets.Toolbar (main_hbox, framework_vbox);
            toolbar.Attach ((Gtk.Orientation) Preferences.Get <int> (Preferences.ToolbarOrientationKey));
            toolbar.AllButton.Clicked += OnAllGames;
            toolbar.LogicButton.Clicked += OnLogicOnly;
            toolbar.CalculationButton.Clicked += OnMathOnly;
            toolbar.MemoryButton.Clicked += OnMemoryOnly;
            toolbar.VerbalButton.Clicked += OnVerbalOnly;
            toolbar.PauseButton.Clicked += OnPauseGame;
            toolbar.FinishButton.Clicked += OnEndGame;

            drawing_area = new GameDrawingArea ();
            drawing_area.Drawable = session;
            GameSensitiveUI ();

            // For low resolutions, hide the toolbar and made the drawing area smaller
            if (drawing_area.Screen.Width> 0 && drawing_area.Screen.Height > 0) {
                if (drawing_area.Screen.Height < 700) {
                    drawing_vbox.HeightRequest = 350;
                    low_res = true;
                }
            }

            EventBox eb = new EventBox (); // Provides a window for drawing area windowless widget

            eb.Events = Gdk.EventMask.PointerMotionMask;
            drawing_vbox.Add (eb);

            eb.Add (drawing_area);

            eb.MotionNotifyEvent += OnMouseMotionEvent;
            eb.ButtonPressEvent += OnHandleButtonPress;

            show_toolbar = Preferences.Get <bool> (Preferences.ToolbarShowKey) == true && low_res == false;

            // We only disable the Arrow if we are going to show the toolbar.
            // It has an impact on the total window width size even if we do not show it
            if (show_toolbar)
                toolbar.ShowArrow = false;

            app_window.IconName = "gbrainy";

            app_window.ShowAll ();

            toolbar_orientation_menuitem.Sensitive = toolbar.Visible;

            // Check default radio button
            switch (toolbar.Orientation) {
            case Gtk.Orientation.Vertical:
                vertical_radiomenuitem.Active = true;
                break;
            case Gtk.Orientation.Horizontal:
                horizontal_radiomenuitem.Active = true;
                break;
            default:
                throw new InvalidOperationException ();
            }

            // The toolbar by default is enabled. By setting this menu entry to false
            // triggers the OnActivateToolbar event that hides the toolbar
            if (show_toolbar == false)
                showtoolbar_menuitem.Active = false;

            #if MONO_ADDINS
            extensions_menuitem.Activated += delegate (object sender, EventArgs ar)
            {
                Mono.Addins.Gui.AddinManagerWindow.Run (app_window);
                GameManagerPreload (session.GameManager);
                CustomGameDialog.Clear ();
            };
            #else
            extensions_menuitem.Visible = false;
            #endif
            ActiveInputControls (false);
        }
Ejemplo n.º 13
0
        public void Run(IBrowsableCollection selection)
        {
            var builder = new GtkBeans.Builder (null, "gallery_export_dialog.ui", null);
            builder.Autoconnect (this);
            export_dialog = new Gtk.Dialog (builder.GetRawObject ("gallery_export_dialog"));

            album_optionmenu = new Gtk.ComboBox ();
            (album_button.Parent as Gtk.HBox).PackStart (album_optionmenu);
            (album_button.Parent as Gtk.HBox).ReorderChild (album_optionmenu, 1);
            album_optionmenu.Show ();

            gallery_optionmenu = new Gtk.ComboBox ();
            (edit_button.Parent as Gtk.HBox).PackStart (gallery_optionmenu);
            (edit_button.Parent as Gtk.HBox).ReorderChild (gallery_optionmenu, 1);
            gallery_optionmenu.Show ();

            this.items = selection.Items;
            Array.Sort<IPhoto> (this.items, new IPhotoComparer.CompareDateName ());
            album_button.Sensitive = false;
            var view = new TrayView (selection);
            view.DisplayDates = false;
            view.DisplayTags = false;

            export_dialog.Modal = false;
            export_dialog.TransientFor = null;

            thumb_scrolledwindow.Add (view);
            view.Show ();
            export_dialog.Show ();

            GalleryAccountManager manager = GalleryAccountManager.GetInstance ();
            manager.AccountListChanged += PopulateGalleryOptionMenu;
            PopulateGalleryOptionMenu (manager, null);

            if (edit_button != null)
                edit_button.Clicked += HandleEditGallery;

            export_dialog.Response += HandleResponse;
            connect = true;
            HandleSizeActive (null, null);
            Connect ();

            LoadPreference (SCALE_KEY);
            LoadPreference (SIZE_KEY);
            LoadPreference (BROWSER_KEY);
            LoadPreference (META_KEY);
        }
Ejemplo n.º 14
0
 public BuilderDialog(GtkBeans.Builder builder, string dialogName) : base(builder.GetRawObject(dialogName))
 {
     builder.Autoconnect(this);
     IconName = "gbrainy";
 }
Ejemplo n.º 15
0
        public void Run(IBrowsableCollection selection)
        {
            this.selection = selection;

            var view = new TrayView (selection);
            view.DisplayDates = false;
            view.DisplayTags = false;

            builder = new GtkBeans.Builder (null, "folder_export.ui", null);
            builder.Autoconnect (this);
            Dialog.Modal = false;
            Dialog.TransientFor = null;

            thumb_scrolledwindow.Add (view);
            HandleSizeActive (null, null);
            name_entry.Text = gallery_name;

            string uri_path = System.IO.Path.Combine (FSpot.Core.Global.HomeDirectory, "Desktop");
            if (!System.IO.Directory.Exists (uri_path))
                    uri_path = FSpot.Core.Global.HomeDirectory;

            uri_chooser = new Gtk.FileChooserButton (Catalog.GetString ("Select Export Folder"),
                                 Gtk.FileChooserAction.SelectFolder);

            uri_chooser.LocalOnly = false;

            if (!String.IsNullOrEmpty (Preferences.Get<string> (URI_KEY)))
                uri_chooser.SetCurrentFolderUri (Preferences.Get<string> (URI_KEY));
            else
                uri_chooser.SetFilename (uri_path);

            chooser_hbox.PackStart (uri_chooser);

            Dialog.ShowAll ();
            Dialog.Response += HandleResponse;

            LoadPreference (SCALE_KEY);
            LoadPreference (SIZE_KEY);
            LoadPreference (OPEN_KEY);
            LoadPreference (EXPORT_TAGS_KEY);
            LoadPreference (EXPORT_TAG_ICONS_KEY);
            LoadPreference (METHOD_KEY);
        }
 private void CreateDialog()
 {
     builder = new GtkBeans.Builder (null, "ChangePhotoPath.ui", null);
     builder.Autoconnect (this);
 }
Ejemplo n.º 17
0
 public override Widget ConfigurationWidget()
 {
     builder = new GtkBeans.Builder (null, "color_editor_prefs_window.ui", null);
     builder.Autoconnect (this);
     AttachInterface ();
     return new VBox (builder.GetRawObject ("color_editor_prefs"));
 }
Ejemplo n.º 18
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 ();
		}
Ejemplo n.º 19
0
        private bool DoGetDecision()
        {
            GtkBeans.Builder builder = new GtkBeans.Builder (
                    Assembly.GetExecutingAssembly (),
                    "TrustError.ui", null);
            builder.Autoconnect (this);
            dialog = (Gtk.Dialog) builder.GetObject (DialogName);

            url_label.Markup = String.Format (
                    url_label.Text, String.Format (
                            "<b>{0}</b>",
                            request.RequestUri));

            Gtk.ResponseType response =
                    (Gtk.ResponseType) dialog.Run ();
            Log.Debug ("Decision dialog response: " + response);

            dialog.Destroy ();

            decision = Decision.DontTrust;
            if (0 == response) {
                if (abort_radiobutton.Active) {
                    decision = Decision.DontTrust;
                } else if (once_radiobutton.Active) {
                    decision = Decision.TrustOnce;
                } else if (always_radiobutton.Active) {
                    decision = Decision.TrustAlways;
                } else {
                    Debug.Assert (false,
                            "Unhandled decision");
                }
            }

            decision_event.Set ();
            return false;
        }
Ejemplo n.º 20
0
        public SingleView(Uri[] uris)
        {
            uri = uris[0];
            Log.Debug("uri: " + uri);

            var builder = new GtkBeans.Builder("single_view.ui");

            builder.Autoconnect(this);

            LoadPreference(Preferences.VIEWER_WIDTH);
            LoadPreference(Preferences.VIEWER_MAXIMIZED);

            var toolbar = new Gtk.Toolbar();

            toolbar_hbox.PackStart(toolbar);

            rl_button             = GtkUtil.ToolButtonFromTheme("object-rotate-left", Strings.RotateLeft, true);
            rl_button.Clicked    += HandleRotate270Command;
            rl_button.TooltipText = Strings.RotatePhotoLeft;
            toolbar.Insert(rl_button, -1);

            rr_button             = GtkUtil.ToolButtonFromTheme("object-rotate-right", Strings.RotateRight, true);
            rr_button.Clicked    += HandleRotate90Command;
            rr_button.TooltipText = Strings.RotatePhotoRight;
            toolbar.Insert(rr_button, -1);

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

            ToolButton fs_button = GtkUtil.ToolButtonFromTheme("view-fullscreen", Strings.Fullscreen, true);

            fs_button.Clicked    += HandleViewFullscreen;
            fs_button.TooltipText = Strings.ViewPhotosFullscreen;
            toolbar.Insert(fs_button, -1);

            ToolButton ss_button = GtkUtil.ToolButtonFromTheme("media-playback-start", Strings.Slideshow, true);

            ss_button.Clicked    += HandleViewSlideshow;
            ss_button.TooltipText = Strings.ViewPhotosInASlideshow;
            toolbar.Insert(ss_button, -1);

            collection = new UriCollection(uris);

            var targetList = new TargetList();

            //targetList.AddTextTargets (DragDropTargets.TargetType.PlainText);
            //targetList.AddUriTargets (DragDropTargets.TargetType.UriList);

            //directory_view = new SelectionCollectionGridView (collection);
            directory_view.Selection.Changed += HandleSelectionChanged;
            directory_view.DragDataReceived  += HandleDragDataReceived;
            Gtk.Drag.DestSet(directory_view, DestDefaults.All, (TargetEntry[])targetList,
                             DragAction.Copy | DragAction.Move);
            directory_view.DisplayTags    = false;
            directory_view.DisplayDates   = false;
            directory_view.DisplayRatings = false;

            directory_scrolled = new ScrolledWindow();
            directory_scrolled.Add(directory_view);

            sidebar = new Sidebar();

            info_vbox.Add(sidebar);
            sidebar.AppendPage(directory_scrolled, Strings.Folder, "gtk-directory");

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

            sidebar.Context = ViewContext.Single;

            sidebar.CloseRequested += HandleHideSidePane;
            sidebar.Show();

            App.Instance.Container.Resolve <IThumbnailLoader> ().OnPixbufLoaded += delegate { directory_view.QueueDraw(); };

            imageView = new PhotoImageView(collection);
            GtkUtil.ModifyColors(imageView);
            GtkUtil.ModifyColors(image_scrolled);
            imageView.ZoomChanged      += HandleZoomChanged;
            imageView.Item.Changed     += HandleItemChanged;
            imageView.ButtonPressEvent += HandleImageViewButtonPressEvent;
            imageView.DragDataReceived += HandleDragDataReceived;
            Gtk.Drag.DestSet(imageView, DestDefaults.All, (TargetEntry[])targetList,
                             DragAction.Copy | DragAction.Move);
            image_scrolled.Add(imageView);

            Window.ShowAll();

            zoom_scale.ValueChanged += HandleZoomScaleValueChanged;

            LoadPreference(Preferences.VIEWER_SHOW_TOOLBAR);
            LoadPreference(Preferences.VIEWER_INTERPOLATION);
            LoadPreference(Preferences.VIEWER_TRANSPARENCY);
            LoadPreference(Preferences.VIEWER_TRANS_COLOR);

            ShowSidebar = collection.Count > 1;

            LoadPreference(Preferences.VIEWER_SHOW_FILENAMES);

            Preferences.SettingChanged += OnPreferencesChanged;
            Window.DeleteEvent         += HandleDeleteEvent;

            collection.Changed += HandleCollectionChanged;

            // wrap the methods to fit to the delegate
            imageView.Item.Changed += delegate(object sender, BrowsablePointerChangedEventArgs old) {
                if (!(sender is BrowsablePointer pointer))
                {
                    return;
                }
                IPhoto[] item = { pointer.Current };
                sidebar.HandleSelectionChanged(new ObservableCollection <IPhoto>(item));
            };

            imageView.Item.Collection.CollectionChanged += sidebar.HandleCollectionItemsChanged;

            UpdateStatusLabel();

            if (collection.Count > 0)
            {
                directory_view.Selection.Add(0);
            }

            export.Submenu = (AddinManager.GetExtensionNode("/FSpot/Menus/Exports") as SubmenuNode).GetMenuItem(this).Submenu;
            export.Submenu.ShowAll();
            export.Activated += HandleExportActivated;
        }
Ejemplo n.º 21
0
        void BuildUI()
        {
            bool show_toolbar;

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

            show_toolbar = Preferences.Get <bool> (Preferences.ToolbarShowKey) == true && low_res == false;

            // Toolbar creation
            toolbar = new Widgets.Toolbar(main_hbox, framework_vbox);
            toolbar.Attach((Gtk.Orientation)Preferences.Get <int> (Preferences.ToolbarOrientationKey));
            toolbar.AllButton.Clicked         += OnAllGames;
            toolbar.LogicButton.Clicked       += OnLogicOnly;
            toolbar.CalculationButton.Clicked += OnMathOnly;
            toolbar.MemoryButton.Clicked      += OnMemoryOnly;
            toolbar.VerbalButton.Clicked      += OnVerbalOnly;
            toolbar.PauseButton.Clicked       += OnPauseGame;
            toolbar.FinishButton.Clicked      += OnEndGame;

            drawing_area          = new GameDrawingArea();
            drawing_area.Drawable = session;
            GameSensitiveUI();

            // For low resolutions, hide the toolbar and made the drawing area smaller
            if (drawing_area.Screen.Width > 0 && drawing_area.Screen.Height > 0)
            {
                if (drawing_area.Screen.Height < 700)
                {
                    drawing_vbox.HeightRequest = 350;
                    low_res = true;
                }
            }

            EventBox eb = new EventBox();              // Provides a window for drawing area windowless widget

            eb.Events = Gdk.EventMask.PointerMotionMask;
            drawing_vbox.Add(eb);

            eb.Add(drawing_area);

            eb.MotionNotifyEvent += OnMouseMotionEvent;
            eb.ButtonPressEvent  += OnHandleButtonPress;

            show_toolbar = Preferences.Get <bool> (Preferences.ToolbarShowKey) == true && low_res == false;

            // We only disable the Arrow if we are going to show the toolbar.
            // It has an impact on the total window width size even if we do not show it
            if (show_toolbar)
            {
                toolbar.ShowArrow = false;
            }

            app_window.IconName = "gbrainy";

            app_window.ShowAll();

            toolbar_orientation_menuitem.Sensitive = toolbar.Visible;

            // Check default radio button
            switch (toolbar.Orientation)
            {
            case Gtk.Orientation.Vertical:
                vertical_radiomenuitem.Active = true;
                break;

            case Gtk.Orientation.Horizontal:
                horizontal_radiomenuitem.Active = true;
                break;

            default:
                throw new InvalidOperationException();
            }

            // The toolbar by default is enabled. By setting this menu entry to false
            // triggers the OnActivateToolbar event that hides the toolbar
            if (show_toolbar == false)
            {
                showtoolbar_menuitem.Active = false;
            }

                #if MONO_ADDINS
            extensions_menuitem.Activated += delegate(object sender, EventArgs ar)
            {
                Mono.Addins.Gui.AddinManagerWindow.Run(app_window);
                GameManagerPreload(session.GameManager);
                CustomGameDialog.Clear();
            };
                #else
            extensions_menuitem.Visible = false;
                #endif
            ActiveInputControls(false);
        }
Ejemplo n.º 22
0
        public void Run(SupportedService service, IBrowsableCollection selection, bool display_tags)
        {
            this.selection = selection;
            this.current_service = FlickrRemote.Service.FromSupported (service);

            var view = new TrayView (selection);
            view.DisplayTags = display_tags;
            view.DisplayDates = false;

            builder = new GtkBeans.Builder (null, "flickr_export.ui", null);
            builder.Autoconnect (this);

            Dialog.Modal = false;
            Dialog.TransientFor = null;

            thumb_scrolledwindow.Add (view);
            HandleSizeActive (null, null);

            public_radio.Toggled += HandlePublicChanged;
            tag_check.Toggled += HandleTagChanged;
            hierarchy_check.Toggled += HandleHierarchyChanged;
            HandleTagChanged (null, null);
            HandleHierarchyChanged (null, null);

            Dialog.ShowAll ();
            Dialog.Response += HandleResponse;
            auth_flickr.Clicked += HandleClicked;
            auth_text = string.Format (auth_label.Text, current_service.Name);
            auth_label.Text = auth_text;
            used_bandwidth.Visible = false;

            LoadPreference (SCALE_KEY);
            LoadPreference (SIZE_KEY);
            LoadPreference (BROWSER_KEY);
            LoadPreference (TAGS_KEY);
            LoadPreference (TAG_HIERARCHY_KEY);
            LoadPreference (IGNORE_TOP_LEVEL_KEY);
            LoadPreference (PUBLIC_KEY);
            LoadPreference (FAMILY_KEY);
            LoadPreference (FRIENDS_KEY);
            LoadPreference (current_service.PreferencePath);

            do_export_flickr.Sensitive = false;
            fr = new FlickrRemote (token, current_service);
            if (token != null && token.Length > 0) {
                StartAuth ();
            }
        }
Ejemplo n.º 23
0
        public void ShowDialog()
        {
            var builder = new GtkBeans.Builder (null, "zip_export.ui", null);
            builder.Autoconnect (this);
            zipdiag.Modal = false;
            zipdiag.TransientFor = null;

            uri_chooser = new Gtk.FileChooserButton (Catalog.GetString ("Select export folder"),
                                 Gtk.FileChooserAction.SelectFolder);
            uri_chooser.LocalOnly = true;
            uri_chooser.SetFilename (System.IO.Path.Combine (FSpot.Core.Global.HomeDirectory, "Desktop"));
            dirchooser_hbox.PackStart (uri_chooser, false, false, 2);
            filename.Text = "f-spot_export.zip";

            zipdiag.Response += on_dialog_response;
            filename.Changed += on_filename_change;
            scale_check.Toggled += on_scalecheck_change;
            on_scalecheck_change (null, null);

            zipdiag.ShowAll ();
        }
Ejemplo n.º 24
0
        public Mistelix(string [] args, params object [] props)
            : base("mistelix", Defines.VERSION, Modules.UI,  args, props)
        {
            Gtk.Application.Init ();
            Logger.Info ("Mistelix " + Defines.VERSION + " starting");

            Catalog.Init ("mistelix", Defines.GNOME_LOCALE_DIR);

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

            foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes ("/Mistelix/SlideTransitions"))
                Logger.Info ("Extension:" + node.CreateInstance ());

            foreach (TypeExtensionNode node in EffectManager.List)
                Logger.Info ("Extension:" + node.CreateInstance ());

            //project = authoring_view.Project = element_view.Project = new Project ();
            //project.Load ("/home/jordi/dev/mistelix/projects/Project_TwoSlidesShows.mistelix");
            //element_view.LoadElements ();
            //authoring_view.UpdateTheme ();

            CreateViews ();

            if (preferences.GetBoolValue (Preferences.SafeAreaKey) == true)
                safearea_menuitem.Active = true;

            recent_submenu = new ExtendedMenu ();
            recent_menuitem.Submenu = recent_submenu;

            app_window.IconName = "mistelix";
            hpaned.Position = 30; // H (right), controls position of top "Project elements" button bar
            vpaned.Position = 700; // W (left)
            LoadWindowPosition ();
            SensitiveToProjectContext ();
        }
Ejemplo n.º 25
0
        public void Run(IBrowsableCollection selection)
        {
            builder = new GtkBeans.Builder (null, "smugmug_export_dialog.ui", null);
            builder.Autoconnect (this);

            gallery_optionmenu = Gtk.ComboBox.NewText();
            album_optionmenu = Gtk.ComboBox.NewText();

            (edit_button.Parent as Gtk.HBox).PackStart (gallery_optionmenu);
            (album_button.Parent as Gtk.HBox).PackStart (album_optionmenu);
            (edit_button.Parent as Gtk.HBox).ReorderChild (gallery_optionmenu, 1);
            (album_button.Parent as Gtk.HBox).ReorderChild (album_optionmenu, 1);

            gallery_optionmenu.Show ();
            album_optionmenu.Show ();

            this.items = selection.Items;
            album_button.Sensitive = false;
            var view = new TrayView (selection);
            view.DisplayDates = false;
            view.DisplayTags = false;

            Dialog.Modal = false;
            Dialog.TransientFor = null;
            Dialog.Close += HandleCloseEvent;

            thumb_scrolledwindow.Add (view);
            view.Show ();
            Dialog.Show ();

            SmugMugAccountManager manager = SmugMugAccountManager.GetInstance ();
            manager.AccountListChanged += PopulateSmugMugOptionMenu;
            PopulateSmugMugOptionMenu (manager, null);

            if (edit_button != null)
                edit_button.Clicked += HandleEditGallery;

            Dialog.Response += HandleResponse;
            connect = true;
            HandleSizeActive (null, null);
            Connect ();

            LoadPreference (SCALE_KEY);
            LoadPreference (SIZE_KEY);
            LoadPreference (BROWSER_KEY);
        }
Ejemplo n.º 26
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 ();
        }