summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk/window/gtksalmenu.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/unx/gtk/window/gtksalmenu.cxx')
-rw-r--r--vcl/unx/gtk/window/gtksalmenu.cxx143
1 files changed, 101 insertions, 42 deletions
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx
index b9d9325e3f7f..3c6ee28640ca 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -152,25 +152,33 @@ bool GtkSalMenu::PrepUpdate()
const GtkSalFrame* pFrame = GetFrame();
if (pFrame)
{
- const GObject* pWindow = G_OBJECT(gtk_widget_get_window( GTK_WIDGET(pFrame->getWindow()) ));
- if(!pWindow)
- {
- SAL_INFO("vcl.unity", "not updating menu model, I have no frame " << mpMenuModel);
+// const GObject* pWindow = G_OBJECT(gtk_widget_get_window( GTK_WIDGET(pFrame->getWindow()) ));
+// if(!pWindow)
+// {
+// SAL_INFO("vcl.unity", "not updating menu model, I have no frame " << mpMenuModel);
+// return false;
+// }
+//
+// // the root menu does not have its own model and has to use the one owned by the frame
+// if(mbMenuBar)
+// {
+// mpMenuModel = G_MENU_MODEL( g_object_get_data( G_OBJECT( pWindow ), "g-lo-menubar" ) );
+// mpActionGroup = G_ACTION_GROUP( g_object_get_data( G_OBJECT( pWindow ), "g-lo-action-group" ) );
+//
+// if(!mpMenuModel || !mpActionGroup)
+// return false;
+// }
+//
+// SAL_INFO("vcl.unity", "updating menu model" << mpMenuModel);
+ GtkSalFrame* pNonConstFrame = ( GtkSalFrame* ) pFrame;
+ GtkSalMenu* pSalMenu = ((GtkSalMenu*) this);
+
+ if ( !pNonConstFrame->GetMenu() )
+ pNonConstFrame->SetMenu( pSalMenu );
+
+ if ( /*!bMenuVisibility ||*/ !mpMenuModel || !mpActionGroup )
return false;
- }
-
- // the root menu does not have its own model and has to use the one owned by the frame
- if(mbMenuBar)
- {
- mpMenuModel = G_MENU_MODEL( g_object_get_data( G_OBJECT( pWindow ), "g-lo-menubar" ) );
- mpActionGroup = G_ACTION_GROUP( g_object_get_data( G_OBJECT( pWindow ), "g-lo-action-group" ) );
-
- if(!mpMenuModel || !mpActionGroup)
- return false;
- }
-
- SAL_INFO("vcl.unity", "updating menu model" << mpMenuModel);
-
+
return true;
}
@@ -256,6 +264,7 @@ void RemoveUnusedCommands( GLOActionGroup* pActionGroup, GList* pOldCommandList,
void GtkSalMenu::UpdateNativeMenu()
{
SolarMutexGuard aGuard;
+ //GTK_YIELD_GRAB();
if( !PrepUpdate() )
return;
@@ -357,16 +366,20 @@ void GtkSalMenu::UpdateNativeMenu()
{
NativeSetItemCommand( nSection, nItemPos, nId, aNativeCommand, itemBits, FALSE, TRUE );
pNewCommandList = g_list_append( pNewCommandList, g_strdup( aNativeCommand ) );
-
+//
GLOMenu* pSubMenuModel = g_lo_menu_get_submenu_from_item_in_section( pLOMenu, nSection, nItemPos );
+// printf("%s (begin) - submenumodel: %p\n", __FUNCTION__, pSubMenuModel);
if ( pSubMenuModel == NULL )
{
- pSubMenuModel = g_lo_menu_new();
- g_lo_menu_set_submenu_to_item_in_section( pLOMenu, nSection, nItemPos, G_MENU_MODEL( pSubMenuModel ) );
+ //pSubMenuModel = g_lo_menu_new();
+ //g_lo_menu_set_submenu_to_item_in_section( pLOMenu, nSection, nItemPos, G_MENU_MODEL( pSubMenuModel ) );
+ g_lo_menu_new_submenu_in_item_in_section( pLOMenu, nSection, nItemPos );
+ pSubMenuModel = g_lo_menu_get_submenu_from_item_in_section( pLOMenu, nSection, nItemPos );
}
g_object_unref( pSubMenuModel );
+// printf("%s (end) - submenumodel: %p\n", __FUNCTION__, pSubMenuModel);
pSubmenu->SetMenuModel( G_MENU_MODEL( pSubMenuModel ) );
pSubmenu->SetActionGroup( G_ACTION_GROUP( pActionGroup ) );
@@ -375,11 +388,10 @@ void GtkSalMenu::UpdateNativeMenu()
pSubmenu->GetMenu()->Deactivate();
pSubmenu->UpdateNativeMenu();
+
+ //pSubmenu->SetMenuModel( NULL );
+ //pSubmenu->SetActionGroup( NULL );
}
-// else if (pSubMenuModel)
-// {
-// g_lo_menu_set_submenu_to_item_in_section( pLOMenu, nSection, nItemPos, NULL );
-// };
g_free( aNativeCommand );
@@ -405,26 +417,49 @@ void GtkSalMenu::UpdateNativeMenu()
GtkSalMenu::GtkSalMenu( sal_Bool bMenuBar ) :
mbMenuBar( bMenuBar ),
mpVCLMenu( NULL ),
+ mpOldSalMenu( NULL ),
mpParentSalMenu( NULL ),
mpFrame( NULL ),
mpMenuModel( NULL ),
mpActionGroup( NULL )
{
+ if (mbMenuBar)
+ printf("[%p] %s\n", this, __FUNCTION__);
}
GtkSalMenu::~GtkSalMenu()
{
SolarMutexGuard aGuard;
+ //GTK_YIELD_GRAB();
+
if ( mbMenuBar == sal_True )
- if ( mpFrame )
- ((GtkSalFrame*) mpFrame)->SetMenu( NULL );
+ {
+ printf("[%p] %s\n", this, __FUNCTION__);
+ //if ( mpFrame )
+ // ((GtkSalFrame*) mpFrame)->SetMenu( NULL );
+
+ if ( mpMenuModel )
+ {
+ g_lo_menu_remove( G_LO_MENU( mpMenuModel ), 0 );
+ g_object_unref( mpMenuModel );
+ }
+
+ //if ( mpActionGroup )
+ //{
+ //g_lo_action_group_clear( G_LO_ACTION_GROUP( mpActionGroup ) );
+ //g_object_unref( mpActionGroup );
+ //}
+ //if ( mpFrame )
+ // ((GtkSalFrame*) mpFrame)->FlushConnection();
+ }
maItems.clear();
}
sal_Bool GtkSalMenu::VisibleMenuBar()
{
- return bMenuVisibility;
+ //return bMenuVisibility;
+ return sal_False;
}
void GtkSalMenu::InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos )
@@ -462,6 +497,8 @@ void GtkSalMenu::SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsig
void GtkSalMenu::SetFrame( const SalFrame* pFrame )
{
SolarMutexGuard aGuard;
+ GTK_YIELD_GRAB();
+
assert(mbMenuBar);
SAL_INFO("vcl.unity", "GtkSalMenu set to frame");
mpFrame = static_cast< const GtkSalFrame* >( pFrame );
@@ -470,25 +507,44 @@ 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
+ mpOldSalMenu = static_cast< GtkSalMenu* >( pFrameNonConst->GetMenu() );
pFrameNonConst->SetMenu( this );
- mpFrame = static_cast< const GtkSalFrame* >( pFrame );
// Clean menu model and action group if needed.
-// GObject* pWindow = G_OBJECT( pFrameNonConst->getWindow() );
GtkWidget* pWidget = pFrameNonConst->getWindow();
GdkWindow* gdkWindow = gtk_widget_get_window( pWidget );
+ printf("[%p] %s - window: %p\n", this, __FUNCTION__, gdkWindow);
+
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" ) );
- if ( pMenuModel && g_menu_model_get_n_items( G_MENU_MODEL( pMenuModel ) ) > 0 )
- g_lo_menu_remove( pMenuModel, 0 );
+ if ( pMenuModel )
+ {
+ if ( g_menu_model_get_n_items( G_MENU_MODEL( pMenuModel ) ) > 0 )
+ g_lo_menu_remove( pMenuModel, 0 );
+
+ //g_lo_menu_new_section( pMenuModel, 0, NULL );
+ //mpMenuModel = G_MENU_MODEL( g_lo_menu_get_section( pMenuModel, 0 ) );
+ mpMenuModel = G_MENU_MODEL( g_lo_menu_new() );
+ //g_lo_menu_insert_section( pMenuModel, 0, NULL, mpMenuModel );
+ }
if ( pActionGroup )
+ {
g_lo_action_group_clear( pActionGroup );
+ mpActionGroup = G_ACTION_GROUP( pActionGroup );
+ }
+
+ //pFrameNonConst->FlushConnection();
// Generate the main menu structure.
UpdateNativeMenu();
+ g_lo_menu_insert_section( pMenuModel, 0, NULL, mpMenuModel );
+
+ //pFrameNonConst->FlushConnection();
+
+ printf("[%p] %s - frame: %p - menu export id: %d - action group export id: %d\n", this, __FUNCTION__, pFrame, pFrameNonConst->m_nMenuExportId, pFrameNonConst->m_nActionGroupExportId);
}
const GtkSalFrame* GtkSalMenu::GetFrame() const
@@ -503,7 +559,7 @@ const GtkSalFrame* GtkSalMenu::GetFrame() const
void GtkSalMenu::NativeCheckItem( unsigned nSection, unsigned nItemPos, MenuItemBits bits, gboolean bCheck )
{
SolarMutexGuard aGuard;
-
+
if ( mpActionGroup == NULL )
return;
@@ -681,6 +737,8 @@ void GtkSalMenu::DispatchCommand( gint itemId, const gchar *aCommand )
if ( mbMenuBar != TRUE )
return;
+ printf("[%p] %s - item id: %d - command: %s\n", this, __FUNCTION__, itemId, aCommand);
+
GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( (gchar*) aCommand, FALSE );
Menu* pSubMenu = ( pSalSubMenu != NULL ) ? pSalSubMenu->GetMenu() : NULL;
@@ -700,6 +758,7 @@ void GtkSalMenu::Activate( const gchar* aMenuCommand )
MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu );
pMenuBar->HandleMenuActivateEvent( pSalSubMenu->mpVCLMenu );
pSalSubMenu->UpdateNativeMenu();
+ //((GtkSalFrame*) mpFrame)->FlushConnection();
}
}
@@ -716,15 +775,15 @@ void GtkSalMenu::Deactivate( const gchar* aMenuCommand )
}
}
-void GtkSalMenu::DisconnectFrame()
-{
- if( mbMenuBar == sal_True )
- {
- mpMenuModel = NULL;
- mpActionGroup = NULL;
- mpFrame = NULL;
- }
-}
+//void GtkSalMenu::DisconnectFrame()
+//{
+// if( mbMenuBar == sal_True )
+// {
+// mpMenuModel = NULL;
+// mpActionGroup = NULL;
+// mpFrame = NULL;
+// }
+//}
void GtkSalMenu::Display( sal_Bool bVisible )
{