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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Oct 6 06:49:00 PDT 2012


 vcl/inc/unx/gtk/gtksalmenu.hxx    |    3 +-
 vcl/unx/gtk/window/gtkframe.cxx   |   24 +++++++++++++---------
 vcl/unx/gtk/window/gtksalmenu.cxx |   40 +++++++++++++++++++++++++-------------
 3 files changed, 43 insertions(+), 24 deletions(-)

New commits:
commit e1ca9ecd43db2256739d2d710823acdd51ca5777
Author: Antonio Fernandez <antonio.fernandez at aentos.es>
Date:   Sat Oct 6 14:46:26 2012 +0100

    Menu is properly visible on non-Unity WM.
    
    Change-Id: If9fea1f3b700a0d957aa1ed11913b2a7982050c2

diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 7dadbfc..6e7084b 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -102,7 +102,8 @@ public:
     void                        DispatchCommand( gint itemId, const gchar* aCommand );
     void                        Activate( const gchar* aMenuCommand );
     void                        Deactivate( const gchar* aMenuCommand );
-    void DisconnectFrame();
+    void                        DisconnectFrame();
+    void                        Display( sal_Bool bVisible );
     void UpdateNativeMenu();
 //    void UpdateNativeSubMenu();
     bool PrepUpdate();
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 3a8a79e..7e944c6 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -567,36 +567,40 @@ void on_registrar_available( GDBusConnection * /*connection*/,
                              gpointer         user_data )
 {
     SolarMutexGuard aGuard;
+
     GtkSalFrame* pSalFrame = reinterpret_cast< GtkSalFrame* >( user_data );
     GdkWindow* gdkWindow = gtk_widget_get_window( pSalFrame->getWindow() );
+
     ensure_dbus_setup(gdkWindow, pSalFrame);
+
     SalMenu* pSalMenu = pSalFrame->GetMenu();
+
     if ( pSalMenu != NULL )
     {
         GtkSalMenu* pGtkSalMenu = static_cast<GtkSalMenu*>(pSalMenu);
         pGtkSalMenu->UpdateNativeMenu();
-        MenuBar* pMenuBar = static_cast< MenuBar* >( pGtkSalMenu->GetMenu() );
-        if(pMenuBar)
-            pMenuBar->SetDisplayable(false);           
+        pGtkSalMenu->Display( sal_True );
     }
 }
 
-//This is called when the registrar becomes unavailable. It shows the menubar.
-void on_registrar_unavailable (GDBusConnection * /*connection*/,
-                          const gchar     * /*name*/,
-                          gpointer         user_data)
+// This is called when the registrar becomes unavailable. It shows the menubar.
+void on_registrar_unavailable( GDBusConnection * /*connection*/,
+                               const gchar     * /*name*/,
+                               gpointer         user_data )
 {
     SolarMutexGuard aGuard;
+
     SAL_INFO("vcl.unity", "on_registrar_unavailable");
+
     pSessionBus = NULL;
     GtkSalFrame* pSalFrame = reinterpret_cast< GtkSalFrame* >( user_data );
+
     SalMenu* pSalMenu = pSalFrame->GetMenu();
 
     if ( pSalMenu ) {
-        GtkSalMenu* pGtkSalMenu = static_cast<GtkSalMenu*>(pSalMenu);
+        GtkSalMenu* pGtkSalMenu = static_cast< GtkSalMenu* >( pSalMenu );
         pGtkSalMenu->DisconnectFrame();
-        MenuBar* pMenuBar = static_cast< MenuBar* >( pGtkSalMenu->GetMenu() );
-        pMenuBar->SetDisplayable( false );
+        pGtkSalMenu->Display( sal_False );
     }
 }
 
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx
index 5a9ac3d..3e2664e 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -37,6 +37,8 @@
 
 #include <sal/log.hxx>
 
+static sal_Bool bMenuVisibility = sal_False;
+
 static gchar* GetCommandForSpecialItem( GtkSalMenuItem* pSalMenuItem )
 {
     gchar* aCommand = NULL;
@@ -380,16 +382,6 @@ void GtkSalMenu::UpdateNativeMenu()
     RemoveUnusedCommands( pActionGroup, pOldCommandList, pNewCommandList );
 }
 
-void GtkSalMenu::DisconnectFrame()
-{
-    if(mbMenuBar)
-    {
-        mpMenuModel = NULL;
-        mpActionGroup = NULL;
-        mpFrame = NULL;
-    }
-}
-
 
 /*
  * GtkSalMenu
@@ -416,7 +408,7 @@ GtkSalMenu::~GtkSalMenu()
 
 sal_Bool GtkSalMenu::VisibleMenuBar()
 {
-    return true;
+    return bMenuVisibility;
 }
 
 void GtkSalMenu::InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos )
@@ -491,7 +483,6 @@ void GtkSalMenu::SetFrame( const SalFrame* pFrame )
 
     // Generate the main menu structure.
     UpdateNativeMenu();
-
 }
 
 const GtkSalFrame* GtkSalMenu::GetFrame() const
@@ -708,7 +699,7 @@ void GtkSalMenu::Activate( const gchar* aMenuCommand )
 
 void GtkSalMenu::Deactivate( const gchar* aMenuCommand )
 {
-    if ( mbMenuBar != TRUE )
+    if ( mbMenuBar == sal_False )
         return;
 
     GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( (gchar*) aMenuCommand, TRUE );
@@ -719,6 +710,29 @@ void GtkSalMenu::Deactivate( const gchar* aMenuCommand )
     }
 }
 
+void GtkSalMenu::DisconnectFrame()
+{
+    if( mbMenuBar == sal_True )
+    {
+        mpMenuModel = NULL;
+        mpActionGroup = NULL;
+        mpFrame = NULL;
+    }
+}
+
+void GtkSalMenu::Display( sal_Bool bVisible )
+{
+    if ( mbMenuBar == sal_False || mpVCLMenu == NULL )
+        return;
+
+    bMenuVisibility = bVisible;
+
+    sal_Bool bVCLMenuVisible = ( bVisible == sal_True ) ? sal_False : sal_True;
+
+    MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu );
+    pMenuBar->SetDisplayable( bVCLMenuVisible );
+}
+
 sal_Bool GtkSalMenu::IsItemVisible( unsigned nPos )
 {
     SolarMutexGuard aGuard;


More information about the Libreoffice-commits mailing list