Merge lp:~mterry/indicator-appmenu/emit-show-now-changed into lp:indicator-appmenu/0.3
- emit-show-now-changed
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ted Gould (community) | Approve | ||
Review via email: mp+52583@code.launchpad.net |
Commit message
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:/
[2] https:/
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.
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
Ted Gould (ted) wrote : | # |
I agree, I had forgot that we were deleting them so that would effectively invalidate their status. Looks good.
Preview Diff
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 | 90 | 90 | ||
6 | 91 | gulong sig_entry_added; | 91 | gulong sig_entry_added; |
7 | 92 | gulong sig_entry_removed; | 92 | gulong sig_entry_removed; |
8 | 93 | gulong sig_status_changed; | ||
9 | 93 | gulong sig_show_menu; | 94 | gulong sig_show_menu; |
10 | 94 | gulong sig_a11y_update; | 95 | gulong sig_a11y_update; |
11 | 95 | 96 | ||
12 | @@ -166,6 +167,9 @@ | |||
13 | 166 | static void window_entry_removed (WindowMenus * mw, | 167 | static void window_entry_removed (WindowMenus * mw, |
14 | 167 | IndicatorObjectEntry * entry, | 168 | IndicatorObjectEntry * entry, |
15 | 168 | gpointer user_data); | 169 | gpointer user_data); |
16 | 170 | static void window_status_changed (WindowMenus * mw, | ||
17 | 171 | DbusmenuStatus status, | ||
18 | 172 | IndicatorAppmenu * iapp); | ||
19 | 169 | static void window_show_menu (WindowMenus * mw, | 173 | static void window_show_menu (WindowMenus * mw, |
20 | 170 | IndicatorObjectEntry * entry, | 174 | IndicatorObjectEntry * entry, |
21 | 171 | guint timestamp, | 175 | guint timestamp, |
22 | @@ -1088,6 +1092,10 @@ | |||
23 | 1088 | g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_entry_removed); | 1092 | g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_entry_removed); |
24 | 1089 | iapp->sig_entry_removed = 0; | 1093 | iapp->sig_entry_removed = 0; |
25 | 1090 | } | 1094 | } |
26 | 1095 | if (iapp->sig_status_changed != 0) { | ||
27 | 1096 | g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_status_changed); | ||
28 | 1097 | iapp->sig_status_changed = 0; | ||
29 | 1098 | } | ||
30 | 1091 | if (iapp->sig_show_menu != 0) { | 1099 | if (iapp->sig_show_menu != 0) { |
31 | 1092 | g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_show_menu); | 1100 | g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_show_menu); |
32 | 1093 | iapp->sig_show_menu = 0; | 1101 | iapp->sig_show_menu = 0; |
33 | @@ -1117,6 +1125,10 @@ | |||
34 | 1117 | WINDOW_MENUS_SIGNAL_ENTRY_REMOVED, | 1125 | WINDOW_MENUS_SIGNAL_ENTRY_REMOVED, |
35 | 1118 | G_CALLBACK(window_entry_removed), | 1126 | G_CALLBACK(window_entry_removed), |
36 | 1119 | iapp); | 1127 | iapp); |
37 | 1128 | iapp->sig_status_changed = g_signal_connect(G_OBJECT(iapp->default_app), | ||
38 | 1129 | WINDOW_MENUS_SIGNAL_STATUS_CHANGED, | ||
39 | 1130 | G_CALLBACK(window_status_changed), | ||
40 | 1131 | iapp); | ||
41 | 1120 | iapp->sig_show_menu = g_signal_connect(G_OBJECT(iapp->default_app), | 1132 | iapp->sig_show_menu = g_signal_connect(G_OBJECT(iapp->default_app), |
42 | 1121 | WINDOW_MENUS_SIGNAL_SHOW_MENU, | 1133 | WINDOW_MENUS_SIGNAL_SHOW_MENU, |
43 | 1122 | G_CALLBACK(window_show_menu), | 1134 | G_CALLBACK(window_show_menu), |
44 | @@ -1154,6 +1166,14 @@ | |||
45 | 1154 | 1166 | ||
46 | 1155 | g_list_free(entry_head); | 1167 | g_list_free(entry_head); |
47 | 1156 | 1168 | ||
48 | 1169 | /* Set up initial state for new entries if needed */ | ||
49 | 1170 | if (iapp->default_app != NULL && | ||
50 | 1171 | window_menus_get_status (iapp->default_app) != DBUSMENU_STATUS_NORMAL) { | ||
51 | 1172 | window_status_changed (iapp->default_app, | ||
52 | 1173 | window_menus_get_status (iapp->default_app), | ||
53 | 1174 | iapp); | ||
54 | 1175 | } | ||
55 | 1176 | |||
56 | 1157 | return; | 1177 | return; |
57 | 1158 | } | 1178 | } |
58 | 1159 | 1179 | ||
59 | @@ -1394,6 +1414,23 @@ | |||
60 | 1394 | return; | 1414 | return; |
61 | 1395 | } | 1415 | } |
62 | 1396 | 1416 | ||
63 | 1417 | /* Pass up the status changed event */ | ||
64 | 1418 | static void | ||
65 | 1419 | window_status_changed (WindowMenus * mw, DbusmenuStatus status, IndicatorAppmenu * iapp) | ||
66 | 1420 | { | ||
67 | 1421 | gboolean show_now = (status == DBUSMENU_STATUS_NOTICE); | ||
68 | 1422 | GList * entry_head, * entries; | ||
69 | 1423 | |||
70 | 1424 | entry_head = indicator_object_get_entries(INDICATOR_OBJECT(iapp)); | ||
71 | 1425 | |||
72 | 1426 | for (entries = entry_head; entries != NULL; entries = g_list_next(entries)) { | ||
73 | 1427 | IndicatorObjectEntry * entry = (IndicatorObjectEntry *)entries->data; | ||
74 | 1428 | g_signal_emit(G_OBJECT(iapp), INDICATOR_OBJECT_SIGNAL_SHOW_NOW_CHANGED_ID, 0, entry, show_now); | ||
75 | 1429 | } | ||
76 | 1430 | |||
77 | 1431 | return; | ||
78 | 1432 | } | ||
79 | 1433 | |||
80 | 1397 | /* Pass up the show menu event */ | 1434 | /* Pass up the show menu event */ |
81 | 1398 | static void | 1435 | static void |
82 | 1399 | window_show_menu (WindowMenus * mw, IndicatorObjectEntry * entry, guint timestamp, gpointer user_data) | 1436 | window_show_menu (WindowMenus * mw, IndicatorObjectEntry * entry, guint timestamp, gpointer user_data) |
83 | 1400 | 1437 | ||
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 | 62 | ENTRY_ADDED, | 62 | ENTRY_ADDED, |
89 | 63 | ENTRY_REMOVED, | 63 | ENTRY_REMOVED, |
90 | 64 | ERROR_STATE, | 64 | ERROR_STATE, |
91 | 65 | STATUS_CHANGED, | ||
92 | 65 | SHOW_MENU, | 66 | SHOW_MENU, |
93 | 66 | A11Y_UPDATE, | 67 | A11Y_UPDATE, |
94 | 67 | LAST_SIGNAL | 68 | LAST_SIGNAL |
95 | @@ -116,6 +117,13 @@ | |||
96 | 116 | NULL, NULL, | 117 | NULL, NULL, |
97 | 117 | g_cclosure_marshal_VOID__BOOLEAN, | 118 | g_cclosure_marshal_VOID__BOOLEAN, |
98 | 118 | G_TYPE_NONE, 1, G_TYPE_BOOLEAN, G_TYPE_NONE); | 119 | G_TYPE_NONE, 1, G_TYPE_BOOLEAN, G_TYPE_NONE); |
99 | 120 | signals[STATUS_CHANGED] = g_signal_new(WINDOW_MENUS_SIGNAL_STATUS_CHANGED, | ||
100 | 121 | G_TYPE_FROM_CLASS(klass), | ||
101 | 122 | G_SIGNAL_RUN_LAST, | ||
102 | 123 | G_STRUCT_OFFSET (WindowMenusClass, status_changed), | ||
103 | 124 | NULL, NULL, | ||
104 | 125 | g_cclosure_marshal_VOID__INT, | ||
105 | 126 | G_TYPE_NONE, 1, G_TYPE_INT, G_TYPE_NONE); | ||
106 | 119 | signals[SHOW_MENU] = g_signal_new(WINDOW_MENUS_SIGNAL_SHOW_MENU, | 127 | signals[SHOW_MENU] = g_signal_new(WINDOW_MENUS_SIGNAL_SHOW_MENU, |
107 | 120 | G_TYPE_FROM_CLASS(klass), | 128 | G_TYPE_FROM_CLASS(klass), |
108 | 121 | G_SIGNAL_RUN_LAST, | 129 | G_SIGNAL_RUN_LAST, |
109 | @@ -366,6 +374,23 @@ | |||
110 | 366 | return; | 374 | return; |
111 | 367 | } | 375 | } |
112 | 368 | 376 | ||
113 | 377 | /* Called when the client changes its status. Used to show panel if requested. | ||
114 | 378 | (Say, by an Alt press.) */ | ||
115 | 379 | static void | ||
116 | 380 | status_changed (DbusmenuClient * client, GParamSpec * pspec, gpointer user_data) | ||
117 | 381 | { | ||
118 | 382 | g_signal_emit(G_OBJECT(user_data), signals[STATUS_CHANGED], 0, dbusmenu_client_get_status (client)); | ||
119 | 383 | } | ||
120 | 384 | |||
121 | 385 | DbusmenuStatus | ||
122 | 386 | window_menus_get_status (WindowMenus * wm) | ||
123 | 387 | { | ||
124 | 388 | g_return_val_if_fail(IS_WINDOW_MENUS(wm), DBUSMENU_STATUS_NORMAL); | ||
125 | 389 | WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(wm); | ||
126 | 390 | |||
127 | 391 | return dbusmenu_client_get_status (DBUSMENU_CLIENT (priv->client)); | ||
128 | 392 | } | ||
129 | 393 | |||
130 | 369 | /* Build a new window menus object and attach to the signals to build | 394 | /* Build a new window menus object and attach to the signals to build |
131 | 370 | up the representative menu. */ | 395 | up the representative menu. */ |
132 | 371 | WindowMenus * | 396 | WindowMenus * |
133 | @@ -402,6 +427,7 @@ | |||
134 | 402 | g_signal_connect(G_OBJECT(priv->client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(root_changed), newmenu); | 427 | g_signal_connect(G_OBJECT(priv->client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(root_changed), newmenu); |
135 | 403 | g_signal_connect(G_OBJECT(priv->client), DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT, G_CALLBACK(event_status), newmenu); | 428 | g_signal_connect(G_OBJECT(priv->client), DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT, G_CALLBACK(event_status), newmenu); |
136 | 404 | g_signal_connect(G_OBJECT(priv->client), DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE, G_CALLBACK(item_activate), newmenu); | 429 | g_signal_connect(G_OBJECT(priv->client), DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE, G_CALLBACK(item_activate), newmenu); |
137 | 430 | g_signal_connect(G_OBJECT(priv->client), "notify::" DBUSMENU_CLIENT_PROP_STATUS, G_CALLBACK(status_changed), newmenu); | ||
138 | 405 | 431 | ||
139 | 406 | DbusmenuMenuitem * root = dbusmenu_client_get_root(DBUSMENU_CLIENT(priv->client)); | 432 | DbusmenuMenuitem * root = dbusmenu_client_get_root(DBUSMENU_CLIENT(priv->client)); |
140 | 407 | if (root != NULL) { | 433 | if (root != NULL) { |
141 | 408 | 434 | ||
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 | 25 | #include <glib.h> | 25 | #include <glib.h> |
147 | 26 | #include <glib-object.h> | 26 | #include <glib-object.h> |
148 | 27 | #include <libindicator/indicator-object.h> | 27 | #include <libindicator/indicator-object.h> |
149 | 28 | #include <libdbusmenu-glib/client.h> | ||
150 | 28 | 29 | ||
151 | 29 | G_BEGIN_DECLS | 30 | G_BEGIN_DECLS |
152 | 30 | 31 | ||
153 | @@ -38,6 +39,7 @@ | |||
154 | 38 | #define WINDOW_MENUS_SIGNAL_ENTRY_ADDED "entry-added" | 39 | #define WINDOW_MENUS_SIGNAL_ENTRY_ADDED "entry-added" |
155 | 39 | #define WINDOW_MENUS_SIGNAL_ENTRY_REMOVED "entry-removed" | 40 | #define WINDOW_MENUS_SIGNAL_ENTRY_REMOVED "entry-removed" |
156 | 40 | #define WINDOW_MENUS_SIGNAL_ERROR_STATE "error-state" | 41 | #define WINDOW_MENUS_SIGNAL_ERROR_STATE "error-state" |
157 | 42 | #define WINDOW_MENUS_SIGNAL_STATUS_CHANGED "status-changed" | ||
158 | 41 | #define WINDOW_MENUS_SIGNAL_SHOW_MENU "show-menu" | 43 | #define WINDOW_MENUS_SIGNAL_SHOW_MENU "show-menu" |
159 | 42 | #define WINDOW_MENUS_SIGNAL_A11Y_UPDATE "a11y-update" | 44 | #define WINDOW_MENUS_SIGNAL_A11Y_UPDATE "a11y-update" |
160 | 43 | 45 | ||
161 | @@ -52,6 +54,7 @@ | |||
162 | 52 | void (*entry_removed) (WindowMenus * wm, IndicatorObjectEntry * entry, gpointer user_data); | 54 | void (*entry_removed) (WindowMenus * wm, IndicatorObjectEntry * entry, gpointer user_data); |
163 | 53 | 55 | ||
164 | 54 | void (*error_state) (WindowMenus * wm, gboolean state, gpointer user_data); | 56 | void (*error_state) (WindowMenus * wm, gboolean state, gpointer user_data); |
165 | 57 | void (*status_changed) (WindowMenus * wm, DbusmenuStatus status, gpointer user_data); | ||
166 | 55 | 58 | ||
167 | 56 | void (*show_menu) (WindowMenus * wm, IndicatorObjectEntry * entry, guint timestamp, gpointer user_data); | 59 | void (*show_menu) (WindowMenus * wm, IndicatorObjectEntry * entry, guint timestamp, gpointer user_data); |
168 | 57 | void (*a11y_update) (WindowMenus * wm, IndicatorObjectEntry * entry, gpointer user_data); | 60 | void (*a11y_update) (WindowMenus * wm, IndicatorObjectEntry * entry, gpointer user_data); |
169 | @@ -71,6 +74,7 @@ | |||
170 | 71 | gchar * window_menus_get_address (WindowMenus * wm); | 74 | gchar * window_menus_get_address (WindowMenus * wm); |
171 | 72 | 75 | ||
172 | 73 | gboolean window_menus_get_error_state (WindowMenus * wm); | 76 | gboolean window_menus_get_error_state (WindowMenus * wm); |
173 | 77 | DbusmenuStatus window_menus_get_status (WindowMenus * wm); | ||
174 | 74 | void window_menus_entry_restore (WindowMenus * wm, IndicatorObjectEntry * entry); | 78 | void window_menus_entry_restore (WindowMenus * wm, IndicatorObjectEntry * entry); |
175 | 75 | 79 | ||
176 | 76 | void window_menus_entry_activate (WindowMenus * wm, IndicatorObjectEntry * entry, guint timestamp); | 80 | void window_menus_entry_activate (WindowMenus * wm, IndicatorObjectEntry * entry, guint timestamp); |
On Tue, 2011-03-08 at 17:16 +0000, Michael Terry wrote: menus_get_ status (iapp->default_app) != DBUSMENU_ STATUS_ NORMAL) { status_ changed (iapp->default_app, menus_get_ status (iapp-> default_ app),
> + /* Set up initial state for new entries if needed */
> + if (window_
> + window_
> + window_
> + 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