[gimp/gimp-2-8] app: make Tab, Shift+Tab and Escape move the focus back to text editing



commit 2a77d536aaa4db9f7f1ce17a3a630fb1c2dc960f
Author: Michael Natterer <mitch gimp org>
Date:   Fri Nov 9 22:06:51 2012 +0100

    app: make Tab, Shift+Tab and Escape move the focus back to text editing
    
    when it was in the floating text style editor. While this doesn't fix
    anything by itself, it enables fixing text style setting to behave
    reasonably when there is no selection.
    (cherry picked from commit 76b05c2afcfb58c1cf00020d39cce23de91af6a5)

 app/tools/gimptexttool-editor.c |   34 +++++++++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 7 deletions(-)
---
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index 1533245..c4e950e 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -415,18 +415,38 @@ gboolean
 gimp_text_tool_editor_key_press (GimpTextTool *text_tool,
                                  GdkEventKey  *kevent)
 {
-  GtkTextBuffer *buffer = GTK_TEXT_BUFFER (text_tool->buffer);
-  GtkTextIter    cursor;
-  GtkTextIter    selection;
-  gint           x_pos  = -1;
-  gboolean       retval = TRUE;
+  GimpTool         *tool   = GIMP_TOOL (text_tool);
+  GimpDisplayShell *shell  = gimp_display_get_shell (tool->display);
+  GtkTextBuffer    *buffer = GTK_TEXT_BUFFER (text_tool->buffer);
+  GtkTextIter       cursor;
+  GtkTextIter       selection;
+  gboolean          retval = TRUE;
+
+  if (! gtk_widget_has_focus (shell->canvas))
+    {
+      /*  The focus is in the floating style editor, and the event
+       *  was not handled there, focus the canvas.
+       */
+      switch (kevent->keyval)
+        {
+        case GDK_KEY_Tab:
+        case GDK_KEY_KP_Tab:
+        case GDK_KEY_ISO_Left_Tab:
+        case GDK_KEY_Escape:
+          gtk_widget_grab_focus (shell->canvas);
+          return TRUE;
+
+        default:
+          break;
+        }
+    }
 
   if (gtk_im_context_filter_keypress (text_tool->im_context, kevent))
     {
       text_tool->needs_im_reset = TRUE;
       text_tool->x_pos          = -1;
 
-     return TRUE;
+      return TRUE;
     }
 
   gimp_text_tool_ensure_proxy (text_tool);
@@ -470,7 +490,7 @@ gimp_text_tool_editor_key_press (GimpTextTool *text_tool,
       retval = FALSE;
     }
 
-  text_tool->x_pos = x_pos;
+  text_tool->x_pos = -1;
 
   return retval;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]