[gimp] app: more text tool fixes



commit 94d9dca2a3565845462f8355c0909c6729771eef
Author: Michael Natterer <mitch gimp org>
Date:   Wed Feb 17 11:57:32 2010 +0100

    app: more text tool fixes
    
    - bail out and don't warn like crazy in draw() when there is no text.
    - fix crash in button_press() when clicking a modified text layer
      bring up the confirm dialog and thus didn't set text_tool->text.
    - pull setting the right text on text_tool->text_buffer into
      gimp_text_tool_canvas_editor() (fixes editing after confirming a
      modified text layer edit).
    - add lots of missing calls to gimp_text_tool_set_layer() so the
      tool will actually start editing.

 app/tools/gimptexttool.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index 841599e..8341a36 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -512,13 +512,9 @@ gimp_text_tool_button_press (GimpTool            *tool,
               if (press_type == GIMP_BUTTON_PRESS_NORMAL)
                 {
                   /* enable keyboard-handling for the text */
-                  if (! text)
+                  if (text_tool->text && text_tool->text != text)
                     {
                       gimp_text_tool_canvas_editor (text_tool);
-                      gtk_text_buffer_set_text (buffer,
-                                                text_tool->text->text, -1);
-
-                      gimp_text_tool_update_layout (text_tool);
                     }
                 }
 
@@ -579,7 +575,6 @@ gimp_text_tool_button_press (GimpTool            *tool,
   text_tool->text_box_fixed = FALSE;
 
   gimp_text_tool_connect (text_tool, NULL, NULL);
-  gtk_text_buffer_set_text (buffer, "", -1);
   gimp_text_tool_canvas_editor (text_tool);
 
   gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
@@ -989,7 +984,8 @@ gimp_text_tool_draw (GimpDrawTool *draw_tool)
 
   gimp_rectangle_tool_draw (draw_tool);
 
-  if (! text_tool->layer ||
+  if (! text_tool->text  ||
+      ! text_tool->layer ||
       ! text_tool->layer->text)
     return;
 
@@ -2285,6 +2281,12 @@ gimp_text_tool_canvas_editor (GimpTextTool *text_tool)
 
   gtk_im_context_focus_in (text_tool->im_context);
 
+  if (text_tool->text)
+    gtk_text_buffer_set_text (text_tool->text_buffer,
+                              text_tool->text->text, -1);
+  else
+    gtk_text_buffer_set_text (text_tool->text_buffer, "", -1);
+
   gimp_text_tool_update_layout (text_tool);
 
   if (options->use_editor)
@@ -2584,8 +2586,18 @@ gimp_text_tool_set_layer (GimpTextTool *text_tool,
 
       if (tool->display)
         {
+          GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
+
           tool->drawable = GIMP_DRAWABLE (layer);
 
+          if (gimp_draw_tool_is_active (draw_tool))
+            gimp_draw_tool_stop (draw_tool);
+
+          gimp_draw_tool_start (draw_tool, display);
+
+          gimp_rectangle_tool_frame_item (GIMP_RECTANGLE_TOOL (tool),
+                                          GIMP_ITEM (layer));
+
           gimp_text_tool_canvas_editor (text_tool);
         }
     }



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