summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-03-15 11:15:40 +0000
committerCaolán McNamara <caolanm@redhat.com>2016-03-15 11:17:35 +0000
commit66db55aa84e8401a9eccedb02c67150833a344ba (patch)
tree0fbf55088502b23f62ec99dd9b472195fb6ac5f7 /vcl
parent04ce76c7211295865e750a2441f94c267ba2f51c (diff)
Resolves: tdf#98636
On changing a menu item from a non-submenu to a submenu then update the newly created menu as if it was the first full update of the entire menu hierarchy. On changing a menu item from a submenu to a non-submenu its evidentially not sufficient to unset the G_LO_MENU_ATTRIBUTE_SUBMENU_ACTION attribute so remove the submenu-item and add a new non-submenu item to force its new type Change-Id: I2030d9198d6849643a5991ddfffc1cc3425ba72e
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/unx/gtk/gtksalmenu.hxx2
-rw-r--r--vcl/unx/gtk/glomenu.cxx1
-rw-r--r--vcl/unx/gtk/gtksalmenu.cxx24
3 files changed, 22 insertions, 5 deletions
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 8dadcfe7e40e..0e1cfd1a5167 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -87,7 +87,7 @@ public:
bool IsItemVisible( unsigned nPos );
void NativeSetItemText( unsigned nSection, unsigned nItemPos, const OUString& rText );
- void NativeSetItemCommand( unsigned nSection,
+ bool NativeSetItemCommand( unsigned nSection,
unsigned nItemPos,
sal_uInt16 nId,
const gchar* aCommand,
diff --git a/vcl/unx/gtk/glomenu.cxx b/vcl/unx/gtk/glomenu.cxx
index 835e832f57b7..e8529e0c43c9 100644
--- a/vcl/unx/gtk/glomenu.cxx
+++ b/vcl/unx/gtk/glomenu.cxx
@@ -294,6 +294,7 @@ g_lo_menu_set_action_and_target_value (GLOMenu *menu,
g_lo_menu_set_attribute_value (menu, position, G_MENU_ATTRIBUTE_ACTION, action_value);
g_lo_menu_set_attribute_value (menu, position, G_MENU_ATTRIBUTE_TARGET, target_value);
+ g_lo_menu_set_attribute_value (menu, position, G_LO_MENU_ATTRIBUTE_SUBMENU_ACTION, nullptr);
g_menu_model_items_changed (G_MENU_MODEL (menu), position, 1, 1);
}
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
index 91b7f3576a5e..48520c28d052 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -297,7 +297,7 @@ void GtkSalMenu::ImplUpdate(bool bRecurse, bool bRemoveDisabledEntries)
if ( pSubmenu && pSubmenu->GetMenu() )
{
- NativeSetItemCommand( nSection, nItemPos, nId, aNativeCommand, itemBits, FALSE, TRUE );
+ bool bNonMenuChangedToMenu = NativeSetItemCommand( nSection, nItemPos, nId, aNativeCommand, itemBits, FALSE, TRUE );
pNewCommandList = g_list_append( pNewCommandList, g_strdup( aNativeCommand ) );
GLOMenu* pSubMenuModel = g_lo_menu_get_submenu_from_item_in_section( pLOMenu, nSection, nItemPos );
@@ -310,12 +310,12 @@ void GtkSalMenu::ImplUpdate(bool bRecurse, bool bRemoveDisabledEntries)
g_object_unref( pSubMenuModel );
- if ( bRecurse )
+ if (bRecurse || bNonMenuChangedToMenu)
{
SAL_INFO("vcl.unity", "preparing submenu " << pSubMenuModel << " to menu model " << G_MENU_MODEL(pSubMenuModel) << " and action group " << G_ACTION_GROUP(pActionGroup));
pSubmenu->SetMenuModel( G_MENU_MODEL( pSubMenuModel ) );
pSubmenu->SetActionGroup( G_ACTION_GROUP( pActionGroup ) );
- pSubmenu->ImplUpdate(bRecurse, bRemoveDisabledEntries);
+ pSubmenu->ImplUpdate(true, bRemoveDisabledEntries);
}
}
@@ -798,7 +798,7 @@ void GtkSalMenu::NativeSetAccelerator( unsigned nSection, unsigned nItemPos, con
g_free( aCurrentAccel );
}
-void GtkSalMenu::NativeSetItemCommand( unsigned nSection,
+bool GtkSalMenu::NativeSetItemCommand( unsigned nSection,
unsigned nItemPos,
sal_uInt16 nId,
const gchar* aCommand,
@@ -806,6 +806,8 @@ void GtkSalMenu::NativeSetItemCommand( unsigned nSection,
gboolean bChecked,
gboolean bIsSubmenu )
{
+ bool bSubMenuAddedOrRemoved = false;
+
SolarMutexGuard aGuard;
GLOActionGroup* pActionGroup = G_LO_ACTION_GROUP( mpActionGroup );
@@ -845,6 +847,18 @@ void GtkSalMenu::NativeSetItemCommand( unsigned nSection,
if ( aCurrentCommand == nullptr || g_strcmp0( aCurrentCommand, aCommand ) != 0 )
{
+ bool bOldHasSubmenu = g_lo_menu_get_submenu_from_item_in_section(pMenu, nSection, nItemPos) != nullptr;
+ bSubMenuAddedOrRemoved = bOldHasSubmenu != bIsSubmenu;
+ if (bSubMenuAddedOrRemoved)
+ {
+ //tdf#98636 its not good enough to unset the "submenu-action" attribute to change something
+ //from a submenu to a non-submenu item, so remove the old one entirely and re-add it to
+ //support achieving that
+ gchar* pLabel = g_lo_menu_get_label_from_item_in_section(pMenu, nSection, nItemPos);
+ g_lo_menu_remove_from_section(pMenu, nSection, nItemPos);
+ g_lo_menu_insert_in_section(pMenu, nSection, nItemPos, pLabel);
+ }
+
g_lo_menu_set_command_to_item_in_section( pMenu, nSection, nItemPos, aCommand );
gchar* aItemCommand = g_strconcat("win.", aCommand, nullptr );
@@ -865,6 +879,8 @@ void GtkSalMenu::NativeSetItemCommand( unsigned nSection,
if (pTarget)
g_variant_unref(pTarget);
+
+ return bSubMenuAddedOrRemoved;
}
GtkSalMenu* GtkSalMenu::GetMenuForItemCommand(gchar* aCommand, int& rDupsToSkip, gboolean bGetSubmenu)