[gimp] app: some signal handling/updating fixes that also make undo mostly work



commit 5feec1dd9f7d6454dd7557789f17aa06fcd6a4e0
Author: Michael Natterer <mitch gimp org>
Date:   Fri Feb 19 12:21:03 2010 +0100

    app: some signal handling/updating fixes that also make undo mostly work
    
    - most importantly, when the text changes and we set the buffer (as
      happens when undoing), block the "changed" signal on the *buffer*
      and not on the proxy (which doesn't even have a "changed"
      signal). This was apparently something that happened during the
      on-canvas editor merging.
    - don't update the proxy when the layout changes, that's the wrong way
      around. Instead, update the layout whenever the proxy changes,
      remove lots of calls to update_layout() from the text editor and let
      the "changed" callback on the buffer do its job of updating
      everything.

 app/tools/gimptexttool-editor.c |    8 ++++----
 app/tools/gimptexttool.c        |   23 +++++++++++------------
 2 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index 22c6b32..fe6b318 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -130,8 +130,6 @@ gimp_text_tool_editor_start (GimpTextTool *text_tool)
   else
     gtk_text_buffer_set_text (text_tool->text_buffer, "", -1);
 
-  gimp_text_tool_update_layout (text_tool);
-
   if (options->use_editor)
     gimp_text_tool_editor_dialog (text_tool);
 
@@ -207,7 +205,6 @@ gimp_text_tool_editor_key_press (GimpTextTool *text_tool,
     case GDK_ISO_Enter:
       gimp_text_tool_enter_text (text_tool, "\n");
       gimp_text_tool_reset_im_context (text_tool);
-      gimp_text_tool_update_layout (text_tool);
       break;
 
     case GDK_Tab:
@@ -215,7 +212,6 @@ gimp_text_tool_editor_key_press (GimpTextTool *text_tool,
     case GDK_ISO_Left_Tab:
       gimp_text_tool_enter_text (text_tool, "\t");
       gimp_text_tool_reset_im_context (text_tool);
-      gimp_text_tool_update_layout (text_tool);
       break;
 
     case GDK_Escape:
@@ -862,5 +858,9 @@ gimp_text_tool_preedit_changed_cb (GtkIMContext *context,
 
   text_tool->preedit_len = strlen (text_tool->preedit_string);
 
+  /* FIXME: call gimp_text_tool_update_layout() here, and make sure
+   * the preedit string is *only* honored for the display, and never
+   * ends up on the text object
+   */
   gimp_text_tool_update_proxy (text_tool);
 }
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index 4884b81..0ec1e9e 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -1355,13 +1355,13 @@ gimp_text_tool_text_notify (GimpText     *text,
    */
   if (strcmp (pspec->name, "text") == 0)
     {
-      g_signal_handlers_block_by_func (text_tool->proxy,
+      g_signal_handlers_block_by_func (text_tool->text_buffer,
                                        gimp_text_tool_text_buffer_changed,
                                        text_tool);
 
       gtk_text_buffer_set_text (text_tool->text_buffer, text->text, -1);
 
-      g_signal_handlers_unblock_by_func (text_tool->proxy,
+      g_signal_handlers_unblock_by_func (text_tool->text_buffer,
                                          gimp_text_tool_text_buffer_changed,
                                          text_tool);
 
@@ -1829,25 +1829,24 @@ gimp_text_tool_update_proxy (GimpTextTool *text_tool)
     {
       gimp_text_tool_create_layer (text_tool, NULL);
     }
+
+  gimp_text_tool_update_layout (text_tool);
 }
 
 void
 gimp_text_tool_update_layout (GimpTextTool *text_tool)
 {
-  GimpImage *image;
-
-  if (! text_tool->text)
+  if (text_tool->text)
     {
-      gimp_text_tool_update_proxy (text_tool);
-      return;
-    }
+      GimpImage *image;
 
-  if (text_tool->layout)
-    g_object_unref (text_tool->layout);
+      if (text_tool->layout)
+        g_object_unref (text_tool->layout);
 
-  image = gimp_item_get_image (GIMP_ITEM (text_tool->layer));
+      image = gimp_item_get_image (GIMP_ITEM (text_tool->layer));
 
-  text_tool->layout = gimp_text_layout_new (text_tool->layer->text, image);
+      text_tool->layout = gimp_text_layout_new (text_tool->layer->text, image);
+    }
 }
 
 static gint



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