Merge lp:~mterry/indicator-appmenu/emit-show-now-changed into lp:indicator-appmenu/0.3

Proposed by Michael Terry
Status: Merged
Merged at revision: 108
Proposed branch: lp:~mterry/indicator-appmenu/emit-show-now-changed
Merge into: lp:indicator-appmenu/0.3
Diff against target: 176 lines (+67/-0)
3 files modified
src/indicator-appmenu.c (+37/-0)
src/window-menus.c (+26/-0)
src/window-menus.h (+4/-0)
To merge this branch: bzr merge lp:~mterry/indicator-appmenu/emit-show-now-changed
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+52583@code.launchpad.net

Description of the change

This branch notices changes in its client window Status property and turns them into emissions of show-now-changed on the IndicatorObject. This is in the service of making Alt presses show the appmenu.

This branch requires [1] to work at all and [2] to be useful.

[1] https://code.launchpad.net/~mterry/dbusmenu/wrap-propertieschanged/+merge/52581
[2] https://code.launchpad.net/~mterry/dbusmenu/pass-mnemonics/+merge/52577

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

On Tue, 2011-03-08 at 17:16 +0000, Michael Terry wrote:
> + /* Set up initial state for new entries if needed */
> + if (window_menus_get_status (iapp->default_app) != DBUSMENU_STATUS_NORMAL) {
> + window_status_changed (iapp->default_app,
> + window_menus_get_status (iapp->default_app),
> + iapp);
> + }

I think that we need to ensure that the one we're switching from wasn't
setting the status to alert as well. I think that the best way to do
this to track the state and see if it changes as we change menus.

  review needsfixing

review: Needs Fixing
Revision history for this message
Michael Terry (mterry) wrote :

But right before that bit of code, we removed all entries, so there shouldn't be a problem.

Though there is a bug, because that bit is called before we set up the new entries, so it when it iterates over entries, they won't have been added yet. I can fix that, but I'm not sure I grok the issue you mentioned.

Revision history for this message
Michael Terry (mterry) wrote :

There. Now the code won't notify about new entries' statuses before notifying that the new entries even exist.

But I still don't think we have to worry about old entries' statuses, because we've already notified that we removed them.

109. By Michael Terry

notify about new entries' statuses after adding new entries, not before

Revision history for this message
Ted Gould (ted) wrote :

I agree, I had forgot that we were deleting them so that would effectively invalidate their status. Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-appmenu.c'
2--- src/indicator-appmenu.c 2011-02-17 20:09:37 +0000
3+++ src/indicator-appmenu.c 2011-03-09 14:18:09 +0000
4@@ -90,6 +90,7 @@
5
6 gulong sig_entry_added;
7 gulong sig_entry_removed;
8+ gulong sig_status_changed;
9 gulong sig_show_menu;
10 gulong sig_a11y_update;
11
12@@ -166,6 +167,9 @@
13 static void window_entry_removed (WindowMenus * mw,
14 IndicatorObjectEntry * entry,
15 gpointer user_data);
16+static void window_status_changed (WindowMenus * mw,
17+ DbusmenuStatus status,
18+ IndicatorAppmenu * iapp);
19 static void window_show_menu (WindowMenus * mw,
20 IndicatorObjectEntry * entry,
21 guint timestamp,
22@@ -1088,6 +1092,10 @@
23 g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_entry_removed);
24 iapp->sig_entry_removed = 0;
25 }
26+ if (iapp->sig_status_changed != 0) {
27+ g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_status_changed);
28+ iapp->sig_status_changed = 0;
29+ }
30 if (iapp->sig_show_menu != 0) {
31 g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_show_menu);
32 iapp->sig_show_menu = 0;
33@@ -1117,6 +1125,10 @@
34 WINDOW_MENUS_SIGNAL_ENTRY_REMOVED,
35 G_CALLBACK(window_entry_removed),
36 iapp);
37+ iapp->sig_status_changed = g_signal_connect(G_OBJECT(iapp->default_app),
38+ WINDOW_MENUS_SIGNAL_STATUS_CHANGED,
39+ G_CALLBACK(window_status_changed),
40+ iapp);
41 iapp->sig_show_menu = g_signal_connect(G_OBJECT(iapp->default_app),
42 WINDOW_MENUS_SIGNAL_SHOW_MENU,
43 G_CALLBACK(window_show_menu),
44@@ -1154,6 +1166,14 @@
45
46 g_list_free(entry_head);
47
48+ /* Set up initial state for new entries if needed */
49+ if (iapp->default_app != NULL &&
50+ window_menus_get_status (iapp->default_app) != DBUSMENU_STATUS_NORMAL) {
51+ window_status_changed (iapp->default_app,
52+ window_menus_get_status (iapp->default_app),
53+ iapp);
54+ }
55+
56 return;
57 }
58
59@@ -1394,6 +1414,23 @@
60 return;
61 }
62
63+/* Pass up the status changed event */
64+static void
65+window_status_changed (WindowMenus * mw, DbusmenuStatus status, IndicatorAppmenu * iapp)
66+{
67+ gboolean show_now = (status == DBUSMENU_STATUS_NOTICE);
68+ GList * entry_head, * entries;
69+
70+ entry_head = indicator_object_get_entries(INDICATOR_OBJECT(iapp));
71+
72+ for (entries = entry_head; entries != NULL; entries = g_list_next(entries)) {
73+ IndicatorObjectEntry * entry = (IndicatorObjectEntry *)entries->data;
74+ g_signal_emit(G_OBJECT(iapp), INDICATOR_OBJECT_SIGNAL_SHOW_NOW_CHANGED_ID, 0, entry, show_now);
75+ }
76+
77+ return;
78+}
79+
80 /* Pass up the show menu event */
81 static void
82 window_show_menu (WindowMenus * mw, IndicatorObjectEntry * entry, guint timestamp, gpointer user_data)
83
84=== modified file 'src/window-menus.c'
85--- src/window-menus.c 2011-02-28 18:56:06 +0000
86+++ src/window-menus.c 2011-03-09 14:18:09 +0000
87@@ -62,6 +62,7 @@
88 ENTRY_ADDED,
89 ENTRY_REMOVED,
90 ERROR_STATE,
91+ STATUS_CHANGED,
92 SHOW_MENU,
93 A11Y_UPDATE,
94 LAST_SIGNAL
95@@ -116,6 +117,13 @@
96 NULL, NULL,
97 g_cclosure_marshal_VOID__BOOLEAN,
98 G_TYPE_NONE, 1, G_TYPE_BOOLEAN, G_TYPE_NONE);
99+ signals[STATUS_CHANGED] = g_signal_new(WINDOW_MENUS_SIGNAL_STATUS_CHANGED,
100+ G_TYPE_FROM_CLASS(klass),
101+ G_SIGNAL_RUN_LAST,
102+ G_STRUCT_OFFSET (WindowMenusClass, status_changed),
103+ NULL, NULL,
104+ g_cclosure_marshal_VOID__INT,
105+ G_TYPE_NONE, 1, G_TYPE_INT, G_TYPE_NONE);
106 signals[SHOW_MENU] = g_signal_new(WINDOW_MENUS_SIGNAL_SHOW_MENU,
107 G_TYPE_FROM_CLASS(klass),
108 G_SIGNAL_RUN_LAST,
109@@ -366,6 +374,23 @@
110 return;
111 }
112
113+/* Called when the client changes its status. Used to show panel if requested.
114+ (Say, by an Alt press.) */
115+static void
116+status_changed (DbusmenuClient * client, GParamSpec * pspec, gpointer user_data)
117+{
118+ g_signal_emit(G_OBJECT(user_data), signals[STATUS_CHANGED], 0, dbusmenu_client_get_status (client));
119+}
120+
121+DbusmenuStatus
122+window_menus_get_status (WindowMenus * wm)
123+{
124+ g_return_val_if_fail(IS_WINDOW_MENUS(wm), DBUSMENU_STATUS_NORMAL);
125+ WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(wm);
126+
127+ return dbusmenu_client_get_status (DBUSMENU_CLIENT (priv->client));
128+}
129+
130 /* Build a new window menus object and attach to the signals to build
131 up the representative menu. */
132 WindowMenus *
133@@ -402,6 +427,7 @@
134 g_signal_connect(G_OBJECT(priv->client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(root_changed), newmenu);
135 g_signal_connect(G_OBJECT(priv->client), DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT, G_CALLBACK(event_status), newmenu);
136 g_signal_connect(G_OBJECT(priv->client), DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE, G_CALLBACK(item_activate), newmenu);
137+ g_signal_connect(G_OBJECT(priv->client), "notify::" DBUSMENU_CLIENT_PROP_STATUS, G_CALLBACK(status_changed), newmenu);
138
139 DbusmenuMenuitem * root = dbusmenu_client_get_root(DBUSMENU_CLIENT(priv->client));
140 if (root != NULL) {
141
142=== modified file 'src/window-menus.h'
143--- src/window-menus.h 2011-02-17 19:45:57 +0000
144+++ src/window-menus.h 2011-03-09 14:18:09 +0000
145@@ -25,6 +25,7 @@
146 #include <glib.h>
147 #include <glib-object.h>
148 #include <libindicator/indicator-object.h>
149+#include <libdbusmenu-glib/client.h>
150
151 G_BEGIN_DECLS
152
153@@ -38,6 +39,7 @@
154 #define WINDOW_MENUS_SIGNAL_ENTRY_ADDED "entry-added"
155 #define WINDOW_MENUS_SIGNAL_ENTRY_REMOVED "entry-removed"
156 #define WINDOW_MENUS_SIGNAL_ERROR_STATE "error-state"
157+#define WINDOW_MENUS_SIGNAL_STATUS_CHANGED "status-changed"
158 #define WINDOW_MENUS_SIGNAL_SHOW_MENU "show-menu"
159 #define WINDOW_MENUS_SIGNAL_A11Y_UPDATE "a11y-update"
160
161@@ -52,6 +54,7 @@
162 void (*entry_removed) (WindowMenus * wm, IndicatorObjectEntry * entry, gpointer user_data);
163
164 void (*error_state) (WindowMenus * wm, gboolean state, gpointer user_data);
165+ void (*status_changed) (WindowMenus * wm, DbusmenuStatus status, gpointer user_data);
166
167 void (*show_menu) (WindowMenus * wm, IndicatorObjectEntry * entry, guint timestamp, gpointer user_data);
168 void (*a11y_update) (WindowMenus * wm, IndicatorObjectEntry * entry, gpointer user_data);
169@@ -71,6 +74,7 @@
170 gchar * window_menus_get_address (WindowMenus * wm);
171
172 gboolean window_menus_get_error_state (WindowMenus * wm);
173+DbusmenuStatus window_menus_get_status (WindowMenus * wm);
174 void window_menus_entry_restore (WindowMenus * wm, IndicatorObjectEntry * entry);
175
176 void window_menus_entry_activate (WindowMenus * wm, IndicatorObjectEntry * entry, guint timestamp);

Subscribers

People subscribed via source and target branches