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

Proposed by Ted Gould
Status: Merged
Merged at revision: 120
Proposed branch: lp:~ted/appmenu-gtk/alt-to-alert
Merge into: lp:appmenu-gtk/0.4
Diff against target: 120 lines (+53/-3)
2 files modified
configure.ac (+1/-1)
src/bridge.c (+52/-2)
To merge this branch: bzr merge lp:~ted/appmenu-gtk/alt-to-alert
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+51645@code.launchpad.net

Description of the change

When the appropriate key is used to show the mnemonics we should allert the menu bar to show the menus.

To post a comment you must log in.
Revision history for this message
Conor Curran (cjcurran) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2011-02-11 15:11:35 +0000
3+++ configure.ac 2011-02-28 22:41:48 +0000
4@@ -1,6 +1,6 @@
5 AC_PREREQ(2.59)
6
7-AC_INIT([appmenu-gtk], [0.1.93], [crussell@canonical.com])
8+AC_INIT([appmenu-gtk], [0.1.94], [crussell@canonical.com])
9 AC_COPYRIGHT([Copyright 2010 Canonical])
10 AC_CONFIG_SRCDIR([src/bridge.c])
11 AC_CONFIG_MACRO_DIR([build/autotools])
12
13=== modified file 'src/bridge.c'
14--- src/bridge.c 2011-02-11 13:59:10 +0000
15+++ src/bridge.c 2011-02-28 22:41:48 +0000
16@@ -40,6 +40,8 @@
17 #define APP_MENU_INTERFACE "com.canonical.AppMenu.Registrar"
18 #define APP_MENU_PATH "/this/is/a/long/object/path"
19
20+typedef struct _AppWindowContext AppWindowContext;
21+
22 static void app_menu_bridge_insert (UbuntuMenuProxy *proxy,
23 GtkWidget *shell,
24 GtkWidget *child,
25@@ -47,6 +49,9 @@
26 static gboolean app_menu_bridge_show_local (UbuntuMenuProxy *proxy);
27 static void toplevel_realized (GtkWidget *widget,
28 gpointer user_data);
29+static void mnemonic_shown_cb (GtkWidget *widget,
30+ GParamSpec *pspec,
31+ AppWindowContext *context);
32 static void toplevel_notify_cb (GtkWidget *widget,
33 GParamSpec *pspec,
34 UbuntuMenuProxy *proxy);
35@@ -60,8 +65,6 @@
36 GAsyncResult * res,
37 gpointer user_data);
38
39-typedef struct _AppWindowContext AppWindowContext;
40-
41 struct _AppWindowContext
42 {
43 GtkWidget *window;
44@@ -177,6 +180,12 @@
45 context->server = NULL;
46 }
47
48+ if (context->window != NULL)
49+ {
50+ g_signal_handlers_disconnect_by_func(context->window, G_CALLBACK(mnemonic_shown_cb), context);
51+ g_object_remove_weak_pointer(G_OBJECT(context->window), (gpointer *)&(context->window));
52+ }
53+
54 if (context->lookup)
55 {
56 g_hash_table_unref (context->lookup);
57@@ -532,6 +541,34 @@
58 return NULL;
59 }
60
61+/* Respond to changing of the mnemonics shown property to say
62+ to the appmenu wether we need to have the menus shown on the
63+ panel. If there is no auto-mnemonics in this theme we're just
64+ not doing this as we can't tell what the user wanted. */
65+static void
66+mnemonic_shown_cb (GtkWidget *widget,
67+ GParamSpec *pspec,
68+ AppWindowContext *context)
69+{
70+ DbusmenuStatus dstatus = DBUSMENU_STATUS_NORMAL;
71+ if (context->window != NULL) {
72+ gboolean mshown = gtk_window_get_mnemonics_visible(GTK_WINDOW(context->window));
73+ gboolean autom;
74+
75+ g_object_get(gtk_widget_get_settings(context->window), "gtk-auto-mnemonics", &autom, NULL);
76+
77+ if (autom && mshown) {
78+ dstatus = DBUSMENU_STATUS_NOTICE;
79+ }
80+ }
81+
82+ if (context->server != NULL) {
83+ /* g_debug("Setting dbusmenu server status to: %d", dstatus); */
84+ dbusmenu_server_set_status(context->server, dstatus);
85+ }
86+
87+ return;
88+}
89
90 static void
91 rebuild_window_items (AppMenuBridge *bridge,
92@@ -615,8 +652,14 @@
93
94 if (context->window != toplevel)
95 {
96+ if (context->window != NULL) {
97+ g_object_remove_weak_pointer(G_OBJECT(context->window), (gpointer *)&(context->window));
98+ g_signal_handlers_disconnect_by_func(context->window, G_CALLBACK(mnemonic_shown_cb), context);
99+ }
100+
101 context->window = toplevel;
102
103+ g_object_add_weak_pointer(G_OBJECT(context->window), (gpointer *)&(context->window));
104 g_signal_connect (toplevel,
105 "destroy",
106 G_CALLBACK (toplevel_destroyed),
107@@ -629,6 +672,13 @@
108 if (!context->server)
109 context->server = dbusmenu_server_new (context->path);
110
111+ if (context->window != NULL) {
112+ g_signal_connect (G_OBJECT (toplevel),
113+ "notify::mnemonics-visible",
114+ G_CALLBACK (mnemonic_shown_cb),
115+ context);
116+ }
117+
118 DbusmenuMenuitem * mi = find_menu_bar(toplevel);
119 dbusmenu_server_set_root(context->server, mi);
120 if (mi != NULL) {

Subscribers

People subscribed via source and target branches