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

Antonio Fernandez afernandez at kemper.freedesktop.org
Mon Jul 30 05:13:10 PDT 2012


 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 <antonio.fernandez at aentos.es>
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 );
+
+//        String aCommandLabel = pMenuBar->GetItemCommand( nId );
+
+//        String label = pMenuBarManager->RetrieveLabelFromCommand( aCommandLabel );
+//        pMenuBar->SetItemText( nId, label );
+//    }
+//}
+
 // XInitialization
 void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
 {
@@ -181,7 +194,6 @@ 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& )
@@ -217,15 +229,15 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th
                                                                       sal_True );
 
                 m_xMenuBarManager = Reference< XComponent >( static_cast< OWeakObject *>( pMenuBarManager ), UNO_QUERY );
+
+//                pMenuBarManager->GenerateFullMenuHierarchy( pVCLMenuBar );
+                pVCLMenuBar->Freeze();
             }
 
             // Initialize toolkit menu bar implementation to have awt::XMenuBar for data exchange.
             // 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/Library_vcl.mk b/vcl/Library_vcl.mk
index 53f9d4a..56d2bf3 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -95,6 +95,7 @@ $(eval $(call gb_Library_use_externals,vcl,\
 	icule \
 	icuuc \
 	lcms2 \
+	gio \
 ))
 
 $(eval $(call gb_Library_add_cobjects,vcl,\
diff --git a/vcl/Library_vclplug_gtk.mk b/vcl/Library_vclplug_gtk.mk
index e816fcf..01f95af 100644
--- a/vcl/Library_vclplug_gtk.mk
+++ b/vcl/Library_vclplug_gtk.mk
@@ -99,10 +99,11 @@ $(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/fpicker/resourceprovider \
-	vcl/unx/gtk/fpicker/SalGtkPicker \
-	vcl/unx/gtk/fpicker/SalGtkFilePicker \
-	vcl/unx/gtk/fpicker/SalGtkFolderPicker \
+    vcl/unx/gtk/window/gtksalmenu \
+    vcl/unx/gtk/fpicker/resourceprovider \
+    vcl/unx/gtk/fpicker/SalGtkPicker \
+    vcl/unx/gtk/fpicker/SalGtkFilePicker \
+    vcl/unx/gtk/fpicker/SalGtkFolderPicker \
 ))
 
 ifeq ($(ENABLE_GTK_PRINT),TRUE)
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 89743ca..5ec226e 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -113,6 +113,10 @@ public:
     virtual SalSystem*          CreateSalSystem();
     virtual SalInfoPrinter*     CreateInfoPrinter(SalPrinterQueueInfo* pPrinterQueueInfo, ImplJobSetup* pJobSetup);
     virtual SalPrinter*         CreatePrinter( SalInfoPrinter* pInfoPrinter );
+    virtual SalMenu*            CreateMenu( sal_Bool, Menu* );
+    virtual void                DestroyMenu( SalMenu* pMenu );
+    virtual SalMenuItem*        CreateMenuItem( const SalItemParams* );
+    virtual void                DestroyMenuItem( SalMenuItem* pItem );
     virtual SalTimer*           CreateSalTimer();
     virtual void                AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType);
     virtual SalVirtualDevice*   CreateVirtualDevice( SalGraphics*,
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
new file mode 100644
index 0000000..c925a99
--- /dev/null
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef GTKSALMENU_HXX
+#define GTKSALMENU_HXX
+
+#include <vcl/sv.h>
+#include <vcl/bitmap.hxx>
+#include <unx/gtk/gtkframe.hxx>
+#include <unx/salmenu.h>
+#include <gio/gio.h>
+
+
+class GtkSalMenu : public SalMenu
+{
+private:
+    sal_Bool    mbMenuBar;
+
+public:
+    Menu*                   mpVCLMenu;
+    const GtkSalFrame*      mpFrame;
+    GMenuModel*             mpParentMenuModel;
+    GMenuModel*             mpMenuModel;
+    gchar*                  aDBusMenubarPath;
+    GDBusConnection*        pSessionBus;
+
+    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 );
+};
+
+class GtkSalMenuItem : public SalMenuItem
+{
+public:
+    GtkSalMenuItem( const SalItemParams* );
+    virtual ~GtkSalMenuItem();
+
+    sal_uInt16          mnId;                 // Item ID
+    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)
+    GMenuItem*          mpMenuItem;           // The GMenuItem
+};
+
+#endif // GTKSALMENU_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/unx/salmenu.h b/vcl/inc/unx/salmenu.h
index f693a33..f9a89f7 100644
--- a/vcl/inc/unx/salmenu.h
+++ b/vcl/inc/unx/salmenu.h
@@ -31,7 +31,7 @@
 
 #include <vcl/sv.h>
 #include <vcl/bitmap.hxx>
-#include <vcl/salmenu.hxx>
+#include <salmenu.hxx>
 
 
 class X11SalMenu : public SalMenu
@@ -40,15 +40,15 @@ public:
     X11SalMenu() {}
     virtual ~X11SalMenu();
 
-    virtual BOOL VisibleMenuBar();  // must return TRUE to actually DISPLAY native menu bars
+    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, BOOL bCheck );
-    virtual void EnableItem( unsigned nPos, BOOL bEnable );
+    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 );
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 121ee14..6d02fc9 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -6064,8 +6064,66 @@ 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();
@@ -6084,6 +6142,7 @@ void printMenu( AbstractMenu* pMenu ) {
 
                 if (itemData->pSubMenu) {
                     cout << ">> SUBMENU <<" << endl;
+                    itemData->pSubMenu->Activate();
                     printMenu( itemData->pSubMenu );
                 }
             }
@@ -6093,6 +6152,9 @@ void printMenu( AbstractMenu* pMenu ) {
 
 void Menu::Freeze() {
     printMenu( this );
+
+//    GMenuModel *menu = G_MENU_MODEL( generateMenuBar(this) );
+//    publishMenu( menu );
     cout << "============================================================" << endl;
 }
 
diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx
index 845e2fc..d4103c3 100644
--- a/vcl/unx/gtk/app/gtkinst.cxx
+++ b/vcl/unx/gtk/app/gtkinst.cxx
@@ -38,6 +38,7 @@
 #include <unx/gtk/gtkobject.hxx>
 #include <unx/gtk/atkbridge.hxx>
 #include <unx/gtk/gtkprn.hxx>
+#include <unx/gtk/gtksalmenu.hxx>
 #include <headless/svpvd.hxx>
 #include <headless/svpbmp.hxx>
 #include <vcl/apptypes.hxx>
@@ -518,6 +519,31 @@ SalBitmap* GtkInstance::CreateSalBitmap()
 #endif
 }
 
+SalMenu* GtkInstance::CreateMenu( sal_Bool bMenuBar, Menu* pVCLMenu )
+{
+    GtkSalMenu *pSalMenu = new GtkSalMenu( bMenuBar );
+    pSalMenu->mpVCLMenu = pVCLMenu;
+
+    return static_cast<SalMenu*>( pSalMenu );
+}
+
+void GtkInstance::DestroyMenu( SalMenu* pMenu )
+{
+    (void)pMenu;
+    OSL_ENSURE( pMenu == 0, "DestroyMenu called with non-native menus" );
+}
+
+SalMenuItem* GtkInstance::CreateMenuItem( const SalItemParams* )
+{
+    return NULL;
+}
+
+void GtkInstance::DestroyMenuItem( SalMenuItem* pItem )
+{
+    (void)pItem;
+    OSL_ENSURE( pItem == 0, "DestroyMenu called with non-native menus" );
+}
+
 SalTimer* GtkInstance::CreateSalTimer()
 {
     GtkSalTimer *pTimer = new GtkSalTimer();
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx
new file mode 100644
index 0000000..823a9c6
--- /dev/null
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -0,0 +1,219 @@
+
+#include "unx/gtk/gtksalmenu.hxx"
+
+#include <gtk/gtk.h>
+#include <iostream>
+
+using namespace std;
+
+
+//const GtkSalMenu * GtkSalMenu::pCurrentMenubar = NULL;
+
+#define BUS_NAME "org.gtk.LibreOffice"
+#define OBJ_PATH "/org/gtk/LibreOffice"
+
+static void
+quit (GSimpleAction *action,
+      GVariant      *parameter,
+      gpointer       user_data)
+{
+    exit(1);
+}
+
+void publishMenu( GtkSalMenu* pMenu )
+{
+    GActionGroup *group;
+    GDBusConnection *bus;
+    GError *error = NULL;
+    gchar *path;
+    guint id;
+
+    if (pMenu->pSessionBus && pMenu->aDBusMenubarPath) {
+        GSimpleActionGroup *simpleGroup = g_simple_action_group_new();
+//        GSimpleAction *action = g_simple_action_new("quit" );
+//        g_simple_action_group_insert( simpleGroup, G_ACTION( action ) );
+
+        group = G_ACTION_GROUP( simpleGroup );
+
+
+        g_print ("Exporting menus on the bus...\n");
+//        path = g_strconcat (OBJ_PATH, "/menus/", "menubar", NULL);
+        if (!g_dbus_connection_export_menu_model (pMenu->pSessionBus, pMenu->aDBusMenubarPath, pMenu->mpMenuModel, &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 (pMenu->pSessionBus, OBJ_PATH, group, &error))
+        {
+            g_warning ("Action export failed: %s", error->message);
+            //        exit (1);
+        }
+
+        g_bus_own_name_on_connection (pMenu->pSessionBus, BUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL);
+    }
+}
+
+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));
+    }
+}
+
+GtkSalMenu::GtkSalMenu( sal_Bool bMenuBar ) :
+    mbMenuBar( bMenuBar ),
+    mpVCLMenu( NULL ),
+    mpParentMenuModel( NULL ),
+    aDBusMenubarPath( NULL ),
+    pSessionBus( NULL )
+{
+    mpMenuModel = G_MENU_MODEL( g_menu_new() );
+
+    if (bMenuBar) {
+//        pSessionBus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
+
+//        aDBusMenubarPath = g_strconcat (OBJ_PATH, "/menus/", "menubar", NULL);
+
+//        GMenu *menu = G_MENU( mpMenuModel );
+
+//        g_menu_append( menu, "Menu1", "app.quit");
+
+//        publishMenu( this );
+    }
+}
+
+GtkSalMenu::~GtkSalMenu()
+{
+    g_object_unref( mpMenuModel );
+    g_object_unref( mpParentMenuModel );
+}
+
+sal_Bool GtkSalMenu::VisibleMenuBar()
+{
+    return sal_False;
+}
+
+void GtkSalMenu::InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos )
+{
+    cout << __FUNCTION__ << endl;
+}
+
+void GtkSalMenu::RemoveItem( unsigned nPos )
+{
+    cout << __FUNCTION__ << endl;
+}
+
+void GtkSalMenu::SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos )
+{
+    cout << __FUNCTION__ << endl;
+}
+
+void GtkSalMenu::SetFrame( const SalFrame* pFrame )
+{
+    cout << __FUNCTION__ << endl;
+
+    mpFrame = static_cast<const GtkSalFrame*>( pFrame );
+
+    GtkWidget *widget = GTK_WIDGET( mpFrame->getWindow() );
+
+    GdkWindow *gdkWindow = gtk_widget_get_window( widget );
+
+    if (gdkWindow) {
+        gdk_x11_window_set_utf8_property (gdkWindow, "_GTK_APPLICATION_ID", "org.libreoffice");
+        gdk_x11_window_set_utf8_property (gdkWindow, "_GTK_UNIQUE_BUS_NAME", "org.libreoffice");
+        gdk_x11_window_set_utf8_property (gdkWindow, "_GTK_APPLICATION_OBJECT_PATH", "/org/libreoffice");
+        gdk_x11_window_set_utf8_property (gdkWindow, "_GTK_WINDOW_OBJECT_PATH", "/org/libreoffice/windows");
+//        gdk_x11_window_set_utf8_property (gdkWindow, "_GTK_APP_MENU_OBJECT_PATH", "/org/libreoffice/menus/appmenu");
+        gdk_x11_window_set_utf8_property (gdkWindow, "_GTK_MENUBAR_OBJECT_PATH", "/org/libreoffice/menus/menubar");
+
+        GMenu *menu = g_menu_new ();
+        //    g_menu_append (menu, "Add", "app.add");
+        //    g_menu_append (menu, "Del", "app.del");
+        g_menu_append (menu, "Quit", "app.quit");
+
+        GDBusConnection *bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+        if(!bus) puts ("Fail bus get");
+        guint bid = g_bus_own_name_on_connection (bus, "org.libreoffice", G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL);
+        if(!bid) puts ("Fail own name");
+
+        guint appmenuID = g_dbus_connection_export_menu_model (bus, "/org/libreoffice/menus/appmenu", G_MENU_MODEL (menu), NULL);
+        if(!appmenuID) puts("Fail export appmenu");
+        guint menubarID = g_dbus_connection_export_menu_model (bus, "/org/libreoffice/menus/menubar", G_MENU_MODEL (menu), NULL);
+        if(!menubarID) puts("Fail export menubar");
+
+        g_object_unref (menu);
+    }
+}
+
+void GtkSalMenu::CheckItem( unsigned nPos, sal_Bool bCheck )
+{
+    cout << __FUNCTION__ << endl;
+}
+
+void GtkSalMenu::EnableItem( unsigned nPos, sal_Bool bEnable )
+{
+    cout << __FUNCTION__ << endl;
+}
+
+void GtkSalMenu::SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const rtl::OUString& rText )
+{
+    cout << __FUNCTION__ << endl;
+}
+
+void GtkSalMenu::SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage)
+{
+    cout << __FUNCTION__ << endl;
+}
+
+void GtkSalMenu::SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const KeyCode& rKeyCode, const rtl::OUString& rKeyName )
+{
+    cout << __FUNCTION__ << endl;
+}
+
+void GtkSalMenu::GetSystemMenuData( SystemMenuData* pData )
+{
+    cout << __FUNCTION__ << endl;
+}
+
+// =======================================================================
+
+/*
+ * GtkSalMenuItem
+ */
+
+GtkSalMenuItem::GtkSalMenuItem( const SalItemParams* pItemData ) :
+    mnId( pItemData->nId ),
+    mpVCLMenu( pItemData->pMenu ),
+    mpParentMenu( NULL ),
+    mpSubMenu( NULL ),
+    mpMenuItem( NULL )
+{
+    mpMenuItem = g_menu_item_new("", NULL);
+}
+
+GtkSalMenuItem::~GtkSalMenuItem()
+{
+    g_object_unref( mpMenuItem );
+}


More information about the Libreoffice-commits mailing list