summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk
diff options
context:
space:
mode:
authorAntonio Fernandez <antonio.fernandez@aentos.es>2012-10-18 19:31:16 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2012-11-14 13:52:57 +0100
commit4ca439fb87da80ce431049abe43a07c82b62f4b4 (patch)
treeb1467da063c7db0cea4684d15fc47c52feabda57 /vcl/unx/gtk
parent34504e4af678b52b6d6cfe7519ee1934f89c95dd (diff)
Fixed menu visibility and cleaned up some code.
Change-Id: Ibda3c5d6f50d12041065f28ddd41eab57ae9560e
Diffstat (limited to 'vcl/unx/gtk')
-rw-r--r--vcl/unx/gtk/window/gloactiongroup.cxx2
-rw-r--r--vcl/unx/gtk/window/glomenu.cxx71
-rw-r--r--vcl/unx/gtk/window/gtkframe.cxx27
-rw-r--r--vcl/unx/gtk/window/gtksalmenu.cxx79
4 files changed, 28 insertions, 151 deletions
diff --git a/vcl/unx/gtk/window/gloactiongroup.cxx b/vcl/unx/gtk/window/gloactiongroup.cxx
index 9f65f37cd4d5..756779a559ca 100644
--- a/vcl/unx/gtk/window/gloactiongroup.cxx
+++ b/vcl/unx/gtk/window/gloactiongroup.cxx
@@ -255,8 +255,6 @@ g_lo_action_group_activate (GActionGroup *group,
{
GTK_YIELD_GRAB();
- printf("%s\n", __FUNCTION__);
-
GLOActionGroup *lo_group = G_LO_ACTION_GROUP (group);
GtkSalFrame *pFrame = lo_group->priv->frame;
diff --git a/vcl/unx/gtk/window/glomenu.cxx b/vcl/unx/gtk/window/glomenu.cxx
index cc8488911923..e804ff980509 100644
--- a/vcl/unx/gtk/window/glomenu.cxx
+++ b/vcl/unx/gtk/window/glomenu.cxx
@@ -100,12 +100,10 @@ g_lo_menu_is_mutable (GMenuModel*)
static gint
g_lo_menu_get_n_items (GMenuModel *model)
{
- //printf("[%p] %s\n", model, __FUNCTION__);
g_return_val_if_fail (model != NULL, 0);
GLOMenu *menu = G_LO_MENU (model);
g_return_val_if_fail (menu->items != NULL, 0);
- //printf("[%p] %s - length: %d\n", model, __FUNCTION__, menu->items->len);
return menu->items->len;
}
@@ -113,7 +111,6 @@ gint
g_lo_menu_get_n_items_from_section (GLOMenu *menu,
gint section)
{
- //printf("[%p] %s - section: %d\n", menu, __FUNCTION__, section);
g_return_val_if_fail (0 <= section && section < (gint) menu->items->len, 0);
GLOMenu *model = g_lo_menu_get_section (menu, section);
@@ -124,7 +121,6 @@ g_lo_menu_get_n_items_from_section (GLOMenu *menu,
g_object_unref (model);
- //printf("[%p] %s - section: %d - length: %d\n", menu, __FUNCTION__, section, length);
return length;
}
@@ -134,9 +130,7 @@ g_lo_menu_get_item_attributes (GMenuModel *model,
GHashTable **table)
{
GLOMenu *menu = G_LO_MENU (model);
-
*table = g_hash_table_ref (g_array_index (menu->items, struct item, position).attributes);
- //printf("[%p] %s - position: %d - table: %p - *table: %p\n", model, __FUNCTION__, position, table, ((table) ? *table : NULL));
}
static void
@@ -145,9 +139,7 @@ g_lo_menu_get_item_links (GMenuModel *model,
GHashTable **table)
{
GLOMenu *menu = G_LO_MENU (model);
-
*table = g_hash_table_ref (g_array_index (menu->items, struct item, position).links);
- //printf("[%p] %s - position: %d - table: %p - *table: %p - items: %p\n", model, __FUNCTION__, position, table, ((table) ? *table : NULL), ((menu) ? menu->items : NULL));
}
void
@@ -164,7 +156,6 @@ g_lo_menu_insert_in_section (GLOMenu *menu,
gint position,
const gchar *label)
{
- //printf("[%p] %s - section: %d - position: %d - label: %s\n", menu, __FUNCTION__, section, position, label);
g_return_if_fail (G_IS_LO_MENU (menu));
g_return_if_fail (0 <= section && section < (gint) menu->items->len);
@@ -189,7 +180,6 @@ g_lo_menu_set_attribute_value (GLOMenu *menu,
const gchar *attribute,
GVariant *value)
{
- //printf("[%p] %s - position: %d - attribute: %s - value: %p\n", menu, __FUNCTION__, position, attribute, value);
g_return_if_fail (G_IS_LO_MENU (menu));
g_return_if_fail (attribute != NULL);
g_return_if_fail (valid_attribute_name (attribute));
@@ -212,7 +202,6 @@ g_lo_menu_get_attribute_value_from_item_in_section (GLOMenu *menu,
const gchar *attribute,
const GVariantType *type)
{
- //printf("[%p] %s - section: %d - position: %d - attribute: %s - type: %p\n", menu, __FUNCTION__, section, position, attribute, type);
GMenuModel *model = G_MENU_MODEL (g_lo_menu_get_section (menu, section));
g_return_val_if_fail (model != NULL, NULL);
@@ -232,7 +221,6 @@ g_lo_menu_set_label (GLOMenu *menu,
gint position,
const gchar *label)
{
- //printf("[%p] %s - position: %d - label: %s\n", menu, __FUNCTION__, position, label);
g_return_if_fail (G_IS_LO_MENU (menu));
GVariant *value;
@@ -251,19 +239,16 @@ g_lo_menu_set_label_to_item_in_section (GLOMenu *menu,
gint position,
const gchar *label)
{
- //printf("[%p] %s - section: %d - position: %d - label: %s\n", menu, __FUNCTION__, section, position, label);
g_return_if_fail (G_IS_LO_MENU (menu));
GLOMenu *model = g_lo_menu_get_section (menu, section);
g_return_if_fail (model != NULL);
- g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 0);
-
g_lo_menu_set_label (model, position, label);
// Notify the update.
- g_menu_model_items_changed (G_MENU_MODEL (model), position, 0, 1);
+ g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 1);
g_object_unref (model);
}
@@ -273,7 +258,6 @@ g_lo_menu_get_label_from_item_in_section (GLOMenu *menu,
gint section,
gint position)
{
- //printf("[%p] %s - section: %d - position: %d\n", menu, __FUNCTION__, section, position);
g_return_val_if_fail (G_IS_LO_MENU (menu), NULL);
GVariant *label_value = g_lo_menu_get_attribute_value_from_item_in_section (menu,
@@ -299,7 +283,6 @@ g_lo_menu_set_action_and_target_value (GLOMenu *menu,
const gchar *action,
GVariant *target_value)
{
- //printf("[%p] %s - position: %d - action: %s - target value: %p\n", menu, __FUNCTION__, position, action, target_value);
g_return_if_fail (G_IS_LO_MENU (menu));
GVariant *action_value;
@@ -327,7 +310,6 @@ g_lo_menu_set_action_and_target_value_to_item_in_section (GLOMenu *menu,
const gchar *command,
GVariant *target_value)
{
- //printf("[%p] %s - section: %d - position: %d - command: %s - target value: %p\n", menu, __FUNCTION__, section, position, command, target_value);
g_return_if_fail (G_IS_LO_MENU (menu));
GLOMenu *model = g_lo_menu_get_section (menu, section);
@@ -345,15 +327,12 @@ g_lo_menu_set_accelerator_to_item_in_section (GLOMenu *menu,
gint position,
const gchar *accelerator)
{
- //printf("[%p] %s - section: %d - position: %d - accelerator: %s\n", menu, __FUNCTION__, section, position, accelerator);
g_return_if_fail (G_IS_LO_MENU (menu));
GLOMenu *model = g_lo_menu_get_section (menu, section);
g_return_if_fail (model != NULL);
- g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 0);
-
GVariant *value;
if (accelerator != NULL)
@@ -364,7 +343,7 @@ g_lo_menu_set_accelerator_to_item_in_section (GLOMenu *menu,
g_lo_menu_set_attribute_value (model, position, G_LO_MENU_ATTRIBUTE_ACCELERATOR, value);
// Notify the update.
- g_menu_model_items_changed (G_MENU_MODEL (model), position, 0, 1);
+ g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 1);
g_object_unref (model);
}
@@ -374,7 +353,6 @@ g_lo_menu_get_accelerator_from_item_in_section (GLOMenu *menu,
gint section,
gint position)
{
- //printf("[%p] %s - section: %d - position: %d\n", menu, __FUNCTION__, section, position);
g_return_val_if_fail (G_IS_LO_MENU (menu), NULL);
GVariant *accel_value = g_lo_menu_get_attribute_value_from_item_in_section (menu,
@@ -400,15 +378,12 @@ g_lo_menu_set_command_to_item_in_section (GLOMenu *menu,
gint position,
const gchar *command)
{
- //printf("[%p] %s - section: %d - position: %d - command: %s\n", menu, __FUNCTION__, section, position, command);
g_return_if_fail (G_IS_LO_MENU (menu));
GLOMenu *model = g_lo_menu_get_section (menu, section);
g_return_if_fail (model != NULL);
- g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 0);
-
GVariant *value;
if (command != NULL)
@@ -419,7 +394,7 @@ g_lo_menu_set_command_to_item_in_section (GLOMenu *menu,
g_lo_menu_set_attribute_value (model, position, G_LO_MENU_ATTRIBUTE_COMMAND, value);
// Notify the update.
- g_menu_model_items_changed (G_MENU_MODEL (model), position, 0, 1);
+ g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 1);
g_object_unref (model);
}
@@ -429,7 +404,6 @@ g_lo_menu_get_command_from_item_in_section (GLOMenu *menu,
gint section,
gint position)
{
- //printf("[%p] %s - section: %d - position: %d\n", menu, __FUNCTION__, section, position);
g_return_val_if_fail (G_IS_LO_MENU (menu), NULL);
GVariant *command_value = g_lo_menu_get_attribute_value_from_item_in_section (menu,
@@ -455,7 +429,6 @@ g_lo_menu_set_link (GLOMenu *menu,
const gchar *link,
GMenuModel *model)
{
- //printf("[%p] %s - position: %d - link: %s - model: %p\n", menu, __FUNCTION__, position, link, model);
g_return_if_fail (G_IS_LO_MENU (menu));
g_return_if_fail (link != NULL);
g_return_if_fail (valid_attribute_name (link));
@@ -463,8 +436,6 @@ g_lo_menu_set_link (GLOMenu *menu,
if (position < 0 || position >= (gint) menu->items->len)
position = menu->items->len - 1;
-// printf ("%s - position: %d\n", __FUNCTION__, position);
-
struct item menu_item = g_array_index (menu->items, struct item, position);
if (model != NULL)
@@ -479,7 +450,6 @@ g_lo_menu_insert_section (GLOMenu *menu,
const gchar *label,
GMenuModel *section)
{
- //printf("[%p] %s - position: %d - label: %s - section: %p\n", menu, __FUNCTION__, position, label, section);
g_return_if_fail (G_IS_LO_MENU (menu));
if (position < 0 || position > (gint) menu->items->len)
@@ -502,7 +472,6 @@ g_lo_menu_new_section (GLOMenu *menu,
gint position,
const gchar *label)
{
- //printf("[%p] %s - position: %d - label: %s\n", menu, __FUNCTION__, position, label);
GMenuModel *section = G_MENU_MODEL (g_lo_menu_new());
g_lo_menu_insert_section (menu, position, label, section);
@@ -514,7 +483,6 @@ GLOMenu *
g_lo_menu_get_section (GLOMenu *menu,
gint section)
{
- //printf("[%p] %s - section: %d\n", menu, __FUNCTION__, section);
g_return_val_if_fail (G_IS_LO_MENU (menu), NULL);
return G_LO_MENU (G_MENU_MODEL_CLASS (g_lo_menu_parent_class)
@@ -532,19 +500,18 @@ g_lo_menu_new_submenu_in_item_in_section (GLOMenu *menu,
GLOMenu* model = g_lo_menu_get_section (menu, section);
g_return_if_fail (model != NULL);
- g_return_if_fail (0 <= position && position < model->items->len);
-
- struct item menu_item = g_array_index (model->items, struct item, position);
- GMenuModel* submenu = G_MENU_MODEL (g_lo_menu_new());
+ if (0 <= position && position < (gint) model->items->len) {
+ GMenuModel* submenu = G_MENU_MODEL (g_lo_menu_new());
- g_lo_menu_set_link (model, position, G_MENU_LINK_SUBMENU, submenu);
+ g_lo_menu_set_link (model, position, G_MENU_LINK_SUBMENU, submenu);
- g_object_unref (submenu);
+ g_object_unref (submenu);
- g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 1);
+ g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 1);
- g_object_unref (model);
+ g_object_unref (model);
+ }
}
@@ -554,7 +521,6 @@ g_lo_menu_set_submenu_to_item_in_section (GLOMenu *menu,
gint position,
GMenuModel *submenu)
{
- printf("[%p] %s (begin) - section: %d - position: %d - submenu: %p\n", menu, __FUNCTION__, section, position, submenu);
g_return_if_fail (G_IS_LO_MENU (menu));
g_return_if_fail (0 <= section && section < (gint) menu->items->len);
@@ -568,7 +534,6 @@ g_lo_menu_set_submenu_to_item_in_section (GLOMenu *menu,
g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 1);
g_object_unref (model);
- printf("[%p] %s (end) - section: %d - position: %d - submenu: %p\n", menu, __FUNCTION__, section, position, submenu);
}
GLOMenu *
@@ -576,7 +541,6 @@ g_lo_menu_get_submenu_from_item_in_section (GLOMenu *menu,
gint section,
gint position)
{
- //printf("[%p] %s - section: %d - position: %d\n", menu, __FUNCTION__, section, position);
g_return_val_if_fail (G_IS_LO_MENU (menu), NULL);
g_return_val_if_fail (0 <= section && section < (gint) menu->items->len, NULL);
@@ -587,10 +551,9 @@ g_lo_menu_get_submenu_from_item_in_section (GLOMenu *menu,
GLOMenu *submenu = NULL;
if (0 <= position && position < (gint) model->items->len)
-
- submenu = G_LO_MENU (G_MENU_MODEL_CLASS (g_lo_menu_parent_class)
- ->get_item_link (G_MENU_MODEL (model), position, G_MENU_LINK_SUBMENU));
- //submenu = g_menu_model_get_item_link (G_MENU_MODEL (model), position, G_MENU_LINK_SUBMENU);
+ submenu = G_LO_MENU (G_MENU_MODEL_CLASS (g_lo_menu_parent_class)
+ ->get_item_link (G_MENU_MODEL (model), position, G_MENU_LINK_SUBMENU));
+ //submenu = g_menu_model_get_item_link (G_MENU_MODEL (model), position, G_MENU_LINK_SUBMENU);
g_object_unref (model);
@@ -603,15 +566,12 @@ g_lo_menu_set_submenu_action_to_item_in_section (GLOMenu *menu,
gint position,
const gchar *action)
{
- //printf("[%p] %s - section: %d - position: %d - action: %s\n", menu, __FUNCTION__, section, position, action);
g_return_if_fail (G_IS_LO_MENU (menu));
GMenuModel *model = G_MENU_MODEL (g_lo_menu_get_section (menu, section));
g_return_if_fail (model != NULL);
- g_menu_model_items_changed (model, position, 1, 0);
-
GVariant *value;
if (action != NULL)
@@ -622,7 +582,7 @@ g_lo_menu_set_submenu_action_to_item_in_section (GLOMenu *menu,
g_lo_menu_set_attribute_value (G_LO_MENU (model), position, G_LO_MENU_ATTRIBUTE_SUBMENU_ACTION, value);
// Notify the update.
- g_menu_model_items_changed (model, position, 0, 1);
+ g_menu_model_items_changed (model, position, 1, 1);
g_object_unref (model);
}
@@ -640,7 +600,6 @@ void
g_lo_menu_remove (GLOMenu *menu,
gint position)
{
- //printf("[%p] %s - position: %d\n", menu, __FUNCTION__, position);
g_return_if_fail (G_IS_LO_MENU (menu));
g_return_if_fail (0 <= position && position < (gint) menu->items->len);
@@ -654,7 +613,6 @@ g_lo_menu_remove_from_section (GLOMenu *menu,
gint section,
gint position)
{
- //printf("[%p] %s - section: %d - position: %d\n", menu, __FUNCTION__, section, position);
g_return_if_fail (G_IS_LO_MENU (menu));
g_return_if_fail (0 <= section && section < (gint) menu->items->len);
@@ -670,7 +628,6 @@ g_lo_menu_remove_from_section (GLOMenu *menu,
static void
g_lo_menu_finalize (GObject *object)
{
- //printf("[%p] %s\n", object, __FUNCTION__);
GLOMenu *menu = G_LO_MENU (object);
struct item *items;
gint n_items;
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 24ddc20dccf7..dbbb088870a2 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -571,8 +571,8 @@ void on_registrar_available( GDBusConnection * /*connection*/,
if ( pSalMenu != NULL )
{
GtkSalMenu* pGtkSalMenu = static_cast<GtkSalMenu*>(pSalMenu);
- //pGtkSalMenu->UpdateNativeMenu();
pGtkSalMenu->Display( sal_True );
+ pGtkSalMenu->UpdateNativeMenu();
}
}
@@ -585,24 +585,17 @@ void on_registrar_unavailable( GDBusConnection * /*connection*/,
SAL_INFO("vcl.unity", "on_registrar_unavailable");
- pSessionBus = NULL;
+ //pSessionBus = NULL;
GtkSalFrame* pSalFrame = reinterpret_cast< GtkSalFrame* >( user_data );
SalMenu* pSalMenu = pSalFrame->GetMenu();
if ( pSalMenu ) {
GtkSalMenu* pGtkSalMenu = static_cast< GtkSalMenu* >( pSalMenu );
-// pGtkSalMenu->DisconnectFrame();
pGtkSalMenu->Display( sal_False );
}
}
-void GtkSalFrame::FlushConnection()
-{
- if (pSessionBus)
- g_dbus_connection_flush_sync( pSessionBus, NULL, NULL );
-}
-
void GtkSalFrame::EnsureAppMenuWatch()
{
if ( !m_nWatcherId )
@@ -626,7 +619,7 @@ void GtkSalFrame::EnsureAppMenuWatch()
NULL );
}
- ensure_dbus_setup( this );
+ //ensure_dbus_setup( this );
}
GtkSalFrame::~GtkSalFrame()
@@ -674,8 +667,6 @@ GtkSalFrame::~GtkSalFrame()
SolarMutexGuard aGuard;
if(m_nWatcherId)
g_bus_unwatch_name(m_nWatcherId);
-// if(m_pSalMenu)
-// static_cast<GtkSalMenu*>(m_pSalMenu)->DisconnectFrame();
if( m_pWindow )
{
g_object_set_data( G_OBJECT( m_pWindow ), "SalFrame", NULL );
@@ -684,16 +675,8 @@ GtkSalFrame::~GtkSalFrame()
{
if(m_nMenuExportId)
g_dbus_connection_unexport_menu_model(pSessionBus, m_nMenuExportId);
- //GLOMenu* pMenuModel = G_LO_MENU(g_object_get_data( G_OBJECT( m_pWindow ), "g-lo-menubar" ));
- //if(pMenuModel)
- //g_lo_menu_remove(pMenuModel,0);
- //g_object_unref( pMenuModel );
if(m_nActionGroupExportId)
g_dbus_connection_unexport_action_group(pSessionBus, m_nActionGroupExportId);
- //GLOActionGroup* pActionGroup = G_LO_ACTION_GROUP(g_object_get_data( G_OBJECT( m_pWindow ), "g-lo-action-group" ));
- //if(pActionGroup)
- //g_lo_action_group_clear( pActionGroup );
- //g_object_unref( pActionGroup );
}
gtk_widget_destroy( m_pWindow );
}
@@ -1123,8 +1106,8 @@ void GtkSalFrame::Init( SalFrame* pParent, sal_uLong nStyle )
if( eWinType == GTK_WINDOW_TOPLEVEL )
{
// Enable DBus native menu if available.
-// ensure_dbus_setup( this );
- EnsureAppMenuWatch();
+ 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 3c6ee28640ca..8c488730db02 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -152,34 +152,14 @@ 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);
-// 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;
-
- return true;
+ if ( bMenuVisibility && mpMenuModel && mpActionGroup )
+ return true;
}
return false;
@@ -366,9 +346,8 @@ 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 )
{
@@ -379,7 +358,6 @@ void GtkSalMenu::UpdateNativeMenu()
}
g_object_unref( pSubMenuModel );
-// printf("%s (end) - submenumodel: %p\n", __FUNCTION__, pSubMenuModel);
pSubmenu->SetMenuModel( G_MENU_MODEL( pSubMenuModel ) );
pSubmenu->SetActionGroup( G_ACTION_GROUP( pActionGroup ) );
@@ -388,9 +366,6 @@ void GtkSalMenu::UpdateNativeMenu()
pSubmenu->GetMenu()->Deactivate();
pSubmenu->UpdateNativeMenu();
-
- //pSubmenu->SetMenuModel( NULL );
- //pSubmenu->SetActionGroup( NULL );
}
g_free( aNativeCommand );
@@ -423,8 +398,6 @@ GtkSalMenu::GtkSalMenu( sal_Bool bMenuBar ) :
mpMenuModel( NULL ),
mpActionGroup( NULL )
{
- if (mbMenuBar)
- printf("[%p] %s\n", this, __FUNCTION__);
}
GtkSalMenu::~GtkSalMenu()
@@ -434,23 +407,11 @@ GtkSalMenu::~GtkSalMenu()
if ( mbMenuBar == sal_True )
{
- printf("[%p] %s\n", this, __FUNCTION__);
- //if ( mpFrame )
- // ((GtkSalFrame*) mpFrame)->SetMenu( NULL );
-
if ( mpMenuModel )
{
- g_lo_menu_remove( G_LO_MENU( mpMenuModel ), 0 );
+// 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();
@@ -458,8 +419,7 @@ GtkSalMenu::~GtkSalMenu()
sal_Bool GtkSalMenu::VisibleMenuBar()
{
- //return bMenuVisibility;
- return sal_False;
+ return bMenuVisibility;
}
void GtkSalMenu::InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos )
@@ -509,13 +469,12 @@ void GtkSalMenu::SetFrame( const SalFrame* pFrame )
// actiongroup
mpOldSalMenu = static_cast< GtkSalMenu* >( pFrameNonConst->GetMenu() );
pFrameNonConst->SetMenu( this );
+ pFrameNonConst->EnsureAppMenuWatch();
// Clean menu model and action group if needed.
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" ) );
@@ -524,10 +483,7 @@ void GtkSalMenu::SetFrame( const SalFrame* pFrame )
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 )
@@ -536,15 +492,11 @@ void GtkSalMenu::SetFrame( const SalFrame* pFrame )
mpActionGroup = G_ACTION_GROUP( pActionGroup );
}
- //pFrameNonConst->FlushConnection();
-
// Generate the main menu structure.
- UpdateNativeMenu();
- g_lo_menu_insert_section( pMenuModel, 0, NULL, mpMenuModel );
-
- //pFrameNonConst->FlushConnection();
+ if (bMenuVisibility)
+ UpdateNativeMenu();
- printf("[%p] %s - frame: %p - menu export id: %d - action group export id: %d\n", this, __FUNCTION__, pFrame, pFrameNonConst->m_nMenuExportId, pFrameNonConst->m_nActionGroupExportId);
+ g_lo_menu_insert_section( pMenuModel, 0, NULL, mpMenuModel );
}
const GtkSalFrame* GtkSalMenu::GetFrame() const
@@ -737,8 +689,6 @@ 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;
@@ -758,7 +708,6 @@ void GtkSalMenu::Activate( const gchar* aMenuCommand )
MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu );
pMenuBar->HandleMenuActivateEvent( pSalSubMenu->mpVCLMenu );
pSalSubMenu->UpdateNativeMenu();
- //((GtkSalFrame*) mpFrame)->FlushConnection();
}
}
@@ -775,16 +724,6 @@ 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 )