[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/unx

2012-08-16 Thread Antonio Fernandez
 vcl/inc/unx/gtk/gloactiongroup.h  |   27 +--
 vcl/inc/unx/gtk/gtksalmenu.hxx|   19 +-
 vcl/unx/gtk/window/gloactiongroup.cxx |  263 +-
 vcl/unx/gtk/window/gtksalmenu.cxx |  130 ++--
 4 files changed, 181 insertions(+), 258 deletions(-)

New commits:
commit a8eca38fa4e5008cb3d2efcba9d2cb412645e71d
Author: Antonio Fernandez 
Date:   Thu Aug 16 22:48:54 2012 +0100

GLOActionGroup partially implemented. Menus work but no special items shown.

Change-Id: I7c48fbc5763daf789e7347cfedc62f14be53c934

diff --git a/vcl/inc/unx/gtk/gloactiongroup.h b/vcl/inc/unx/gtk/gloactiongroup.h
index 431b93b..a44dbaa 100644
--- a/vcl/inc/unx/gtk/gloactiongroup.h
+++ b/vcl/inc/unx/gtk/gloactiongroup.h
@@ -2,7 +2,6 @@
 #define GLOACTIONGROUP_H
 
 #include 
-//#include "gactionmap.h"
 
 G_BEGIN_DECLS
 
@@ -39,26 +38,22 @@ struct _GLOActionGroupClass
 gpointer padding[12];
 };
 
-GType   g_lo_action_group_get_type  (void) 
G_GNUC_CONST;
+GType   g_lo_action_group_get_type  (void) 
G_GNUC_CONST;
 
-GLOActionGroup *g_lo_action_group_new   (void);
+GLOActionGroup *g_lo_action_group_new   (void);
 
-GAction *   g_lo_action_group_lookup
(GLOActionGroup *group,
- const gchar   
 *action_name);
+voidg_lo_action_group_insert(GLOActionGroup 
*group,
+ const gchar
*action_name,
+ gpointer
action_info);
 
-voidg_lo_action_group_insert
(GLOActionGroup *group,
- GAction   
 *action);
+voidg_lo_action_group_set_action_enabled(GLOActionGroup 
*group,
+ const gchar
*action_name,
+ gboolean
enabled);
 
-voidg_lo_action_group_remove
(GLOActionGroup *group,
- const gchar   
 *action_name);
+voidg_lo_action_group_remove(GLOActionGroup 
*group,
+ const gchar
*action_name);
 
-// This function has been added to make current implementation of GtkSalMenu 
work.
-voidg_lo_action_group_clear 
(GLOActionGroup *group);
-
-voidg_lo_action_group_add_entries   
(GLOActionGroup *group,
- const 
GActionEntry *entries,
- gint  
  n_entries,
- gpointer  
  user_data);
+voidg_lo_action_group_clear (GLOActionGroup 
*group);
 
 G_END_DECLS
 
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 3bffc6c..d5ee38f 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -98,6 +98,7 @@ public:
 virtual GMenuModel* GetCurrentSection() { return mpCurrentSection; 
}
 virtual unsignedGetItemCount() { return maItems.size(); }
 virtual GtkSalMenuItem* GetItemAtPos( unsigned nPos ) { return 
maItems[ nPos ]; }
+virtual GActionGroup*   GetActionGroup() { return mpActionGroup; }
 };
 
 class GtkSalMenuItem : public SalMenuItem
@@ -106,14 +107,16 @@ public:
 GtkSalMenuItem( const SalItemParams* );
 virtual ~GtkSalMenuItem();
 
-sal_uInt16  mnId; // Item ID
-sal_uInt16  mnPos;// Item position
-Menu*   mpVCLMenu;// VCL Menu into which this 
MenuItem is inserted
-GtkSalMenu* mpParentMenu; // The menu in which this menu 
item is inserted
-GtkSalMenu* mpSubMenu;// Sub menu of this item (if 
defined)
-GMenuModel* mpParentSection;  // Section where this item is 
added.
-GLOMenuItem*mpMenuItem;   // The GMenuItem
-GAction*mpAction; // The GAction associated with 
this item
+sal_uInt16  mnId;   // Item ID
+sal_uInt16  mnPos;  // Item position
+gchar*  maCommand;  // Item command
+Menu*   mpVCLMenu;  // VCL Menu into which this 
MenuItem is inserted
+GtkSalMenu* mpParentMenu;   // The menu in which this menu 
item is inserted
+GtkSalMenu* mpSubMenu;  // Sub me

[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/unx

2012-08-15 Thread Antonio Fernandez
 vcl/inc/unx/gtk/gloactiongroup.h  |3 
 vcl/inc/unx/gtk/glomenu.h |  168 +--
 vcl/unx/gtk/app/gtkinst.cxx   |2 
 vcl/unx/gtk/window/gloactiongroup.cxx |   23 +++
 vcl/unx/gtk/window/gtksalmenu.cxx |  209 +++---
 5 files changed, 228 insertions(+), 177 deletions(-)

New commits:
commit c833b98c0a84b0aeedd5e50d3cc03047f1ece94a
Author: Antonio Fernandez 
Date:   Wed Aug 15 10:15:44 2012 +0100

Menu is now displayed properly in all windows.

Change-Id: I9f8cffc3d19bb4c75c1153ff9f06fd5bab3440f6

diff --git a/vcl/inc/unx/gtk/gloactiongroup.h b/vcl/inc/unx/gtk/gloactiongroup.h
index b71ae47..431b93b 100644
--- a/vcl/inc/unx/gtk/gloactiongroup.h
+++ b/vcl/inc/unx/gtk/gloactiongroup.h
@@ -52,6 +52,9 @@ voidg_lo_action_group_insert  
  (GLOActionGroup
 voidg_lo_action_group_remove
(GLOActionGroup *group,
  const gchar   
 *action_name);
 
+// This function has been added to make current implementation of GtkSalMenu 
work.
+voidg_lo_action_group_clear 
(GLOActionGroup *group);
+
 voidg_lo_action_group_add_entries   
(GLOActionGroup *group,
  const 
GActionEntry *entries,
  gint  
  n_entries,
diff --git a/vcl/inc/unx/gtk/glomenu.h b/vcl/inc/unx/gtk/glomenu.h
index 54c7b5b..db2f034 100644
--- a/vcl/inc/unx/gtk/glomenu.h
+++ b/vcl/inc/unx/gtk/glomenu.h
@@ -42,91 +42,91 @@ typedef struct _GLOMenuItem GLOMenuItem;
 typedef struct _GLOMenu GLOMenu;
 
 GLIB_AVAILABLE_IN_2_32
-GType   g_lo_menu_get_type (void) G_GNUC_CONST;
+GType   g_lo_menu_get_type  (void) 
G_GNUC_CONST;
 GLIB_AVAILABLE_IN_2_32
-GLOMenu * g_lo_menu_new  (void);
-
-voidg_lo_menu_freeze   (GLOMenu   *menu);
-
-voidg_lo_menu_insert_item  (GLOMenu   *menu,
-gint position,
-GLOMenuItem   *item);
-voidg_lo_menu_prepend_item (GLOMenu   *menu,
-GLOMenuItem   *item);
-voidg_lo_menu_append_item  (GLOMenu   *menu,
-GLOMenuItem   *item);
-voidg_lo_menu_remove   (GLOMenu   *menu,
-gint position);
-
-voidg_lo_menu_insert   (GLOMenu   *menu,
-gint position,
-const gchar *label,
-const gchar 
*detailed_action);
-voidg_lo_menu_prepend  (GLOMenu   *menu,
-const gchar *label,
-const gchar 
*detailed_action);
-voidg_lo_menu_append   (GLOMenu   *menu,
-const gchar *label,
-const gchar 
*detailed_action);
-
-voidg_lo_menu_insert_section   (GLOMenu   *menu,
-gint position,
-const gchar *label,
-GMenuModel  *section);
-voidg_lo_menu_prepend_section  (GLOMenu   *menu,
-const gchar *label,
-GMenuModel  *section);
-voidg_lo_menu_append_section   (GLOMenu   *menu,
-const gchar *label,
-GMenuModel  *section);
-
-voidg_lo_menu_insert_submenu   (GLOMenu   *menu,
-gintposition,
-const gchar *label,
-GMenuModel  *submenu);
-voidg_lo_menu_prepend_submenu  (GLOMenu   *menu,
-const gchar *label

[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/unx

2012-08-14 Thread Antonio Fernandez
 vcl/inc/unx/gtk/gtksalmenu.hxx|3 -
 vcl/unx/gtk/window/gtksalmenu.cxx |   84 +-
 2 files changed, 59 insertions(+), 28 deletions(-)

New commits:
commit cd3845cb77a77293bcd3db00058c4e45bdc959b1
Author: Antonio Fernandez 
Date:   Tue Aug 14 14:38:35 2012 +0100

Menu is published once. Only special menus are updated now.

Change-Id: Ie7643e81c61ae0794bdf8a6e1e7d292f9550674b

diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 78ec7a1..3bffc6c 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -62,9 +62,10 @@ private:
 sal_Int32   mMenubarId;
 sal_Int32   mActionGroupId;
 
-// GMenuModel attributes
+// GMenuModel and GActionGroup attributes
 GMenuModel* mpMenuModel;
 GMenuModel* mpCurrentSection;
+GActionGroup*   mpActionGroup;
 
 virtual voidpublishMenu( GMenuModel*, GActionGroup* );
 GtkSalMenuItem* GetSalMenuItem( sal_uInt16 nId );
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx 
b/vcl/unx/gtk/window/gtksalmenu.cxx
index 642f2b8..a3812d7 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -186,7 +186,8 @@ GtkSalMenu::GtkSalMenu( sal_Bool bMenuBar ) :
 aDBusMenubarPath( NULL ),
 pSessionBus( NULL ),
 mMenubarId( 0 ),
-mActionGroupId ( 0 )
+mActionGroupId ( 0 ),
+mpActionGroup( NULL )
 {
 mpCurrentSection = G_MENU_MODEL( g_lo_menu_new() );
 maSections.push_back( mpCurrentSection );
@@ -195,6 +196,8 @@ GtkSalMenu::GtkSalMenu( sal_Bool bMenuBar ) :
 g_lo_menu_append_section( G_LO_MENU( mpMenuModel ), NULL, mpCurrentSection 
);
 
 if (bMenuBar) {
+mpActionGroup = G_ACTION_GROUP( g_lo_action_group_new() );
+
 pSessionBus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
 if(!pSessionBus) puts ("Fail bus get");
 }
@@ -202,6 +205,8 @@ GtkSalMenu::GtkSalMenu( sal_Bool bMenuBar ) :
 
 GtkSalMenu::~GtkSalMenu()
 {
+g_source_remove_by_user_data( this );
+
 // FIXME: Not sure if we need to unset X Properties.
 if ( mpFrame ) {
 GtkWidget *widget = GTK_WIDGET( mpFrame->getWindow() );
@@ -238,11 +243,15 @@ GtkSalMenu::~GtkSalMenu()
 
 g_object_unref( mpMenuModel );
 g_object_unref( mpCurrentSection );
+
+if ( mpActionGroup ) {
+g_object_unref( mpActionGroup );
+}
 }
 
 sal_Bool GtkSalMenu::VisibleMenuBar()
 {
-return sal_True;
+return sal_False;
 }
 
 void GtkSalMenu::InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos )
@@ -268,6 +277,13 @@ void GtkSalMenu::InsertItem( SalMenuItem* pSalMenuItem, 
unsigned nPos )
 
 void GtkSalMenu::RemoveItem( unsigned nPos )
 {
+// FIXME: This method makes the application crash.
+//if ( nPos < maItems.size() ) {
+//GtkSalMenuItem* pSalMenuItem = maItems[ nPos ];
+
+//g_lo_menu_remove( G_LO_MENU( pSalMenuItem->mpParentSection ), 
pSalMenuItem->mnPos );
+//maItems.erase( maItems.begin() + nPos, maItems.begin() + nPos );
+//}
 }
 
 void GtkSalMenu::SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, 
unsigned nPos )
@@ -287,14 +303,32 @@ void GtkSalMenu::SetSubMenu( SalMenuItem* pSalMenuItem, 
SalMenu* pSubMenu, unsig
 
 void updateNativeMenu( GtkSalMenu* pMenu );
 
+void updateSpecialMenus( GtkSalMenu *pMenu ) {
+if ( pMenu ) {
+for ( sal_uInt16 i = 0; i < pMenu->GetItemCount(); i++ ) {
+GtkSalMenuItem* pSalMenuItem = pMenu->GetItemAtPos( i );
+
+rtl::OUString aCommand = pSalMenuItem->mpVCLMenu->GetItemCommand( 
pSalMenuItem->mnId );
+
+if ( isSpecialSubmenu( aCommand ) ) {
+updateNativeMenu( pSalMenuItem->mpSubMenu );
+}
+
+updateSpecialMenus( pSalMenuItem->mpSubMenu );
+}
+}
+}
+
 gboolean GenerateMenu(gpointer user_data) {
 cout << "Generating menu..." << endl;
 GtkSalMenu* pSalMenu = static_cast< GtkSalMenu* >( user_data );
-updateNativeMenu( pSalMenu );
+//updateNativeMenu( pSalMenu );
+updateSpecialMenus( pSalMenu );
 
 return TRUE;
 }
 
+
 void GtkSalMenu::SetFrame( const SalFrame* pFrame )
 {
 mpFrame = static_cast( pFrame );
@@ -315,12 +349,12 @@ void GtkSalMenu::SetFrame( const SalFrame* pFrame )
 gdk_x11_window_set_utf8_property ( gdkWindow, 
"_GTK_WINDOW_OBJECT_PATH", aDBusWindowPath );
 gdk_x11_window_set_utf8_property ( gdkWindow, 
"_GTK_MENUBAR_OBJECT_PATH", aDBusMenubarPath );
 
-// Try to publish the menu with the right bus data.
-Freeze();
+// Publish the menu.
+this->publishMenu( mpMenuModel, mpActionGroup );
 
 // Refresh the menu every second.
 // This code is a workaround until required modifications in Gtk+ are 
available.
-// 

[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/unx

2012-08-14 Thread Antonio Fernandez
 vcl/inc/unx/gtk/gtksalmenu.hxx|1 -
 vcl/unx/gtk/window/gtksalmenu.cxx |   22 --
 2 files changed, 16 insertions(+), 7 deletions(-)

New commits:
commit 02f0ab10969751353bd850f9704da7ef975b6926
Author: Antonio Fernandez 
Date:   Tue Aug 14 11:22:57 2012 +0100

Fixed a regression with popup menus. Added a method to update menu every 
sec.

Change-Id: I419a304f2c90d07ee7a5365e0397040b7eb953d7

diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index d0ce612..78ec7a1 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -88,7 +88,6 @@ public:
 virtual voidSetAccelerator( unsigned nPos, SalMenuItem* 
pSalMenuItem, const KeyCode& rKeyCode, const rtl::OUString& rKeyName );
 virtual voidGetSystemMenuData( SystemMenuData* pData );
 virtual voidSetItemCommand( unsigned nPos, SalMenuItem* 
pSalMenuItem, const rtl::OUString& aCommandStr );
-virtual boolShowNativePopupMenu(FloatingWindow * pWin, 
const Rectangle& rRect, sal_uLong nFlags);
 virtual voidFreeze();
 
 virtual voidSetMenu( Menu* pMenu ) { mpVCLMenu = pMenu; }
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx 
b/vcl/unx/gtk/window/gtksalmenu.cxx
index 0c78997..642f2b8 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -202,6 +202,7 @@ GtkSalMenu::GtkSalMenu( sal_Bool bMenuBar ) :
 
 GtkSalMenu::~GtkSalMenu()
 {
+// FIXME: Not sure if we need to unset X Properties.
 if ( mpFrame ) {
 GtkWidget *widget = GTK_WIDGET( mpFrame->getWindow() );
 GdkWindow *gdkWindow = gtk_widget_get_window( widget );
@@ -241,7 +242,7 @@ GtkSalMenu::~GtkSalMenu()
 
 sal_Bool GtkSalMenu::VisibleMenuBar()
 {
-return sal_False;
+return sal_True;
 }
 
 void GtkSalMenu::InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos )
@@ -284,6 +285,16 @@ void GtkSalMenu::SetSubMenu( SalMenuItem* pSalMenuItem, 
SalMenu* pSubMenu, unsig
 }
 }
 
+void updateNativeMenu( GtkSalMenu* pMenu );
+
+gboolean GenerateMenu(gpointer user_data) {
+cout << "Generating menu..." << endl;
+GtkSalMenu* pSalMenu = static_cast< GtkSalMenu* >( user_data );
+updateNativeMenu( pSalMenu );
+
+return TRUE;
+}
+
 void GtkSalMenu::SetFrame( const SalFrame* pFrame )
 {
 mpFrame = static_cast( pFrame );
@@ -306,6 +317,10 @@ void GtkSalMenu::SetFrame( const SalFrame* pFrame )
 
 // Try to publish the menu with the right bus data.
 Freeze();
+
+// Refresh the menu every second.
+// This code is a workaround until required modifications in Gtk+ are 
available.
+//g_timeout_add( 1000, GenerateMenu, this );
 }
 }
 
@@ -391,11 +406,6 @@ void GtkSalMenu::GetSystemMenuData( SystemMenuData* pData )
 {
 }
 
-bool GtkSalMenu::ShowNativePopupMenu(FloatingWindow * pWin, const Rectangle& 
rRect, sal_uLong nFlags)
-{
-return TRUE;
-}
-
 void updateNativeMenu( GtkSalMenu* pMenu ) {
 if ( pMenu ) {
 for ( sal_uInt16 i = 0; i < pMenu->GetItemCount(); i++ ) {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/unx

2012-08-14 Thread Antonio Fernandez
 vcl/inc/unx/gtk/gtksalmenu.hxx|   78 --
 vcl/unx/gtk/app/gtkinst.cxx   |2 
 vcl/unx/gtk/window/gtksalmenu.cxx |   97 --
 3 files changed, 63 insertions(+), 114 deletions(-)

New commits:
commit 376df92806d3ae1138529bccae2820428c7fc92c
Author: Antonio Fernandez 
Date:   Tue Aug 14 10:20:01 2012 +0100

Cleaned up some code and did a small refactoring.

Change-Id: I06b987a06ccadd00ee67db8e781ec5a9e42fc89e

diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 67adec4..d0ce612 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -47,53 +47,57 @@ class GtkSalMenuItem;
 class GtkSalMenu : public SalMenu
 {
 private:
-sal_BoolmbMenuBar;
+sal_BoolmbMenuBar;
+Menu*   mpVCLMenu;
+GtkSalMenu* mpParentSalMenu;
+const GtkSalFrame*  mpFrame;
 
-virtual void publishMenu( GMenuModel*, GActionGroup* );
-
-GtkSalMenuItem* GetSalMenuItem( sal_uInt16 nId );
-
-public:
 std::vector< GMenuModel* >  maSections;
 std::vector< GtkSalMenuItem* >  maItems;
 
-Menu*   mpVCLMenu;
-GtkSalMenu* mpParentSalMenu;
-const GtkSalFrame*  mpFrame;
-
-// DBus variables
-gchar*  aDBusPath;
-gchar*  aDBusMenubarPath;
-GDBusConnection*pSessionBus;
-sal_Int32   mBusId;
-sal_Int32   mMenubarId;
-sal_Int32   mActionGroupId;
+// DBus attributes
+gchar*  aDBusPath;
+gchar*  aDBusMenubarPath;
+GDBusConnection*pSessionBus;
+sal_Int32   mMenubarId;
+sal_Int32   mActionGroupId;
 
 // GMenuModel attributes
-GMenuModel* mpMenuModel;
-GMenuModel* mpCurrentSection;
+GMenuModel* mpMenuModel;
+GMenuModel* mpCurrentSection;
+
+virtual voidpublishMenu( GMenuModel*, GActionGroup* );
+GtkSalMenuItem* GetSalMenuItem( sal_uInt16 nId );
 
+public:
 GtkSalMenu( sal_Bool bMenuBar );
 virtual ~GtkSalMenu();
 
-virtual sal_Bool VisibleMenuBar();  // must return TRUE to actually 
DISPLAY native menu bars
-// otherwise only menu messages are 
processed (eg, OLE on Windows)
-
-virtual void InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos );
-virtual void RemoveItem( unsigned nPos );
-virtual void SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, 
unsigned nPos );
-virtual void SetFrame( const SalFrame* pFrame );
-virtual void CheckItem( unsigned nPos, sal_Bool bCheck );
-virtual void EnableItem( unsigned nPos, sal_Bool bEnable );
-virtual void SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const 
rtl::OUString& rText );
-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 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;
+virtual sal_BoolVisibleMenuBar();   // must return TRUE to 
actually DISPLAY native menu bars
+// otherwise only menu 
messages are processed (eg, OLE on Windows)
+
+virtual voidInsertItem( SalMenuItem* pSalMenuItem, 
unsigned nPos );
+virtual voidRemoveItem( unsigned nPos );
+virtual voidSetSubMenu( SalMenuItem* pSalMenuItem, 
SalMenu* pSubMenu, unsigned nPos );
+virtual voidSetFrame( const SalFrame* pFrame );
+virtual const GtkSalFrame*  GetFrame() const;
+virtual voidCheckItem( unsigned nPos, sal_Bool bCheck );
+virtual voidEnableItem( unsigned nPos, sal_Bool bEnable );
+virtual voidSetItemText( unsigned nPos, SalMenuItem* 
pSalMenuItem, const rtl::OUString& rText );
+virtual voidSetItemImage( unsigned nPos, SalMenuItem* 
pSalMenuItem, const Image& rImage);
+virtual voidSetAccelerator( unsigned nPos, SalMenuItem* 
pSalMenuItem, const KeyCode& rKeyCode, co

[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/source vcl/unx

2012-08-13 Thread Antonio Fernandez
 vcl/source/window/menu.cxx|   68 +-
 vcl/unx/gtk/window/gtksalmenu.cxx |   24 ++---
 2 files changed, 27 insertions(+), 65 deletions(-)

New commits:
commit 8af3f23b0632beec4147329877717d431c6942c0
Author: Antonio Fernandez 
Date:   Mon Aug 13 22:19:30 2012 +0100

All menu labels are now displayed. There are some issues with repeated 
labels.

Change-Id: I1b92b91f34003f20aaa56558c1c0e231d1de6f94

diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 3a14ca6..e921805 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -3244,6 +3244,15 @@ void Menu::HighlightItem( sal_uInt16 nItemPos )
 }
 }
 
+void Menu::Freeze() {
+SalMenu *pSalMenu = ImplGetSalMenu();
+
+if ( pSalMenu ) {
+pSalMenu->Freeze();
+}
+}
+
+
 // ---
 // - MenuBar -
 // ---
@@ -6069,63 +6078,4 @@ ImplMenuDelData::~ImplMenuDelData()
 const_cast< Menu* >( mpMenu )->ImplRemoveDel( *this );
 }
 
-#include 
-
-using namespace std;
-
-void printMenu( AbstractMenu* pMenu ) {
-if ( pMenu ) {
-sal_uInt16 itemCount = pMenu->GetItemCount();
-MenuItemList *items = ((Menu*)pMenu)->GetItemList();
-
-for (int i=0; i < itemCount; i++) {
-MenuItemData *itemData = items->GetDataFromPos(i);
-sal_uInt16 itemId = pMenu->GetItemId(i);
-
-if (itemData->eType == MENUITEM_SEPARATOR) {
-cout << "---" << endl;
-} else {
-rtl::OUString itemText = itemData->aText;
-rtl::OUString cmdString = itemData->aCommandStr;
-cout << "Item ID: " << itemId << "  Text: " << itemText << "  
CMD: " << cmdString << endl;
-
-if (itemData->pSubMenu) {
-cout << ">> SUBMENU <<" << endl;
-//FIXME: This callback would introduce some noise in 
accessibility software.
-itemData->pSubMenu->Activate();
-printMenu( itemData->pSubMenu );
-}
-}
-}
-}
-}
-
-void generateMenuHierarchy( AbstractMenu* pMenu ) {
-if ( pMenu ) {
-sal_uInt16 itemCount = pMenu->GetItemCount();
-MenuItemList *items = ((Menu*)pMenu)->GetItemList();
-
-for (int i=0; i < itemCount; i++) {
-MenuItemData *itemData = items->GetDataFromPos(i);
-
-if (itemData->pSubMenu) {
-itemData->pSubMenu->Activate();
-generateMenuHierarchy( itemData->pSubMenu );
-}
-}
-}
-}
-
-void Menu::Freeze() {
-//printMenu( this );
-generateMenuHierarchy( this );
-//cout << "" 
<< endl;
-
-SalMenu *pSalMenu = ImplGetSalMenu();
-
-if ( pSalMenu ) {
-pSalMenu->Freeze();
-}
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx 
b/vcl/unx/gtk/window/gtksalmenu.cxx
index c0a69c1..163564a 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -451,20 +451,32 @@ bool GtkSalMenu::ShowNativePopupMenu(FloatingWindow * 
pWin, const Rectangle& rRe
 return TRUE;
 }
 
+void updateNativeMenu( GtkSalMenu* pMenu ) {
+if ( pMenu ) {
+for (int i=0; i < pMenu->maItems.size(); i++) {
+GtkSalMenuItem* pSalMenuItem = pMenu->maItems[ i ];
+String aText = pSalMenuItem->mpVCLMenu->GetItemText( 
pSalMenuItem->mnId );
+
+// Force updating of native menu labels.
+pMenu->SetItemText( i, pSalMenuItem, aText );
+
+if ( pSalMenuItem->mpSubMenu && pSalMenuItem->mpSubMenu->mpVCLMenu 
) {
+pSalMenuItem->mpSubMenu->mpVCLMenu->Activate();
+updateNativeMenu( pSalMenuItem->mpSubMenu );
+}
+}
+}
+}
 void GtkSalMenu::Freeze()
 {
-cout << __FUNCTION__ << endl;
-GLOActionGroup *mpActionGroup = g_lo_action_group_new();
+updateNativeMenu( this );
 
-//GMenuModel *pMenuModel = generateMenuModelAndActions( this, 
mpActionGroup );
+GLOActionGroup *mpActionGroup = g_lo_action_group_new();
 
 generateActions( this, mpActionGroup );
 
-//this->publishMenu( mpMenuModel, G_ACTION_GROUP( mpActionGroup ) );
-
 // Menubar would have one section only.
 this->publishMenu( mpMenuModel, G_ACTION_GROUP( mpActionGroup ) );
-//g_object_unref( pMenuModel );
 }
 
 // ===
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/unx

2012-08-12 Thread Antonio Fernandez
 vcl/inc/unx/gtk/gtksalmenu.hxx|   37 +--
 vcl/unx/gtk/window/gtksalmenu.cxx |  177 +-
 2 files changed, 85 insertions(+), 129 deletions(-)

New commits:
commit b3fb9d3fb27cae173604c7a97a3034e3914b13d0
Author: Antonio Fernandez 
Date:   Sun Aug 12 20:17:23 2012 +0100

Menu model hierarchy is now updated everytime a menu item is changed.

Change-Id: I8d591902405ae84ee8758da0ace6680b0516dbc6

diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 3e30323..3d1073b 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -33,7 +33,10 @@
 #include 
 #include 
 #include 
+
 #include 
+
+#include "glomenu.h"
 #include "gloactiongroup.h"
 
 #include 
@@ -41,8 +44,6 @@
 
 class GtkSalMenuItem;
 
-typedef std::vector< GtkSalMenuItem* > GtkSalMenuSection;
-
 class GtkSalMenu : public SalMenu
 {
 private:
@@ -53,17 +54,25 @@ private:
 GtkSalMenuItem* GetSalMenuItem( sal_uInt16 nId );
 
 public:
-std::vector< GtkSalMenuSection* >   maSections;
-GtkSalMenuSection*  mpCurrentSection;
-
-Menu*   mpVCLMenu;
-GtkSalMenu* mpParentSalMenu;
-const GtkSalFrame*  mpFrame;
-gchar*  aDBusMenubarPath;
-GDBusConnection*pSessionBus;
-sal_Int32   mBusId;
-sal_Int32   mMenubarId;
-sal_Int32   mActionGroupId;
+std::vector< GMenuModel* >  maSections;
+std::vector< GtkSalMenuItem* >  maItems;
+
+Menu*   mpVCLMenu;
+GtkSalMenu* mpParentSalMenu;
+const GtkSalFrame*  mpFrame;
+
+// DBus variables
+gchar*  aDBusMenubarPath;
+GDBusConnection*pSessionBus;
+sal_Int32   mBusId;
+sal_Int32   mMenubarId;
+sal_Int32   mActionGroupId;
+
+// GMenuModel attributes
+GMenuModel* mpMenuModel;
+GMenuModel* mpCurrentSection;
+//GLOMenu*mpParentMenuModel;
+//std::vector< GLOMenu* > maSectionMenus;
 
 GtkSalMenu( sal_Bool bMenuBar );
 virtual ~GtkSalMenu();
@@ -95,9 +104,11 @@ public:
 virtual ~GtkSalMenuItem();
 
 sal_uInt16  mnId; // Item ID
+sal_uInt16  mnPos;// Item position
 Menu*   mpVCLMenu;// VCL Menu into which this 
MenuItem is inserted
 GtkSalMenu* mpParentMenu; // The menu in which this menu 
item is inserted
 GtkSalMenu* mpSubMenu;// Sub menu of this item (if 
defined)
+GMenuModel* mpParentSection;  // Section where this item is 
added.
 GMenuItem*  mpMenuItem;   // The GMenuItem
 GAction*mpAction; // The GAction associated with 
this item
 };
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx 
b/vcl/unx/gtk/window/gtksalmenu.cxx
index 74ad97a..08aa521 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -68,104 +68,20 @@ dispatchAction (GSimpleAction   *action,
 }
 }
 
-//GMenuModel* generateMenuModel2( Menu *pVCLMenu )
-//{
-//if (!pVCLMenu)
-//return NULL;
-
-//GMenu *pMenuModel = g_menu_new();
-//GMenu *pSectionMenuModel = g_menu_new();
-
-//for (int i = 0; i < pVCLMenu->GetItemCount(); i++) {
-//MenuItemType itemType = pVCLMenu->GetItemType( i );
-
-//if ( itemType == MENUITEM_SEPARATOR ) {
-//g_menu_append_section( pMenuModel, NULL, G_MENU_MODEL( 
pSectionMenuModel ) );
-//pSectionMenuModel = g_menu_new();
-//} else {
-//sal_Int16 nId = pVCLMenu->GetItemId( i );
-
-//// Menu item label
-//rtl::OUString aTextLabel = pVCLMenu->GetItemText( nId );
-//rtl::OUString aText = aTextLabel.replace( '~', '_' );
-//rtl::OString aConvertedText = OUStringToOString(aText, 
RTL_TEXTENCODING_UTF8);
-
-//// Menu item accelerator key
-KeyCode accelKey = pVCLMenu->GetAccelKey( nId );
-
-//GMenuItem *menuItem = g_menu_item_new( (char*) 
aConvertedText.getStr(), NULL);
-
-//GMenuModel *pSubmenu = generateMenuModel2( 
pVCLMenu->GetPopupMenu( nId ) );
-
-//g_menu_item_set_submenu( menuItem, pSubmenu );
-
-//g_menu_append_item( pSectionMenuModel, menuItem );
-//}
-//}
-
-//g_menu_append_section( pMenuModel, NULL, G_MENU_MODEL( pSectionMenuModel 
) );
-
-//return G_MENU_MODEL( pMenuModel );
-//}
-
-
-GMenuModel *generateMenuModelAndActions( GtkSalMen

[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/unx

2012-08-09 Thread Antonio Fernandez
 vcl/inc/unx/gtk/gtksalmenu.hxx|   19 +-
 vcl/unx/gtk/window/gtksalmenu.cxx |  109 +++---
 2 files changed, 60 insertions(+), 68 deletions(-)

New commits:
commit 9259bc34b95f8bc090477f9c74fed6f6d5cfb00e
Author: Antonio Fernandez 
Date:   Thu Aug 9 19:01:52 2012 +0100

Items are now correctly enabled and disabled.

Change-Id: I93e3e4bf804ff1ec95368f2918581af33d22263c

diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index bb62969..3e30323 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -38,22 +38,23 @@
 
 #include 
 
+
 class GtkSalMenuItem;
-class GtkSalMenuSection;
+
+typedef std::vector< GtkSalMenuItem* > GtkSalMenuSection;
 
 class GtkSalMenu : public SalMenu
 {
 private:
-//static GLOActionGroup*  pCurrentActionGroup;
 sal_BoolmbMenuBar;
 
 virtual void publishMenu( GMenuModel*, GActionGroup* );
 
+GtkSalMenuItem* GetSalMenuItem( sal_uInt16 nId );
+
 public:
 std::vector< GtkSalMenuSection* >   maSections;
-std::vector< GtkSalMenuItem* >  maItems;
 GtkSalMenuSection*  mpCurrentSection;
-GActionEntry*   mpActionEntry;
 
 Menu*   mpVCLMenu;
 GtkSalMenu* mpParentSalMenu;
@@ -87,16 +88,6 @@ public:
 virtual const GtkSalFrame* getFrame() const;
 };
 
-class GtkSalMenuItem;
-
-class GtkSalMenuSection
-{
-public:
-std::vector< GtkSalMenuItem* >  maItems;
-
-virtual ~GtkSalMenuSection();
-};
-
 class GtkSalMenuItem : public SalMenuItem
 {
 public:
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx 
b/vcl/unx/gtk/window/gtksalmenu.cxx
index 4016a08..74ad97a 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -111,15 +111,15 @@ dispatchAction (GSimpleAction   *action,
 
 GMenuModel *generateMenuModelAndActions( GtkSalMenu*, GLOActionGroup* );
 
-GMenuModel *generateSectionMenuModel( GtkSalMenuSection *pSection, 
GLOActionGroup *pActionGroup )
+GMenuModel *generateSectionMenuModel( GtkSalMenuSection* pSection, 
GLOActionGroup* pActionGroup )
 {
 if ( !pSection )
 return NULL;
 
 GMenu *pSectionMenuModel = g_menu_new();
 
-for (sal_uInt16 i = 0; i < pSection->maItems.size(); i++) {
-GtkSalMenuItem *pSalMenuItem = pSection->maItems[ i ];
+for (sal_uInt16 i = 0; i < pSection->size(); i++) {
+GtkSalMenuItem *pSalMenuItem = pSection->at( i );
 GMenuItem *pMenuItem = pSalMenuItem->mpMenuItem;
 
 if (pSalMenuItem->mpSubMenu) {
@@ -144,18 +144,18 @@ GMenuModel *generateMenuModelAndActions( GtkSalMenu 
*pMenu, GLOActionGroup *pAct
 
 GMenu *pMenuModel = g_menu_new();
 
-for (sal_uInt16 i = 0; i < pMenu->maItems.size(); i++) {
-GtkSalMenuItem *pSalMenuItem = pMenu->maItems[ i ];
-GMenuItem *pMenuItem = pSalMenuItem->mpMenuItem;
+//for (sal_uInt16 i = 0; i < pMenu->maItems.size(); i++) {
+//GtkSalMenuItem *pSalMenuItem = pMenu->maItems[ i ];
+//GMenuItem *pMenuItem = pSalMenuItem->mpMenuItem;
 
-if (pSalMenuItem->mpSubMenu) {
-GMenuModel *pSubmenu = generateMenuModelAndActions( 
pSalMenuItem->mpSubMenu, pActionGroup );
-g_menu_item_set_submenu( pMenuItem, pSubmenu );
-}
+//if (pSalMenuItem->mpSubMenu) {
+//GMenuModel *pSubmenu = generateMenuModelAndActions( 
pSalMenuItem->mpSubMenu, pActionGroup );
+//g_menu_item_set_submenu( pMenuItem, pSubmenu );
+//}
 
-g_menu_append_item( pMenuModel, pMenuItem );
-g_lo_action_group_insert( pActionGroup, pSalMenuItem->mpAction );
-}
+//g_menu_append_item( pMenuModel, pMenuItem );
+//g_lo_action_group_insert( pActionGroup, pSalMenuItem->mpAction );
+//}
 
 for (sal_uInt16 i = 0; i < pMenu->maSections.size(); i++) {
 GtkSalMenuSection *pSection = pMenu->maSections[ i ];
@@ -212,29 +212,56 @@ void GtkSalMenu::publishMenu( GMenuModel *pMenu, 
GActionGroup *pActionGroup )
 g_dbus_connection_export_action_group( pSessionBus, GTK_MENU_OBJ_PATH, 
pActionGroup, NULL);
 }
 
+
+// FIXME: HIGHLY IMPROVABLE CODE
+GtkSalMenuItem* GtkSalMenu::GetSalMenuItem( sal_uInt16 nId )
+{
+for ( sal_uInt16 i = 0; i < maSections.size(); i++ )
+{
+GtkSalMenuSection* pSection = maSections[ i ];
+
+for ( sal_uInt16 j = 0; j < pSection->size(); j++ )
+{
+GtkSalMenuItem* pSalMenuItem = pSection->at( j );
+
+if ( pSalMenuItem->mnId == nId ) {
+return pSalMenuItem;
+}
+
+if ( pSalMenuItem->mpSubMenu )
+{
+pSalMenuItem = pSalMenuItem->mpSubMenu->GetSalMenuItem( nId );
+if (pSalMenuItem) {
+return pSalMenuIt

[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/source vcl/unx

2012-08-09 Thread Antonio Fernandez
 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 
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 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -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_cast(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 !" );
+}
  

[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/unx

2012-08-08 Thread Antonio Fernandez
 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 
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( 
pSalMenuItem );
 GtkSalMenu *pGtkSubMenu = static_cast( 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 );
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/Library_vclplug_gtk.mk vcl/source vcl/unx

2012-08-08 Thread Antonio Fernandez
 vcl/Library_vclplug_gtk.mk|2 
 vcl/inc/salmenu.hxx   |2 
 vcl/inc/unx/gtk/gloactiongroup.h  |   62 +++
 vcl/inc/unx/gtk/glomenu.h |   87 +
 vcl/inc/unx/gtk/gtksalmenu.hxx|   10 
 vcl/source/window/menu.cxx|7 
 vcl/unx/gtk/window/gloactiongroup.cxx |  325 +++
 vcl/unx/gtk/window/glomenu.cxx|  574 ++
 vcl/unx/gtk/window/gtksalmenu.cxx |  284 ++--
 9 files changed, 1238 insertions(+), 115 deletions(-)

New commits:
commit e90a58c3403b6b4dc99970ee95aeebd44b496330
Author: Antonio Fernandez 
Date:   Wed Aug 8 16:18:14 2012 +0100

Added GLOMenu and GLOActionGroup. Menu is published with actions (not 
working)

Change-Id: I3400980e4605fbf78755532c696e021d3466675b

diff --git a/vcl/Library_vclplug_gtk.mk b/vcl/Library_vclplug_gtk.mk
index 01f95af..c4cce2a 100644
--- a/vcl/Library_vclplug_gtk.mk
+++ b/vcl/Library_vclplug_gtk.mk
@@ -99,7 +99,9 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gtk,\
 vcl/unx/gtk/gdi/salnativewidgets-gtk \
 vcl/unx/gtk/window/gtkframe \
 vcl/unx/gtk/window/gtkobject \
+vcl/unx/gtk/window/gloactiongroup \
 vcl/unx/gtk/window/gtksalmenu \
+vcl/unx/gtk/window/glomenu \
 vcl/unx/gtk/fpicker/resourceprovider \
 vcl/unx/gtk/fpicker/SalGtkPicker \
 vcl/unx/gtk/fpicker/SalGtkFilePicker \
diff --git a/vcl/inc/salmenu.hxx b/vcl/inc/salmenu.hxx
index b3dc25f..dafe19a 100644
--- a/vcl/inc/salmenu.hxx
+++ b/vcl/inc/salmenu.hxx
@@ -90,6 +90,8 @@ 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 SetItemCommand( unsigned nPos, SalMenuItem* pSalMenuItem, 
const rtl::OUString& aCommandStr ) {}
 virtual void Freeze() {}
 
 // return an empty rectangle if not implemented
diff --git a/vcl/inc/unx/gtk/gloactiongroup.h b/vcl/inc/unx/gtk/gloactiongroup.h
new file mode 100644
index 000..b71ae47
--- /dev/null
+++ b/vcl/inc/unx/gtk/gloactiongroup.h
@@ -0,0 +1,62 @@
+#ifndef GLOACTIONGROUP_H
+#define GLOACTIONGROUP_H
+
+#include 
+//#include "gactionmap.h"
+
+G_BEGIN_DECLS
+
+#define G_TYPE_LO_ACTION_GROUP  
(g_lo_action_group_get_type ())
+#define G_LO_ACTION_GROUP(inst) 
(G_TYPE_CHECK_INSTANCE_CAST ((inst), \
+ 
G_TYPE_LO_ACTION_GROUP, GLOActionGroup))
+#define G_LO_ACTION_GROUP_CLASS(klass)  
(G_TYPE_CHECK_CLASS_CAST ((klass),   \
+ 
G_TYPE_LO_ACTION_GROUP, GLOActionGroupClass))
+#define G_IS_LO_ACTION_GROUP(inst)  
(G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
+ 
G_TYPE_LO_ACTION_GROUP))
+#define G_IS_LO_ACTION_GROUP_CLASS(klass)   
(G_TYPE_CHECK_CLASS_TYPE ((klass),   \
+ 
G_TYPE_LO_ACTION_GROUP))
+#define G_LO_ACTION_GROUP_GET_CLASS(inst)   
(G_TYPE_INSTANCE_GET_CLASS ((inst),  \
+ 
G_TYPE_LO_ACTION_GROUP, GLOActionGroupClass))
+
+typedef struct _GLOActionGroupPrivate   GLOActionGroupPrivate;
+typedef struct _GLOActionGroupClass GLOActionGroupClass;
+typedef struct _GLOActionGroup  GLOActionGroup;
+
+struct _GLOActionGroup
+{
+/*< private >*/
+GObject parent_instance;
+
+GLOActionGroupPrivate *priv;
+};
+
+struct _GLOActionGroupClass
+{
+/*< private >*/
+GObjectClass parent_class;
+
+/*< private >*/
+gpointer padding[12];
+};
+
+GType   g_lo_action_group_get_type  (void) 
G_GNUC_CONST;
+
+GLOActionGroup *g_lo_action_group_new   (void);
+
+GAction *   g_lo_action_group_lookup
(GLOActionGroup *group,
+ const gchar   
 *action_name);
+
+voidg_lo_action_group_insert
(GLOActionGroup *group,
+ GAction   
 *action);
+
+voidg_lo_action_group_remove
(GLOActionGroup *group,
+ const gchar   
 *action_name);
+
+voidg_lo_action_group_add_entries   
(GLOActionGroup *group,
+ 

[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/unx

2012-08-01 Thread Antonio Fernandez
 vcl/inc/unx/gtk/gtksalmenu.hxx|   25 ++
 vcl/unx/gtk/app/gtkinst.cxx   |9 -
 vcl/unx/gtk/window/gtksalmenu.cxx |  340 ++
 3 files changed, 264 insertions(+), 110 deletions(-)

New commits:
commit fd842d453953c44a30db6c46d7b63aca8994daeb
Author: Antonio Fernandez 
Date:   Wed Aug 1 16:52:50 2012 +0100

Internal native menu is created in steps, but is incomplete at the moment.

Change-Id: I323b80b74218be853fe2893b3f328ff3ef74d4cb

diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 69fcec8..65c2bc8 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -35,22 +35,29 @@
 #include 
 #include 
 
+#include 
+
+class GtkSalMenuItem;
+class GtkSalMenuSection;
 
 class GtkSalMenu : public SalMenu
 {
 private:
+
 sal_BoolmbMenuBar;
 
-virtual void publishMenu();
+virtual void publishMenu( GMenuModel* );
 
 public:
+std::vector< GtkSalMenuSection* >   maSections;
+std::vector< GtkSalMenuItem* >  maItems;
+GtkSalMenuSection*  mpCurrentSection;
+
 Menu*   mpVCLMenu;
 const GtkSalFrame*  mpFrame;
-GMenuModel* mpParentMenuModel;
-GMenuModel* mpMenuModel;
-GMenuModel* mpSectionMenuModel;
 gchar*  aDBusMenubarPath;
 GDBusConnection*pSessionBus;
+sal_Int32   mBusId;
 sal_Int32   mMenubarId;
 
 GtkSalMenu( sal_Bool bMenuBar );
@@ -72,6 +79,16 @@ public:
 virtual void Freeze();
 };
 
+class GtkSalMenuItem;
+
+class GtkSalMenuSection
+{
+public:
+std::vector< GtkSalMenuItem* >  maItems;
+
+virtual ~GtkSalMenuSection();
+};
+
 class GtkSalMenuItem : public SalMenuItem
 {
 public:
diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx
index e8ec95a..dceca0d 100644
--- a/vcl/unx/gtk/app/gtkinst.cxx
+++ b/vcl/unx/gtk/app/gtkinst.cxx
@@ -530,23 +530,20 @@ SalMenu* GtkInstance::CreateMenu( sal_Bool bMenuBar, 
Menu* pVCLMenu )
 void GtkInstance::DestroyMenu( SalMenu* pMenu )
 {
 (void)pMenu;
+delete pMenu;
 OSL_ENSURE( pMenu == 0, "DestroyMenu called with non-native menus" );
 }
 
 SalMenuItem* GtkInstance::CreateMenuItem( const SalItemParams* pItemData )
 {
-GtkSalMenuItem *pMenuItem = NULL;
-
-//if (pItemData->eType != MENUITEM_SEPARATOR) {
-pMenuItem = new GtkSalMenuItem( pItemData );
-//}
-
+GtkSalMenuItem *pMenuItem = new GtkSalMenuItem( pItemData );
 return static_cast( pMenuItem );
 }
 
 void GtkInstance::DestroyMenuItem( SalMenuItem* pItem )
 {
 (void)pItem;
+//delete pItem;
 OSL_ENSURE( pItem == 0, "DestroyMenu called with non-native menus" );
 }
 
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx 
b/vcl/unx/gtk/window/gtksalmenu.cxx
index 9c3acdd..f612a23 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -20,35 +20,7 @@ quit (GSimpleAction *action,
 exit(1);
 }
 
-void
-gdk_x11_window_set_utf8_property  (GdkWindow *window,
-   const gchar *name,
-   const gchar *value)
-{
-  GdkDisplay *display;
-
-  //if (!WINDOW_IS_TOPLEVEL (window))
-//return;
-
-  display = gdk_window_get_display (window);
-
-  if (value != NULL)
-{
-  XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
-   GDK_WINDOW_XID (window),
-   gdk_x11_get_xatom_by_name_for_display (display, name),
-   gdk_x11_get_xatom_by_name_for_display (display, 
"UTF8_STRING"), 8,
-   PropModeReplace, (guchar *)value, strlen (value));
-}
-  else
-{
-  XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
-   GDK_WINDOW_XID (window),
-   gdk_x11_get_xatom_by_name_for_display (display, name));
-}
-}
-
-GMenuModel* generateMenuModel( Menu *pVCLMenu )
+GMenuModel* generateMenuModel2( Menu *pVCLMenu )
 {
 if (!pVCLMenu)
 return NULL;
@@ -65,13 +37,17 @@ GMenuModel* generateMenuModel( Menu *pVCLMenu )
 } else {
 sal_Int16 nId = pVCLMenu->GetItemId( i );
 
+// Menu item label
 rtl::OUString aTextLabel = pVCLMenu->GetItemText( nId );
 rtl::OUString aText = aTextLabel.replace( '~', '_' );
 rtl::OString aConvertedText = OUStringToOString(aText, 
RTL_TEXTENCODING_UTF8);
 
+// Menu item accelerator key
+//KeyCode accelKey = pVCLMenu->GetAccelKey( nId );
+
 GMenuItem *menuItem = g_menu_item_new( (char*) 
aConvertedText.getStr(), NULL);
 
-GMenuModel *pSubmenu = generateMenuModel( pVCLMenu->GetPopupMenu( 
nId ) );
+GMenuModel *pSubmenu = generateMenuModel2( pVCLMenu->GetPopupMenu( 
nId ) );
 
   

[Libreoffice-commits] .: Branch 'feature/unitymenus' - vcl/inc vcl/source vcl/unx

2012-08-01 Thread Antonio Fernandez
 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 
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 
-#include 
 
 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->GetItem

[Libreoffice-commits] .: Branch 'feature/unitymenus' - framework/inc framework/source vcl/inc vcl/Library_vcl.mk vcl/Library_vclplug_gtk.mk vcl/source vcl/unx

2012-07-30 Thread Antonio Fernandez
 framework/inc/uielement/menubarmanager.hxx|2 
 framework/inc/uielement/menubarwrapper.hxx|1 
 framework/source/uielement/menubarmanager.cxx |   30 +++
 framework/source/uielement/menubarwrapper.cxx |   20 +-
 vcl/Library_vcl.mk|1 
 vcl/Library_vclplug_gtk.mk|9 -
 vcl/inc/unx/gtk/gtkinst.hxx   |4 
 vcl/inc/unx/gtk/gtksalmenu.hxx|   85 ++
 vcl/inc/unx/salmenu.h |8 
 vcl/source/window/menu.cxx|   62 +++
 vcl/unx/gtk/app/gtkinst.cxx   |   26 +++
 vcl/unx/gtk/window/gtksalmenu.cxx |  219 ++
 12 files changed, 452 insertions(+), 15 deletions(-)

New commits:
commit 682d1626617757d9b5c737a01d03eee205887f00
Author: Antonio Fernandez 
Date:   Mon Jul 30 13:11:09 2012 +0100

Menubar hierarchy fully generated. Native GTK menu is published on DBus.

Change-Id: I340d3e14b590b4a694082cfb3e2200d6ad8ef39a

diff --git a/framework/inc/uielement/menubarmanager.hxx 
b/framework/inc/uielement/menubarmanager.hxx
index 59273e8..e134431 100644
--- a/framework/inc/uielement/menubarmanager.hxx
+++ b/framework/inc/uielement/menubarmanager.hxx
@@ -179,6 +179,8 @@ class MenuBarManager : public 
com::sun::star::frame::XStatusListener
 void SetItemContainer( const ::com::sun::star::uno::Reference< 
::com::sun::star::container::XIndexAccess >& rItemContainer );
 void GetPopupController( PopupControllerCache& rPopupController );
 
+void GenerateFullMenuHierarchy( AbstractMenu* pMenu );
+
 protected:
 DECL_LINK(Highlight, void *);
 DECL_LINK( Activate, AbstractMenu * );
diff --git a/framework/inc/uielement/menubarwrapper.hxx 
b/framework/inc/uielement/menubarwrapper.hxx
index 7aa5c0a..3ef24f0 100644
--- a/framework/inc/uielement/menubarwrapper.hxx
+++ b/framework/inc/uielement/menubarwrapper.hxx
@@ -96,6 +96,7 @@ class MenuBarWrapper : public UIConfigElementWrapperBase,
 private:
 virtual void impl_fillNewData();
 void fillPopupControllerCache();
+//void GenerateFullMenuBar( MenuBar *pMenuBar );
 
 sal_Bool   
 m_bRefreshPopupControllerCache : 1;
 com::sun::star::uno::Reference< com::sun::star::lang::XComponent > 
 m_xMenuBarManager;
diff --git a/framework/source/uielement/menubarmanager.cxx 
b/framework/source/uielement/menubarmanager.cxx
index d19a8bb..1072fd9 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -863,8 +863,9 @@ IMPL_LINK( MenuBarManager, Activate, AbstractMenu *, pMenu )
 ( pMenu->GetItemText( nItemId ).Len() == 0 ))
 {
 String aCommand = pMenu->GetItemCommand( nItemId );
-if ( aCommand.Len() > 0 )
+if ( aCommand.Len() > 0 ) {
 pMenu->SetItemText( nItemId, RetrieveLabelFromCommand( 
aCommand ));
+}
 }
 }
 
@@ -1004,8 +1005,8 @@ IMPL_LINK( MenuBarManager, Activate, AbstractMenu *, 
pMenu )
 }
 }
 
-//pMenu->Freeze();
-m_pVCLMenu->Freeze();
+// Freeze the menu
+//m_pVCLMenu->Freeze();
 
 return 1;
 }
@@ -2106,6 +2107,29 @@ void MenuBarManager::SetHdl()
  UNO_QUERY );
 }
 
+void MenuBarManager::GenerateFullMenuHierarchy( AbstractMenu* pMenu )
+{
+if (pMenu) {
+for (int i=0; i < pMenu->GetItemCount(); i++)
+{
+sal_Int16 nId = pMenu->GetItemId( i );
+
+//this->Activate( pMenu->GetPopupMenu( nId ) );
+//this->Activate(pMenu);
+//this->Deactivate(pMenu);
+
+String aCommandLabel = pMenu->GetItemCommand( nId );
+::rtl::OUString aCommand( aCommandLabel );
+
+String label = RetrieveLabelFromCommand( aCommandLabel );
+pMenu->SetItemText( nId, label );
+
+AddMenu( this, aCommand, nId );
+GenerateFullMenuHierarchy( pMenu->GetPopupMenu( nId ) );
+}
+}
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uielement/menubarwrapper.cxx 
b/framework/source/uielement/menubarwrapper.cxx
index 888f9d8..f819b5a 100644
--- a/framework/source/uielement/menubarwrapper.cxx
+++ b/framework/source/uielement/menubarwrapper.cxx
@@ -130,6 +130,19 @@ void SAL_CALL MenuBarWrapper::dispose() throw 
(::com::sun::star::uno::RuntimeExc
 m_bDisposed = sal_True;
 }
 
+//void generateFullMenuBar( MenuBarManager *pMenuBarManager, MenuBar *pMenuBar 
)
+//{
+//for (int i=0; i < pMenuBar->GetItemCount(); i++)
+//{
+//sal_Int16 nId = pMenuBar->GetItemId( i );
+
+//  

[Libreoffice-commits] .: Branch 'feature/unitymenus' - framework/source vcl/inc vcl/source

2012-07-19 Thread Antonio Fernandez
 framework/source/uielement/menubarmanager.cxx |5 +++
 framework/source/uielement/menubarwrapper.cxx |4 +++
 vcl/inc/vcl/menu.hxx  |4 +++
 vcl/source/window/menu.cxx|   33 ++
 4 files changed, 45 insertions(+), 1 deletion(-)

New commits:
commit 432cb6e505251a6465db5b1d49f5831b0b4ec380
Author: Antonio Fernandez 
Date:   Thu Jul 19 17:40:17 2012 +0100

Added a "freeze" method to Menu. Menus are now displayed on console.

Change-Id: I71bfc2c0272154b9ff5c2dabe7508a98950e199c

diff --git a/framework/source/uielement/menubarmanager.cxx 
b/framework/source/uielement/menubarmanager.cxx
index 5e85620..d19a8bb 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -1004,6 +1004,9 @@ IMPL_LINK( MenuBarManager, Activate, AbstractMenu *, 
pMenu )
 }
 }
 
+//pMenu->Freeze();
+m_pVCLMenu->Freeze();
+
 return 1;
 }
 
@@ -1708,7 +1711,7 @@ void MenuBarManager::FillMenu(
 {
 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "ocke.jans...@sun.com", 
"MenuBarManager::FillMenu" );
 // Fill menu bar with container contents
-for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ )
+ for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ )
 {
 Sequence< PropertyValue >   aProp;
 rtl::OUString   aCommandURL;
diff --git a/framework/source/uielement/menubarwrapper.cxx 
b/framework/source/uielement/menubarwrapper.cxx
index 45d5bf8..888f9d8 100644
--- a/framework/source/uielement/menubarwrapper.cxx
+++ b/framework/source/uielement/menubarwrapper.cxx
@@ -181,6 +181,7 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< 
Any >& aArguments ) th
 // Fill menubar with container contents
 sal_uInt16 nId = 1;
 MenuBarManager::FillMenuWithConfiguration( nId, 
pVCLMenuBar, aModuleIdentifier, m_xConfigData, xTrans );
+//pVCLMenuBar->Freeze();
 }
 }
 catch ( const NoSuchElementException& )
@@ -222,6 +223,9 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< 
Any >& aArguments ) th
 // Don't use this toolkit menu bar or one of its functions. It is 
only used as a data container!
 pAwtMenuBar = new VCLXMenuBar( pVCLMenuBar );
 m_xMenuBar = Reference< XMenuBar >( static_cast< OWeakObject *>( 
pAwtMenuBar ), UNO_QUERY );
+
+// Freeze the menubar
+pVCLMenuBar->Freeze();
 }
 }
 }
diff --git a/vcl/inc/vcl/menu.hxx b/vcl/inc/vcl/menu.hxx
index 3c4c753..f98e87e 100644
--- a/vcl/inc/vcl/menu.hxx
+++ b/vcl/inc/vcl/menu.hxx
@@ -198,6 +198,8 @@ public:
 // Returns the system's menu handle if native menus are supported
 // pData must point to a SystemMenuData structure
 virtual sal_BoolGetSystemMenuData( SystemMenuData* pData ) 
const = 0;
+
+virtual voidFreeze(void) = 0;
 };
 
 // 
@@ -455,6 +457,8 @@ public:
 
 voidHighlightItem( sal_uInt16 nItemPos );
 voidDeHighlight() { HighlightItem( 0x ); } // 
MENUITEMPOS_INVALID
+
+voidFreeze();
 };
 
 // ---
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 3b4ac0d..121ee14 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -6063,4 +6063,37 @@ ImplMenuDelData::~ImplMenuDelData()
 const_cast< Menu* >( mpMenu )->ImplRemoveDel( *this );
 }
 
+#include 
+using namespace std;
+
+void printMenu( AbstractMenu* pMenu ) {
+if ( pMenu ) {
+sal_uInt16 itemCount = pMenu->GetItemCount();
+MenuItemList *items = ((Menu*)pMenu)->GetItemList();
+
+for (int i=0; i < itemCount; i++) {
+MenuItemData *itemData = items->GetDataFromPos(i);
+sal_uInt16 itemId = pMenu->GetItemId(i);
+
+if (itemData->eType == MENUITEM_SEPARATOR) {
+cout << "---" << endl;
+} else {
+rtl::OUString itemText = itemData->aText;
+rtl::OUString cmdString = itemData->aCommandStr;
+cout << "Item ID: " << itemId << "  Text: " << itemText << "  
CMD: " << cmdString << endl;
+
+if (itemData->pSubMenu) {
+cout << ">> SUBMENU <<" << endl;
+printMenu( itemData->pSubMenu );
+}
+}
+}
+}
+}
+
+void Menu::Freeze() {
+printMenu( this );
+cout << "" << 
endl;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: Branch 'feature/unitymenus' - framework/inc framework/source vcl/inc

2012-07-18 Thread Antonio Fernandez
 framework/inc/classes/menumanager.hxx |   22 ++--
 framework/inc/uielement/menubarmanager.hxx|   24 ++--
 framework/inc/uielement/menubarmerger.hxx |   16 +-
 framework/source/classes/menumanager.cxx  |   16 +-
 framework/source/uielement/menubarmanager.cxx |   32 ++---
 framework/source/uielement/menubarmerger.cxx  |   18 +--
 vcl/inc/vcl/menu.hxx  |  140 +-
 7 files changed, 178 insertions(+), 90 deletions(-)

New commits:
commit 358a80b7a82bc13f18e42c9b42adab8a3677f31a
Author: Antonio Fernandez 
Date:   Wed Jul 18 17:04:55 2012 +0100

Refactor of Menu classes from VCL module and Framework module.

Change-Id: I47aa65d3851692d38ee0741031d72fb02e9da785

diff --git a/framework/inc/classes/menumanager.hxx 
b/framework/inc/classes/menumanager.hxx
index 3ac4588..56ecc90 100644
--- a/framework/inc/classes/menumanager.hxx
+++ b/framework/inc/classes/menumanager.hxx
@@ -78,7 +78,7 @@ class MenuManager : public ThreadHelpBase   ,
 MenuManager(
 const ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
 REFERENCE< XFRAME >& rFrame,
-Menu* pMenu,
+AbstractMenu* pMenu,
 sal_Bool bDelete,
 sal_Bool bDeleteChildren );
 
@@ -90,33 +90,33 @@ class MenuManager : public ThreadHelpBase   ,
 // XEventListener
 virtual void SAL_CALL disposing( const EVENTOBJECT& Source ) throw ( 
RUNTIMEEXCEPTION );
 
-DECL_LINK( Select, Menu * );
+DECL_LINK( Select, AbstractMenu * );
 
-Menu*   GetMenu() const { return m_pVCLMenu; }
+AbstractMenu*   GetMenu() const { return m_pVCLMenu; }
 
 voidRemoveListener();
 
 const ::com::sun::star::uno::Reference< 
::com::sun::star::lang::XMultiServiceFactory >& getServiceFactory();
 
-static void UpdateSpecialWindowMenu( Menu* pMenu ,const 
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory 
>& xServiceFactory,IMutex& _rMutex);
+static void UpdateSpecialWindowMenu( AbstractMenu* pMenu ,const 
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory 
>& xServiceFactory,IMutex& _rMutex);
 static void FillMenuImages(
 ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& 
xFrame,
-Menu* _pMenu,
+AbstractMenu* _pMenu,
 sal_Bool bShowMenuImages
 );
 
 protected:
 DECL_LINK(Highlight, void *);
-DECL_LINK( Activate, Menu * );
-DECL_LINK( Deactivate, Menu * );
+DECL_LINK( Activate, AbstractMenu * );
+DECL_LINK( Deactivate, AbstractMenu * );
 
 private:
-void UpdateSpecialFileMenu( Menu* pMenu );
-void UpdateSpecialWindowMenu( Menu* pMenu );
+void UpdateSpecialFileMenu( AbstractMenu* pMenu );
+void UpdateSpecialWindowMenu( AbstractMenu* pMenu );
 void ClearMenuDispatch(const EVENTOBJECT& Source = EVENTOBJECT(),bool 
_bRemoveOnly = true);
 void SetHdl();
 void AddMenu(PopupMenu* _pPopupMenu,const ::rtl::OUString& 
_sItemCommand,sal_uInt16 _nItemId,sal_Bool _bDelete,sal_Bool _bDeleteChildren);
-sal_uInt16 FillItemCommand(::rtl::OUString& _rItemCommand,Menu* 
_pMenu,sal_uInt16 _nIndex) const;
+sal_uInt16 FillItemCommand(::rtl::OUString& _rItemCommand, 
AbstractMenu* _pMenu,sal_uInt16 _nIndex) const;
 
 
 struct MenuItemHandler
@@ -147,7 +147,7 @@ class MenuManager : public ThreadHelpBase   ,
 sal_Boolm_bIsBookmarkMenu;
 sal_Boolm_bShowMenuImages;
 ::rtl::OUString m_aMenuItemCommand;
-Menu*   m_pVCLMenu;
+AbstractMenu*   m_pVCLMenu;
 REFERENCE< XFRAME > m_xFrame;
 ::std::vector< MenuItemHandler* >   m_aMenuItemHandlerVector;
 
diff --git a/framework/inc/uielement/menubarmanager.hxx 
b/framework/inc/uielement/menubarmanager.hxx
index 6836707..59273e8 100644
--- a/framework/inc/uielement/menubarmanager.hxx
+++ b/framework/inc/uielement/menubarmanager.hxx
@@ -120,7 +120,7 @@ class MenuBarManager : public 
com::sun::star::frame::XStatusListener
 const ::com::sun::star::uno::Reference< 
::com::sun::star::util::XURLTransformer >& _xURLTransformer,
 const ::com::sun::star::uno::Reference< 
::com::sun::star::frame::XDispatchProvider >& rDispatchProvider,
 const rtl::OUString& aModuleIdentifier,
-Menu* pMenu,
+AbstractMenu* pMenu,
 sal_Bool bDelete,
 sal_Bool bDeleteChildren );
 
@@ -155,22 +155,22 @@ class MenuBarManager : public 
com::sun::star::frame::XStatusLi