[Libreoffice-commits] .: Branch 'feature/unitymenus-quantal' - 5 commits - vcl/inc vcl/Library_vclplug_gtk3.mk vcl/Library_vclplug_gtk.mk vcl/unx
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Oct 30 08:57:27 PDT 2012
vcl/Library_vclplug_gtk.mk | 1
vcl/Library_vclplug_gtk3.mk | 1
vcl/inc/unx/gtk/gtkframe.hxx | 1
vcl/inc/unx/gtk/hudawareness.h | 45 +++++++++++
vcl/unx/gtk/window/gtkframe.cxx | 28 +++++-
vcl/unx/gtk/window/gtksalmenu.cxx | 51 +++++-------
vcl/unx/gtk/window/hudawareness.cxx | 126 +++++++++++++++++++++++++++++++
vcl/unx/gtk3/window/gtk3hudawareness.cxx | 1
8 files changed, 222 insertions(+), 32 deletions(-)
New commits:
commit 6831d028d77ee073983c30db5b78afa720d7a428
Author: Antonio Fernandez <antonio.fernandez at aentos.es>
Date: Fri Oct 26 12:58:56 2012 +0100
Menu is fully updated when receiving a HUD activation event.
Change-Id: I4d275bc01ac0baa265d22dcd849020e8f51fc447
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 124f149..a97b376 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -524,7 +524,14 @@ static void ObjectDestroyedNotify( gpointer data )
static void hud_activated( gboolean hud_active, gpointer user_data )
{
- printf("HUD active state: %d\n", hud_active);
+ if ( hud_activated )
+ {
+ GtkSalFrame* pSalFrame = reinterpret_cast< GtkSalFrame* >( user_data );
+ GtkSalMenu* pSalMenu = reinterpret_cast< GtkSalMenu* >( pSalFrame->GetMenu() );
+
+ if ( pSalMenu )
+ pSalMenu->UpdateFull();
+ }
}
gboolean ensure_dbus_setup( gpointer data )
commit 8d8335176631f6fbf01692472cff5fbc32c80349
Author: Antonio Fernandez <antonio.fernandez at aentos.es>
Date: Wed Oct 24 17:36:59 2012 +0100
Menu is now subscribed to HUD awareness protocol events.
Change-Id: I0649ac50a93b3b6379642fac4d5d532d46251d72
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 8c3f76e..a07cd94 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -226,7 +226,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_nHudAwarenessId;
void Init( SalFrame* pParent, sal_uLong nStyle );
void Init( SystemParentData* pSysData );
@@ -313,6 +312,7 @@ public:
guint m_nMenuExportId;
guint m_nActionGroupExportId;
+ guint m_nHudAwarenessId;
// dispatches an event, returns true if dispatched
// and false else; if true was returned the event should
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index ebf1010..124f149 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -522,6 +522,11 @@ static void ObjectDestroyedNotify( gpointer data )
}
}
+static void hud_activated( gboolean hud_active, gpointer user_data )
+{
+ printf("HUD active state: %d\n", hud_active);
+}
+
gboolean ensure_dbus_setup( gpointer data )
{
GtkSalFrame* pSalFrame = reinterpret_cast< GtkSalFrame* >( data );
@@ -558,6 +563,7 @@ gboolean ensure_dbus_setup( gpointer data )
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);
+ pSalFrame->m_nHudAwarenessId = hud_awareness_register( pSessionBus, aDBusMenubarPath, hud_activated, pSalFrame, NULL, NULL );
g_free( aDBusPath );
g_free( aDBusWindowPath );
@@ -683,10 +689,12 @@ GtkSalFrame::~GtkSalFrame()
if ( pSessionBus )
{
- if(m_nMenuExportId)
- g_dbus_connection_unexport_menu_model(pSessionBus, m_nMenuExportId);
- if(m_nActionGroupExportId)
- g_dbus_connection_unexport_action_group(pSessionBus, m_nActionGroupExportId);
+ if ( m_nHudAwarenessId )
+ hud_awareness_unregister( pSessionBus, m_nHudAwarenessId );
+ if ( m_nMenuExportId )
+ g_dbus_connection_unexport_menu_model( pSessionBus, m_nMenuExportId );
+ if ( m_nActionGroupExportId )
+ g_dbus_connection_unexport_action_group( pSessionBus, m_nActionGroupExportId );
}
gtk_widget_destroy( m_pWindow );
}
@@ -804,6 +812,9 @@ void GtkSalFrame::InitCommon()
m_bSetFocusOnMap = false;
m_pSalMenu = NULL;
m_nWatcherId = 0;
+ m_nMenuExportId = 0;
+ m_nActionGroupExportId = 0;
+ m_nHudAwarenessId = 0;
gtk_widget_set_app_paintable( m_pWindow, TRUE );
gtk_widget_set_double_buffered( m_pWindow, FALSE );
@@ -1117,7 +1128,6 @@ void GtkSalFrame::Init( SalFrame* pParent, sal_uLong nStyle )
{
// 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 )
commit cc0b38458e71247c41df516f9cd9b1ab1473641a
Author: Antonio Fernandez <antonio.fernandez at aentos.es>
Date: Wed Oct 24 17:17:27 2012 +0100
Added missing files for HUD awareness support.
Change-Id: If3544734e8c4a1c632a24976e9340ef84869d22a
diff --git a/vcl/inc/unx/gtk/hudawareness.h b/vcl/inc/unx/gtk/hudawareness.h
new file mode 100644
index 0000000..47c5f90
--- /dev/null
+++ b/vcl/inc/unx/gtk/hudawareness.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright © 2012 Canonical Ltd.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *
+ * Author: Ryan Lortie <desrt at desrt.ca>
+ */
+
+#ifndef _hudawareness_h_
+#define _hudawareness_h_
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+typedef void (* HudAwarenessCallback) (gboolean hud_active,
+ gpointer user_data);
+
+
+guint hud_awareness_register (GDBusConnection *connection,
+ const gchar *object_path,
+ HudAwarenessCallback callback,
+ gpointer user_data,
+ GDestroyNotify notify,
+ GError **error);
+
+void hud_awareness_unregister (GDBusConnection *connection,
+ guint awareness_id);
+
+G_END_DECLS
+
+#endif /* _hudawareness_h_ */
diff --git a/vcl/unx/gtk/window/hudawareness.cxx b/vcl/unx/gtk/window/hudawareness.cxx
new file mode 100644
index 0000000..b36f553
--- /dev/null
+++ b/vcl/unx/gtk/window/hudawareness.cxx
@@ -0,0 +1,126 @@
+/*
+ * Copyright © 2012 Canonical Ltd.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *
+ * Author: Ryan Lortie <desrt at desrt.ca>
+ */
+
+#include <unx/gtk/hudawareness.h>
+
+typedef struct
+{
+ GDBusConnection *connection;
+ HudAwarenessCallback callback;
+ gpointer user_data;
+ GDestroyNotify notify;
+} HudAwarenessHandle;
+
+static void
+hud_awareness_method_call (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ HudAwarenessHandle *handle = (HudAwarenessHandle*) user_data;
+
+ if (g_str_equal (method_name, "HudActiveChanged"))
+ {
+ gboolean active;
+
+ g_variant_get (parameters, "(b)", &active);
+
+ (* handle->callback) (active, handle->user_data);
+ }
+
+ g_dbus_method_invocation_return_value (invocation, NULL);
+}
+
+static void
+hud_awareness_handle_free (gpointer data)
+{
+ HudAwarenessHandle *handle = (HudAwarenessHandle*) data;
+
+ g_object_unref (handle->connection);
+
+ if (handle->notify)
+ (* handle->notify) (handle->user_data);
+
+ g_slice_free (HudAwarenessHandle, handle);
+}
+
+guint
+hud_awareness_register (GDBusConnection *connection,
+ const gchar *object_path,
+ HudAwarenessCallback callback,
+ gpointer user_data,
+ GDestroyNotify notify,
+ GError **error)
+{
+ static GDBusInterfaceInfo *iface;
+ GDBusInterfaceVTable vtable = {
+ hud_awareness_method_call
+ };
+ HudAwarenessHandle *handle;
+ guint object_id;
+
+ if G_UNLIKELY (iface == NULL)
+ {
+ GError *error = NULL;
+ GDBusNodeInfo *info;
+
+ info = g_dbus_node_info_new_for_xml ("<node>"
+ "<interface name='com.canonical.hud.Awareness'>"
+ "<method name='CheckAwareness'/>"
+ "<method name='HudActiveChanged'>"
+ "<arg type='b'/>"
+ "</method>"
+ "</interface>"
+ "</node>",
+ &error);
+ g_assert_no_error (error);
+ iface = g_dbus_node_info_lookup_interface (info, "com.canonical.hud.Awareness");
+ g_assert (iface != NULL);
+ }
+
+ handle = g_slice_new (HudAwarenessHandle);
+
+ object_id = g_dbus_connection_register_object (connection, object_path, iface, &vtable, handle, NULL, error);
+
+ if (object_id == 0)
+ {
+ g_slice_free (HudAwarenessHandle, handle);
+ return 0;
+ }
+
+ handle->connection = (GDBusConnection*) g_object_ref (connection);
+ handle->callback = callback;
+ handle->user_data = user_data;
+ handle->notify = notify;
+
+ return object_id;
+}
+
+void
+hud_awareness_unregister (GDBusConnection *connection,
+ guint subscription_id)
+{
+ g_dbus_connection_unregister_object (connection, subscription_id);
+}
diff --git a/vcl/unx/gtk3/window/gtk3hudawareness.cxx b/vcl/unx/gtk3/window/gtk3hudawareness.cxx
new file mode 100644
index 0000000..1a22211
--- /dev/null
+++ b/vcl/unx/gtk3/window/gtk3hudawareness.cxx
@@ -0,0 +1 @@
+#include "../../gtk/window/hudawareness.cxx"
commit f1400c2db8ca7b02513ff8a1340703b56197c712
Author: Antonio Fernandez <antonio.fernandez at aentos.es>
Date: Wed Oct 24 17:15:57 2012 +0100
Added files to implement HUD awareness protocol support.
Change-Id: I1ce292811b0ac53c35b5a9026a1c1a4f4ef02cf4
diff --git a/vcl/Library_vclplug_gtk.mk b/vcl/Library_vclplug_gtk.mk
index c4cce2a..e95de0a 100644
--- a/vcl/Library_vclplug_gtk.mk
+++ b/vcl/Library_vclplug_gtk.mk
@@ -102,6 +102,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gtk,\
vcl/unx/gtk/window/gloactiongroup \
vcl/unx/gtk/window/gtksalmenu \
vcl/unx/gtk/window/glomenu \
+ vcl/unx/gtk/window/hudawareness \
vcl/unx/gtk/fpicker/resourceprovider \
vcl/unx/gtk/fpicker/SalGtkPicker \
vcl/unx/gtk/fpicker/SalGtkFilePicker \
diff --git a/vcl/Library_vclplug_gtk3.mk b/vcl/Library_vclplug_gtk3.mk
index fd66689..6ca6da6 100644
--- a/vcl/Library_vclplug_gtk3.mk
+++ b/vcl/Library_vclplug_gtk3.mk
@@ -113,6 +113,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gtk3,\
vcl/unx/gtk3/window/gtk3gtksalmenu \
vcl/unx/gtk3/window/gtk3glomenu \
vcl/unx/gtk3/window/gtk3gloactiongroup \
+ vcl/unx/gtk3/window/gtk3hudawareness \
))
$(eval $(call gb_Library_use_static_libraries,vclplug_gtk3,\
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 93b043d..8c3f76e 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -226,6 +226,7 @@ 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_nHudAwarenessId;
void Init( SalFrame* pParent, sal_uLong nStyle );
void Init( SystemParentData* pSysData );
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 4b27b7d..ebf1010 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -34,6 +34,7 @@
#include <unx/gtk/glomenu.h>
#include <unx/gtk/gloactiongroup.h>
#include <unx/gtk/gtksalmenu.hxx>
+#include <unx/gtk/hudawareness.h>
#include <vcl/keycodes.hxx>
#include <unx/wmadaptor.hxx>
#include <unx/sm.hxx>
commit 75e162a7b7b8baadf61b2bda7611c48efe6b0f94
Author: Antonio Fernandez <antonio.fernandez at aentos.es>
Date: Fri Oct 26 13:21:49 2012 +0100
Duplicated commands are now handled properly.
Change-Id: I80dd2d05060dcad3c6375a4e1c7b2109e451169b
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx
index a6295c4..4b9a358 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -40,10 +40,10 @@
static sal_Bool bMenuVisibility = sal_False;
/*
- * This function generates an alternative command name to avoid name collisions
- * or to give a valid command name to certain menu items.
+ * This function generates the proper command name for all actions, including
+ * duplicated or special ones.
*/
-static gchar* GetCommandForSpecialItem( GtkSalMenuItem* pSalMenuItem )
+static gchar* GetCommandForItem( GtkSalMenuItem* pSalMenuItem, gchar* aCurrentCommand, GActionGroup* pActionGroup )
{
gchar* aCommand = NULL;
@@ -54,15 +54,28 @@ static gchar* GetCommandForSpecialItem( GtkSalMenuItem* pSalMenuItem )
if ( ( nId >= START_ITEMID_WINDOWLIST ) && ( nId <= END_ITEMID_WINDOWLIST ) )
aCommand = g_strdup_printf( "window-%d", nId );
else
- if ( pMenu )
+ {
+ if ( !pMenu )
+ return NULL;
+
+ rtl::OUString aMenuCommand = pMenu->GetItemCommand( nId );
+ gchar* aCommandStr = g_strdup( rtl::OUStringToOString( aMenuCommand, RTL_TEXTENCODING_UTF8 ).getStr() );
+ aCommand = g_strdup( aCommandStr );
+
+ // Some items could have duplicated commands. A new one should be generated.
+ for ( sal_uInt16 i = 2; ; i++ )
{
- rtl::OUString aMenuCommand = pMenu->GetItemCommand( nId );
- MenuItemBits nBits = pMenu->GetItemBits( nId );
+ if ( !g_action_group_has_action( pActionGroup, aCommand )
+ || ( aCurrentCommand && g_strcmp0( aCurrentCommand, aCommand ) == 0 ) )
+ break;
- if ( aMenuCommand.equalsAscii(".uno:Presentation") && nBits == 0 )
- aCommand = g_strdup(".uno:Presentation2");
+ g_free( aCommand );
+ aCommand = g_strdup_printf("%s%d", aCommandStr, i);
}
+ g_free( aCommandStr );
+ }
+
return aCommand;
}
@@ -244,7 +257,6 @@ void RemoveUnusedCommands( GLOActionGroup* pActionGroup, GList* pOldCommandList,
void GtkSalMenu::ImplUpdate( gboolean bRecurse )
{
SolarMutexGuard aGuard;
- //GTK_YIELD_GRAB();
if( !PrepUpdate() )
return;
@@ -304,8 +316,6 @@ void GtkSalMenu::ImplUpdate( gboolean bRecurse )
// Convert internal values to native values.
gboolean bChecked = ( itemChecked == sal_True ) ? TRUE : FALSE;
gboolean bEnabled = ( itemEnabled == sal_True ) ? TRUE : FALSE;
-// gchar* aNativeCommand = g_strdup( rtl::OUStringToOString( aCommand, RTL_TEXTENCODING_UTF8 ).getStr() );
- gchar* aNativeCommand = GetCommandForSpecialItem( pSalMenuItem );
// Store current item command in command list.
gchar *aCurrentCommand = g_lo_menu_get_command_from_item_in_section( pLOMenu, nSection, nItemPos );
@@ -313,24 +323,13 @@ void GtkSalMenu::ImplUpdate( gboolean bRecurse )
if ( aCurrentCommand != NULL )
pOldCommandList = g_list_append( pOldCommandList, aCurrentCommand );
+ // Get the new command for the item.
+ gchar* aNativeCommand = GetCommandForItem( pSalMenuItem, aCurrentCommand, mpActionGroup );
+
// Force updating of native menu labels.
NativeSetItemText( nSection, nItemPos, aText );
NativeSetAccelerator( nSection, nItemPos, nAccelKey, nAccelKey.GetName( GetFrame()->GetWindow() ) );
- // Some items are special, so they have different commands.
-// if ( g_strcmp0( aNativeCommand, "" ) == 0 )
- if ( !aNativeCommand )
- {
-// gchar *aSpecialItemCmd = GetCommandForSpecialItem( pSalMenuItem );
- aNativeCommand = g_strdup( rtl::OUStringToOString( aCommand, RTL_TEXTENCODING_UTF8 ).getStr() );
-
-// if ( aSpecialItemCmd != NULL )
-// {
-// g_free( aNativeCommand );
-// aNativeCommand = aSpecialItemCmd;
-// }
- }
-
if ( g_strcmp0( aNativeCommand, "" ) != 0 && pSalMenuItem->mpSubMenu == NULL )
{
NativeSetItemCommand( nSection, nItemPos, nId, aNativeCommand, itemBits, bChecked, FALSE );
@@ -351,8 +350,6 @@ void GtkSalMenu::ImplUpdate( gboolean bRecurse )
if ( pSubMenuModel == NULL )
{
- //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 );
}
More information about the Libreoffice-commits
mailing list