Merge lp:~mterry/appmenu-gtk/fix-alt-shortcuts into lp:appmenu-gtk/0.4

Proposed by Michael Terry
Status: Merged
Approved by: Ted Gould
Approved revision: 129
Merged at revision: 127
Proposed branch: lp:~mterry/appmenu-gtk/fix-alt-shortcuts
Merge into: lp:appmenu-gtk/0.4
Diff against target: 110 lines (+16/-42)
1 file modified
src/bridge.c (+16/-42)
To merge this branch: bzr merge lp:~mterry/appmenu-gtk/fix-alt-shortcuts
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+52755@code.launchpad.net

Description of the change

When we moved the parser to dbusmenu, we forgot about the lookup table for widgets to menu items in appmenu-gtk. This lookup table is used to support key presses like Alt+F for the menus.

To fix this, I used the sorta-secret gobject data "dbusmenu-gtk-parser-cached-item" saved on GtkMenuItems by the parser to map to Dbusmenuitems. This may be considered bad?

If it is considered bad to use that string directly, we should either expose the string in a header or introduce a convenience function to dbusmenu to grab the data.

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

On Wed, 2011-03-09 at 20:12 +0000, Michael Terry wrote:
> To fix this, I used the sorta-secret gobject data "dbusmenu-gtk-parser-cached-item" saved on GtkMenuItems by the parser to map to Dbusmenuitems. This may be considered bad?
>
> If it is considered bad to use that string directly, we should either expose the string in a header or introduce a convenience function to dbusmenu to grab the data.

I think it's better to expose via API. What do you think about:

  lp:~ted/dbusmenu/get-cached-menuitem

I think that works and is API we could support for a while.

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

Looks fine. I updated this branch to use the new function.

128. By Michael Terry

update to use new get_cached_item function

129. By Michael Terry

whoops, remove some debugging code I accidentally committed

Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/bridge.c'
--- src/bridge.c 2011-03-09 15:56:32 +0000
+++ src/bridge.c 2011-03-10 14:06:48 +0000
@@ -75,7 +75,6 @@
75 gchar *path;75 gchar *path;
76 gboolean registered;76 gboolean registered;
77 AppMenuBridge *bridge;77 AppMenuBridge *bridge;
78 GHashTable *lookup;
79 GCancellable *cancel;78 GCancellable *cancel;
80};79};
8180
@@ -108,24 +107,14 @@
108 GtkWidget *widget,107 GtkWidget *widget,
109 gpointer user_data)108 gpointer user_data)
110{109{
111 GList *list;110 DbusmenuMenuitem *mi = dbusmenu_gtk_parse_get_cached_item (widget);
112111
113 for (list = bridge->priv->windows; list != NULL; list = list->next)112 if (mi != NULL)
114 {113 {
115 AppWindowContext *context = list->data;114 dbusmenu_menuitem_show_to_user (mi, 0);
116
117 if (context->lookup)
118 {
119 DbusmenuMenuitem *mi = g_hash_table_lookup (context->lookup, widget);
120
121 if (mi != NULL)
122 {
123 dbusmenu_menuitem_show_to_user (mi, 0);
124
125 return;
126 }
127 }
128 }115 }
116
117 return;
129}118}
130119
131static void120static void
@@ -178,12 +167,6 @@
178 g_object_remove_weak_pointer(G_OBJECT(context->window), (gpointer *)&(context->window));167 g_object_remove_weak_pointer(G_OBJECT(context->window), (gpointer *)&(context->window));
179 context->window = NULL;168 context->window = NULL;
180 }169 }
181
182 if (context->lookup != NULL)
183 {
184 g_hash_table_unref (context->lookup);
185 context->lookup = NULL;
186 }
187}170}
188171
189static void172static void
@@ -678,7 +661,6 @@
678 {661 {
679 context = g_new0 (AppWindowContext, 1);662 context = g_new0 (AppWindowContext, 1);
680 context->bridge = bridge;663 context->bridge = bridge;
681 context->lookup = g_hash_table_new (g_direct_hash, g_direct_equal);
682 bridge->priv->windows = g_list_prepend (bridge->priv->windows, context);664 bridge->priv->windows = g_list_prepend (bridge->priv->windows, context);
683 }665 }
684666
@@ -849,17 +831,20 @@
849 else if (GTK_IS_MENU (parent))831 else if (GTK_IS_MENU (parent))
850 {832 {
851 GtkWidget *attach = NULL;833 GtkWidget *attach = NULL;
852 GList *tmp = NULL;
853 AppWindowContext *context = NULL;
854834
855 g_object_get (parent, "attach-widget", &attach, NULL);835 g_object_get (parent, "attach-widget", &attach, NULL);
856836
857 /* First attempt to setup the menuitem immediately if possible. */837 if (attach == NULL)
858 for (tmp = bridge->priv->windows; tmp != NULL; tmp = tmp->next)838 {
859 {839 g_signal_connect (G_OBJECT (parent),
860 context = (AppWindowContext *)tmp->data;840 "notify",
861841 G_CALLBACK (attach_notify_cb),
862 DbusmenuMenuitem *mi = (DbusmenuMenuitem *)g_hash_table_lookup (context->lookup, attach);842 bridge);
843 return;
844 }
845 else
846 {
847 DbusmenuMenuitem *mi = dbusmenu_gtk_parse_get_cached_item (attach);
863848
864 if (mi != NULL)849 if (mi != NULL)
865 {850 {
@@ -871,18 +856,7 @@
871 position);856 position);
872 return;857 return;
873 }858 }
874 }
875859
876 if (attach == NULL)
877 {
878 g_signal_connect (G_OBJECT (parent),
879 "notify",
880 G_CALLBACK (attach_notify_cb),
881 bridge);
882 return;
883 }
884 else
885 {
886 rebuild (bridge, toplevel);860 rebuild (bridge, toplevel);
887 }861 }
888 }862 }

Subscribers

People subscribed via source and target branches