summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk
diff options
context:
space:
mode:
authorAntonio Fernandez <antonio.fernandez@aentos.es>2012-08-31 12:28:33 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2012-11-14 13:52:46 +0100
commita5e35f8d8042c6c8b444de9eb8162bf8e917f533 (patch)
tree48ff03873d710c9484d5a15f4bc64ce9d8a39d76 /vcl/unx/gtk
parent34839e9a56739e79cbae2a843b51ea2a0b540fc9 (diff)
Added code for special items.
Change-Id: I8fb03bee33da052654559329a84d9a753d091ae1
Diffstat (limited to 'vcl/unx/gtk')
-rw-r--r--vcl/unx/gtk/window/gtksalmenu.cxx43
1 files changed, 41 insertions, 2 deletions
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx
index ca3e9ef660fa..f098d760f2fe 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 )
{
}