[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/unx
Antonio Fernandez
afernandez at kemper.freedesktop.org
Wed Aug 8 12:06:20 PDT 2012
vcl/inc/unx/gtk/gtksalmenu.hxx | 3 ++
vcl/unx/gtk/window/gtksalmenu.cxx | 39 ++++++++++++++++++++++++++++++++------
2 files changed, 36 insertions(+), 6 deletions(-)
New commits:
commit 81ab273ba750927def5764231e69600be320dfdf
Author: Antonio Fernandez <antonio.fernandez at aentos.es>
Date: Wed Aug 8 20:05:40 2012 +0100
Some actions are now performed from Unity menubar.
Change-Id: I854794ab11f63306a2e976d16876fc79564e44ff
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 03c07bb..bb62969 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -56,6 +56,7 @@ public:
GActionEntry* mpActionEntry;
Menu* mpVCLMenu;
+ GtkSalMenu* mpParentSalMenu;
const GtkSalFrame* mpFrame;
gchar* aDBusMenubarPath;
GDBusConnection* pSessionBus;
@@ -82,6 +83,8 @@ public:
virtual void SetItemCommand( unsigned nPos, SalMenuItem* pSalMenuItem, const rtl::OUString& aCommandStr );
virtual bool ShowNativePopupMenu(FloatingWindow * pWin, const Rectangle& rRect, sal_uLong nFlags);
virtual void Freeze();
+
+ virtual const GtkSalFrame* getFrame() const;
};
class GtkSalMenuItem;
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx
index 134d5e2..a7a3ba6 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -23,12 +23,22 @@ dispatchAction (GSimpleAction *action,
GtkSalMenuItem *pSalMenuItem = static_cast< GtkSalMenuItem* >( user_data );
if ( !pSalMenuItem->mpSubMenu ) {
- if ( !pSalMenuItem->mpVCLMenu->IsMenuBar() ) {
-// ((PopupMenu*) pSalMenuItem->mpVCLMenu)->SetSelectedEntry( pSalMenuItem->mnId );
-// pSalMenuItem->mpVCLMenu->Select();
-// pSalMenuItem->mpVCLMenu->DeSelect();
+ const GtkSalFrame *pFrame = pSalMenuItem->mpParentMenu ? pSalMenuItem->mpParentMenu->getFrame() : NULL;
+
+ if ( pFrame ) {
+ ((PopupMenu*) pSalMenuItem->mpVCLMenu)->SetSelectedEntry( pSalMenuItem->mnId );
+ SalMenuEvent aMenuEvt( pSalMenuItem->mnId, pSalMenuItem->mpVCLMenu );
+ pFrame->CallCallback( SALEVENT_MENUCOMMAND, &aMenuEvt );
}
}
+
+// if ( !pSalMenuItem->mpSubMenu ) {
+// if ( !pSalMenuItem->mpVCLMenu->IsMenuBar() ) {
+//// ((PopupMenu*) pSalMenuItem->mpVCLMenu)->SetSelectedEntry( pSalMenuItem->mnId );
+//// pSalMenuItem->mpVCLMenu->Select();
+//// pSalMenuItem->mpVCLMenu->DeSelect();
+// }
+// }
}
}
@@ -223,6 +233,7 @@ void GtkSalMenu::publishMenu( GMenuModel *pMenu, GActionGroup *pActionGroup )
GtkSalMenu::GtkSalMenu( sal_Bool bMenuBar ) :
mbMenuBar( bMenuBar ),
mpVCLMenu( NULL ),
+ mpParentSalMenu( NULL ),
aDBusMenubarPath( NULL ),
pSessionBus( NULL ),
mpActionEntry( NULL ),
@@ -313,7 +324,13 @@ void GtkSalMenu::SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsig
GtkSalMenuItem *pGtkSalMenuItem = static_cast<GtkSalMenuItem*>( pSalMenuItem );
GtkSalMenu *pGtkSubMenu = static_cast<GtkSalMenu*>( pSubMenu );
- pGtkSalMenuItem->mpSubMenu = pGtkSubMenu;
+ if ( pGtkSubMenu ) {
+ pGtkSalMenuItem->mpSubMenu = pGtkSubMenu;
+
+ if ( !pGtkSubMenu->mpParentSalMenu ) {
+ pGtkSubMenu->mpParentSalMenu = this;
+ }
+ }
}
void GtkSalMenu::SetFrame( const SalFrame* pFrame )
@@ -344,6 +361,14 @@ void GtkSalMenu::SetFrame( const SalFrame* pFrame )
}
}
+const GtkSalFrame* GtkSalMenu::getFrame() const
+{
+ const GtkSalMenu* pMenu = this;
+ while( pMenu && ! pMenu->mpFrame )
+ pMenu = pMenu->mpParentSalMenu;
+ return pMenu ? pMenu->mpFrame : NULL;
+}
+
void GtkSalMenu::CheckItem( unsigned nPos, sal_Bool bCheck )
{
cout << __FUNCTION__ << endl;
@@ -410,7 +435,9 @@ void GtkSalMenu::SetItemCommand( unsigned nPos, SalMenuItem* pSalMenuItem, const
// Disable action by default.
// g_simple_action_set_enabled( pAction, FALSE );
- g_signal_connect(pAction, "activate", G_CALLBACK( dispatchAction ), pGtkSalMenuItem);
+// if ( !pGtkSalMenuItem->mpVCLMenu->GetPopupMenu( pGtkSalMenuItem->mnId ) ) {
+ g_signal_connect(pAction, "activate", G_CALLBACK( dispatchAction ), pGtkSalMenuItem);
+// }
pGtkSalMenuItem->mpAction = G_ACTION( pAction );
More information about the Libreoffice-commits
mailing list