tdf#166200 The list of open documents/windows is incorrect

Revert "speed up menu construction at app startup"

This reverts commit a18b0b4aa5.

Change-Id: Ibfa0fe91fcfacf4a357782fedb48468b711044af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185036
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2025-05-07 23:32:19 +02:00
parent 33434f1620
commit 15ed00fcef
4 changed files with 13 additions and 27 deletions

View File

@@ -76,8 +76,7 @@ void g_lo_menu_set_icon (GLOMenu
void g_lo_menu_set_label_to_item_in_section (GLOMenu *menu,
gint section,
gint position,
const gchar *label,
bool fire_event = true);
const gchar *label);
void g_lo_menu_set_icon_to_item_in_section (GLOMenu *menu,
gint section,
@@ -102,8 +101,7 @@ void g_lo_menu_set_action_and_target_value_to_item_in_section (GLOMenu
void g_lo_menu_set_command_to_item_in_section (GLOMenu *menu,
gint section,
gint position,
const gchar *command,
bool fire_event = true);
const gchar *command);
gchar * g_lo_menu_get_command_from_item_in_section (GLOMenu *menu,
gint section,

View File

@@ -89,7 +89,7 @@ public:
void SetActionGroup( GActionGroup* pActionGroup ) { mpActionGroup = pActionGroup; }
bool IsItemVisible( unsigned nPos );
void NativeSetItemText( unsigned nSection, unsigned nItemPos, const OUString& rText, bool bFireEvent = true );
void NativeSetItemText( unsigned nSection, unsigned nItemPos, const OUString& rText );
void NativeSetItemIcon( unsigned nSection, unsigned nItemPos, const Image& rImage );
bool NativeSetItemCommand( unsigned nSection,
unsigned nItemPos,

View File

@@ -266,8 +266,7 @@ void
g_lo_menu_set_label_to_item_in_section (GLOMenu *menu,
gint section,
gint position,
const gchar *label,
bool fire_event)
const gchar *label)
{
g_return_if_fail (G_IS_LO_MENU (menu));
@@ -278,8 +277,7 @@ g_lo_menu_set_label_to_item_in_section (GLOMenu *menu,
g_lo_menu_set_label (model, position, label);
// Notify the update.
if (fire_event)
g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 1);
g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 1);
g_object_unref (model);
}
@@ -428,8 +426,7 @@ void
g_lo_menu_set_command_to_item_in_section (GLOMenu *menu,
gint section,
gint position,
const gchar *command,
bool fire_event)
const gchar *command)
{
g_return_if_fail (G_IS_LO_MENU (menu));
@@ -447,8 +444,7 @@ g_lo_menu_set_command_to_item_in_section (GLOMenu *menu,
g_lo_menu_set_attribute_value (model, position, G_LO_MENU_ATTRIBUTE_COMMAND, value);
// Notify the update.
if (fire_event)
g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 1);
g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 1);
g_object_unref (model);
}

View File

@@ -300,24 +300,18 @@ void GtkSalMenu::ImplUpdate(bool bRecurse, bool bRemoveDisabledEntries)
OString sNativeCommand = GetCommandForItem(pSalMenuItem);
// Force updating of native menu labels.
NativeSetItemText( nSection, nItemPos, aText );
NativeSetItemIcon( nSection, nItemPos, aImage );
NativeSetAccelerator(nSection, nItemPos, nAccelKey, nAccelKey.GetName());
if (!sNativeCommand.isEmpty() && pSalMenuItem->mpSubMenu == nullptr)
{
NativeSetItemText( nSection, nItemPos, aText, false );
NativeSetItemIcon( nSection, nItemPos, aImage );
NativeSetAccelerator(nSection, nItemPos, nAccelKey, nAccelKey.GetName());
NativeSetItemCommand(nSection, nItemPos, nId, sNativeCommand.getStr(), itemBits, bChecked, false);
NativeCheckItem( nSection, nItemPos, itemBits, bChecked );
NativeSetEnableItem(sNativeCommand, bEnabled);
pNewCommandList = g_list_append(pNewCommandList, g_strdup(sNativeCommand.getStr()));
}
else
{
NativeSetItemText( nSection, nItemPos, aText );
NativeSetItemIcon( nSection, nItemPos, aImage );
NativeSetAccelerator(nSection, nItemPos, nAccelKey, nAccelKey.GetName());
}
GtkSalMenu* pSubmenu = pSalMenuItem->mpSubMenu;
@@ -1175,7 +1169,7 @@ void GtkSalMenu::NativeSetEnableItem(const OString& sCommand, gboolean bEnable)
g_lo_action_group_set_action_enabled(pActionGroup, sCommand.getStr(), bEnable);
}
void GtkSalMenu::NativeSetItemText( unsigned nSection, unsigned nItemPos, const OUString& rText, bool bFireEvent )
void GtkSalMenu::NativeSetItemText( unsigned nSection, unsigned nItemPos, const OUString& rText )
{
SolarMutexGuard aGuard;
// Escape all underscores so that they don't get interpreted as hotkeys
@@ -1188,7 +1182,7 @@ void GtkSalMenu::NativeSetItemText( unsigned nSection, unsigned nItemPos, const
gchar* aLabel = g_lo_menu_get_label_from_item_in_section( G_LO_MENU( mpMenuModel ), nSection, nItemPos );
if ( aLabel == nullptr || g_strcmp0( aLabel, aConvertedText.getStr() ) != 0 )
g_lo_menu_set_label_to_item_in_section( G_LO_MENU( mpMenuModel ), nSection, nItemPos, aConvertedText.getStr(), bFireEvent );
g_lo_menu_set_label_to_item_in_section( G_LO_MENU( mpMenuModel ), nSection, nItemPos, aConvertedText.getStr() );
if ( aLabel )
g_free( aLabel );
@@ -1318,9 +1312,7 @@ bool GtkSalMenu::NativeSetItemCommand( unsigned nSection,
g_free(pLabel);
}
// suppress event firing here, we will do so anyway in the g_lo_menu_set_action_and_target_value_to_item_in_section call,
// speeds up constructing menus
g_lo_menu_set_command_to_item_in_section( pMenu, nSection, nItemPos, aCommand, /*fire_event*/false );
g_lo_menu_set_command_to_item_in_section( pMenu, nSection, nItemPos, aCommand );
gchar* aItemCommand = g_strconcat("win.", aCommand, nullptr );