[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/source vcl/unx
vcl/inc/vcl/menu.hxx | 12 ++-- vcl/source/window/menu.cxx|5 + vcl/unx/gtk/window/gtksalmenu.cxx | 97 +++--- 3 files changed, 50 insertions(+), 64 deletions(-) New commits: commit 17e0471b2a2bc15a6f20a26bd26c64404451e879 Author: Antonio Fernandez antonio.fernan...@aentos.es Date: Thu Aug 9 15:58:03 2012 +0100 Most actions seem to work now. Enabled ImplSelectWithStart() for all builds. Change-Id: Ib309112de07d125fbe3b61ea20d5e26d1016912b diff --git a/vcl/inc/vcl/menu.hxx b/vcl/inc/vcl/menu.hxx index f98e87e..7538faf 100644 --- a/vcl/inc/vcl/menu.hxx +++ b/vcl/inc/vcl/menu.hxx @@ -298,11 +298,13 @@ public: Menu(); Menu( sal_Bool bMenuBar ); SAL_DLLPRIVATE Window* ImplGetWindow() const { return pWindow; } -#if defined(QUARTZ) -// ImplSelectWithStart() is used in vcl/aqua/source/window/salnsmenu.mm -SAL_DLLPRIVATE void ImplSelectWithStart( Menu* pStartMenu = NULL ); -#endif -public: +//#if defined(QUARTZ) +//// ImplSelectWithStart() is used in vcl/aqua/source/window/salnsmenu.mm +//SAL_DLLPRIVATE void ImplSelectWithStart( Menu* pStartMenu = NULL ); +//#endif +void ImplSelectWithStart( Menu* pStartMenu = NULL ); + +public: virtual ~Menu(); virtual voidActivate(); diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 02fbe67..2361a18 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -1146,7 +1146,8 @@ void Menu::Select() } } -#if defined(QUARTZ) +// FIXME: Workaround to make GLOMenu without defining macros. +//#if defined(QUARTZ) void Menu::ImplSelectWithStart( Menu* pSMenu ) { Menu* pOldStartedFrom = pStartedFrom; @@ -1157,7 +1158,7 @@ void Menu::ImplSelectWithStart( Menu* pSMenu ) pOldStartedFrom-pStartedFrom = pOldStartedStarted; pStartedFrom = pOldStartedFrom; } -#endif +//#endif void Menu::RequestHelp( const HelpEvent ) { diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx index a7a3ba6..4016a08 100644 --- a/vcl/unx/gtk/window/gtksalmenu.cxx +++ b/vcl/unx/gtk/window/gtksalmenu.cxx @@ -4,6 +4,8 @@ //#include gtk/gtk.h #include unx/gtk/glomenu.h #include unx/gtk/gloactiongroup.h +#include vcl/menu.hxx +#include unx/gtk/gtkinst.hxx #include iostream @@ -18,6 +20,7 @@ dispatchAction (GSimpleAction *action, gpointeruser_data) { cout ACTION: g_action_get_name( G_ACTION( action ) ) triggered. endl; +GTK_YIELD_GRAB(); if ( user_data ) { GtkSalMenuItem *pSalMenuItem = static_cast GtkSalMenuItem* ( user_data ); @@ -25,20 +28,43 @@ dispatchAction (GSimpleAction *action, if ( !pSalMenuItem-mpSubMenu ) { const GtkSalFrame *pFrame = pSalMenuItem-mpParentMenu ? pSalMenuItem-mpParentMenu-getFrame() : NULL; -if ( pFrame ) { +if ( pFrame !pFrame-GetParent() ) { ((PopupMenu*) pSalMenuItem-mpVCLMenu)-SetSelectedEntry( pSalMenuItem-mnId ); SalMenuEvent aMenuEvt( pSalMenuItem-mnId, pSalMenuItem-mpVCLMenu ); pFrame-CallCallback( SALEVENT_MENUCOMMAND, aMenuEvt ); } +else if ( pSalMenuItem-mpVCLMenu ) +{ +// if an item from submenu was selected. the corresponding Window does not exist because +// we use native popup menus, so we have to set the selected menuitem directly +// incidentally this of course works for top level popup menus, too +PopupMenu * pPopupMenu = dynamic_castPopupMenu *(pSalMenuItem-mpVCLMenu); +if( pPopupMenu ) +{ +// FIXME: revise this ugly code + +// select handlers in vcl are dispatch on the original menu +// if not consumed by the select handler of the current menu +// however since only the starting menu ever came into Execute +// the hierarchy is not build up. Workaround this by getting +// the menu it should have been + +// get started from hierarchy in vcl menus +GtkSalMenu* pParentMenu = pSalMenuItem-mpParentMenu; +Menu* pCurMenu = pSalMenuItem-mpVCLMenu; +while( pParentMenu pParentMenu-mpVCLMenu ) +{ +pCurMenu = pParentMenu-mpVCLMenu; +pParentMenu = pParentMenu-mpParentSalMenu; +} + +pPopupMenu-SetSelectedEntry( pSalMenuItem-mnId ); +pPopupMenu-ImplSelectWithStart( pCurMenu ); +} +else +OSL_FAIL( menubar item without frame ! ); +} } - -//if ( !pSalMenuItem-mpSubMenu ) { -//
[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/source vcl/unx
vcl/inc/salmenu.hxx |3 vcl/inc/unx/gtk/gtksalmenu.hxx|7 + vcl/source/window/menu.cxx| 66 + vcl/unx/gtk/app/gtkinst.cxx | 10 + vcl/unx/gtk/window/gtksalmenu.cxx | 191 +- 5 files changed, 150 insertions(+), 127 deletions(-) New commits: commit 2ffb9baa6d69584bbc19b6e2c84a4d7cfc1a3956 Author: Antonio Fernandez antonio.fernan...@aentos.es Date: Wed Aug 1 11:05:53 2012 +0100 Native menu is completely build in one step. Change-Id: I772c267b3c136e6baab2623dbf5538b5076d43ff diff --git a/vcl/inc/salmenu.hxx b/vcl/inc/salmenu.hxx index 1d14a7e..b3dc25f 100644 --- a/vcl/inc/salmenu.hxx +++ b/vcl/inc/salmenu.hxx @@ -41,7 +41,7 @@ class SalFrame; struct SalItemParams { -sal_uInt16 nId;// item Id +sal_uInt16 nId;// item Id MenuItemTypeeType; // MenuItem-Type MenuItemBitsnBits; // MenuItem-Bits Menu* pMenu; // Pointer to Menu @@ -90,6 +90,7 @@ public: virtual bool ShowNativePopupMenu(FloatingWindow * pWin, const Rectangle rRect, sal_uLong nFlags); virtual bool AddMenuBarButton( const SalMenuButtonItem ); // return false if not implemented or failure virtual void RemoveMenuBarButton( sal_uInt16 nId ); +virtual void Freeze() {} // return an empty rectangle if not implemented // return Rectangle( Point( -1, -1 ), Size( 1, 1 ) ) if menu bar buttons implemented diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx index c925a99..69fcec8 100644 --- a/vcl/inc/unx/gtk/gtksalmenu.hxx +++ b/vcl/inc/unx/gtk/gtksalmenu.hxx @@ -39,15 +39,19 @@ class GtkSalMenu : public SalMenu { private: -sal_BoolmbMenuBar; +sal_BoolmbMenuBar; + +virtual void publishMenu(); public: Menu* mpVCLMenu; const GtkSalFrame* mpFrame; GMenuModel* mpParentMenuModel; GMenuModel* mpMenuModel; +GMenuModel* mpSectionMenuModel; gchar* aDBusMenubarPath; GDBusConnection*pSessionBus; +sal_Int32 mMenubarId; GtkSalMenu( sal_Bool bMenuBar ); virtual ~GtkSalMenu(); @@ -65,6 +69,7 @@ public: virtual void SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image rImage); virtual void SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const KeyCode rKeyCode, const rtl::OUString rKeyName ); virtual void GetSystemMenuData( SystemMenuData* pData ); +virtual void Freeze(); }; class GtkSalMenuItem : public SalMenuItem diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 6d02fc9..cc15191 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -6064,66 +6064,9 @@ ImplMenuDelData::~ImplMenuDelData() } #include iostream -#include gio/gio.h using namespace std; -GMenu* generateMenuBar( AbstractMenu *pMenu ) -{ -GMenu *menu = g_menu_new(); - -g_menu_append(menu, Submenu1, NULL); - -return menu; -} - -#define BUS_NAME org.libreoffice.LibreOffice -#define OBJ_PATH /org/libreoffice/LibreOffice - -void publishMenu( GMenuModel *menu ) -{ -GActionGroup *group; -GDBusConnection *bus; -GError *error = NULL; -gchar *path; -guint id; - -bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); -group = G_ACTION_GROUP( g_simple_action_group_new() ); - -//g_print (Exporting menus on the bus...\n); -//if (!g_dbus_connection_export_menu_model (bus, OBJ_PATH, menu, error)) -//{ -//g_warning (Menu export failed: %s, error-message); -//exit (1); -//} -//g_print (Exporting actions on the bus...\n); -//if (!g_dbus_connection_export_action_group (bus, OBJ_PATH, group, error)) -//{ -//g_warning (Action export failed: %s, error-message); -//exit (1); -//} - -g_bus_own_name_on_connection (bus, BUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL); - - -/* export the new menu, if there is one */ -if (menu != NULL) -{ -/* try getting the preferred name */ -path = g_strconcat (OBJ_PATH, /menus/, menubar, NULL); -id = g_dbus_connection_export_menu_model (bus, path, menu, NULL); - -/* keep trying until we get a working name... */ -for (int i = 0; id == 0; i++) -{ -g_free (path); -path = g_strdup_printf (%s/menus/%s%d,OBJ_PATH, menubar, i); -id = g_dbus_connection_export_menu_model (bus, path, menu, NULL); -} -} -} - void printMenu( AbstractMenu* pMenu ) { if ( pMenu ) { sal_uInt16 itemCount = pMenu-GetItemCount(); @@ -6152,10 +6095,13 @@ void printMenu( AbstractMenu* pMenu ) { void Menu::Freeze() { printMenu( this ); - -//