[gtk/shortcuts-rebased-again: 109/159] popover menu: Implement shortcut manager
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/shortcuts-rebased-again: 109/159] popover menu: Implement shortcut manager
- Date: Mon, 24 Jun 2019 11:44:19 +0000 (UTC)
commit 25ddcd382ad7a5107d58f4c5109c4f40d483b68f
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jun 21 01:06:28 2019 +0000
popover menu: Implement shortcut manager
And make mnemonics trigger without Alt,
like we already do for GtkMenu.
gtk/gtkpopovermenu.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkpopovermenu.c b/gtk/gtkpopovermenu.c
index dcd2dc1043..0badd92d43 100644
--- a/gtk/gtkpopovermenu.c
+++ b/gtk/gtkpopovermenu.c
@@ -34,6 +34,7 @@
#include "gtkshortcut.h"
#include "gtkshortcutcontroller.h"
#include "gtkshortcuttrigger.h"
+#include "gtkshortcutmanager.h"
/**
@@ -137,7 +138,15 @@ enum {
PROP_VISIBLE_SUBMENU = 1
};
-G_DEFINE_TYPE (GtkPopoverMenu, gtk_popover_menu, GTK_TYPE_POPOVER)
+static void
+gtk_popover_menu_shortcut_manager_interface_init (GtkShortcutManagerInterface *iface)
+{
+}
+
+G_DEFINE_TYPE_WITH_CODE (GtkPopoverMenu, gtk_popover_menu, GTK_TYPE_POPOVER,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SHORTCUT_MANAGER,
+ gtk_popover_menu_shortcut_manager_interface_init))
+
void
gtk_popover_menu_set_active_item (GtkPopoverMenu *menu,
@@ -186,6 +195,7 @@ gtk_popover_menu_init (GtkPopoverMenu *popover)
GtkWidget *stack;
GtkStyleContext *style_context;
GtkEventController *controller;
+ GList *controllers, *l;
stack = gtk_stack_new ();
gtk_stack_set_vhomogeneous (GTK_STACK (stack), FALSE);
@@ -201,6 +211,15 @@ gtk_popover_menu_init (GtkPopoverMenu *popover)
controller = gtk_event_controller_key_new ();
g_signal_connect (controller, "focus-out", G_CALLBACK (focus_out), popover);
gtk_widget_add_controller (GTK_WIDGET (popover), controller);
+
+ /* Trigger mnemonics without Alt */
+ controllers = _gtk_widget_list_controllers (GTK_WIDGET (popover), GTK_PHASE_CAPTURE);
+ for (l = controllers; l; l = l->next)
+ {
+ if (GTK_IS_SHORTCUT_CONTROLLER (l->data))
+ gtk_shortcut_controller_set_mnemonics_modifiers (l->data, 0);
+ }
+ g_list_free (controllers);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]