summaryrefslogtreecommitdiff
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
parent34839e9a56739e79cbae2a843b51ea2a0b540fc9 (diff)
Added code for special items.
Change-Id: I8fb03bee33da052654559329a84d9a753d091ae1
-rw-r--r--vcl/inc/unx/gtk/gtksalmenu.hxx7
-rw-r--r--vcl/unx/gtk/window/gtksalmenu.cxx43
2 files changed, 45 insertions, 5 deletions
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 5525b19333cd..2d4cbe321297 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 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 )
{
}