コード例 #1
0
ファイル: ViewActions.cs プロジェクト: mfcallahan/Pinta
        public void RegisterActions(Gtk.Application app, GLib.Menu menu)
        {
            var zoom_section = new GLib.Menu();

            menu.AppendSection(null, zoom_section);

            app.AddAccelAction(ZoomIn, new[] { "<Primary>plus", "<Primary>equal", "equal", "<Primary>KP_Add", "KP_Add" });
            zoom_section.AppendItem(ZoomIn.CreateMenuItem());

            app.AddAccelAction(ZoomOut, new[] { "<Primary>minus", "<Primary>underscore", "minus", "<Primary>KP_Subtract", "KP_Subtract" });
            zoom_section.AppendItem(ZoomOut.CreateMenuItem());

            app.AddAccelAction(ActualSize, new[] { "<Primary>0", "<Primary><Shift>A" });
            zoom_section.AppendItem(ActualSize.CreateMenuItem());

            app.AddAccelAction(ZoomToWindow, "<Primary>B");
            zoom_section.AppendItem(ZoomToWindow.CreateMenuItem());

            app.AddAccelAction(Fullscreen, "F11");
            zoom_section.AppendItem(Fullscreen.CreateMenuItem());

            var metric_section = new GLib.Menu();

            menu.AppendSection(null, metric_section);

            var metric_menu = new GLib.Menu();

            metric_section.AppendSubmenu(Translations.GetString("Ruler Units"), metric_menu);

            app.AddAction(RulerMetric);
            metric_menu.Append(Translations.GetString("Pixels"), $"app.{RulerMetric.Name}(0)");
            metric_menu.Append(Translations.GetString("Inches"), $"app.{RulerMetric.Name}(1)");
            metric_menu.Append(Translations.GetString("Centimeters"), $"app.{RulerMetric.Name}(2)");

            var show_hide_section = new GLib.Menu();

            menu.AppendSection(null, show_hide_section);

            var show_hide_menu = new GLib.Menu();

            show_hide_section.AppendSubmenu(Translations.GetString("Show/Hide"), show_hide_menu);

            app.AddAction(PixelGrid);
            show_hide_menu.AppendItem(PixelGrid.CreateMenuItem());

            app.AddAction(Rulers);
            show_hide_menu.AppendItem(Rulers.CreateMenuItem());

            app.AddAction(ToolBar);
            show_hide_menu.AppendItem(ToolBar.CreateMenuItem());

            app.AddAction(StatusBar);
            show_hide_menu.AppendItem(StatusBar.CreateMenuItem());

            app.AddAction(ToolBox);
            show_hide_menu.AppendItem(ToolBox.CreateMenuItem());

            app.AddAction(ImageTabs);
            show_hide_menu.AppendItem(ImageTabs.CreateMenuItem());
        }
コード例 #2
0
ファイル: FileActions.cs プロジェクト: mfcallahan/Pinta
        public void RegisterActions(Gtk.Application app, GLib.Menu menu)
        {
            app.AddAccelAction(New, "<Primary>N");
            menu.AppendItem(New.CreateMenuItem());

            app.AddAction(NewScreenshot);
            menu.AppendItem(NewScreenshot.CreateMenuItem());

            app.AddAccelAction(Open, "<Primary>O");
            menu.AppendItem(Open.CreateMenuItem());

            var save_section = new GLib.Menu();

            menu.AppendSection(null, save_section);

            app.AddAccelAction(Save, "<Primary>S");
            save_section.AppendItem(Save.CreateMenuItem());

            app.AddAccelAction(SaveAs, "<Primary><Shift>S");
            save_section.AppendItem(SaveAs.CreateMenuItem());

            var close_section = new GLib.Menu();

            menu.AppendSection(null, close_section);

            app.AddAccelAction(Close, "<Primary>W");
            close_section.AppendItem(Close.CreateMenuItem());

            // This is part of the application menu on macOS.
            if (PintaCore.System.OperatingSystem != OS.Mac)
            {
                var exit = PintaCore.Actions.App.Exit;
                app.AddAccelAction(exit, "<Primary>Q");
                close_section.AppendItem(exit.CreateMenuItem());
            }

            // Printing is disabled for now until it is fully functional.
#if false
            menu.Append(Print.CreateAcceleratedMenuItem(Gdk.Key.P, Gdk.ModifierType.ControlMask));
            menu.AppendSeparator();
#endif
        }