[Libreoffice-commits] .: Branch 'feature/unitymenus' - 2 commits - vcl/inc vcl/unx
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Sep 12 03:40:39 PDT 2012
vcl/inc/unx/gtk/gtksalmenu.hxx | 8 --
vcl/unx/gtk/window/gloactiongroup.cxx | 37 +++------
vcl/unx/gtk/window/gtksalmenu.cxx | 127 +++++++++++++++++++++-------------
3 files changed, 96 insertions(+), 76 deletions(-)
New commits:
commit f304540454838efbc6cc3b19b863e64cbbd07523
Author: Antonio Fernandez <antonio.fernandez at aentos.es>
Date: Wed Sep 12 11:39:11 2012 +0100
Some code reordering and cleaning.
Change-Id: Ide46f6f68f3ba2632988b490820cb1ca576bab43
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 04b7361..d88c50d 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -61,7 +61,6 @@ public:
GtkSalMenu( sal_Bool bMenuBar );
virtual ~GtkSalMenu();
- virtual void SetVisibleMenuBar( sal_Bool bVisible );
virtual sal_Bool VisibleMenuBar(); // must return TRUE to actually DISPLAY native menu bars
// otherwise only menu messages are processed (eg, OLE on Windows)
@@ -105,7 +104,6 @@ public:
virtual ~GtkSalMenuItem();
sal_uInt16 mnId; // Item ID
- MenuItemBits mnBits; // Item bits
MenuItemType mnType; // Item type
Menu* mpVCLMenu; // VCL Menu into which this MenuItem is inserted
GtkSalMenu* mpParentMenu; // The menu in which this menu item is inserted
diff --git a/vcl/unx/gtk/window/gloactiongroup.cxx b/vcl/unx/gtk/window/gloactiongroup.cxx
index 8f7d469..171341d 100644
--- a/vcl/unx/gtk/window/gloactiongroup.cxx
+++ b/vcl/unx/gtk/window/gloactiongroup.cxx
@@ -158,21 +158,17 @@ g_lo_action_group_query_action (GActionGroup *group,
if (enabled)
*enabled = action->enabled;
- if (parameter_type) {
+ if (parameter_type)
*parameter_type = action->parameter_type;
- }
- if (state_type) {
+ if (state_type)
*state_type = action->state_type;
- }
- if (state_hint) {
+ if (state_hint)
*state_hint = (action->state_hint) ? g_variant_ref(action->state_hint) : NULL;
- }
- if (state) {
+ if (state)
*state = (action->state) ? g_variant_ref(action->state) : NULL;
- }
return TRUE;
}
@@ -213,8 +209,6 @@ g_lo_action_group_activate (GActionGroup *group,
GTK_YIELD_GRAB();
GLOActionGroup *lo_group = G_LO_ACTION_GROUP (group);
- GLOAction* action = G_LO_ACTION (g_hash_table_lookup (lo_group->priv->table, action_name));
-
GtkSalFrame *pFrame = lo_group->priv->frame;
if ( pFrame != NULL )
@@ -222,7 +216,10 @@ g_lo_action_group_activate (GActionGroup *group,
GtkSalMenu* pSalMenu = static_cast< GtkSalMenu* >( pFrame->GetMenu() );
if ( pSalMenu != NULL )
+ {
+ GLOAction* action = G_LO_ACTION (g_hash_table_lookup (lo_group->priv->table, action_name));
pSalMenu->DispatchCommand( action->item_id, action_name );
+ }
}
}
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx
index 52e7dd6..594d9ac 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -146,7 +146,6 @@ static void UpdateNativeMenu( GtkSalMenu* pMenu )
pSubmenu->SetMenuModel( G_MENU_MODEL( pSubMenuModel ) );
pSubmenu->SetActionGroup( pActionGroup );
UpdateNativeMenu( pSubmenu );
-
}
nItemPos++;
@@ -275,7 +274,6 @@ on_registrar_available (GDBusConnection * /*connection*/,
g_free( aDBusMenubarPath );
bDBusIsAvailable = sal_True;
- pSalMenu->SetVisibleMenuBar( sal_True );
pMenuBar->SetDisplayable( sal_False );
}
}
@@ -296,7 +294,6 @@ on_registrar_unavailable (GDBusConnection * /*connection*/,
MenuBar* pMenuBar = static_cast< MenuBar* >( pSalMenu->GetMenu() );
bDBusIsAvailable = sal_False;
- pSalMenu->SetVisibleMenuBar( sal_False );
pMenuBar->SetDisplayable( sal_True );
}
@@ -338,14 +335,8 @@ GtkSalMenu::~GtkSalMenu()
maItems.clear();
}
-void GtkSalMenu::SetVisibleMenuBar( sal_Bool bVisible )
-{
-// mbVisible = bVisible;
-}
-
sal_Bool GtkSalMenu::VisibleMenuBar()
{
-// return mbVisible;
return bDBusIsAvailable;
}
@@ -428,10 +419,6 @@ const GtkSalFrame* GtkSalMenu::GetFrame() const
return pMenu ? pMenu->mpFrame : NULL;
}
-void GtkSalMenu::CheckItem( unsigned nPos, sal_Bool bCheck )
-{
-}
-
void GtkSalMenu::NativeCheckItem( unsigned nSection, unsigned nItemPos, MenuItemBits bits, gboolean bCheck )
{
if ( mpActionGroup == NULL )
@@ -463,10 +450,6 @@ void GtkSalMenu::NativeCheckItem( unsigned nSection, unsigned nItemPos, MenuItem
g_free( aCommand );
}
-void GtkSalMenu::EnableItem( unsigned nPos, sal_Bool bEnable )
-{
-}
-
void GtkSalMenu::NativeSetEnableItem( gchar* aCommand, gboolean bEnable )
{
GLOActionGroup* pActionGroup = G_LO_ACTION_GROUP( mpActionGroup );
@@ -475,10 +458,6 @@ void GtkSalMenu::NativeSetEnableItem( gchar* aCommand, gboolean bEnable )
g_lo_action_group_set_action_enabled( pActionGroup, aCommand, bEnable );
}
-void GtkSalMenu::SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const rtl::OUString& rText )
-{
-}
-
void GtkSalMenu::NativeSetItemText( unsigned nSection, unsigned nItemPos, const rtl::OUString& rText )
{
// Replace the "~" character with "_".
@@ -495,14 +474,6 @@ void GtkSalMenu::NativeSetItemText( unsigned nSection, unsigned nItemPos, const
g_free( aLabel );
}
-void GtkSalMenu::SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage)
-{
-}
-
-void GtkSalMenu::SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const KeyCode& rKeyCode, const rtl::OUString& rKeyName )
-{
-}
-
void GtkSalMenu::NativeSetAccelerator( unsigned nSection, unsigned nItemPos, const KeyCode& rKeyCode, const rtl::OUString& rKeyName )
{
if ( rKeyName.isEmpty() )
@@ -519,10 +490,6 @@ void GtkSalMenu::NativeSetAccelerator( unsigned nSection, unsigned nItemPos, con
g_free( aCurrentAccel );
}
-void GtkSalMenu::SetItemCommand( unsigned nPos, SalMenuItem* pSalMenuItem, const rtl::OUString& aCommandStr )
-{
-}
-
void GtkSalMenu::NativeSetItemCommand( unsigned nSection, unsigned nItemPos, GtkSalMenuItem* pItem, const gchar* aCommand )
{
GLOActionGroup* pActionGroup = G_LO_ACTION_GROUP( mpActionGroup );
@@ -580,10 +547,6 @@ void GtkSalMenu::NativeSetItemCommand( unsigned nSection, unsigned nItemPos, Gtk
g_free( aCurrentCommand );
}
-void GtkSalMenu::GetSystemMenuData( SystemMenuData* pData )
-{
-}
-
GtkSalMenu* GtkSalMenu::GetMenuForItemCommand( gchar* aCommand )
{
GtkSalMenu* pMenu = NULL;
@@ -628,6 +591,34 @@ void GtkSalMenu::DispatchCommand( gint itemId, const gchar *aCommand )
pMenuBar->HandleMenuCommandEvent( pSubMenu, itemId );
}
+void GtkSalMenu::CheckItem( unsigned nPos, sal_Bool bCheck )
+{
+}
+
+void GtkSalMenu::EnableItem( unsigned nPos, sal_Bool bEnable )
+{
+}
+
+void GtkSalMenu::SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const rtl::OUString& rText )
+{
+}
+
+void GtkSalMenu::SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage)
+{
+}
+
+void GtkSalMenu::SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const KeyCode& rKeyCode, const rtl::OUString& rKeyName )
+{
+}
+
+void GtkSalMenu::SetItemCommand( unsigned nPos, SalMenuItem* pSalMenuItem, const rtl::OUString& aCommandStr )
+{
+}
+
+void GtkSalMenu::GetSystemMenuData( SystemMenuData* pData )
+{
+}
+
void GtkSalMenu::Freeze()
{
}
@@ -640,7 +631,6 @@ void GtkSalMenu::Freeze()
GtkSalMenuItem::GtkSalMenuItem( const SalItemParams* pItemData ) :
mnId( pItemData->nId ),
- mnBits( pItemData->nBits ),
mnType( pItemData->eType ),
mpVCLMenu( pItemData->pMenu ),
mpParentMenu( NULL ),
commit 56a92d82c52d8802292ad6539b6528cfcf85b5bc
Author: Antonio Fernandez <antonio.fernandez at aentos.es>
Date: Tue Sep 11 21:25:22 2012 +0100
All Special items, including window list items are displayed, but with issues.
Change-Id: I23a6857f7aa738c48061ab51f3c015c41abc84cc
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index f746b4b..04b7361 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -55,8 +55,7 @@ private:
GMenuModel* mpMenuModel;
GActionGroup* mpActionGroup;
- sal_Int32 GetPositionFromItem( GtkSalMenuItem* pSalMenuItem );
- void GetItemSectionAndPosition( unsigned nPos, unsigned *insertSection, unsigned *insertPos );
+ GtkSalMenu* GetMenuForItemCommand( gchar* aCommand );
public:
GtkSalMenu( sal_Bool bMenuBar );
@@ -89,13 +88,14 @@ public:
virtual GtkSalMenuItem* GetItemAtPos( unsigned nPos ) { return maItems[ nPos ]; }
virtual void SetActionGroup( GActionGroup* pActionGroup ) { mpActionGroup = pActionGroup; }
virtual GActionGroup* GetActionGroup() { return mpActionGroup; }
- GtkSalMenu* GetMenuForItemCommand( gchar* aCommand );
void NativeSetItemText( unsigned nSection, unsigned nItemPos, const rtl::OUString& rText );
void NativeSetItemCommand( unsigned nSection, unsigned nItemPos, GtkSalMenuItem* pItem, const gchar* aCommandStr );
void NativeSetEnableItem( gchar* aCommand, gboolean bEnable );
void NativeCheckItem( unsigned nSection, unsigned nItemPos, MenuItemBits bits, gboolean bCheck );
void NativeSetAccelerator( unsigned nSection, unsigned nItemPos, const KeyCode& rKeyCode, const rtl::OUString& rKeyName );
+
+ void DispatchCommand( gint itemId, const gchar* aCommand );
};
class GtkSalMenuItem : public SalMenuItem
diff --git a/vcl/unx/gtk/window/gloactiongroup.cxx b/vcl/unx/gtk/window/gloactiongroup.cxx
index 33e756c..8f7d469 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 b61af31..52e7dd6 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()
{
}
More information about the Libreoffice-commits
mailing list