include/vcl/menu.hxx | 1 vcl/inc/salmenu.hxx | 2 - vcl/inc/unx/gtk/gtksalmenu.hxx | 1 vcl/source/window/menu.cxx | 14 +++++++--- vcl/unx/gtk/gtksalframe.cxx | 1 vcl/unx/gtk/gtksalmenu.cxx | 57 +++++++++++++++++++++++++++++++---------- vcl/unx/gtk3/gtk3gtkframe.cxx | 1 7 files changed, 58 insertions(+), 19 deletions(-)
New commits: commit 13714d994471a5d53b673d97e4fcf56b5dc3d057 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Tue Aug 30 21:38:37 2016 +0300 Implement disabling of Menubar under Unity This is a combination of 5 commits: * gtk3: Implement menubar hiding * tdf#106271 Cannot disable Menubar under Unity * Destroy menu widget when enabling Unity integration * Don't use SetDisplayable when enabling Unity mode * Keep menubar hidden after Unity registrar activated Change-Id: I3c5e17100622cd8d22c4348cf90a76233dd0fd4c Reviewed-on: https://gerrit.libreoffice.org/35206 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx index 92d4b4e30bff..8c1b94788791 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -483,6 +483,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/inc/salmenu.hxx b/vcl/inc/salmenu.hxx index a792356ab92e..3c23fc022b73 100644 --- a/vcl/inc/salmenu.hxx +++ b/vcl/inc/salmenu.hxx @@ -63,7 +63,7 @@ public: virtual bool VisibleMenuBar() = 0; // must return true to actually DISPLAY native menu bars // otherwise only menu messages are processed (eg, OLE on Windows) - + virtual void ShowMenuBar( bool ) {} virtual void InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ) = 0; virtual void RemoveItem( unsigned nPos ) = 0; virtual void SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos ) = 0; diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx index 08b4113cd5a7..6c417c3736dd 100644 --- a/vcl/inc/unx/gtk/gtksalmenu.hxx +++ b/vcl/inc/unx/gtk/gtksalmenu.hxx @@ -110,6 +110,7 @@ public: static void Activate(const gchar* pMenuCommand); static void Deactivate(const gchar* pMenuCommand); void EnableUnity(bool bEnable); + virtual void ShowMenuBar( bool bVisible ) override; bool PrepUpdate(); virtual void Update() override; // Update this menu only. // Update full menu hierarchy from this menu. diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index d7f6b0875fff..24743fb2723a 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2481,14 +2481,22 @@ 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 ) { + if ( ImplGetSalMenu() ) + ImplGetSalMenu()->ShowMenuBar( bDisplayable ); + mbDisplayable = bDisplayable; - MenuBarWindow* pMenuWin = getMenuBarWindow(); - if (pMenuWin) - pMenuWin->LayoutChanged(); + LayoutChanged(); } } diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx index 9fd351825da8..b56c899ed431 100644 --- a/vcl/unx/gtk/gtksalframe.cxx +++ b/vcl/unx/gtk/gtksalframe.cxx @@ -705,7 +705,6 @@ void on_registrar_available( GDBusConnection * /*connection*/, { GtkSalMenu* pGtkSalMenu = static_cast<GtkSalMenu*>(pSalMenu); pGtkSalMenu->EnableUnity(true); - pGtkSalMenu->UpdateFull(); } } diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx index 75cab1cab1cd..3aee9dd796a3 100644 --- a/vcl/unx/gtk/gtksalmenu.cxx +++ b/vcl/unx/gtk/gtksalmenu.cxx @@ -484,11 +484,7 @@ GtkSalMenu::~GtkSalMenu() bool GtkSalMenu::VisibleMenuBar() { -#if GTK_CHECK_VERSION(3,0,0) - return mbMenuBar; -#else - return mbMenuBar && bUnityMode; -#endif + return mbMenuBar && (bUnityMode || mpMenuBarContainerWidget); } void GtkSalMenu::InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ) @@ -539,7 +535,9 @@ void GtkSalMenu::ShowCloseButton(bool bShow) { #if GTK_CHECK_VERSION(3,0,0) assert(mbMenuBar); - MenuBar *pVclMenuBar = static_cast<MenuBar*>(mpVCLMenu); + if (!mpMenuBarContainerWidget) + return; + if (!bShow) { if (mpCloseButton) @@ -547,6 +545,7 @@ void GtkSalMenu::ShowCloseButton(bool bShow) return; } + MenuBar *pVclMenuBar = static_cast<MenuBar*>(mpVCLMenu); mpCloseButton = gtk_button_new(); g_signal_connect(mpCloseButton, "clicked", G_CALLBACK(CloseMenuBar), pVclMenuBar); @@ -695,6 +694,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(); @@ -710,6 +712,8 @@ void GtkSalMenu::CreateMenuBarWidget() g_signal_connect(G_OBJECT(mpMenuBarWidget), "key-press-event", G_CALLBACK(MenuBarSignalKey), this); gtk_widget_show_all(mpMenuBarContainerWidget); + + ShowCloseButton( static_cast<MenuBar*>(mpVCLMenu)->HasCloseButton() ); #else (void)mpMenuBarContainerWidget; #endif @@ -722,6 +726,7 @@ void GtkSalMenu::DestroyMenuBarWidget() { gtk_widget_destroy(mpMenuBarContainerWidget); mpMenuBarContainerWidget = nullptr; + mpCloseButton = nullptr; } #else (void)mpMenuBarContainerWidget; @@ -1087,15 +1092,41 @@ void GtkSalMenu::Deactivate(const gchar* pCommand) void GtkSalMenu::EnableUnity(bool bEnable) { - if (bUnityMode != bEnable) + bUnityMode = bEnable; + + MenuBar* pMenuBar(static_cast<MenuBar*>(mpVCLMenu)); + bool bDisplayable(pMenuBar->IsDisplayable()); + + if (bEnable) { - if (!bEnable) - CreateMenuBarWidget(); - else - DestroyMenuBarWidget(); - bUnityMode = bEnable; - static_cast<MenuBar*>(mpVCLMenu)->SetDisplayable(!bEnable); + DestroyMenuBarWidget(); + UpdateFull(); + if (!bDisplayable) + ShowMenuBar(false); + } + else + { + Update(); + ShowMenuBar(bDisplayable); } + + pMenuBar->LayoutChanged(); +} + +void GtkSalMenu::ShowMenuBar( bool bVisible ) +{ + // 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(); } bool GtkSalMenu::IsItemVisible( unsigned nPos ) diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx index f09905b1a30d..7c8c127ea8c0 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -719,7 +719,6 @@ void on_registrar_available( GDBusConnection * /*connection*/, { GtkSalMenu* pGtkSalMenu = static_cast<GtkSalMenu*>(pSalMenu); pGtkSalMenu->EnableUnity(true); - pGtkSalMenu->UpdateFull(); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits