← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~ted/appmenu-gtk/alt-to-alert into lp:appmenu-gtk

 

Ted Gould has proposed merging lp:~ted/appmenu-gtk/alt-to-alert into lp:appmenu-gtk.

Requested reviews:
  Canonical Desktop Experience Team (canonical-dx-team)

For more details, see:
https://code.launchpad.net/~ted/appmenu-gtk/alt-to-alert/+merge/51645

When the appropriate key is used to show the mnemonics we should allert the menu bar to show the menus.
-- 
https://code.launchpad.net/~ted/appmenu-gtk/alt-to-alert/+merge/51645
Your team ayatana-commits is subscribed to branch lp:appmenu-gtk.
=== modified file 'configure.ac'
--- configure.ac	2011-02-11 15:11:35 +0000
+++ configure.ac	2011-02-28 22:41:48 +0000
@@ -1,6 +1,6 @@
 AC_PREREQ(2.59)
 
-AC_INIT([appmenu-gtk], [0.1.93], [crussell@xxxxxxxxxxxxx])
+AC_INIT([appmenu-gtk], [0.1.94], [crussell@xxxxxxxxxxxxx])
 AC_COPYRIGHT([Copyright 2010 Canonical])
 AC_CONFIG_SRCDIR([src/bridge.c])
 AC_CONFIG_MACRO_DIR([build/autotools])

=== modified file 'src/bridge.c'
--- src/bridge.c	2011-02-11 13:59:10 +0000
+++ src/bridge.c	2011-02-28 22:41:48 +0000
@@ -40,6 +40,8 @@
 #define APP_MENU_INTERFACE   "com.canonical.AppMenu.Registrar"
 #define APP_MENU_PATH        "/this/is/a/long/object/path"
 
+typedef struct _AppWindowContext AppWindowContext;
+
 static void app_menu_bridge_insert         (UbuntuMenuProxy   *proxy,
                                             GtkWidget         *shell,
                                             GtkWidget         *child,
@@ -47,6 +49,9 @@
 static gboolean app_menu_bridge_show_local (UbuntuMenuProxy   *proxy);
 static void     toplevel_realized          (GtkWidget         *widget,
                                             gpointer           user_data);
+static void     mnemonic_shown_cb          (GtkWidget         *widget,
+                                            GParamSpec        *pspec,
+                                            AppWindowContext  *context);
 static void     toplevel_notify_cb         (GtkWidget         *widget,
                                             GParamSpec        *pspec,
                                             UbuntuMenuProxy   *proxy);
@@ -60,8 +65,6 @@
                                             GAsyncResult *     res,
                                             gpointer           user_data);
 
-typedef struct _AppWindowContext AppWindowContext;
-
 struct _AppWindowContext
 {
   GtkWidget        *window;
@@ -177,6 +180,12 @@
       context->server = NULL;
     }
 
+  if (context->window != NULL)
+    {
+      g_signal_handlers_disconnect_by_func(context->window, G_CALLBACK(mnemonic_shown_cb), context);
+      g_object_remove_weak_pointer(G_OBJECT(context->window), (gpointer *)&(context->window));
+    }
+
   if (context->lookup)
     {
       g_hash_table_unref (context->lookup);
@@ -532,6 +541,34 @@
 	return NULL;
 }
 
+/* Respond to changing of the mnemonics shown property to say
+   to the appmenu wether we need to have the menus shown on the
+   panel.  If there is no auto-mnemonics in this theme we're just
+   not doing this as we can't tell what the user wanted. */
+static void
+mnemonic_shown_cb (GtkWidget       *widget,
+                    GParamSpec      *pspec,
+                    AppWindowContext *context)
+{
+	DbusmenuStatus dstatus = DBUSMENU_STATUS_NORMAL;
+	if (context->window != NULL) {
+		gboolean mshown = gtk_window_get_mnemonics_visible(GTK_WINDOW(context->window));
+		gboolean autom;
+
+		g_object_get(gtk_widget_get_settings(context->window), "gtk-auto-mnemonics", &autom, NULL);
+
+		if (autom && mshown) {
+			dstatus = DBUSMENU_STATUS_NOTICE;
+		}
+	}
+
+	if (context->server != NULL) {
+		/* g_debug("Setting dbusmenu server status to: %d", dstatus); */
+		dbusmenu_server_set_status(context->server, dstatus);
+	}
+
+	return;
+}
 
 static void
 rebuild_window_items (AppMenuBridge *bridge,
@@ -615,8 +652,14 @@
 
   if (context->window != toplevel)
     {
+      if (context->window != NULL) {
+        g_object_remove_weak_pointer(G_OBJECT(context->window), (gpointer *)&(context->window));
+        g_signal_handlers_disconnect_by_func(context->window, G_CALLBACK(mnemonic_shown_cb), context);
+      }
+
       context->window = toplevel;
 
+      g_object_add_weak_pointer(G_OBJECT(context->window), (gpointer *)&(context->window));
       g_signal_connect (toplevel,
                         "destroy",
                         G_CALLBACK (toplevel_destroyed),
@@ -629,6 +672,13 @@
   if (!context->server)
     context->server = dbusmenu_server_new (context->path);
 
+  if (context->window != NULL) {
+    g_signal_connect (G_OBJECT (toplevel),
+                      "notify::mnemonics-visible",
+                      G_CALLBACK (mnemonic_shown_cb),
+                      context);
+  }
+
   DbusmenuMenuitem * mi = find_menu_bar(toplevel);
   dbusmenu_server_set_root(context->server, mi);
   if (mi != NULL) {


Follow ups