You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
3.5 KiB
78 lines
3.5 KiB
From 1d40ccd2f55173f954e596ce59bc4307eceae453 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
|
|
Date: Wed, 24 Feb 2016 10:40:10 +0000
|
|
Subject: [PATCH 4/8] gtk3: replace old action if same command is added
|
|
|
|
i.e. originally we preferred the old action, now
|
|
prefer the new action because e.g. wrap items in
|
|
writer only contain their "checkable" state on
|
|
their update
|
|
|
|
Change-Id: I6a6ce94126253396cc273834a7e8a4fb0a56921d
|
|
(cherry picked from commit 36bddcbaa2d1673c1331c788eae9534aca2c5ec3)
|
|
---
|
|
vcl/unx/gtk/gtksalmenu.cxx | 45 +++++++++++++++++++++++----------------------
|
|
1 file changed, 23 insertions(+), 22 deletions(-)
|
|
|
|
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
|
|
index 6887ade..a9a0932 100644
|
|
--- a/vcl/unx/gtk/gtksalmenu.cxx
|
|
+++ b/vcl/unx/gtk/gtksalmenu.cxx
|
|
@@ -530,30 +530,31 @@ void GtkSalMenu::NativeSetItemCommand( unsigned nSection,
|
|
|
|
GVariant *pTarget = nullptr;
|
|
|
|
- if ( g_action_group_has_action( mpActionGroup, aCommand ) == FALSE ) {
|
|
- if ( ( nBits & MenuItemBits::CHECKABLE ) || bIsSubmenu )
|
|
- {
|
|
- // Item is a checkmark button.
|
|
- GVariantType* pStateType = g_variant_type_new( reinterpret_cast<gchar const *>(G_VARIANT_TYPE_BOOLEAN) );
|
|
- GVariant* pState = g_variant_new_boolean( bChecked );
|
|
+ if (g_action_group_has_action(mpActionGroup, aCommand))
|
|
+ g_lo_action_group_remove(pActionGroup, aCommand);
|
|
|
|
- g_lo_action_group_insert_stateful( pActionGroup, aCommand, nId, bIsSubmenu, nullptr, pStateType, nullptr, pState );
|
|
- }
|
|
- else if ( nBits & MenuItemBits::RADIOCHECK )
|
|
- {
|
|
- // Item is a radio button.
|
|
- GVariantType* pParameterType = g_variant_type_new( reinterpret_cast<gchar const *>(G_VARIANT_TYPE_STRING) );
|
|
- GVariantType* pStateType = g_variant_type_new( reinterpret_cast<gchar const *>(G_VARIANT_TYPE_STRING) );
|
|
- GVariant* pState = g_variant_new_string( "" );
|
|
- pTarget = g_variant_new_string( aCommand );
|
|
+ if ( ( nBits & MenuItemBits::CHECKABLE ) || bIsSubmenu )
|
|
+ {
|
|
+ // Item is a checkmark button.
|
|
+ GVariantType* pStateType = g_variant_type_new( reinterpret_cast<gchar const *>(G_VARIANT_TYPE_BOOLEAN) );
|
|
+ GVariant* pState = g_variant_new_boolean( bChecked );
|
|
|
|
- g_lo_action_group_insert_stateful( pActionGroup, aCommand, nId, FALSE, pParameterType, pStateType, nullptr, pState );
|
|
- }
|
|
- else
|
|
- {
|
|
- // Item is not special, so insert a stateless action.
|
|
- g_lo_action_group_insert( pActionGroup, aCommand, nId, FALSE );
|
|
- }
|
|
+ g_lo_action_group_insert_stateful( pActionGroup, aCommand, nId, bIsSubmenu, nullptr, pStateType, nullptr, pState );
|
|
+ }
|
|
+ else if ( nBits & MenuItemBits::RADIOCHECK )
|
|
+ {
|
|
+ // Item is a radio button.
|
|
+ GVariantType* pParameterType = g_variant_type_new( reinterpret_cast<gchar const *>(G_VARIANT_TYPE_STRING) );
|
|
+ GVariantType* pStateType = g_variant_type_new( reinterpret_cast<gchar const *>(G_VARIANT_TYPE_STRING) );
|
|
+ GVariant* pState = g_variant_new_string( "" );
|
|
+ pTarget = g_variant_new_string( aCommand );
|
|
+
|
|
+ g_lo_action_group_insert_stateful( pActionGroup, aCommand, nId, FALSE, pParameterType, pStateType, nullptr, pState );
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ // Item is not special, so insert a stateless action.
|
|
+ g_lo_action_group_insert( pActionGroup, aCommand, nId, FALSE );
|
|
}
|
|
|
|
GLOMenu* pMenu = G_LO_MENU( mpMenuModel );
|
|
--
|
|
2.7.1
|
|
|