Пример #1
0
        public void RegisterActions(Gtk.Application app, GLib.Menu menu)
        {
            app.AddAccelAction(Contents, "F1");
            menu.AppendItem(Contents.CreateMenuItem());

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

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

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

            // This is part of the application menu on macOS.
            if (PintaCore.System.OperatingSystem != OS.Mac)
            {
                var about_section = new GLib.Menu();
                menu.AppendSection(null, about_section);

                var about = PintaCore.Actions.App.About;
                app.AddAction(about);
                about_section.AppendItem(about.CreateMenuItem());
            }
        }
Пример #2
0
        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());
        }
Пример #3
0
        public void RegisterActions(Gtk.Application app, GLib.Menu menu)
        {
            app.AddAction(About);
            menu.AppendItem(About.CreateMenuItem());

            app.AddAccelAction(Exit, "<Primary>Q");
            menu.AppendItem(Exit.CreateMenuItem());
        }
Пример #4
0
        public void RegisterActions(Gtk.Application app, GLib.Menu menu)
        {
            app.AddAccelAction(SaveAll, "<Ctrl><Alt>A");
            menu.AppendItem(SaveAll.CreateMenuItem());

            app.AddAccelAction(CloseAll, "<Primary><Shift>W");
            menu.AppendItem(CloseAll.CreateMenuItem());

            doc_section = new GLib.Menu();
            menu.AppendSection(null, doc_section);

            app.AddAction(active_doc_action);
        }
Пример #5
0
        public void Initialize(Dock workspace, Application app, GLib.Menu padMenu)
        {
            var      layers      = new LayersListWidget();
            DockItem layers_item = new DockItem(layers, "Layers")
            {
                Label = Translations.GetString("Layers")
            };

            var layers_tb = layers_item.AddToolBar();

            layers_tb.Add(PintaCore.Actions.Layers.AddNewLayer.CreateDockToolBarItem());
            layers_tb.Add(PintaCore.Actions.Layers.DeleteLayer.CreateDockToolBarItem());
            layers_tb.Add(PintaCore.Actions.Layers.DuplicateLayer.CreateDockToolBarItem());
            layers_tb.Add(PintaCore.Actions.Layers.MergeLayerDown.CreateDockToolBarItem());
            layers_tb.Add(PintaCore.Actions.Layers.MoveLayerUp.CreateDockToolBarItem());
            layers_tb.Add(PintaCore.Actions.Layers.MoveLayerDown.CreateDockToolBarItem());

            // TODO-GTK3 (docking)
#if false
            layers_item.Icon         = Gtk.IconTheme.Default.LoadIcon(Resources.Icons.LayerMergeDown, 16);
            layers_item.DefaultWidth = 100;
            layers_item.Behavior    |= DockItemBehavior.CantClose;
#endif
            workspace.AddItem(layers_item, DockPlacement.Right);

            var show_layers = new ToggleCommand("layers", Translations.GetString("Layers"), null, Resources.Icons.LayerMergeDown)
            {
                Value = true
            };
            app.AddAction(show_layers);
            padMenu.AppendItem(show_layers.CreateMenuItem());

            show_layers.Toggled += (val) => { layers_item.Visible = val; };
            layers_item.VisibilityNotifyEvent += (o, args) => { show_layers.Value = layers_item.Visible; };
        }
Пример #6
0
        public void Initialize(Dock workspace, Application app, GLib.Menu padMenu)
        {
            var      history      = new HistoryTreeView();
            DockItem history_item = new DockItem(history, "History")
            {
                Label = Translations.GetString("History")
            };

            // TODO-GTK3 (docking)
#if false
            history_item.DefaultLocation = "Images/Bottom";
            history_item.Icon            = Gtk.IconTheme.Default.LoadIcon(Resources.Icons.LayerDuplicate, 16);
            history_item.DefaultWidth    = 100;
            history_item.Behavior       |= DockItemBehavior.CantClose;
#endif
            var history_tb = history_item.AddToolBar();
            history_tb.Add(PintaCore.Actions.Edit.Undo.CreateDockToolBarItem());
            history_tb.Add(PintaCore.Actions.Edit.Redo.CreateDockToolBarItem());

            workspace.AddItem(history_item, DockPlacement.Right);

            var show_history = new ToggleCommand("history", Translations.GetString("History"), null, Resources.Icons.LayerDuplicate)
            {
                Value = true
            };
            app.AddAction(show_history);
            padMenu.AppendItem(show_history.CreateMenuItem());

            show_history.Toggled += (val) => { history_item.Visible = val; };
            history_item.VisibilityNotifyEvent += (o, args) => { show_history.Value = history_item.Visible; };
        }
Пример #7
0
        private void Fill()
        {
            var menu = new GLib.Menu();

            menu.AppendItem(new GLib.MenuItem("Help", "app.help"));
            menu.AppendItem(new GLib.MenuItem("About", "app.about"));
            menu.AppendItem(new GLib.MenuItem("Quit", "app.quit"));
            app.AppMenu = menu;

            win.DefaultSize = new Size(300, 300);

            var s = new Scale(Orientation.Horizontal, 0, 100, 1);

            s.ShowAll();
            win.Add(s);
        }
Пример #8
0
        public void RegisterActions(Gtk.Application app, GLib.Menu menu)
        {
            app.AddAction(AddinManager);
            menu.AppendItem(AddinManager.CreateMenuItem());

            addins_menu = new GLib.Menu();
            menu.AppendSection(null, addins_menu);
        }
Пример #9
0
        public void RegisterActions(Gtk.Application app, GLib.Menu menu)
        {
            app.AddAccelAction(CropToSelection, "<Primary><Shift>X");
            menu.AppendItem(CropToSelection.CreateMenuItem());

            app.AddAccelAction(AutoCrop, "<Ctrl><Alt>X");
            menu.AppendItem(AutoCrop.CreateMenuItem());

            app.AddAccelAction(Resize, "<Primary>R");
            menu.AppendItem(Resize.CreateMenuItem());

            app.AddAccelAction(CanvasSize, "<Primary><Shift>R");
            menu.AppendItem(CanvasSize.CreateMenuItem());

            var flip_section = new GLib.Menu();

            menu.AppendSection(null, flip_section);

            app.AddAction(FlipHorizontal);
            flip_section.AppendItem(FlipHorizontal.CreateMenuItem());

            app.AddAction(FlipVertical);
            flip_section.AppendItem(FlipVertical.CreateMenuItem());

            var rotate_section = new GLib.Menu();

            menu.AppendSection(null, rotate_section);

            app.AddAccelAction(RotateCW, "<Primary>H");
            rotate_section.AppendItem(RotateCW.CreateMenuItem());

            app.AddAccelAction(RotateCCW, "<Primary>G");
            rotate_section.AppendItem(RotateCCW.CreateMenuItem());

            app.AddAccelAction(Rotate180, "<Primary>J");
            rotate_section.AppendItem(Rotate180.CreateMenuItem());

            var flatten_section = new GLib.Menu();

            menu.AppendSection(null, flatten_section);

            app.AddAccelAction(Flatten, "<Primary><Shift>F");
            flatten_section.AppendItem(Flatten.CreateMenuItem());
        }
Пример #10
0
        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
        }
Пример #11
0
        public void RegisterActions(Gtk.Application app, GLib.Menu menu)
        {
            app.AddAccelAction(AddNewLayer, "<Primary><Shift>N");
            menu.AppendItem(AddNewLayer.CreateMenuItem());

            app.AddAccelAction(DeleteLayer, "<Primary><Shift>Delete");
            menu.AppendItem(DeleteLayer.CreateMenuItem());

            app.AddAccelAction(DuplicateLayer, "<Primary><Shift>D");
            menu.AppendItem(DuplicateLayer.CreateMenuItem());

            app.AddAccelAction(MergeLayerDown, "<Primary>M");
            menu.AppendItem(MergeLayerDown.CreateMenuItem());

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

            var flip_section = new GLib.Menu();

            menu.AppendSection(null, flip_section);

            app.AddAction(FlipHorizontal);
            flip_section.AppendItem(FlipHorizontal.CreateMenuItem());

            app.AddAction(FlipVertical);
            flip_section.AppendItem(FlipVertical.CreateMenuItem());

            app.AddAction(RotateZoom);
            flip_section.AppendItem(RotateZoom.CreateMenuItem());

            var prop_section = new GLib.Menu();

            menu.AppendSection(null, prop_section);

            app.AddAccelAction(Properties, "F4");
            prop_section.AppendItem(Properties.CreateMenuItem());

            app.AddAction(MoveLayerDown);
            app.AddAction(MoveLayerUp);
        }
Пример #12
0
        private void AddDocumentMenuItem(int idx)
        {
            var doc       = PintaCore.Workspace.OpenDocuments[idx];
            var action_id = string.Format("app.{0}({1})", doc_action_id, idx);
            var label     = string.Format("{0}{1}", doc.Filename, doc.IsDirty ? "*" : string.Empty);
            var menu_item = new GLib.MenuItem(label, action_id);

            doc_section.AppendItem(menu_item);

            // We only assign accelerators up to Alt-9
            if (idx < 9)
            {
                PintaCore.Chrome.Application.SetAccelsForAction(action_id, new[] { string.Format("<Alt>{0}", idx + 1) });
            }
        }
Пример #13
0
        public static void AppendMenuItemSorted(this GLib.Menu menu, GLib.MenuItem item)
        {
            var new_label = (string)item.GetAttributeValue("label", GLib.VariantType.String);

            for (int i = 0; i < menu.NItems; i++)
            {
                var label = (string)menu.GetItemAttributeValue(i, "label", GLib.VariantType.String);
                if (string.Compare(label, new_label) > 0)
                {
                    menu.InsertItem(i, item);
                    return;
                }
            }

            menu.AppendItem(item);
        }
Пример #14
0
        public ToolBarItem AddItem(string text, string imageId, object?tag)
        {
            ToolBarItem item = new ToolBarItem(text, imageId, tag);

            action_group.AddAction(item.Action);
            dropdown.AppendItem(new GLib.MenuItem(text, string.Format("{0}.{1}", action_prefix, item.Action.Name)));

            Items.Add(item);
            item.Action.Activated += delegate { SetSelectedItem(item); };

            if (selected_item == null)
            {
                SetSelectedItem(item);
            }

            return(item);
        }
Пример #15
0
        public static void Main(string[] args)
        {
            Application.Init();

            App = new Application("org.Samples.Samples", GLib.ApplicationFlags.None);
            App.Register(GLib.Cancellable.Current);

            Win = new ConfigForm();
            App.AddWindow(Win);

            var menu = new GLib.Menu();

            menu.AppendItem(new GLib.MenuItem("Quit", "app.quit"));
            App.AppMenu = menu;

            var quitAction = new GLib.SimpleAction("quit", null);

            quitAction.Activated += QuitActivated;
            App.AddAction(quitAction);

            Win.ShowAll();
            Application.Run();
        }
Пример #16
0
        public void RegisterActions(Gtk.Application app, GLib.Menu menu)
        {
            app.AddAccelAction(Undo, "<Primary>Z");
            menu.AppendItem(Undo.CreateMenuItem());

            app.AddAccelAction(Redo, new[] { "<Primary><Shift>Z", "<Ctrl>Y" });
            menu.AppendItem(Redo.CreateMenuItem());

            var paste_section = new GLib.Menu();

            menu.AppendSection(null, paste_section);

            app.AddAccelAction(Cut, "<Primary>X");
            paste_section.AppendItem(Cut.CreateMenuItem());

            app.AddAccelAction(Copy, "<Primary>C");
            paste_section.AppendItem(Copy.CreateMenuItem());

            app.AddAccelAction(CopyMerged, "<Primary><Shift>C");
            paste_section.AppendItem(CopyMerged.CreateMenuItem());

            app.AddAccelAction(Paste, "<Primary>V");
            paste_section.AppendItem(Paste.CreateMenuItem());

            app.AddAccelAction(PasteIntoNewLayer, "<Primary><Shift>V");
            paste_section.AppendItem(PasteIntoNewLayer.CreateMenuItem());

            app.AddAccelAction(PasteIntoNewImage, "<Primary><Alt>V");
            paste_section.AppendItem(PasteIntoNewImage.CreateMenuItem());

            var sel_section = new GLib.Menu();

            menu.AppendSection(null, sel_section);

            app.AddAccelAction(SelectAll, "<Primary>A");
            sel_section.AppendItem(SelectAll.CreateMenuItem());

            app.AddAccelAction(Deselect, new[] { "<Primary><Shift>A", "<Ctrl>D" });
            sel_section.AppendItem(Deselect.CreateMenuItem());

            var edit_sel_section = new GLib.Menu();

            menu.AppendSection(null, edit_sel_section);

            app.AddAccelAction(EraseSelection, "Delete");
            edit_sel_section.AppendItem(EraseSelection.CreateMenuItem());

            app.AddAccelAction(FillSelection, "BackSpace");
            edit_sel_section.AppendItem(FillSelection.CreateMenuItem());

            app.AddAccelAction(InvertSelection, "<Primary>I");
            edit_sel_section.AppendItem(InvertSelection.CreateMenuItem());

            var palette_section = new GLib.Menu();

            menu.AppendSection(null, palette_section);

            var palette_menu = new GLib.Menu();

            menu.AppendSubmenu(Translations.GetString("Palette"), palette_menu);

            app.AddAction(LoadPalette);
            palette_menu.AppendItem(LoadPalette.CreateMenuItem());

            app.AddAction(SavePalette);
            palette_menu.AppendItem(SavePalette.CreateMenuItem());

            app.AddAction(ResetPalette);
            palette_menu.AppendItem(ResetPalette.CreateMenuItem());

            app.AddAction(ResizePalette);
            palette_menu.AppendItem(ResizePalette.CreateMenuItem());
        }
Пример #17
0
 /// <summary>
 /// Adds a new item to the Add-ins menu.
 /// </summary>
 public void AddMenuItem(GLib.MenuItem item)
 {
     addins_menu.AppendItem(item);
 }