[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - include/vcl vcl/source vcl/unx
Samuel Mehrbrodt
Samuel.Mehrbrodt at cib.de
Tue Mar 14 17:00:33 UTC 2017
include/vcl/menu.hxx | 1 +
vcl/source/window/menu.cxx | 11 ++++++++---
vcl/unx/gtk/gtksalmenu.cxx | 28 ++++++++++++++++++++++++----
3 files changed, 33 insertions(+), 7 deletions(-)
New commits:
commit 449733a5c3b59c7b56db1db3dbc7fd0dcefd1a55
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Fri Mar 3 15:55:40 2017 +0100
tdf#106271 Cannot disable Menubar under Unity
Empty the global menu when the user wants to hide the menubar.
When showing it again, the global menu is refilled.
(cherry picked from commit f2fa5951bf3d02439a3e96d1f9d89962f0901edc)
The following commits have been squashed into this commit:
1.
Destroy menu widget when enabling Unity integration
Like GtkSalMenu::ShowMenuBar did before
f2fa5951bf3d02439a3e96d1f9d89962f0901edc
("tdf#106271 Cannot disable Menubar under Unity")
Should fix https://lists.freedesktop.org/archives/libreoffice/2017-
March/077225.html
(cherry-picked from commit 27f89f08cf4086802ce67f12389414bef6ab64ca)
2.
Don't use SetDisplayable when enabling Unity mode
because now it tracks the global menu too, but all we need
here is to hide the in-window menubar widget.
(cherry-picked from commit 3daa6c66eb9a4c334d6f72a8fd4bb09d7360a913)
Change-Id: I3c5e17100622cd8d22c4348cf90a76233dd0fd4c
Reviewed-on: https://gerrit.libreoffice.org/34919
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index 959d54d..3c132cc 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -478,6 +478,7 @@ public:
// if the menubar is unattached an empty rectangle is returned
Rectangle GetMenuBarButtonRectPixel( sal_uInt16 nId );
void RemoveMenuBarButton( sal_uInt16 nId );
+ void LayoutChanged();
};
inline MenuBar& MenuBar::operator=( const MenuBar& rMenu )
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index e88914c..b327f3d 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2464,6 +2464,13 @@ void MenuBar::ShowButtons( bool bClose, bool bFloat, bool bHide )
}
}
+void MenuBar::LayoutChanged()
+{
+ MenuBarWindow* pMenuWin = getMenuBarWindow();
+ if (pMenuWin)
+ pMenuWin->LayoutChanged();
+}
+
void MenuBar::SetDisplayable( bool bDisplayable )
{
if( bDisplayable != mbDisplayable )
@@ -2472,9 +2479,7 @@ void MenuBar::SetDisplayable( bool bDisplayable )
ImplGetSalMenu()->ShowMenuBar( bDisplayable );
mbDisplayable = bDisplayable;
- MenuBarWindow* pMenuWin = getMenuBarWindow();
- if (pMenuWin)
- pMenuWin->LayoutChanged();
+ LayoutChanged();
}
}
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
index 2cf072a..807470a 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -766,6 +766,9 @@ static gboolean MenuBarSignalKey(GtkWidget*, GdkEventKey* pEvent, gpointer menu)
void GtkSalMenu::CreateMenuBarWidget()
{
#if GTK_CHECK_VERSION(3,0,0)
+ if (mpMenuBarContainerWidget)
+ return;
+
GtkGrid* pGrid = mpFrame->getTopLevelGridWidget();
mpMenuBarContainerWidget = gtk_grid_new();
@@ -1153,16 +1156,33 @@ void GtkSalMenu::Deactivate(const gchar* pCommand)
void GtkSalMenu::EnableUnity(bool bEnable)
{
- if (bUnityMode != bEnable)
+ bUnityMode = bEnable;
+
+ MenuBar* pMenuBar(static_cast<MenuBar*>(mpVCLMenu.get()));
+
+ if (bEnable)
+ DestroyMenuBarWidget();
+ else
{
- bUnityMode = bEnable;
- static_cast<MenuBar*>(mpVCLMenu.get())->SetDisplayable(!bEnable);
+ Update();
+ if (pMenuBar->IsDisplayable())
+ CreateMenuBarWidget();
}
+
+ pMenuBar->LayoutChanged();
}
void GtkSalMenu::ShowMenuBar( bool bVisible )
{
- if (bVisible && !bUnityMode && !mpMenuBarContainerWidget)
+ // Unity tdf#106271: Can't hide global menu, so empty it instead when user wants to hide menubar,
+ if (bUnityMode)
+ {
+ if (bVisible)
+ Update();
+ else if (mpMenuModel && g_menu_model_get_n_items(G_MENU_MODEL(mpMenuModel)) > 0)
+ g_lo_menu_remove(G_LO_MENU(mpMenuModel), 0);
+ }
+ else if (bVisible)
CreateMenuBarWidget();
else
DestroyMenuBarWidget();
More information about the Libreoffice-commits
mailing list