[Libreoffice-commits] core.git: vcl/inc vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Dec 15 00:58:27 UTC 2018


 vcl/inc/unx/gtk/gtksalmenu.hxx |    1 +
 vcl/unx/gtk/gtksalmenu.cxx     |   15 ++++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 4f4f74642838d19278339fac9f8bc75ed8bfe1d5
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Dec 14 15:22:59 2018 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sat Dec 15 01:57:59 2018 +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/65171
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 2c287aa93354..9ab448857085 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 f9053ce23f6f..f6f45cf4acad 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -528,6 +528,7 @@ GtkSalMenu::GtkSalMenu( bool bMenuBar ) :
     mbReturnFocusToDocument( false ),
     mbAddedGrab( false ),
     mpMenuBarContainerWidget( nullptr ),
+    mpMenuAllowShrinkWidget( nullptr ),
     mpMenuBarWidget( nullptr ),
     mpCloseButton( nullptr ),
     mpVCLMenu( nullptr ),
@@ -815,10 +816,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);
 
@@ -826,6 +838,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