[gimp] app: create a different tag for underlined text during preedit.



commit a86b0cf0a2ce5ca96b4c476aea3fe9bfdca1a6d5
Author: Jehan <jehan girinstud io>
Date:   Wed Jun 1 17:02:21 2016 +0200

    app: create a different tag for underlined text during preedit.
    
    It still shows up as underlined during preedit, but does not toggle the
    underline button in the style editor.

 app/tools/gimptexttool-editor.c |    2 +-
 app/widgets/gimptextbuffer.c    |   29 +++++++++++++++++++++++------
 app/widgets/gimptextbuffer.h    |    2 ++
 3 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index c930194..0ceb257 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -1450,7 +1450,7 @@ gimp_text_tool_im_preedit_changed (GtkIMContext *context,
                         {
                         case PANGO_ATTR_UNDERLINE:
                           gtk_text_buffer_apply_tag (buffer,
-                                                     text_tool->buffer->underline_tag,
+                                                     text_tool->buffer->preedit_underline_tag,
                                                      &start, &end);
                           break;
                         case PANGO_ATTR_BACKGROUND:
diff --git a/app/widgets/gimptextbuffer.c b/app/widgets/gimptextbuffer.c
index a6f040c..271cb41 100644
--- a/app/widgets/gimptextbuffer.c
+++ b/app/widgets/gimptextbuffer.c
@@ -106,6 +106,11 @@ gimp_text_buffer_constructed (GObject *object)
                                                       "underline", PANGO_UNDERLINE_SINGLE,
                                                       NULL);
 
+  buffer->preedit_underline_tag = gtk_text_buffer_create_tag (GTK_TEXT_BUFFER (buffer),
+                                                              "preedit-underline",
+                                                              "underline", PANGO_UNDERLINE_SINGLE,
+                                                              NULL);
+
   buffer->strikethrough_tag = gtk_text_buffer_create_tag (GTK_TEXT_BUFFER (buffer),
                                                           "strikethrough",
                                                           "strikethrough", TRUE,
@@ -1091,12 +1096,14 @@ gimp_text_buffer_set_bg_color (GimpTextBuffer    *buffer,
 
 /*  Pango markup attribute names  */
 
-#define GIMP_TEXT_ATTR_NAME_SIZE     "size"
-#define GIMP_TEXT_ATTR_NAME_BASELINE "rise"
-#define GIMP_TEXT_ATTR_NAME_KERNING  "letter_spacing"
-#define GIMP_TEXT_ATTR_NAME_FONT     "font"
-#define GIMP_TEXT_ATTR_NAME_COLOR    "foreground"
-#define GIMP_TEXT_ATTR_NAME_BG_COLOR "background"
+#define GIMP_TEXT_ATTR_NAME_SIZE      "size"
+#define GIMP_TEXT_ATTR_NAME_BASELINE  "rise"
+#define GIMP_TEXT_ATTR_NAME_KERNING   "letter_spacing"
+#define GIMP_TEXT_ATTR_NAME_FONT      "font"
+#define GIMP_TEXT_ATTR_NAME_STYLE     "style"
+#define GIMP_TEXT_ATTR_NAME_COLOR     "foreground"
+#define GIMP_TEXT_ATTR_NAME_BG_COLOR  "background"
+#define GIMP_TEXT_ATTR_NAME_UNDERLINE "underline"
 
 const gchar *
 gimp_text_buffer_tag_to_name (GimpTextBuffer  *buffer,
@@ -1205,6 +1212,16 @@ gimp_text_buffer_tag_to_name (GimpTextBuffer  *buffer,
 
       return "span";
     }
+  else if (tag == buffer->preedit_underline_tag)
+    {
+      if (attribute)
+        *attribute = GIMP_TEXT_ATTR_NAME_UNDERLINE;
+
+      if (value)
+        *value = g_strdup ("single");
+
+      return "span";
+    }
 
   return NULL;
 }
diff --git a/app/widgets/gimptextbuffer.h b/app/widgets/gimptextbuffer.h
index dc6fa63..15b7ccd 100644
--- a/app/widgets/gimptextbuffer.h
+++ b/app/widgets/gimptextbuffer.h
@@ -47,6 +47,8 @@ struct _GimpTextBuffer
   GList         *color_tags;
   GList         *bg_color_tags;
 
+  GtkTextTag    *preedit_underline_tag;
+
   gboolean       insert_tags_set;
   GList         *insert_tags;
   GList         *remove_tags;


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