コード例 #1
0
        public static void Main(string[] args)
        {
            Application.Init();

            App = new Application("local.SiKLink.SiKGuiGtk", GLib.ApplicationFlags.None);
            App.Register(GLib.Cancellable.Current);

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

            var menu = new GLib.Menu();

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

            var aboutAction = new GLib.SimpleAction("about", null);

            aboutAction.Activated += AboutActivated;
            App.AddAction(aboutAction);

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

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

            Win.ShowAll();
            Application.Run();
        }
コード例 #2
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; };
        }
コード例 #3
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());
            }
        }
コード例 #4
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; };
        }
コード例 #5
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());
        }
コード例 #6
0
ファイル: AppActions.cs プロジェクト: mfcallahan/Pinta
        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());
        }
コード例 #7
0
ファイル: AddinActions.cs プロジェクト: mfcallahan/Pinta
        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);
        }
コード例 #8
0
        public GLib.Menu GetMenuById(string id)
        {
            IntPtr native_id = GLib.Marshaller.StringToPtrGStrdup(id);
            IntPtr raw_ret   = gtk_application_get_menu_by_id(Handle, native_id);

            GLib.Menu ret = GLib.Object.GetObject(raw_ret) as GLib.Menu;
            GLib.Marshaller.Free(native_id);
            return(ret);
        }
コード例 #9
0
 public static void Remove(this GLib.Menu menu, Command action)
 {
     for (int i = 0; i < menu.NItems; ++i)
     {
         var name_attr = (string)menu.GetItemAttributeValue(i, "action", GLib.VariantType.String);
         if (name_attr == action.FullName)
         {
             menu.Remove(i);
             return;
         }
     }
 }
コード例 #10
0
ファイル: WindowActions.cs プロジェクト: mfcallahan/Pinta
        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);
        }
コード例 #11
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);
        }
コード例 #12
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);
        }
コード例 #13
0
ファイル: EffectsActions.cs プロジェクト: mfcallahan/Pinta
        public void AddEffect(string category, Command action)
        {
            var effects_menu = PintaCore.Chrome.EffectsMenu;

            if (!Menus.ContainsKey(category))
            {
                var category_menu = new GLib.Menu();
                effects_menu.AppendMenuItemSorted(GLib.MenuItem.NewSubmenu(Translations.GetString(category), category_menu));
                Menus.Add(category, category_menu);
            }

            Actions.Add(action);

            GLib.Menu m = Menus[category];
            m.AppendMenuItemSorted(action.CreateMenuItem());
        }
コード例 #14
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());
        }
コード例 #15
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
        }
コード例 #16
0
ファイル: LayerActions.cs プロジェクト: mfcallahan/Pinta
        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);
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: techyian/SwitchCam
        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();
        }
コード例 #18
0
        public ToolBarDropDownButton(bool showLabel = false)
        {
            Items = new List <ToolBarItem> ();

            menu_button = new Gtk.MenuButton();
            image       = new Image();

            dropdown = new GLib.Menu();
            menu_button.MenuModel  = dropdown;
            menu_button.UsePopover = false;

            action_group = new GLib.SimpleActionGroup();
            menu_button.InsertActionGroup(action_prefix, action_group);

            var box = new HBox();

            if (showLabel)
            {
                box.PackStart(image, true, true, 3);
                label_widget = new Gtk.Label();
                box.PackStart(label_widget, true, false, 2);
            }
            else
            {
                box.PackStart(image, true, true, 5);
            }

            var alignment = new Alignment(0f, 0.5f, 0f, 0f);
            var arrow     = new Arrow(ArrowType.Down, ShadowType.None);

            alignment.Add(arrow);
            box.PackStart(alignment, false, false, 0);

            menu_button.Add(box);
            Add(menu_button);
            ShowAll();
        }
コード例 #19
0
ファイル: EditActions.cs プロジェクト: mfcallahan/Pinta
        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());
        }
コード例 #20
0
 public void InitializeMainMenu(GLib.Menu adj_menu, GLib.Menu effects_menu)
 {
     AdjustmentsMenu = adj_menu;
     EffectsMenu     = effects_menu;
 }