Пример #1
0
	public MainWindow (): base (MainClass.AppName)
	{
		this.Build();
				
		_views = new IGedcomView[]
		{
			SummaryViewView,
			FamilyViewView,
			IndividualViewView
		};
		_viewActions = new Gtk.Action[]
		{
			SummaryViewAction,
			FamilyViewAction,
			IndividualViewAction,
			SourceViewAction,
			MultimediaViewAction,
			RepositoryViewAction,
			PedigreeViewAction,
			NoteViewAction
		};
		
		foreach (IGedcomView view in _views)
		{
			view.MoreInformation += new EventHandler<IndividualArgs>(OnMoreInformation);
			view.MoreFamilyInformation += new EventHandler<FamilyArgs>(OnMoreFamilyInformation);
		    view.SpouseSelect += new EventHandler<SpouseSelectArgs>(OnSpouseSelect);
		    view.ShowSourceCitation += new EventHandler<SourceCitationArgs>(OnShowSourceCitation);
			view.SelectNewChild += new EventHandler<IndividualArgs>(OnSelectNewChild);
			view.SelectNewSpouse += new EventHandler<IndividualArgs>(OnSelectNewSpouse);
			view.SelectNewNote += new EventHandler<NoteArgs>(OnSelectNewNote);
			view.ShowScrapBook += new EventHandler<ScrapBookArgs>(OnShowScrapBook);
			view.ShowName += new EventHandler<IndividualArgs>(OnShowName);
			view.DeleteIndividual += new EventHandler<IndividualArgs>(OnDeleteIndividual);
			view.MoreFactInformation += new EventHandler<FactArgs>(OnMoreFactInformation);
		}

		SourceViewView.ShowScrapBook += new EventHandler<ScrapBookArgs>(OnShowScrapBook);
		SourceViewView.ShowSourceCitation += new EventHandler<SourceCitationArgs>(OnShowSourceCitation);
		MultimediaViewView.AddFile += new EventHandler<MultimediaFileArgs>(OnMultimediaView_AddFile);
		MultimediaViewView.OpenFile += new EventHandler<MultimediaFileArgs>(OnMultimediaView_OpenFile);
		MultimediaViewView.ShowSourceCitation += new EventHandler<SourceCitationArgs>(OnShowSourceCitation);
		RepositoryViewView.ShowSourceCitation += new EventHandler<SourceCitationArgs>(OnShowSourceCitation);
		NotesViewView.ShowSourceCitation += new EventHandler<SourceCitationArgs>(OnShowSourceCitation);
		
		// FIXME: not working via property in designer show all kicking in?
		NotesViewView.NoteOnly = true;
		
		ViewNotebook.ShowTabs = false;		
		ViewNotebook.Page = 0;
		_currentView = _views[0];
		
		ViewNotebook.Sensitive = false;
		Merge.Sensitive = false;
		Save.Sensitive = false;
		SaveAs.Sensitive = false;
		PropertiesAction.Sensitive = false;


		_viewGroup = View.ActionGroup;
		_toolsGroup = Tools.ActionGroup;
		_reportsGroup = Reports.ActionGroup;
		_defaultGroup = New.ActionGroup;		
		
		// get all report related actions, make insensitive
		foreach (Gtk.Action action in _reportsGroup.ListActions())
		{
			action.Sensitive = false;
		}
		
		// get all tools related actions, make insensitive
		foreach (Gtk.Action action in _toolsGroup.ListActions())
		{
			action.Sensitive = false;
		}
		
		// get all view related actions, make insensitive
		foreach (Gtk.Action action in _viewGroup.ListActions())
		{
			action.Sensitive = false;
		}
		SummaryViewAction.ActionGroup.Sensitive = true;

		NewIndividual.Sensitive = false;
		NewMedia.Sensitive = false;
		NewRepository.Sensitive = false;
		NewSource.Sensitive = false;
		NewNote.Sensitive = false;	

		// dropdown actions, not supported by stetic
		Gtk.UIManager manager = new Gtk.UIManager();
		GtkDropDownAction newDropDown = new GtkDropDownAction("New", "New", string.Empty, Gtk.Stock.New);
		newDropDown.Activated += OnNew_Activated;
		newDropDown.UIManager = manager;
		newDropDown.MenuPath = "/newpopup";
		manager.InsertActionGroup(_defaultGroup, 0);
		manager.AddUiFromString("<ui><popup name='newpopup'><menuitem action='NewDatabase'/><menuitem action='NewIndividual'/><menuitem action='NewMedia'/><menuitem action='NewRepository'/><menuitem action='NewSource'/><menuitem action='NewNote'/></popup></ui>");
		Gtk.Widget newButton = newDropDown.CreateToolItem();
		newDropDown.ConnectProxy(newButton);
		
		toolbar1.Insert((Gtk.ToolItem)newButton, 0);
		
		// gtk recent actions, not supported by stetic or gtk# 2.10
		_recentManager = Gtk.RecentManager.Default;
		//_recentManager.Limit = 4; // FIXME: don't hardcode max recent file count
		
		Gtk.RecentChooserMenu menu = new RecentChooserMenu(_recentManager);
		menu.LocalOnly = true;
		menu.SortType = RecentSortType.Mru;
		
		Gtk.RecentFilter filter = new RecentFilter();
		filter.Name = "GEDCOM files";
		filter.AddMimeType("application/x-gedcom");
		menu.AddFilter(filter);		
		menu.Filter = filter;
		menu.ItemActivated += RecentMenu_ItemActivated;
		_toolbarRecentMenu = menu;
		
		GtkDropDownAction recentDropDown = new GtkDropDownAction("Open", "Open", "Open File", Gtk.Stock.Open);
		recentDropDown.Menu = menu;
		recentDropDown.Activated += OnOpen_Activated;
		Gtk.Widget openButton = recentDropDown.CreateToolItem();
		recentDropDown.ConnectProxy(openButton);
		
		toolbar1.Insert((Gtk.ToolItem)openButton, 1);
	}
Пример #2
0
        public Actions (Client app, ActionManager action_manager) : base (action_manager, "Global")
        {
            this.app = app;
            undo_manager = new UndoManager ();

            AddImportant (
                new ActionEntry ("FileMenu", null, Catalog.GetString ("_File"), null, null, null),
                new ActionEntry ("Open",   Gtk.Stock.Open,   null, "<control>O", Catalog.GetString ("Open a document"), OnOpen),
                new ActionEntry ("Save",   Gtk.Stock.Save,   null, "<control>S", Catalog.GetString ("Save changes to this document, overwriting the existing file"), OnSave),
                new ActionEntry ("SaveAs", Gtk.Stock.SaveAs, null, "<control><shift>S", Catalog.GetString ("Save this document to a new file"), OnSaveAs),
                new ActionEntry ("RecentMenu", null, Catalog.GetString ("Recent _Files"), null, null, null),
                new ActionEntry ("InsertFrom", Gtk.Stock.Add, Catalog.GetString("_Insert From..."), null, Catalog.GetString("Insert pages from another document"), OnInsertFrom),
                new ActionEntry ("Close", Gtk.Stock.Close, null, "<control>W", null, OnClose),

                new ActionEntry ("EditMenu", null, Catalog.GetString ("_Edit"), null, null, null),
                new ActionEntry ("Undo", Stock.Undo, null, "<control>z", null, OnUndo),
                new ActionEntry ("Redo", Stock.Redo, null, "<control>y", null, OnRedo),
                new ActionEntry ("Extract", Gtk.Stock.New, null, null, null, OnExtractPages),
                new ActionEntry ("Remove", Gtk.Stock.Remove, null, "Delete", null, OnRemove),
                new ActionEntry ("RotateLeft", null, Catalog.GetString ("Rotate Left"), "bracketleft", Catalog.GetString ("Rotate left"), OnRotateLeft),
                new ActionEntry ("RotateRight", null, Catalog.GetString ("Rotate Right"), "bracketright", Catalog.GetString ("Rotate right"), OnRotateRight),
                new ActionEntry ("ExportImages", null, null, null, null, OnExportImages),
                new ActionEntry ("SelectAll", Stock.SelectAll, null, "<control>A", null, OnSelectAll),
                new ActionEntry ("SelectOdds", null, Catalog.GetString ("Select Odd Pages"), null, null, OnSelectOdds),
                new ActionEntry ("SelectEvens", null, Catalog.GetString ("Select Even Pages"), null, null, OnSelectEvens),
                new ActionEntry ("SelectMatching", null, Catalog.GetString ("Select Matching..."), "<control>F", null, OnSelectMatching),
                new ActionEntry ("SelectInverse", null, Catalog.GetString ("_Invert Selection"), "<shift><control>I", null, OnSelectInverse),

                new ActionEntry ("ViewMenu", null, Catalog.GetString ("_View"), null, null, null),
                new ActionEntry ("ZoomIn", Stock.ZoomIn, null, "<control>plus", null, OnZoomIn),
                new ActionEntry ("ZoomOut", Stock.ZoomOut, null, "<control>minus", null, OnZoomOut),
                new ActionEntry ("OpenInViewer", null, Catalog.GetString ("Open in Viewer"), "F5", Catalog.GetString ("Open in viewer"), OnOpenInViewer),

                new ActionEntry ("BookmarksMenu", null, Catalog.GetString ("_Bookmarks"), null, null, null),
                new ActionEntry ("AddBookmark", null, Catalog.GetString ("_Add Bookmark"), "<control>d", null, null),
                new ActionEntry ("RenameBookmark", null, Catalog.GetString ("Re_name Bookmark"), "F2", null, null),
                new ActionEntry ("ChangeBookmarkDest", null, Catalog.GetString ("_Change Bookmark Destination"), null, null, null),
                new ActionEntry ("RemoveBookmarks", Stock.Remove, Catalog.GetString ("_Remove Bookmark"), null, null, null),
                new ActionEntry ("EditBookmarks", null, Catalog.GetString ("_Edit Bookmarks"), "<control>B", null, OnEditBookmarks),

                new ActionEntry ("HelpMenu", null, Catalog.GetString ("_Help"), null, null, null),
                new ActionEntry ("Help", Stock.Help, Catalog.GetString ("_Contents"), "F1", null, OnHelp),
                new ActionEntry ("About", Stock.About, null, null, null, OnAbout),

                new ActionEntry ("PageContextMenu", null, "", null, null, OnPageContextMenu),
                new ActionEntry ("BookmarkContextMenu", null, "", null, null, OnBookmarkContextMenu)
            );

            this["AddBookmark"].ShortLabel = Catalog.GetString ("_Add");
            this["RemoveBookmarks"].ShortLabel = Catalog.GetString ("_Remove");

            AddImportant (
                new ToggleActionEntry ("Properties", Stock.Properties, null, "<alt>Return", Catalog.GetString ("View and edit the title, keywords, and more for this document"), OnProperties, false),
                new ToggleActionEntry ("ZoomFit", Stock.ZoomFit, null, "<control>0", null, OnZoomFit, true),
                new ToggleActionEntry ("ViewToolbar", null, Catalog.GetString ("Toolbar"), null, null, OnViewToolbar, Client.Configuration.ShowToolbar),
                new ToggleActionEntry ("ViewBookmarks", null, Catalog.GetString ("Bookmarks"), "F9", null, OnViewBookmarks, Client.Configuration.ShowBookmarks),
                new ToggleActionEntry ("FullScreenView", null, Catalog.GetString ("Fullscreen"), "F11", null, OnFullScreenView, false)
            );

            this["RotateRight"].IconName = "object-rotate-right";
            this["RotateLeft"].IconName = "object-rotate-left";
            this["ExportImages"].IconName = "image-x-generic";
            this["ViewBookmarks"].IconName = "user-bookmarks";
            this["AddBookmark"].IconName = "bookmark-new";

            UpdateAction ("Help", true);

            Update ();
            app.IconView.SelectionChanged += OnChanged;
            app.IconView.ZoomChanged += delegate { Update (); };
            app.DocumentLoaded += (o, a) => {
                app.Document.Changed += () => Update ();
                Update ();
            };
            undo_manager.UndoChanged += OnChanged;

            AddUiFromFile ("UIManager.xml");
            Register ();

            // Add additional menu item keybindings
            AddAccel ("/MainMenu/ViewMenu/ZoomIn",  Gdk.ModifierType.ControlMask, Gdk.Key.KP_Add, Gdk.Key.equal);
            AddAccel ("/MainMenu/ViewMenu/ZoomOut", Gdk.ModifierType.ControlMask, Gdk.Key.KP_Subtract, Gdk.Key.underscore);
            AddAccel ("/MainMenu/FileMenu/Close",   Gdk.ModifierType.ControlMask, Gdk.Key.q);
            AddAccel ("/MainMenu/EditMenu/Redo",    Gdk.ModifierType.ControlMask | Gdk.ModifierType.ShiftMask, Gdk.Key.z);

            // Set up recent documents menu
            MenuItem recent_item = ActionManager.UIManager.GetWidget ("/MainMenu/FileMenu/RecentMenu") as MenuItem;
            var recent_chooser_item = new RecentChooserMenu (RecentManager.Default) {
                Filter = new RecentFilter (),
                SortType = RecentSortType.Mru
            };
            recent_chooser_item.Filter.AddPattern ("*.pdf");
            recent_chooser_item.ItemActivated += delegate {
                Client.RunIdle (delegate { app.LoadPath (recent_chooser_item.CurrentUri); });
            };
            recent_item.Submenu = recent_chooser_item;
        }