[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - vcl/inc vcl/unx
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Jan 11 16:27:17 UTC 2019
vcl/inc/unx/gtk/gtksalmenu.hxx | 1 +
vcl/unx/gtk/gtksalmenu.cxx | 15 ++++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
New commits:
commit 10d1a285511bc9109f44cc6da2558d820bef321c
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Dec 14 15:22:59 2018 +0000
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Jan 11 17:26:52 2019 +0100
tdf#116290 allow menubar to shrink past its minimum size
with a scrolledwindow with a horizontal external policy which doesn't
show a scrollbar, but allows the scrolledwindow to shrink past its
child size
Change-Id: Ia73fc819a16bef49008e7e41bcc2d523c28268b0
Reviewed-on: https://gerrit.libreoffice.org/65173
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index b9ac55570f0d..b162f7e34182 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -55,6 +55,7 @@ private:
bool mbReturnFocusToDocument;
bool mbAddedGrab;
GtkWidget* mpMenuBarContainerWidget;
+ GtkWidget* mpMenuAllowShrinkWidget;
GtkWidget* mpMenuBarWidget;
GtkWidget* mpCloseButton;
VclPtr<Menu> mpVCLMenu;
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
index c946ae0d32d4..9755afb78aad 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -497,6 +497,7 @@ GtkSalMenu::GtkSalMenu( bool bMenuBar ) :
mbReturnFocusToDocument( false ),
mbAddedGrab( false ),
mpMenuBarContainerWidget( nullptr ),
+ mpMenuAllowShrinkWidget( nullptr ),
mpMenuBarWidget( nullptr ),
mpCloseButton( nullptr ),
mpVCLMenu( nullptr ),
@@ -785,10 +786,21 @@ void GtkSalMenu::CreateMenuBarWidget()
gtk_grid_insert_row(pGrid, 0);
gtk_grid_attach(pGrid, mpMenuBarContainerWidget, 0, 0, 1, 1);
+ mpMenuAllowShrinkWidget = gtk_scrolled_window_new(nullptr, nullptr);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(mpMenuAllowShrinkWidget), GTK_SHADOW_NONE);
+ // tdf#116290 external policy on scrolledwindow will not show a scrollbar,
+ // but still allow scrolled window to not be sized to the child content.
+ // So the menubar can be shrunk past its nominal smallest width.
+ // Unlike a hack using GtkFixed/GtkLayout the correct placement of the menubar occurs under RTL
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(mpMenuAllowShrinkWidget), GTK_POLICY_EXTERNAL, GTK_POLICY_NEVER);
+ gtk_grid_attach(GTK_GRID(mpMenuBarContainerWidget), mpMenuAllowShrinkWidget, 0, 0, 1, 1);
+
mpMenuBarWidget = gtk_menu_bar_new_from_model(mpMenuModel);
gtk_widget_insert_action_group(mpMenuBarWidget, "win", mpActionGroup);
gtk_widget_set_hexpand(GTK_WIDGET(mpMenuBarWidget), true);
- gtk_grid_attach(GTK_GRID(mpMenuBarContainerWidget), mpMenuBarWidget, 0, 0, 1, 1);
+ gtk_widget_set_hexpand(mpMenuAllowShrinkWidget, true);
+ gtk_container_add(GTK_CONTAINER(mpMenuAllowShrinkWidget), mpMenuBarWidget);
+
g_signal_connect(G_OBJECT(mpMenuBarWidget), "deactivate", G_CALLBACK(MenuBarReturnFocus), this);
g_signal_connect(G_OBJECT(mpMenuBarWidget), "key-press-event", G_CALLBACK(MenuBarSignalKey), this);
@@ -796,6 +808,7 @@ void GtkSalMenu::CreateMenuBarWidget()
ShowCloseButton( static_cast<MenuBar*>(mpVCLMenu.get())->HasCloseButton() );
#else
+ (void)mpMenuAllowShrinkWidget;
(void)mpMenuBarContainerWidget;
#endif
}
More information about the Libreoffice-commits
mailing list