From d27f13a56a1d1eadac0f9ed6b3e58bd56d40dd2b Mon Sep 17 00:00:00 2001 From: Cameron White Date: Thu, 23 Apr 2026 23:31:21 -0400 Subject: [PATCH] Configure menu buttons to show traditional submenus without sliding --- .../Extensions/Gtk/GtkExtensions.Widget.cs | 16 +++++ Pinta/MainWindow.cs | 59 +++++++++---------- Pinta/Pads/LayersPad.cs | 18 +++--- 3 files changed, 51 insertions(+), 42 deletions(-) diff --git a/Pinta.Core/Extensions/Gtk/GtkExtensions.Widget.cs b/Pinta.Core/Extensions/Gtk/GtkExtensions.Widget.cs index d03044160d..73e1294ccd 100644 --- a/Pinta.Core/Extensions/Gtk/GtkExtensions.Widget.cs +++ b/Pinta.Core/Extensions/Gtk/GtkExtensions.Widget.cs @@ -171,6 +171,22 @@ public static Gtk.SpinButton CreateToolBarSpinButton ( return spin; } + /// + /// Creates a Gtk.MenuButton with the popover configured to show regular nested + /// menus rather than sliding menus. + /// + public static Gtk.MenuButton CreateMenuButton (Gio.MenuModel model, string iconName, string? tooltip = null) + { + Gtk.PopoverMenu popover = Gtk.PopoverMenu.NewFromModelFull (model, Gtk.PopoverMenuFlags.Nested); + + Gtk.MenuButton menu = Gtk.MenuButton.New (); + menu.Popover = popover; + menu.IconName = iconName; + menu.TooltipText = tooltip; + + return menu; + } + public static Gtk.Scale CreateToolBarSlider ( int min, int max, diff --git a/Pinta/MainWindow.cs b/Pinta/MainWindow.cs index 09385fc515..c011128057 100644 --- a/Pinta/MainWindow.cs +++ b/Pinta/MainWindow.cs @@ -434,38 +434,33 @@ private void CreateMainMenu () private void CreateMainToolBar () { if (window_shell.HeaderBar is not null) { - var header_bar = window_shell.HeaderBar; - header_bar.PackEnd (new Gtk.MenuButton () { - MenuModel = this.menu_bar, - IconName = Resources.StandardIcons.OpenMenu, - TooltipText = Translations.GetString ("Main Menu"), - }); - - header_bar.PackEnd (new Gtk.MenuButton () { - MenuModel = PintaCore.Chrome.EffectsMenu, - IconName = Resources.Icons.EffectsDefault, - TooltipText = Translations.GetString ("Effects"), - }); - - header_bar.PackEnd (new Gtk.MenuButton () { - MenuModel = PintaCore.Chrome.AdjustmentsMenu, - IconName = Resources.Icons.AdjustmentsDefault, - TooltipText = Translations.GetString ("Adjustments"), - }); - - header_bar.PackEnd (new Gtk.MenuButton () { - MenuModel = this.image_menu, - IconName = Resources.StandardIcons.ImageGeneric, - TooltipText = Translations.GetString ("Image"), - }); - - header_bar.PackEnd (new Gtk.MenuButton () { - MenuModel = this.view_menu, - IconName = Resources.StandardIcons.ViewReveal, - TooltipText = Translations.GetString ("View"), - }); - - PintaCore.Actions.CreateHeaderToolBar (header_bar); + var headerBar = window_shell.HeaderBar; + headerBar.PackEnd (GtkExtensions.CreateMenuButton ( + this.menu_bar, + Resources.StandardIcons.OpenMenu, + Translations.GetString ("Main Menu"))); + + headerBar.PackEnd (GtkExtensions.CreateMenuButton ( + PintaCore.Chrome.EffectsMenu, + Resources.Icons.EffectsDefault, + Translations.GetString ("Effects"))); + + headerBar.PackEnd (GtkExtensions.CreateMenuButton ( + PintaCore.Chrome.AdjustmentsMenu, + Resources.Icons.AdjustmentsDefault, + Translations.GetString ("Adjustments"))); + + headerBar.PackEnd (GtkExtensions.CreateMenuButton ( + this.image_menu, + Resources.StandardIcons.ImageGeneric, + Translations.GetString ("Image"))); + + headerBar.PackEnd (GtkExtensions.CreateMenuButton ( + this.view_menu, + Resources.StandardIcons.ViewReveal, + Translations.GetString ("View"))); + + PintaCore.Actions.CreateHeaderToolBar (headerBar); } else { var main_toolbar = window_shell.CreateToolBar ("main_toolbar"); PintaCore.Actions.CreateToolBar (main_toolbar); diff --git a/Pinta/Pads/LayersPad.cs b/Pinta/Pads/LayersPad.cs index ae573135fa..2a45f09ecf 100644 --- a/Pinta/Pads/LayersPad.cs +++ b/Pinta/Pads/LayersPad.cs @@ -1,21 +1,21 @@ -// +// // LayersPad.cs -// +// // Author: // Jonathan Pobst -// +// // Copyright (c) 2011 Jonathan Pobst -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -63,10 +63,8 @@ public void Initialize (Dock workspace) hamburger_menu.AppendSection (null, flip_section); hamburger_menu.AppendSection (null, prop_section); - Gtk.MenuButton hamburger_button = new Gtk.MenuButton () { - MenuModel = hamburger_menu, - IconName = Resources.StandardIcons.OpenMenu - }; + Gtk.MenuButton hamburger_button = GtkExtensions.CreateMenuButton ( + hamburger_menu, Resources.StandardIcons.OpenMenu); hamburger_button.Direction = Gtk.ArrowType.Up;