summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorAntonio Fernandez <antonio.fernandez@aentos.es>2012-09-24 13:11:45 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2012-11-14 13:52:54 +0100
commit30e4465c44cb729b9238f33c4f21dade2a83d6f1 (patch)
tree5d3dc8d4f8438835a41866480225409da0e11e64 /vcl
parentcf7908f875a6091e8fe8dd7bfe87dfbd9ac5078e (diff)
Hidden items are not shown anymore.
Change-Id: I957c8c7690321be58e8daaf2fb65ebef136d95bc
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/salmenu.hxx6
-rw-r--r--vcl/inc/unx/gtk/gtksalmenu.hxx9
-rw-r--r--vcl/source/window/menu.cxx3
-rw-r--r--vcl/unx/gtk/window/gtksalmenu.cxx60
4 files changed, 55 insertions, 23 deletions
diff --git a/vcl/inc/salmenu.hxx b/vcl/inc/salmenu.hxx
index fcec96af5590..13f058c6047b 100644
--- a/vcl/inc/salmenu.hxx
+++ b/vcl/inc/salmenu.hxx
@@ -66,7 +66,7 @@ public:
virtual ~SalMenu();
virtual sal_Bool VisibleMenuBar() = 0; // must return sal_True to actually DISPLAY native menu bars
- // otherwise only menu messages are processed (eg, OLE on Windows)
+ // otherwise only menu messages are processed (eg, OLE on Windows)
virtual void InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ) = 0;
virtual void RemoveItem( unsigned nPos ) = 0;
@@ -82,7 +82,9 @@ public:
virtual bool AddMenuBarButton( const SalMenuButtonItem& ); // return false if not implemented or failure
virtual void RemoveMenuBarButton( sal_uInt16 nId );
- virtual void SetItemCommand( unsigned nPos, SalMenuItem* pSalMenuItem, const rtl::OUString& aCommandStr ) {}
+ // FIXME: Make the other VCL native backends to work with these new methods.
+ virtual void SetItemCommand( unsigned, SalMenuItem*, const rtl::OUString& ) {}
+ virtual void ShowItem( unsigned nPos, sal_Bool bShow ) { EnableItem( nPos, bShow ); }
virtual void Freeze() {}
// return an empty rectangle if not implemented
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index e9ffb017ff81..1c4a326485fd 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -69,6 +69,7 @@ public:
virtual const GtkSalFrame* GetFrame() const;
virtual void CheckItem( unsigned nPos, sal_Bool bCheck );
virtual void EnableItem( unsigned nPos, sal_Bool bEnable );
+ virtual void ShowItem( unsigned nPos, sal_Bool bShow );
virtual void SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const rtl::OUString& rText );
virtual void SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage);
virtual void SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const KeyCode& rKeyCode, const rtl::OUString& rKeyName );
@@ -85,6 +86,7 @@ public:
virtual GtkSalMenuItem* GetItemAtPos( unsigned nPos ) { return maItems[ nPos ]; }
virtual void SetActionGroup( GActionGroup* pActionGroup ) { mpActionGroup = pActionGroup; }
virtual GActionGroup* GetActionGroup() { return mpActionGroup; }
+ virtual sal_Bool IsItemVisible( unsigned nPos );
void NativeSetItemText( unsigned nSection, unsigned nItemPos, const rtl::OUString& rText );
void NativeSetItemCommand( unsigned nSection,
@@ -114,9 +116,10 @@ public:
sal_uInt16 mnId; // Item ID
MenuItemType mnType; // Item type
- Menu* mpVCLMenu; // VCL Menu into which this MenuItem is inserted
- GtkSalMenu* mpParentMenu; // The menu in which this menu item is inserted
- GtkSalMenu* mpSubMenu; // Sub menu of this item (if defined)
+ sal_Bool mbVisible; // Item visibility.
+ Menu* mpVCLMenu; // VCL Menu into which this menu item is inserted
+ GtkSalMenu* mpParentMenu; // The menu into which this menu item is inserted
+ GtkSalMenu* mpSubMenu; // Submenu of this item (if defined)
};
#endif // GTKSALMENU_HXX
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 00abe068dfee..23bfa8105a62 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -1800,7 +1800,8 @@ void Menu::ShowItem( sal_uInt16 nItemId, sal_Bool bVisible )
// as long as there is no support to hide native menu entries, we just disable them
// TODO: add support to show/hide native menu entries
if( ImplGetSalMenu() )
- ImplGetSalMenu()->EnableItem( nPos, bVisible );
+// ImplGetSalMenu()->EnableItem( nPos, bVisible );
+ ImplGetSalMenu()->ShowItem( nPos, bVisible );
}
}
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx
index bad553e189d0..acd176c1acdc 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -31,6 +31,8 @@
# include <gdk/gdkkeysyms-compat.h>
#endif
+#include <svtools/menuoptions.hxx>
+
#include <framework/menuconfiguration.hxx>
#include <sal/log.hxx>
@@ -136,23 +138,24 @@ bool GtkSalMenu::PrepUpdate()
const GtkSalFrame* pFrame = GetFrame();
if (!pFrame)
{
- const GObject* pWindow = G_OBJECT(gtk_widget_get_window( GTK_WIDGET(pFrame->getWindow()) ));
- if(!pWindow)
- {
- SAL_INFO("vcl.unity", "not updating menu model, I have no frame " << mpMenuModel);
- return false;
- }
+ const GObject* pWindow = G_OBJECT(gtk_widget_get_window( GTK_WIDGET(pFrame->getWindow()) ));
+ if(!pWindow)
+ {
+ SAL_INFO("vcl.unity", "not updating menu model, I have no frame " << mpMenuModel);
+ return false;
+ }
- // the root menu does not have its own model and has to use the one owned by the frame
- if(mbMenuBar)
- {
- mpMenuModel = G_MENU_MODEL( g_object_get_data( G_OBJECT( pWindow ), "g-lo-menubar" ) );
- mpActionGroup = G_ACTION_GROUP( g_object_get_data( G_OBJECT( pWindow ), "g-lo-action-group" ) );
+ // the root menu does not have its own model and has to use the one owned by the frame
+ if(mbMenuBar)
+ {
+ mpMenuModel = G_MENU_MODEL( g_object_get_data( G_OBJECT( pWindow ), "g-lo-menubar" ) );
+ mpActionGroup = G_ACTION_GROUP( g_object_get_data( G_OBJECT( pWindow ), "g-lo-action-group" ) );
+ }
+ if(!mpMenuModel || !mpActionGroup)
+ return false;
+ SAL_INFO("vcl.unity", "updating menu model" << mpMenuModel);
+ return true;
}
- if(!mpMenuModel || !mpActionGroup)
- return false;
- SAL_INFO("vcl.unity", "updating menu model" << mpMenuModel);
- return true;
}
void GtkSalMenu::UpdateNativeMenu( )
@@ -173,16 +176,21 @@ void GtkSalMenu::UpdateNativeMenu( )
sal_uInt16 validItems = 0;
sal_uInt16 nItem;
- for ( nItem = 0; nItem < GetItemCount(); nItem++ ) {
- GtkSalMenuItem *pSalMenuItem = GetItemAtPos( nItem );
+ for ( nItem = 0; nItem < pMenu->GetItemCount(); nItem++ ) {
+ if ( pMenu->IsItemVisible( nItem ) == sal_False )
+ continue;
+
+ GtkSalMenuItem *pSalMenuItem = pMenu->GetItemAtPos( nItem );
sal_uInt16 nId = pSalMenuItem->mnId;
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 );
+
nSection++;
nItemPos = 0;
+ validItems = 0;
if ( nLOMenuSize <= nSection )
{
@@ -601,6 +609,16 @@ void GtkSalMenu::Deactivate( const gchar* aMenuCommand )
}
}
+sal_Bool GtkSalMenu::IsItemVisible( unsigned nPos )
+{
+ sal_Bool bVisible = sal_False;
+
+ if ( nPos < maItems.size() )
+ bVisible = ( ( GtkSalMenuItem* ) maItems[ nPos ])->mbVisible;
+
+ return bVisible;
+}
+
void GtkSalMenu::CheckItem( unsigned nPos, sal_Bool bCheck )
{
}
@@ -609,6 +627,13 @@ 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;
+}
+
+
void GtkSalMenu::SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const rtl::OUString& rText )
{
}
@@ -642,6 +667,7 @@ void GtkSalMenu::Freeze()
GtkSalMenuItem::GtkSalMenuItem( const SalItemParams* pItemData ) :
mnId( pItemData->nId ),
mnType( pItemData->eType ),
+ mbVisible( sal_True ),
mpVCLMenu( pItemData->pMenu ),
mpParentMenu( NULL ),
mpSubMenu( NULL )