[gtk/matthiasc/for-master: 13/14] shortcutcontroller: Don't reinject menu accels
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 13/14] shortcutcontroller: Don't reinject menu accels
- Date: Thu, 17 Jun 2021 13:00:30 +0000 (UTC)
commit 7344a03aa33e334e034a6542b391f9649ffe38f5
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jun 17 08:43:48 2021 -0400
shortcutcontroller: Don't reinject menu accels
The normal way to associate accels with actions is
to attach a shortcut controller to the widget. The shorcut
controller will inject the accel into the action muxer
tree, so that it can get displayed in widgets that activate
the action (say, in menus.
This approach does not works for generated menus, since the
widgets are not in the hands of the app developer, so attaching
shortcut controllers to them is impractical.
Instead, GtkModelButton has an accel property that gets
bound to the accel coming from the action muxer tree (most
likely put there via gtk_application_set_accel_for_action),
and creates a shortcut controller itself.
The change in this commit is to prevent the shortcut controller
from injecting the accel into the action muxer tree in this case.
Otherwise, the accels get 'stuck' and we won't update them if the
global accels are later changed.
This is a hack, and needs a better solution.
gtk/gtkshortcutcontroller.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkshortcutcontroller.c b/gtk/gtkshortcutcontroller.c
index 01bc60208c..e830503b15 100644
--- a/gtk/gtkshortcutcontroller.c
+++ b/gtk/gtkshortcutcontroller.c
@@ -78,6 +78,7 @@
#include "gtkwidgetprivate.h"
#include "gtknative.h"
#include "gtkdebug.h"
+#include "gtkmodelbuttonprivate.h"
#include <gdk/gdk.h>
@@ -489,7 +490,7 @@ gtk_shortcut_controller_update_accels (GtkShortcutController *self)
guint i, p;
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (self));
- if (!widget)
+ if (!widget || GTK_IS_MODEL_BUTTON (widget))
return;
muxer = _gtk_widget_get_action_muxer (widget, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]