diff options
author | Antonio Fernandez <antonio.fernandez@aentos.es> | 2012-09-11 21:25:22 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2012-11-14 13:52:47 +0100 |
commit | 1d4719b3a75babd6a7368bc06dd18b4251ffed93 (patch) | |
tree | 8e40edd7510d3741f2f0df6024e9ba7b5d000053 /vcl/unx | |
parent | 1f4f5a55556dae157eaeec14d34f3f706d93b983 (diff) |
All Special items, including window list items are displayed, but with issues.
Change-Id: I23a6857f7aa738c48061ab51f3c015c41abc84cc
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/gtk/window/gloactiongroup.cxx | 20 | ||||
-rw-r--r-- | vcl/unx/gtk/window/gtksalmenu.cxx | 61 |
2 files changed, 58 insertions, 23 deletions
diff --git a/vcl/unx/gtk/window/gloactiongroup.cxx b/vcl/unx/gtk/window/gloactiongroup.cxx index 33e756c14229..8f7d4692b851 100644 --- a/vcl/unx/gtk/window/gloactiongroup.cxx +++ b/vcl/unx/gtk/window/gloactiongroup.cxx @@ -26,7 +26,6 @@ #include <unx/gtk/gtkinst.hxx> #include <unx/gtk/gtkframe.hxx> #include <unx/gtk/gtksalmenu.hxx> -#include <vcl/menu.hxx> /* @@ -218,20 +217,13 @@ g_lo_action_group_activate (GActionGroup *group, GtkSalFrame *pFrame = lo_group->priv->frame; - if ( pFrame == NULL ) - return; - - GtkSalMenu* pSalMenu = static_cast< GtkSalMenu* >( pFrame->GetMenu() ); - - if ( pSalMenu == NULL ) - return; - - GtkSalMenu* pSalSubMenu = pSalMenu->GetMenuForItemCommand( (gchar*) action_name ); - Menu* pSubMenu = ( pSalMenu != NULL ) ? pSalSubMenu->GetMenu() : NULL; - - MenuBar* pMenuBar = static_cast< MenuBar* >( pSalMenu->GetMenu() ); + if ( pFrame != NULL ) + { + GtkSalMenu* pSalMenu = static_cast< GtkSalMenu* >( pFrame->GetMenu() ); - pMenuBar->HandleMenuCommandEvent( pSubMenu, action->item_id ); + if ( pSalMenu != NULL ) + pSalMenu->DispatchCommand( action->item_id, action_name ); + } } void diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx index b61af316f4ab..52e7dd6c9dd1 100644 --- a/vcl/unx/gtk/window/gtksalmenu.cxx +++ b/vcl/unx/gtk/window/gtksalmenu.cxx @@ -28,11 +28,28 @@ #include <vcl/menu.hxx> #include <unx/gtk/gtkinst.hxx> +#include <framework/menuconfiguration.hxx> + #include <iostream> using namespace std; +static gchar* GetCommandForSpecialItem( GtkSalMenuItem* pSalMenuItem ) +{ + gchar* aCommand = NULL; + + sal_uInt16 nId = pSalMenuItem->mnId; + + // If item belongs to window list, generate a command with "window-(id)" format. + if ( ( nId >= START_ITEMID_WINDOWLIST ) && ( nId <= END_ITEMID_WINDOWLIST ) ) + { + aCommand = g_strdup_printf( "window-%d", nId ); + } + + return aCommand; +} + static void UpdateNativeMenu( GtkSalMenu* pMenu ) { if ( pMenu == NULL ) @@ -90,13 +107,23 @@ static void UpdateNativeMenu( GtkSalMenu* pMenu ) pMenu->NativeSetItemText( nSection, nItemPos, aText ); pMenu->NativeSetAccelerator( nSection, nItemPos, nAccelKey, nAccelKey.GetName( pMenu->GetFrame()->GetWindow() ) ); + // Some items are special, so they have different commands. + if ( g_strcmp0( aNativeCommand, "" ) == 0 ) + { + gchar *aSpecialItemCmd = GetCommandForSpecialItem( pSalMenuItem ); + + if ( aSpecialItemCmd != NULL ) + { + g_free( aNativeCommand ); + aNativeCommand = aSpecialItemCmd; + } + } + if ( g_strcmp0( aNativeCommand, "" ) != 0 && pSalMenuItem->mpSubMenu == NULL ) { pMenu->NativeSetItemCommand( nSection, nItemPos, pSalMenuItem, aNativeCommand ); + pMenu->NativeCheckItem( nSection, nItemPos, itemBits, bChecked ); pMenu->NativeSetEnableItem( aNativeCommand, bEnabled ); - - if ( ( itemBits & MIB_CHECKABLE ) || ( itemBits & MIB_RADIOCHECK ) ) - pMenu->NativeCheckItem( nSection, nItemPos, itemBits, bChecked ); } g_free( aNativeCommand ); @@ -114,12 +141,12 @@ static void UpdateNativeMenu( GtkSalMenu* pMenu ) } pSubmenu->GetMenu()->Activate(); + pSubmenu->GetMenu()->Deactivate(); pSubmenu->SetMenuModel( G_MENU_MODEL( pSubMenuModel ) ); pSubmenu->SetActionGroup( pActionGroup ); UpdateNativeMenu( pSubmenu ); - pSubmenu->GetMenu()->Deactivate(); } nItemPos++; @@ -417,16 +444,18 @@ void GtkSalMenu::NativeCheckItem( unsigned nSection, unsigned nItemPos, MenuItem GVariant *pCheckValue = NULL; GVariant *pCurrentState = g_action_group_get_action_state( mpActionGroup, aCommand ); - if ( bits & MIB_CHECKABLE ) + if ( bits & MIB_RADIOCHECK ) { - pCheckValue = g_variant_new_boolean( bCheck ); + pCheckValue = ( bCheck == TRUE ) ? g_variant_new_string( aCommand ) : g_variant_new_string( "" ); } - else if ( bits & MIB_RADIOCHECK ) + else { - pCheckValue = ( bCheck == TRUE ) ? g_variant_new_string( aCommand ) : g_variant_new_string( "" ); + // By default, all checked items are checkmark buttons. + if ( bCheck == TRUE || ( ( bCheck == FALSE ) && pCurrentState != NULL ) ) + pCheckValue = g_variant_new_boolean( bCheck ); } - if ( pCurrentState == NULL || g_variant_equal( pCurrentState, pCheckValue) == FALSE ) + if ( pCheckValue != NULL && ( pCurrentState == NULL || g_variant_equal( pCurrentState, pCheckValue) == FALSE ) ) g_action_group_change_action_state( mpActionGroup, aCommand, pCheckValue ); } @@ -585,6 +614,20 @@ GtkSalMenu* GtkSalMenu::GetMenuForItemCommand( gchar* aCommand ) return pMenu; } +void GtkSalMenu::DispatchCommand( gint itemId, const gchar *aCommand ) +{ + // Only the menubar is allowed to dispatch commands. + if ( mbMenuBar != TRUE ) + return; + + GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( (gchar*) aCommand ); + Menu* pSubMenu = ( pSalSubMenu != NULL ) ? pSalSubMenu->GetMenu() : NULL; + + MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu ); + + pMenuBar->HandleMenuCommandEvent( pSubMenu, itemId ); +} + void GtkSalMenu::Freeze() { } |