summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-03-15 20:44:50 +0000
committerCaolán McNamara <caolanm@redhat.com>2016-03-16 09:27:36 +0000
commit86f504ee014d17172267f14742b8edd5789cbbc6 (patch)
tree6b6c78ac513e2169e9bceb7ffa99a16753a2eea5 /vcl/unx
parent84aee1ae9d4e03054dfcf5f8a9f10ecd2b0496b8 (diff)
Related: tdf#98637 make this a tractable problem
This is just too hard, it would all be much easier if the ActionGroup existed right from the start of the entire process. So smuggle in to the ctor the toplevel frame that the menubar will be inserted into so we can use its ActionGroup from the start. That would suggest that we could then just keep the hierarchy in sync as it is created rather than finding opportune moments to update /generate it. Change-Id: I550f94a994210423ab9cea1986e643056cb5bd29 Reviewed-on: https://gerrit.libreoffice.org/23287 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/gtk/gtkinst.cxx19
-rw-r--r--vcl/unx/gtk/gtksalmenu.cxx28
2 files changed, 31 insertions, 16 deletions
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
index a37102e0f30f..eacc457b1350 100644
--- a/vcl/unx/gtk/gtkinst.cxx
+++ b/vcl/unx/gtk/gtkinst.cxx
@@ -32,6 +32,7 @@
#include <headless/svpvd.hxx>
#include <headless/svpbmp.hxx>
#include <vcl/inputtypes.hxx>
+#include <vcl/syswin.hxx>
#include <unx/genpspgraphics.h>
#include <rtl/strbuf.hxx>
#include <rtl/uri.hxx>
@@ -347,10 +348,24 @@ SalBitmap* GtkInstance::CreateSalBitmap()
#ifdef ENABLE_GMENU_INTEGRATION
-SalMenu* GtkInstance::CreateMenu( bool bMenuBar, Menu* pVCLMenu )
+SalMenu* GtkInstance::CreateMenu( bool bMenuBar, Menu* pVCLMenu, SystemWindow* pAssociatedSystemWindow )
{
EnsureInit();
- GtkSalMenu* pSalMenu = new GtkSalMenu( bMenuBar );
+
+ GtkSalFrame *pFrame = pAssociatedSystemWindow ? dynamic_cast<GtkSalFrame*>(pAssociatedSystemWindow->ImplGetFrame())
+ : nullptr;
+
+ GActionGroup* pActionGroup;
+ if (pFrame)
+ {
+ GtkWidget* pWidget = pFrame->getWindow();
+ GdkWindow* gdkWindow = gtk_widget_get_window( pWidget );
+ pActionGroup = G_ACTION_GROUP( g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-action-group" ) );
+ }
+ else
+ pActionGroup = nullptr;
+
+ GtkSalMenu* pSalMenu = new GtkSalMenu(bMenuBar, pActionGroup);
pSalMenu->SetMenu( pVCLMenu );
return pSalMenu;
}
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
index 204415564b96..0378b49f45e0 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -456,16 +456,26 @@ bool GtkSalMenu::ShowNativePopupMenu(FloatingWindow* pWin, const Rectangle& rRec
* GtkSalMenu
*/
-GtkSalMenu::GtkSalMenu( bool bMenuBar ) :
+GtkSalMenu::GtkSalMenu( bool bMenuBar, GActionGroup *pActionGroup ) :
mbMenuBar( bMenuBar ),
mpMenuBarWidget( nullptr ),
mpCloseButton( nullptr ),
mpVCLMenu( nullptr ),
mpParentSalMenu( nullptr ),
mpFrame( nullptr ),
- mpMenuModel( nullptr ),
- mpActionGroup( nullptr )
+ mpActionGroup(pActionGroup)
{
+ if (bMenuBar)
+ mpMenuModel = G_MENU_MODEL(g_lo_menu_new());
+ else
+ mpMenuModel = nullptr;
+
+ GLOActionGroup* pLOActionGroup = G_LO_ACTION_GROUP( mpActionGroup );
+ if (pLOActionGroup)
+ {
+ g_lo_action_group_clear(pLOActionGroup);
+ g_lo_action_group_set_top_menu(pLOActionGroup, static_cast<gpointer>(this));
+ }
}
void GtkSalMenu::SetMenuModel(GMenuModel* pMenuModel)
@@ -664,22 +674,12 @@ void GtkSalMenu::SetFrame(const SalFrame* pFrame)
GdkWindow* gdkWindow = gtk_widget_get_window( pWidget );
GLOMenu* pMenuModel = G_LO_MENU( g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-menubar" ) );
- GLOActionGroup* pActionGroup = G_LO_ACTION_GROUP( g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-action-group" ) );
- SAL_INFO("vcl.unity", "Found menu model: " << pMenuModel << " and action group: " << pActionGroup);
+ SAL_INFO("vcl.unity", "Found menu model: " << pMenuModel);
if ( pMenuModel )
{
if ( g_menu_model_get_n_items( G_MENU_MODEL( pMenuModel ) ) > 0 )
g_lo_menu_remove( pMenuModel, 0 );
-
- mpMenuModel = G_MENU_MODEL( g_lo_menu_new() );
- }
-
- if ( pActionGroup )
- {
- g_lo_action_group_clear( pActionGroup );
- g_lo_action_group_set_top_menu(pActionGroup, static_cast<gpointer>(this));
- mpActionGroup = G_ACTION_GROUP( pActionGroup );
}
// Generate the main menu structure.