vcl/unx/gtk/gtksalmenu.cxx | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-)
New commits: commit 36bddcbaa2d1673c1331c788eae9534aca2c5ec3 Author: Caolán McNamara <caol...@redhat.com> Date: Wed Feb 24 10:40:10 2016 +0000 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 diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx index 7d73cac..49270bb 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 );
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits