From 999eec53c643721b37bc7ad847cdfdf93c124085 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Thu, 7 Oct 2021 19:43:23 +0200 Subject: stickynotes: Popup the note menu with the keyboard --- stickynotes/stickynotes_callbacks.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'stickynotes/stickynotes_callbacks.c') diff --git a/stickynotes/stickynotes_callbacks.c b/stickynotes/stickynotes_callbacks.c index 3e849131..dac681a1 100644 --- a/stickynotes/stickynotes_callbacks.c +++ b/stickynotes/stickynotes_callbacks.c @@ -122,11 +122,12 @@ stickynote_show_popup_menu (GtkWidget *widget, return FALSE; } -/* Sticky Window Callback : Exit entry field on key press. */ +/* Sticky Window Callback : Exit entry field on key press or popup + * the right click menu. */ gboolean -stickynote_keypress_cb (GtkWidget *widget, - GdkEventKey *event, - StickyNote *note) +stickynote_keypress_cb (GtkWidget *widget, + GdkEventKey *event, + GtkMenu *popup_menu) { GdkModifierType state = event->state & gtk_accelerator_get_default_mod_mask (); @@ -143,6 +144,22 @@ stickynote_keypress_cb (GtkWidget *widget, break; } + if ((event->keyval == GDK_KEY_F10 && (state == 0 || state == GDK_SHIFT_MASK)) || + (event->keyval == GDK_KEY_Menu && state == 0)) { + GtkWidget *focus_widget = NULL; + + if (GTK_IS_WINDOW (widget)) + focus_widget = gtk_window_get_focus (GTK_WINDOW (widget)); + if (! focus_widget) + focus_widget = widget; + + gtk_menu_popup_at_widget (popup_menu, focus_widget, + GDK_GRAVITY_SOUTH_WEST, + GDK_GRAVITY_NORTH_WEST, + (const GdkEvent*) event); + return TRUE; + } + return FALSE; } -- cgit v1.2.1