talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit a5a06781957dde46bf24e75d0c2e9919a980ea54
parent b976c1dc267711cee1bfea10ab241b38b2c99a21
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Mon, 12 May 2014 18:39:29 +0200

Make Up key bring focus to Subject line, if the cursor is on the first line of body textview.

Diffstat:
Msrc/compose.c | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/compose.c b/src/compose.c @@ -11005,6 +11005,10 @@ static gboolean completion_set_focus_to_subject GdkEventKey *event, Compose *compose) { + GtkTextBuffer *buffer; + GtkTextMark *mark; + GtkTextIter iter; + cm_return_val_if_fail(compose != NULL, FALSE); /* make backtab move to subject field */ @@ -11012,6 +11016,24 @@ static gboolean completion_set_focus_to_subject gtk_widget_grab_focus(compose->subject_entry); return TRUE; } + + // Up key should also move the focus to subject field, if the cursor + // is on the first line. + if (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_KP_Up) { + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)); + g_return_val_if_fail(buffer != NULL, FALSE); + + mark = gtk_text_buffer_get_mark(buffer, "insert"); + g_return_val_if_fail(mark != NULL, FALSE); + + gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark); + + if (gtk_text_iter_get_line(&iter) == 0) { + gtk_widget_grab_focus(compose->subject_entry); + return TRUE; + } + } + return FALSE; }