summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vcl/menu.hxx1
-rw-r--r--vcl/source/window/menu.cxx11
-rw-r--r--vcl/unx/gtk/gtksalmenu.cxx28
3 files changed, 33 insertions, 7 deletions
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index 959d54d9f118..3c132cc32e07 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 e88914c2d361..b327f3d10e7e 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 2cf072a01d5d..807470ab1066 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();