summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorAntonio Fernandez <antonio.fernandez@aentos.es>2012-09-24 16:20:57 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2012-11-14 13:52:54 +0100
commit5178cabb0953c90d1b0b63525869fbe27f307cee (patch)
tree2f3d953d26040b9633fb9abf69fbe8fbe1f6e028 /vcl/unx
parent30e4465c44cb729b9238f33c4f21dade2a83d6f1 (diff)
Extra menu items are removed when needed, but not their actions.
Change-Id: If817b03cc7b30bfeb751e47fff4aa571fdaaafdc
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/gtk/window/gtksalmenu.cxx33
1 files changed, 24 insertions, 9 deletions
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx
index acd176c1acdc..c8ba23d3a1d2 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -171,12 +171,12 @@ void GtkSalMenu::UpdateNativeMenu( )
if ( nLOMenuSize == 0 )
g_lo_menu_new_section( pLOMenu, 0, NULL );
- sal_uInt16 nSection = 0;
- sal_uInt16 nItemPos = 0;
- sal_uInt16 validItems = 0;
- sal_uInt16 nItem;
+ sal_Int32 nSection = 0;
+ sal_Int32 nItemPos = 0;
+ sal_Int32 validItems = 0;
+ sal_Int32 nItem;
- for ( nItem = 0; nItem < pMenu->GetItemCount(); nItem++ ) {
+ for ( nItem = 0; nItem < ( sal_Int32 ) pMenu->GetItemCount(); nItem++ ) {
if ( pMenu->IsItemVisible( nItem ) == sal_False )
continue;
@@ -185,9 +185,13 @@ void GtkSalMenu::UpdateNativeMenu( )
if ( pSalMenuItem->mnType == MENUITEM_SEPARATOR )
{
- while ( nItemPos < g_lo_menu_get_n_items_from_section( pLOMenu, nSection ) )
- g_lo_menu_remove_from_section( pLOMenu, nSection, nItemPos );
-
+ // Delete extra items from current section.
+ sal_uInt16 nSectionItems = g_lo_menu_get_n_items_from_section( pLOMenu, nSection );
+
+ while ( nSectionItems > validItems )
+ // FIXME Remove associated command if needed.
+ g_lo_menu_remove_from_section( pLOMenu, nSection, --nSectionItems );
+
nSection++;
nItemPos = 0;
validItems = 0;
@@ -279,6 +283,17 @@ void GtkSalMenu::UpdateNativeMenu( )
SAL_INFO("vcl.unity", "nSection " << nSection << " model sections " << g_menu_model_get_n_items( G_MENU_MODEL( pLOMenu ) ));
g_lo_menu_remove(pLOMenu, nSection );
}
+
+ // Delete extra items in last section.
+ sal_Int32 nSectionItems = (sal_Int32) g_lo_menu_get_n_items_from_section( pLOMenu, nSection );
+
+ while ( nSectionItems > validItems )
+ g_lo_menu_remove_from_section( pLOMenu, nSection, --nSectionItems );
+
+ // Delete extra sections.
+ for ( sal_Int32 n = nLOMenuSize - 1; n > nSection; )
+ // FIXME Remove associated command if needed.
+ g_lo_menu_remove( pLOMenu, n-- );
}
void GtkSalMenu::DisconnectFrame()
@@ -630,7 +645,7 @@ void GtkSalMenu::EnableItem( unsigned nPos, sal_Bool bEnable )
void GtkSalMenu::ShowItem( unsigned nPos, sal_Bool bShow )
{
if ( nPos < maItems.size() )
- ( ( GtkSalMenuItem* ) maItems[ nPos ])->mbVisible = bShow;
+ ( ( GtkSalMenuItem* ) maItems[ nPos ] )->mbVisible = bShow;
}