From: Andrej Kacian Date: Mon, 12 May 2014 16:39:29 +0000 (+0200) Subject: Make Up key bring focus to Subject line, if the cursor is on the first line of body... X-Git-Tag: 3.10.0~55 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=a5a06781957dde46bf24e75d0c2e9919a980ea54;ds=sidebyside Make Up key bring focus to Subject line, if the cursor is on the first line of body textview. --- diff --git a/src/compose.c b/src/compose.c index cad91a1ae..7a1f17731 100644 --- 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; }