diff options
author | Antonio Fernandez <antonio.fernandez@aentos.es> | 2012-07-30 13:11:09 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2012-11-14 13:52:39 +0100 |
commit | 818acaaa0d77e363c74112c435ab8bea425f34ae (patch) | |
tree | 9c204378f89a0951f8bf18284ffb1241c79114c5 /vcl/source | |
parent | a09c7f8e2b4d717bb488040ca096ee79c3e07609 (diff) |
Menubar hierarchy fully generated. Native GTK menu is published on DBus.
Change-Id: I340d3e14b590b4a694082cfb3e2200d6ad8ef39a
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/window/menu.cxx | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index a759dfe03727..103719a54659 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -6040,8 +6040,66 @@ ImplMenuDelData::~ImplMenuDelData() } #include <iostream> +#include <gio/gio.h> + using namespace std; +GMenu* generateMenuBar( AbstractMenu *pMenu ) +{ + GMenu *menu = g_menu_new(); + + g_menu_append(menu, "Submenu1", NULL); + + return menu; +} + +#define BUS_NAME "org.libreoffice.LibreOffice" +#define OBJ_PATH "/org/libreoffice/LibreOffice" + +void publishMenu( GMenuModel *menu ) +{ + GActionGroup *group; + GDBusConnection *bus; + GError *error = NULL; + gchar *path; + guint id; + + bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); + group = G_ACTION_GROUP( g_simple_action_group_new() ); + + // g_print ("Exporting menus on the bus...\n"); + // if (!g_dbus_connection_export_menu_model (bus, OBJ_PATH, menu, &error)) + // { + // g_warning ("Menu export failed: %s", error->message); + // exit (1); + // } + // g_print ("Exporting actions on the bus...\n"); + // if (!g_dbus_connection_export_action_group (bus, OBJ_PATH, group, &error)) + // { + // g_warning ("Action export failed: %s", error->message); + // exit (1); + // } + + g_bus_own_name_on_connection (bus, BUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL); + + + /* export the new menu, if there is one */ + if (menu != NULL) + { + /* try getting the preferred name */ + path = g_strconcat (OBJ_PATH, "/menus/", "menubar", NULL); + id = g_dbus_connection_export_menu_model (bus, path, menu, NULL); + + /* keep trying until we get a working name... */ + for (int i = 0; id == 0; i++) + { + g_free (path); + path = g_strdup_printf ("%s/menus/%s%d",OBJ_PATH, "menubar", i); + id = g_dbus_connection_export_menu_model (bus, path, menu, NULL); + } + } +} + void printMenu( AbstractMenu* pMenu ) { if ( pMenu ) { sal_uInt16 itemCount = pMenu->GetItemCount(); @@ -6060,6 +6118,7 @@ void printMenu( AbstractMenu* pMenu ) { if (itemData->pSubMenu) { cout << ">> SUBMENU <<" << endl; + itemData->pSubMenu->Activate(); printMenu( itemData->pSubMenu ); } } @@ -6069,6 +6128,9 @@ void printMenu( AbstractMenu* pMenu ) { void Menu::Freeze() { printMenu( this ); + +// GMenuModel *menu = G_MENU_MODEL( generateMenuBar(this) ); +// publishMenu( menu ); cout << "============================================================" << endl; } |