summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorAntonio Fernandez <antonio.fernandez@aentos.es>2012-10-15 11:13:35 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2012-11-14 13:52:56 +0100
commit097e8668a416362ed5f80c0d33888678da416f5d (patch)
treed4aecaf14c6009f3c5e5b6687df4044f06b26105 /vcl
parentce989d9a550fdd07b0af7809935bba0c1f1ca14e (diff)
Menu is always visible now.
Change-Id: Ia6153c6630af2b04f3b022051aa1f7c48e2bfc1e
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/unx/gtk/gtkframe.hxx5
-rw-r--r--vcl/unx/gtk/window/gtkframe.cxx68
-rw-r--r--vcl/unx/gtk/window/gtksalmenu.cxx19
3 files changed, 41 insertions, 51 deletions
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 125c074fbd62..cc4451a1e331 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -217,8 +217,6 @@ class GtkSalFrame : public SalFrame
friend void on_registrar_available (GDBusConnection*, const gchar*, const gchar*, gpointer);
friend void on_registrar_unavailable (GDBusConnection*, const gchar*, gpointer);
guint m_nWatcherId;
- guint m_nMenuExportId;
- guint m_nActionGroupExportId;
void Init( SalFrame* pParent, sal_uLong nStyle );
void Init( SystemParentData* pSysData );
@@ -303,6 +301,9 @@ public:
GtkSalFrame( SalFrame* pParent, sal_uLong nStyle );
GtkSalFrame( SystemParentData* pSysData );
+ guint m_nMenuExportId;
+ guint m_nActionGroupExportId;
+
// dispatches an event, returns true if dispatched
// and false else; if true was returned the event should
// be swallowed
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 1107aed37cf3..cf86115e0754 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -512,15 +512,18 @@ static void ObjectDestroyedNotify( gpointer data )
}
}
-void ensure_dbus_setup( GdkWindow* gdkWindow, GtkSalFrame* pSalFrame )
+gboolean ensure_dbus_setup( gpointer data )
{
+ GtkSalFrame* pSalFrame = reinterpret_cast< GtkSalFrame* >( data );
+ GdkWindow* gdkWindow = gtk_widget_get_window( pSalFrame->getWindow() );
+
if ( gdkWindow != NULL && g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-menubar" ) == NULL )
{
// Get a DBus session connection.
if(!pSessionBus)
pSessionBus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
- if( pSessionBus == NULL )
- return;
+ if( !pSessionBus )
+ return FALSE;
// Create menu model and action group attached to this frame.
GMenuModel* pMenuModel = G_MENU_MODEL( g_lo_menu_new() );
@@ -532,11 +535,6 @@ void ensure_dbus_setup( GdkWindow* gdkWindow, GtkSalFrame* pSalFrame )
gchar* aDBusWindowPath = g_strdup_printf( "/window/%lu", windowId );
gchar* aDBusMenubarPath = g_strdup_printf( "/window/%lu/menus/menubar", windowId );
- // Publish the menu model and the action group.
- SAL_INFO("vcl.unity", "exporting menu model at " << pMenuModel << " for window " << windowId);
- pSalFrame->m_nMenuExportId = g_dbus_connection_export_menu_model (pSessionBus, aDBusMenubarPath, pMenuModel, NULL);
- pSalFrame->m_nActionGroupExportId = g_dbus_connection_export_action_group( pSessionBus, aDBusPath, pActionGroup, NULL);
-
// Set window properties.
g_object_set_data_full( G_OBJECT(gdkWindow), "g-lo-menubar", pMenuModel, ObjectDestroyedNotify);
g_object_set_data_full( G_OBJECT(gdkWindow), "g-lo-action-group", pActionGroup, ObjectDestroyedNotify);
@@ -546,10 +544,17 @@ void ensure_dbus_setup( GdkWindow* gdkWindow, GtkSalFrame* pSalFrame )
gdk_x11_window_set_utf8_property ( gdkWindow, "_GTK_WINDOW_OBJECT_PATH", aDBusWindowPath );
gdk_x11_window_set_utf8_property ( gdkWindow, "_GTK_MENUBAR_OBJECT_PATH", aDBusMenubarPath );
+ // Publish the menu model and the action group.
+ SAL_INFO("vcl.unity", "exporting menu model at " << pMenuModel << " for window " << windowId);
+ pSalFrame->m_nMenuExportId = g_dbus_connection_export_menu_model (pSessionBus, aDBusMenubarPath, pMenuModel, NULL);
+ pSalFrame->m_nActionGroupExportId = g_dbus_connection_export_action_group( pSessionBus, aDBusPath, pActionGroup, NULL);
+
g_free( aDBusPath );
g_free( aDBusWindowPath );
g_free( aDBusMenubarPath );
}
+
+ return FALSE;
}
void on_registrar_available( GDBusConnection * /*connection*/,
@@ -560,9 +565,6 @@ void on_registrar_available( GDBusConnection * /*connection*/,
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();
@@ -597,32 +599,28 @@ void on_registrar_unavailable( GDBusConnection * /*connection*/,
void GtkSalFrame::EnsureAppMenuWatch()
{
- SolarMutexGuard aGuard;
-
- if ( m_nWatcherId )
- //g_bus_unwatch_name( m_nWatcherId );
- return;
-
-
- // Get a DBus session connection.
- if ( pSessionBus == NULL )
+ if ( !m_nWatcherId )
{
- pSessionBus = g_bus_get_sync( G_BUS_TYPE_SESSION, NULL, NULL );
-
+ // Get a DBus session connection.
if ( pSessionBus == NULL )
- return;
- }
+ {
+ pSessionBus = g_bus_get_sync( G_BUS_TYPE_SESSION, NULL, NULL );
+
+ if ( pSessionBus == NULL )
+ return;
+ }
- // Publish the menu only if AppMenu registrar is available.
- m_nWatcherId = g_bus_watch_name_on_connection( pSessionBus,
- "com.canonical.AppMenu.Registrar",
- G_BUS_NAME_WATCHER_FLAGS_NONE,
- on_registrar_available,
- on_registrar_unavailable,
- static_cast<GtkSalFrame*>(this),
- NULL );
+ // Publish the menu only if AppMenu registrar is available.
+ m_nWatcherId = g_bus_watch_name_on_connection( pSessionBus,
+ "com.canonical.AppMenu.Registrar",
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ on_registrar_available,
+ on_registrar_unavailable,
+ static_cast<GtkSalFrame*>(this),
+ NULL );
+ }
- ensure_dbus_setup( gtk_widget_get_window(GTK_WIDGET(m_pWindow)), static_cast<GtkSalFrame*>(this) );
+ ensure_dbus_setup( this );
}
GtkSalFrame::~GtkSalFrame()
@@ -1120,6 +1118,10 @@ void GtkSalFrame::Init( SalFrame* pParent, sal_uLong nStyle )
#if !GTK_CHECK_VERSION(3,0,0)
if( eWinType == GTK_WINDOW_TOPLEVEL )
{
+ // Enable DBus native menu if available.
+// ensure_dbus_setup( this );
+ EnsureAppMenuWatch();
+
guint32 nUserTime = 0;
if( (nStyle & (SAL_FRAME_STYLE_OWNERDRAWDECORATION|SAL_FRAME_STYLE_TOOLWINDOW)) == 0 )
{
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx
index 65ee72b9e2e0..13afb2bf912a 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -244,10 +244,10 @@ void RemoveUnusedCommands( GLOActionGroup* pActionGroup, GList* pOldCommandList,
void GtkSalMenu::UpdateNativeMenu()
{
SolarMutexGuard aGuard;
+
if( !PrepUpdate() )
return;
-
Menu* pVCLMenu = mpVCLMenu;
GLOMenu* pLOMenu = G_LO_MENU( mpMenuModel );
GLOActionGroup* pActionGroup = G_LO_ACTION_GROUP( mpActionGroup );
@@ -431,7 +431,7 @@ void GtkSalMenu::RemoveItem( unsigned nPos )
maItems.erase( maItems.begin() + nPos );
}
-void GtkSalMenu::SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos )
+void GtkSalMenu::SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned )
{
SolarMutexGuard aGuard;
GtkSalMenuItem *pItem = static_cast< GtkSalMenuItem* >( pSalMenuItem );
@@ -455,23 +455,11 @@ void GtkSalMenu::SetFrame( const SalFrame* pFrame )
// if we had a menu on the GtkSalMenu we have to free it as we generate a
// full menu anyway and we might need to reuse an existing model and
// actiongroup
-// if(mpMenuModel)
-// {
-// g_object_unref(G_OBJECT(mpMenuModel));
-// mpMenuModel = NULL;
-// }
-
-// if(mpActionGroup)
-// {
-// g_object_unref(G_OBJECT(mpActionGroup));
-// mpActionGroup = NULL;
-// }
pFrameNonConst->SetMenu( this );
mpFrame = static_cast< const GtkSalFrame* >( pFrame );
- pFrameNonConst->EnsureAppMenuWatch();
// Clean menu model and action group if needed.
- GObject* pWindow = G_OBJECT( gtk_widget_get_window( GTK_WIDGET( pFrameNonConst->getWindow() ) ) );
+ GObject* pWindow = G_OBJECT( pFrameNonConst->getWindow() );
GLOMenu* pMenuModel = G_LO_MENU( g_object_get_data( pWindow, "g-lo-menubar" ) );
GLOActionGroup* pActionGroup = G_LO_ACTION_GROUP( g_object_get_data( pWindow, "g-lo-action-group" ) );
@@ -481,7 +469,6 @@ void GtkSalMenu::SetFrame( const SalFrame* pFrame )
if ( pActionGroup )
g_lo_action_group_clear( pActionGroup );
-
// Generate the main menu structure.
UpdateNativeMenu();
}