RunIdle() public static method

public static RunIdle ( InvokeHandler handler ) : void
handler InvokeHandler
return void
示例#1
0
        // File menu actions

        void OnOpen(object o, EventArgs args)
        {
            var chooser = app.CreateChooser(Catalog.GetString("Select PDF"), FileChooserAction.Open);

            chooser.SelectMultiple = true;
            chooser.AddButton(Stock.Open, ResponseType.Ok);

            if (app.Document != null)
            {
                chooser.SetCurrentFolder(System.IO.Path.GetDirectoryName(app.Document.SuggestedSavePath));
            }
            else
            {
                chooser.SetCurrentFolder(Client.Configuration.LastOpenFolder);
            }

            var response  = chooser.Run();
            var filenames = chooser.Filenames;

            chooser.Destroy();

            if (response == (int)ResponseType.Ok)
            {
                Client.RunIdle(delegate {
                    foreach (var file in filenames)
                    {
                        app.LoadPath(file);
                    }
                });
            }
        }
示例#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;
        }