summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk/gtksalmenu.cxx
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2016-09-24 23:47:04 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2016-09-25 00:06:47 +0300
commita05b67585249b895a70e7fae89dc177e3aeaf57a (patch)
treee0c6ac5241c937d5a63978467793614f6060c09b /vcl/unx/gtk/gtksalmenu.cxx
parent9aef73aa452f86df8c760ca028914fc542909a58 (diff)
tdf#102266 Try to keep HUD up to date
Recent HUD versions don't seem to support the activation callback, so we have to update menus in the background. (regression of 15436c009e756dd4c94046f9849ad5a186454af8) TODO: Is this manual iteration in GtkSalMenu::SetItemText worth it, or maybe simply calling Update() will be good enough, too? Change-Id: I7f08c3518e1767915d84036cdce7f678961595ef
Diffstat (limited to 'vcl/unx/gtk/gtksalmenu.cxx')
-rw-r--r--vcl/unx/gtk/gtksalmenu.cxx49
1 files changed, 47 insertions, 2 deletions
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
index be68eff0522e..9e4547b35acb 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -417,6 +417,7 @@ bool GtkSalMenu::ShowNativePopupMenu(FloatingWindow* pWin, const Rectangle& rRec
*/
GtkSalMenu::GtkSalMenu( bool bMenuBar ) :
+ mbInActivateCallback( false ),
mbMenuBar( bMenuBar ),
mbNeedsUpdate( false ),
mbReturnFocusToDocument( false ),
@@ -1049,7 +1050,9 @@ void GtkSalMenu::ActivateAllSubmenus(Menu* pMenuBar)
{
if ( pSalItem->mpSubMenu != nullptr )
{
+ pSalItem->mpSubMenu->mbInActivateCallback = true;
pMenuBar->HandleMenuActivateEvent(pSalItem->mpSubMenu->GetMenu());
+ pSalItem->mpSubMenu->mbInActivateCallback = false;
pSalItem->mpSubMenu->ActivateAllSubmenus(pMenuBar);
pSalItem->mpSubMenu->Update();
pMenuBar->HandleMenuDeActivateEvent(pSalItem->mpSubMenu->GetMenu());
@@ -1077,7 +1080,11 @@ void GtkSalMenu::Activate(const gchar* pCommand)
GtkSalMenu* pTopLevel = pSalMenu->GetTopLevel();
Menu* pVclMenu = pSalMenu->GetMenu();
Menu* pVclSubMenu = pVclMenu->GetPopupMenu(aMenuAndId.second);
+ GtkSalMenu* pSubMenu = pSalMenu->GetItemAtPos(pVclMenu->GetItemPos(aMenuAndId.second))->mpSubMenu;
+
+ pSubMenu->mbInActivateCallback = true;
pTopLevel->GetMenu()->HandleMenuActivateEvent(pVclSubMenu);
+ pSubMenu->mbInActivateCallback = false;
pVclSubMenu->UpdateNativeMenu();
}
@@ -1123,19 +1130,57 @@ void GtkSalMenu::CheckItem( unsigned, bool )
{
}
-void GtkSalMenu::EnableItem( unsigned, bool )
+void GtkSalMenu::EnableItem( unsigned nPos, bool bEnable )
{
+ SolarMutexGuard aGuard;
+ if ( bUnityMode && !mbInActivateCallback && !mbNeedsUpdate && GetTopLevel()->mbMenuBar && ( nPos < maItems.size() ) )
+ {
+ gchar* pCommand = GetCommandForItem( GetItemAtPos( nPos ) );
+ NativeSetEnableItem( pCommand, bEnable );
+ g_free( pCommand );
+ }
}
void GtkSalMenu::ShowItem( unsigned nPos, bool bShow )
{
SolarMutexGuard aGuard;
if ( nPos < maItems.size() )
+ {
maItems[ nPos ]->mbVisible = bShow;
+ if ( bUnityMode && !mbInActivateCallback && !mbNeedsUpdate && GetTopLevel()->mbMenuBar )
+ Update();
+ }
}
-void GtkSalMenu::SetItemText( unsigned, SalMenuItem*, const OUString& )
+void GtkSalMenu::SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const OUString& rText )
{
+ SolarMutexGuard aGuard;
+ if ( bUnityMode && !mbInActivateCallback && !mbNeedsUpdate && GetTopLevel()->mbMenuBar && ( nPos < maItems.size() ) )
+ {
+ gchar* pCommand = GetCommandForItem( static_cast< GtkSalMenuItem* >( pSalMenuItem ) );
+
+ gint nSectionsCount = g_menu_model_get_n_items( mpMenuModel );
+ for ( gint nSection = 0; nSection < nSectionsCount; ++nSection )
+ {
+ gint nItemsCount = g_lo_menu_get_n_items_from_section( G_LO_MENU( mpMenuModel ), nSection );
+ for ( gint nItem = 0; nItem < nItemsCount; ++nItem )
+ {
+ gchar* pCommandFromModel = g_lo_menu_get_command_from_item_in_section( G_LO_MENU( mpMenuModel ), nSection, nItem );
+
+ if ( !g_strcmp0( pCommandFromModel, pCommand ) )
+ {
+ NativeSetItemText( nSection, nItem, rText );
+ g_free( pCommandFromModel );
+ g_free( pCommand );
+ return;
+ }
+
+ g_free( pCommandFromModel );
+ }
+ }
+
+ g_free( pCommand );
+ }
}
void GtkSalMenu::SetItemImage( unsigned, SalMenuItem*, const Image& )