summaryrefslogtreecommitdiff
path: root/stickynotes
diff options
context:
space:
mode:
authorColomban Wendling <[email protected]>2021-10-07 19:43:23 +0200
committerraveit65 <[email protected]>2021-10-26 16:00:45 +0200
commit999eec53c643721b37bc7ad847cdfdf93c124085 (patch)
tree7b6eb27b0e6d3588179141c834e225d7d1a93cf4 /stickynotes
parentd3527344f928d0352e6ec92e6e6d954374664e71 (diff)
downloadmate-applets-999eec53c643721b37bc7ad847cdfdf93c124085.tar.bz2
mate-applets-999eec53c643721b37bc7ad847cdfdf93c124085.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