Наследование: Core.Client
Пример #1
0
        public QueryBox (Client app)
        {
            this.app = app;
            AppPaintable = true;

            hbox = new HBox () { BorderWidth = 6 };

            Entry = new Gtk.Entry () { WidthChars = 40 };
            Entry.Activated += OnActivated;

            var query_button = new Hyena.Widgets.ImageButton (Catalog.GetString ("Select Matching"), Gtk.Stock.Find);
            query_button.Clicked += OnActivated;

            var close_button = new Hyena.Widgets.ImageButton (null, Gtk.Stock.Close);
            close_button.Clicked += delegate {
                Hide ();
            };

            hbox.PackStart (Entry, true, true, 0);
            hbox.PackStart (query_button, false, false, 0);
            hbox.PackStart (close_button, false, false, 0);
            Child = hbox;

            KeyPressEvent += delegate (object o, KeyPressEventArgs args) {
                if (args.Event.Key == Gdk.Key.Escape) {
                    Hide ();
                }
            };

            ShowAll ();
        }
Пример #2
0
        public DocumentIconView (Client app) : base ()
        {
            this.app = app;

            TooltipColumn = PageListStore.TooltipColumn;
            SelectionMode = SelectionMode.Multiple;
            ColumnSpacing = RowSpacing = Margin;
            Model = store = new PageListStore ();
            Reorderable = false;
            Spacing = 0;
            Orientation = Orientation.Vertical;

            // Properties not bound in Gtk#
            SetProperty ("item-padding", new GLib.Value ((int)0));

            CanZoomIn = CanZoomOut = true;

            page_renderer = new PageCell (this);
            PackStart (page_renderer, false);
            AddAttribute (page_renderer, "page", PageListStore.PageColumn);

            // TODO enable uri-list as drag source target for drag-out-of-pdfmod-to-extract feature
            EnableModelDragSource (Gdk.ModifierType.None, new TargetEntry [] { move_internal_target, move_external_target, uri_src_target }, Gdk.DragAction.Default | Gdk.DragAction.Move);
            EnableModelDragDest (new TargetEntry [] { move_internal_target, move_external_target, uri_dest_target }, Gdk.DragAction.Default | Gdk.DragAction.Move);

            SizeAllocated += HandleSizeAllocated;
            PopupMenu += HandlePopupMenu;
            ButtonPressEvent += HandleButtonPressEvent;
            SelectionChanged += HandleSelectionChanged;
            DragDataReceived += HandleDragDataReceived;
            DragDataGet += HandleDragDataGet;
            DragBegin += HandleDragBegin;
            DragLeave += HandleDragLeave;
        }
Пример #3
0
        public ZoomSlider (Client app) : base (1f, 0.5f, 0f, 0f)
        {
            RightPadding = 16;

            var box = new HBox () { Spacing = 2 };

            // Zoom in/out buttons
            var zoom_out = new Button (new Image (Stock.ZoomOut, IconSize.Button)) { Relief = ReliefStyle.None };
            app.Actions["ZoomOut"].ConnectProxy (zoom_out);

            var zoom_in  = new Button (new Image (Stock.ZoomIn, IconSize.Button)) { Relief = ReliefStyle.None };
            app.Actions["ZoomIn"].ConnectProxy (zoom_in);

            // Slider
            var slider = new HScale (DocumentIconView.MIN_WIDTH, DocumentIconView.MAX_WIDTH, 1) {
                WidthRequest = 100,
                DrawValue = false,
                Sensitive = false
            };

            bool setting_via_slider = false;
            slider.ValueChanged += (o, a) => {
                if (!setting_via_slider) {
                    setting_via_slider = true;
                    app.IconView.Zoom ((int)slider.Value, true);
                    setting_via_slider = false;
                }
            };

            app.IconView.ZoomChanged += () => {
                if (!setting_via_slider) {
                    setting_via_slider = true;
                    slider.Value = app.IconView.ItemSize;
                    setting_via_slider = false;
                }
            };

            app.DocumentLoaded += (o, a) => slider.Sensitive = app.Document != null;
            box.PackStart (zoom_out, false, false, 0);
            box.PackStart (slider,   false, false, 0);
            box.PackStart (zoom_in,  false, false, 0);
            Child = box;
        }
Пример #4
0
        public MetadataEditorBox (Client app)
        {
            this.app = app;
            app.DocumentLoaded += HandleDocumentLoaded;

            Child = table = new Table (2, 5, false) {
                RowSpacing = 6,
                ColumnSpacing = 6,
                BorderWidth = 6
            };

            BuildEditor ();
            BuildButtons ();

            KeyPressEvent += (o, args) => {
                if (args.Event.Key == Gdk.Key.Escape) {
                    Hide ();
                }
            };

            UpdateSensitivity ();
            ShowAll ();
        }
Пример #5
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;
        }