diff options
Diffstat (limited to 'stickynotes')
-rw-r--r-- | stickynotes/stickynotes.c | 6 | ||||
-rw-r--r-- | stickynotes/stickynotes_callbacks.c | 25 | ||||
-rw-r--r-- | stickynotes/stickynotes_callbacks.h | 2 |
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 |