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
=== modified file 'src/indicator-appmenu.c'
--- src/indicator-appmenu.c 2011-02-17 20:09:37 +0000
+++ src/indicator-appmenu.c 2011-03-09 14:18:09 +0000
@@ -90,6 +90,7 @@
9090
91 gulong sig_entry_added;91 gulong sig_entry_added;
92 gulong sig_entry_removed;92 gulong sig_entry_removed;
93 gulong sig_status_changed;
93 gulong sig_show_menu;94 gulong sig_show_menu;
94 gulong sig_a11y_update;95 gulong sig_a11y_update;
9596
@@ -166,6 +167,9 @@
166static void window_entry_removed (WindowMenus * mw,167static void window_entry_removed (WindowMenus * mw,
167 IndicatorObjectEntry * entry,168 IndicatorObjectEntry * entry,
168 gpointer user_data);169 gpointer user_data);
170static void window_status_changed (WindowMenus * mw,
171 DbusmenuStatus status,
172 IndicatorAppmenu * iapp);
169static void window_show_menu (WindowMenus * mw,173static void window_show_menu (WindowMenus * mw,
170 IndicatorObjectEntry * entry,174 IndicatorObjectEntry * entry,
171 guint timestamp,175 guint timestamp,
@@ -1088,6 +1092,10 @@
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);
1089 iapp->sig_entry_removed = 0;1093 iapp->sig_entry_removed = 0;
1090 }1094 }
1095 if (iapp->sig_status_changed != 0) {
1096 g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_status_changed);
1097 iapp->sig_status_changed = 0;
1098 }
1091 if (iapp->sig_show_menu != 0) {1099 if (iapp->sig_show_menu != 0) {
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);
1093 iapp->sig_show_menu = 0;1101 iapp->sig_show_menu = 0;
@@ -1117,6 +1125,10 @@
1117 WINDOW_MENUS_SIGNAL_ENTRY_REMOVED,1125 WINDOW_MENUS_SIGNAL_ENTRY_REMOVED,
1118 G_CALLBACK(window_entry_removed),1126 G_CALLBACK(window_entry_removed),
1119 iapp);1127 iapp);
1128 iapp->sig_status_changed = g_signal_connect(G_OBJECT(iapp->default_app),
1129 WINDOW_MENUS_SIGNAL_STATUS_CHANGED,
1130 G_CALLBACK(window_status_changed),
1131 iapp);
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),
1121 WINDOW_MENUS_SIGNAL_SHOW_MENU,1133 WINDOW_MENUS_SIGNAL_SHOW_MENU,
1122 G_CALLBACK(window_show_menu),1134 G_CALLBACK(window_show_menu),
@@ -1154,6 +1166,14 @@
11541166
1155 g_list_free(entry_head);1167 g_list_free(entry_head);
11561168
1169 /* Set up initial state for new entries if needed */
1170 if (iapp->default_app != NULL &&
1171 window_menus_get_status (iapp->default_app) != DBUSMENU_STATUS_NORMAL) {
1172 window_status_changed (iapp->default_app,
1173 window_menus_get_status (iapp->default_app),
1174 iapp);
1175 }
1176
1157 return;1177 return;
1158}1178}
11591179
@@ -1394,6 +1414,23 @@
1394 return;1414 return;
1395}1415}
13961416
1417/* Pass up the status changed event */
1418static void
1419window_status_changed (WindowMenus * mw, DbusmenuStatus status, IndicatorAppmenu * iapp)
1420{
1421 gboolean show_now = (status == DBUSMENU_STATUS_NOTICE);
1422 GList * entry_head, * entries;
1423
1424 entry_head = indicator_object_get_entries(INDICATOR_OBJECT(iapp));
1425
1426 for (entries = entry_head; entries != NULL; entries = g_list_next(entries)) {
1427 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)entries->data;
1428 g_signal_emit(G_OBJECT(iapp), INDICATOR_OBJECT_SIGNAL_SHOW_NOW_CHANGED_ID, 0, entry, show_now);
1429 }
1430
1431 return;
1432}
1433
1397/* Pass up the show menu event */1434/* Pass up the show menu event */
1398static void1435static void
1399window_show_menu (WindowMenus * mw, IndicatorObjectEntry * entry, guint timestamp, gpointer user_data)1436window_show_menu (WindowMenus * mw, IndicatorObjectEntry * entry, guint timestamp, gpointer user_data)
14001437
=== modified file 'src/window-menus.c'
--- src/window-menus.c 2011-02-28 18:56:06 +0000
+++ src/window-menus.c 2011-03-09 14:18:09 +0000
@@ -62,6 +62,7 @@
62 ENTRY_ADDED,62 ENTRY_ADDED,
63 ENTRY_REMOVED,63 ENTRY_REMOVED,
64 ERROR_STATE,64 ERROR_STATE,
65 STATUS_CHANGED,
65 SHOW_MENU,66 SHOW_MENU,
66 A11Y_UPDATE,67 A11Y_UPDATE,
67 LAST_SIGNAL68 LAST_SIGNAL
@@ -116,6 +117,13 @@
116 NULL, NULL,117 NULL, NULL,
117 g_cclosure_marshal_VOID__BOOLEAN,118 g_cclosure_marshal_VOID__BOOLEAN,
118 G_TYPE_NONE, 1, G_TYPE_BOOLEAN, G_TYPE_NONE);119 G_TYPE_NONE, 1, G_TYPE_BOOLEAN, G_TYPE_NONE);
120 signals[STATUS_CHANGED] = g_signal_new(WINDOW_MENUS_SIGNAL_STATUS_CHANGED,
121 G_TYPE_FROM_CLASS(klass),
122 G_SIGNAL_RUN_LAST,
123 G_STRUCT_OFFSET (WindowMenusClass, status_changed),
124 NULL, NULL,
125 g_cclosure_marshal_VOID__INT,
126 G_TYPE_NONE, 1, G_TYPE_INT, G_TYPE_NONE);
119 signals[SHOW_MENU] = g_signal_new(WINDOW_MENUS_SIGNAL_SHOW_MENU,127 signals[SHOW_MENU] = g_signal_new(WINDOW_MENUS_SIGNAL_SHOW_MENU,
120 G_TYPE_FROM_CLASS(klass),128 G_TYPE_FROM_CLASS(klass),
121 G_SIGNAL_RUN_LAST,129 G_SIGNAL_RUN_LAST,
@@ -366,6 +374,23 @@
366 return;374 return;
367}375}
368376
377/* Called when the client changes its status. Used to show panel if requested.
378 (Say, by an Alt press.) */
379static void
380status_changed (DbusmenuClient * client, GParamSpec * pspec, gpointer user_data)
381{
382 g_signal_emit(G_OBJECT(user_data), signals[STATUS_CHANGED], 0, dbusmenu_client_get_status (client));
383}
384
385DbusmenuStatus
386window_menus_get_status (WindowMenus * wm)
387{
388 g_return_val_if_fail(IS_WINDOW_MENUS(wm), DBUSMENU_STATUS_NORMAL);
389 WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(wm);
390
391 return dbusmenu_client_get_status (DBUSMENU_CLIENT (priv->client));
392}
393
369/* Build a new window menus object and attach to the signals to build394/* Build a new window menus object and attach to the signals to build
370 up the representative menu. */395 up the representative menu. */
371WindowMenus *396WindowMenus *
@@ -402,6 +427,7 @@
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);
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);
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);
430 g_signal_connect(G_OBJECT(priv->client), "notify::" DBUSMENU_CLIENT_PROP_STATUS, G_CALLBACK(status_changed), newmenu);
405431
406 DbusmenuMenuitem * root = dbusmenu_client_get_root(DBUSMENU_CLIENT(priv->client));432 DbusmenuMenuitem * root = dbusmenu_client_get_root(DBUSMENU_CLIENT(priv->client));
407 if (root != NULL) {433 if (root != NULL) {
408434
=== modified file 'src/window-menus.h'
--- src/window-menus.h 2011-02-17 19:45:57 +0000
+++ src/window-menus.h 2011-03-09 14:18:09 +0000
@@ -25,6 +25,7 @@
25#include <glib.h>25#include <glib.h>
26#include <glib-object.h>26#include <glib-object.h>
27#include <libindicator/indicator-object.h>27#include <libindicator/indicator-object.h>
28#include <libdbusmenu-glib/client.h>
2829
29G_BEGIN_DECLS30G_BEGIN_DECLS
3031
@@ -38,6 +39,7 @@
38#define WINDOW_MENUS_SIGNAL_ENTRY_ADDED "entry-added"39#define WINDOW_MENUS_SIGNAL_ENTRY_ADDED "entry-added"
39#define WINDOW_MENUS_SIGNAL_ENTRY_REMOVED "entry-removed"40#define WINDOW_MENUS_SIGNAL_ENTRY_REMOVED "entry-removed"
40#define WINDOW_MENUS_SIGNAL_ERROR_STATE "error-state"41#define WINDOW_MENUS_SIGNAL_ERROR_STATE "error-state"
42#define WINDOW_MENUS_SIGNAL_STATUS_CHANGED "status-changed"
41#define WINDOW_MENUS_SIGNAL_SHOW_MENU "show-menu"43#define WINDOW_MENUS_SIGNAL_SHOW_MENU "show-menu"
42#define WINDOW_MENUS_SIGNAL_A11Y_UPDATE "a11y-update"44#define WINDOW_MENUS_SIGNAL_A11Y_UPDATE "a11y-update"
4345
@@ -52,6 +54,7 @@
52 void (*entry_removed) (WindowMenus * wm, IndicatorObjectEntry * entry, gpointer user_data);54 void (*entry_removed) (WindowMenus * wm, IndicatorObjectEntry * entry, gpointer user_data);
5355
54 void (*error_state) (WindowMenus * wm, gboolean state, gpointer user_data);56 void (*error_state) (WindowMenus * wm, gboolean state, gpointer user_data);
57 void (*status_changed) (WindowMenus * wm, DbusmenuStatus status, gpointer user_data);
5558
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);
57 void (*a11y_update) (WindowMenus * wm, IndicatorObjectEntry * entry, gpointer user_data);60 void (*a11y_update) (WindowMenus * wm, IndicatorObjectEntry * entry, gpointer user_data);
@@ -71,6 +74,7 @@
71gchar * window_menus_get_address (WindowMenus * wm);74gchar * window_menus_get_address (WindowMenus * wm);
7275
73gboolean window_menus_get_error_state (WindowMenus * wm);76gboolean window_menus_get_error_state (WindowMenus * wm);
77DbusmenuStatus window_menus_get_status (WindowMenus * wm);
74void window_menus_entry_restore (WindowMenus * wm, IndicatorObjectEntry * entry);78void window_menus_entry_restore (WindowMenus * wm, IndicatorObjectEntry * entry);
7579
76void window_menus_entry_activate (WindowMenus * wm, IndicatorObjectEntry * entry, guint timestamp);80void window_menus_entry_activate (WindowMenus * wm, IndicatorObjectEntry * entry, guint timestamp);

Subscribers

People subscribed via source and target branches