summaryrefslogtreecommitdiff
path: root/stickynotes
diff options
context:
space:
mode:
authorColomban Wendling <[email protected]>2021-10-07 19:43:23 +0200
committerraveit65 <[email protected]>2021-11-09 22:39:46 +0100
commitecee6aeced75c30414345b5f31182f1ccae08076 (patch)
tree92534e749d20a64694d840857dd98d926034e0fd /stickynotes
parent63b52c7b872258270f7f75d52dcf4edff83cefc3 (diff)
downloadmate-applets-ecee6aeced75c30414345b5f31182f1ccae08076.tar.bz2
mate-applets-ecee6aeced75c30414345b5f31182f1ccae08076.tar.xz
stickynotes: Popup the note menu with the keyboard
Diffstat (limited to 'stickynotes')
-rw-r--r--stickynotes/stickynotes.c6
-rw-r--r--stickynotes/stickynotes_callbacks.c25
-rw-r--r--stickynotes/stickynotes_callbacks.h2
3 files changed, 25 insertions, 8 deletions
diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c
index 698a83d7..17b6f347 100644
--- a/stickynotes/stickynotes.c
+++ b/stickynotes/stickynotes.c
@@ -368,9 +368,9 @@ stickynote_new_aux (GdkScreen *screen,
G_CALLBACK (gtk_widget_hide),
note);
- g_signal_connect (note->w_window, "key-press-event",
- G_CALLBACK (stickynote_keypress_cb),
- note);
+ g_signal_connect_after (note->w_window, "key-press-event",
+ G_CALLBACK (stickynote_keypress_cb),
+ note->w_menu);
g_object_unref (builder);
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;
}
diff --git a/stickynotes/stickynotes_callbacks.h b/stickynotes/stickynotes_callbacks.h
index a155d812..57ba9428 100644
--- a/stickynotes/stickynotes_callbacks.h
+++ b/stickynotes/stickynotes_callbacks.h
@@ -52,7 +52,7 @@ stickynote_show_popup_menu (GtkWidget *widget,
gboolean
stickynote_keypress_cb (GtkWidget *widget,
GdkEventKey *event,
- StickyNote *note);
+ GtkMenu *popup_menu);
/* Callbacks for the sticky notes popup menu */
void