vcl/inc/unx/gtk/gtksalmenu.hxx | 7 +++--- vcl/unx/gtk/window/gtksalmenu.cxx | 43 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 5 deletions(-)
New commits: commit 5645ed605633bf866468c35310d4e0aebe5f88c2 Author: Antonio Fernandez <antonio.fernan...@aentos.es> Date: Fri Aug 31 12:28:33 2012 +0100 Added code for special items. Change-Id: I8fb03bee33da052654559329a84d9a753d091ae1 diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx index 5525b19..2d4cbe3 100644 --- a/vcl/inc/unx/gtk/gtksalmenu.hxx +++ b/vcl/inc/unx/gtk/gtksalmenu.hxx @@ -86,9 +86,10 @@ public: virtual void SetActionGroup( GActionGroup* pActionGroup ) { mpActionGroup = pActionGroup; } virtual GActionGroup* GetActionGroup() { return mpActionGroup; } - virtual void SetNativeItemText( unsigned nSection, unsigned nItemPos, const rtl::OUString& rText ); - virtual void SetNativeItemCommand( unsigned nSection, unsigned nItemPos, GtkSalMenuItem* pItem, const gchar* aCommandStr ); - virtual void SetNativeEnableItem( gchar* aCommand, gboolean bEnable ); + void SetNativeItemText( unsigned nSection, unsigned nItemPos, const rtl::OUString& rText ); + void SetNativeItemCommand( unsigned nSection, unsigned nItemPos, GtkSalMenuItem* pItem, const gchar* aCommandStr ); + void SetNativeEnableItem( gchar* aCommand, gboolean bEnable ); + void NativeCheckItem( unsigned nSection, unsigned nItemPos, GtkSalMenuItem* pItem, gboolean bCheck ); }; class GtkSalMenuItem : public SalMenuItem diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx index ca3e9ef..f098d76 100644 --- a/vcl/unx/gtk/window/gtksalmenu.cxx +++ b/vcl/unx/gtk/window/gtksalmenu.cxx @@ -93,7 +93,7 @@ static void UpdateNativeMenu( GtkSalMenu* pMenu ) { pMenu->SetNativeItemCommand( nSection, nItemPos, pSalMenuItem, aNativeCommand ); pMenu->SetNativeEnableItem( aNativeCommand, bEnabled ); -// pMenu->CheckItem( nItem, itemChecked ); + pMenu->NativeCheckItem( nSection, nItemPos, pSalMenuItem, bChecked ); } g_free( aNativeCommand ); @@ -269,7 +269,7 @@ GtkSalMenu::~GtkSalMenu() sal_Bool GtkSalMenu::VisibleMenuBar() { - return sal_False; + return sal_True; } void GtkSalMenu::InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ) @@ -429,6 +429,45 @@ void GtkSalMenu::CheckItem( unsigned nPos, sal_Bool bCheck ) // g_free( aCommand ); } +void GtkSalMenu::NativeCheckItem( unsigned nSection, unsigned nItemPos, GtkSalMenuItem* pItem, gboolean bCheck ) +{ + gchar* aCommand = g_lo_menu_get_command_from_item_in_section( G_LO_MENU( mpMenuModel ), nSection, nItemPos ); + + if ( aCommand == NULL && g_strcmp0( aCommand, "" ) != 0 ) + { + if ( mpActionGroup != NULL ) + { + GVariant *pCheckValue = NULL; + + // FIXME: Why pItem->mnBits differs from GetItemBits value? + MenuItemBits bits = pItem->mpVCLMenu->GetItemBits( pItem->mnId ); + + if ( bits & MIB_CHECKABLE ) { + GVariant* pState = g_action_group_get_action_state( mpActionGroup, aCommand ); + gboolean bCurrentState = g_variant_get_boolean( pState ); + + if ( bCurrentState != bCheck ) + pCheckValue = g_variant_new_boolean( bCheck ); + } + else if ( bits & MIB_RADIOCHECK ) + { + GVariant* pState = g_action_group_get_action_state( mpActionGroup, aCommand ); + gchar* aCurrentState = (gchar*) g_variant_get_string( pState, NULL ); + gboolean bCurrentState = g_strcmp0( aCurrentState, "" ) != 0; + + if ( bCurrentState != bCheck ) + pCheckValue = ( bCheck == TRUE ) ? g_variant_new_string( aCommand ) : g_variant_new_string( "" ); + } + + if ( pCheckValue ) + g_action_group_change_action_state( mpActionGroup, aCommand, pCheckValue ); + } + } + + if ( aCommand ) + g_free( aCommand ); +} + void GtkSalMenu::EnableItem( unsigned nPos, sal_Bool bEnable ) { } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits