sfx2/source/sidebar/TabBar.cxx |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

New commits:
commit bc73078803956561334f283311a83ff6e210723a
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Aug 10 14:14:41 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Aug 11 10:08:05 2022 +0200

    gtk4: get the menu in sidebar menubutton working
    
    this is an edge case where for gtk3 there has to be a GtkWindow present
    to support the accelerators, and for gtk4 the final window the
    menubutton is in must be the same one present when the actions were
    created.
    
    Change-Id: I08911daf8e7752b6eb589a162bb07edda76b6f30
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138091
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx
index 218a6de74ade..177ca960af6b 100644
--- a/sfx2/source/sidebar/TabBar.cxx
+++ b/sfx2/source/sidebar/TabBar.cxx
@@ -53,9 +53,6 @@ TabBar::TabBar(vcl::Window* pParentWindow,
     , mxAuxBuilder(Application::CreateBuilder(m_xContainer.get(), 
"sfx/ui/tabbarcontents.ui"))
     , mxTempToplevel(mxAuxBuilder->weld_box("toplevel"))
     , mxContents(mxAuxBuilder->weld_widget("TabBarContents"))
-    , mxMenuButton(mxAuxBuilder->weld_menu_button("menubutton"))
-    , mxMainMenu(mxAuxBuilder->weld_menu("mainmenu"))
-    , mxSubMenu(mxAuxBuilder->weld_menu("submenu"))
     , mxMeasureBox(mxAuxBuilder->weld_widget("measure"))
     , maDeckActivationFunctor(std::move(aDeckActivationFunctor))
     , maPopupMenuProvider(std::move(aPopupMenuProvider))
@@ -65,6 +62,13 @@ TabBar::TabBar(vcl::Window* pParentWindow,
 
     mxTempToplevel->move(mxContents.get(), m_xContainer.get());
 
+    // For Gtk4 defer menu_button until after the contents have been
+    // transferred to its final home (where the old parent is a GtkWindow to
+    // support loading the accelerators in the menu for Gtk3)
+    mxMenuButton = mxAuxBuilder->weld_menu_button("menubutton");
+    mxMainMenu = mxAuxBuilder->weld_menu("mainmenu");
+    mxSubMenu = mxAuxBuilder->weld_menu("submenu");
+
     gDefaultWidth = m_xContainer->get_preferred_size().Width();
 
     // we have this widget just so we can measure best width for static 
TabBar::GetDefaultWidth

Reply via email to