[pango/pango2: 131/168] Rename PangoUnderline to PangoLineStyle




commit ef158b49734b8ded2bbf27e4a016b2a465a706f2
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Feb 7 00:55:04 2022 -0500

    Rename PangoUnderline to PangoLineStyle

 pango/pango-attr-list.c  |  4 ++--
 pango/pango-attributes.c |  8 ++++----
 pango/pango-attributes.h | 34 ++++++++++++++--------------------
 pango/pango-item.c       |  8 ++++----
 pango/pango-markup.c     |  8 ++++----
 pango/pango-renderer.c   | 38 +++++++++++++++++++-------------------
 pango/pango-renderer.h   |  2 +-
 pango/serializer.c       |  9 ++++-----
 tests/testattributes.c   |  8 ++++----
 9 files changed, 56 insertions(+), 63 deletions(-)
---
diff --git a/pango/pango-attr-list.c b/pango/pango-attr-list.c
index 30de2178..6f85eeec 100644
--- a/pango/pango-attr-list.c
+++ b/pango/pango-attr-list.c
@@ -771,7 +771,7 @@ get_attr_value_type (PangoAttrType type)
     case PANGO_ATTR_STRETCH: return PANGO_TYPE_STRETCH;
     case PANGO_ATTR_GRAVITY: return PANGO_TYPE_GRAVITY;
     case PANGO_ATTR_GRAVITY_HINT: return PANGO_TYPE_GRAVITY_HINT;
-    case PANGO_ATTR_UNDERLINE: return PANGO_TYPE_UNDERLINE;
+    case PANGO_ATTR_UNDERLINE: return PANGO_TYPE_LINE_STYLE;
     case PANGO_ATTR_OVERLINE: return PANGO_TYPE_OVERLINE;
     case PANGO_ATTR_BASELINE_SHIFT: return PANGO_TYPE_BASELINE_SHIFT;
     case PANGO_ATTR_FONT_SCALE: return PANGO_TYPE_FONT_SCALE;
@@ -1141,7 +1141,7 @@ pango_attr_list_from_string (const char *text)
           break;
 
         case PANGO_ATTR_UNDERLINE:
-          ENUM_ATTR(underline, PangoUnderline, PANGO_UNDERLINE_NONE, PANGO_UNDERLINE_ERROR);
+          ENUM_ATTR(underline, PangoLineStyle, PANGO_LINE_STYLE_NONE, PANGO_LINE_STYLE_DOTTED);
           break;
 
         case PANGO_ATTR_UNDERLINE_POSITION:
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 70863859..e4ba9149 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -325,18 +325,18 @@ pango_attr_font_desc_new (const PangoFontDescription *desc)
 
 /**
  * pango_attr_underline_new:
- * @underline: the underline style
+ * @style: the line style
  *
- * Create a new underline-style attribute.
+ * Create a new underline attribute.
  *
  * Return value: (transfer full): the newly allocated
  *   `PangoAttribute`, which should be freed with
  *   [method@Pango.Attribute.destroy]
  */
 PangoAttribute *
-pango_attr_underline_new (PangoUnderline underline)
+pango_attr_underline_new (PangoLineStyle style)
 {
-  return pango_attr_int_new (PANGO_ATTR_UNDERLINE, (int)underline);
+  return pango_attr_int_new (PANGO_ATTR_UNDERLINE, (int)style);
 }
 
 /**
diff --git a/pango/pango-attributes.h b/pango/pango-attributes.h
index 805e1e2c..cbc05ab2 100644
--- a/pango/pango-attributes.h
+++ b/pango/pango-attributes.h
@@ -148,31 +148,25 @@ PANGO_AVAILABLE_IN_ALL
 PangoAttribute *        pango_attr_font_desc_new                (const PangoFontDescription *desc);
 
 /**
- * PangoUnderline:
- * @PANGO_UNDERLINE_NONE: no underline should be drawn
- * @PANGO_UNDERLINE_SINGLE: a single underline should be drawn
- * @PANGO_UNDERLINE_DOUBLE: a double underline should be drawn
- * @PANGO_UNDERLINE_ERROR: an underline indicating an error should
- *   be drawn below. The exact style of rendering is up to the
- *   `PangoRenderer` in use, but typical styles include wavy
- *   or dotted lines.
- *   This underline is typically used to indicate an error such
- *   as a possible mispelling; in some cases a contrasting color
- *   may automatically be used. This type of underlining is
- *   available since Pango 1.4.
+ * PangoLineStyle:
+ * @PANGO_LINE_STYLE_NONE: no line should be drawn
+ * @PANGO_LINE_STYLE_SINGLE: a single line should be drawn
+ * @PANGO_LINE_STYLE_DOUBLE: a double line should be drawn
+ * @PANGO_LINE_STYLE_DOTTED: an dotted line should be drawn
  *
- * The `PangoUnderline` enumeration is used to specify whether text
- * should be underlined, and if so, the type of underlining.
+ * The `PangoLineStyle` enumeration is used to specify how
+ * lines should be drawn.
  */
 typedef enum {
-  PANGO_UNDERLINE_NONE,
-  PANGO_UNDERLINE_SINGLE,
-  PANGO_UNDERLINE_DOUBLE,
-  PANGO_UNDERLINE_ERROR
-} PangoUnderline;
+  PANGO_LINE_STYLE_NONE,
+  PANGO_LINE_STYLE_SINGLE,
+  PANGO_LINE_STYLE_DOUBLE,
+  PANGO_LINE_STYLE_DOTTED
+} PangoLineStyle;
 
 PANGO_AVAILABLE_IN_ALL
-PangoAttribute *        pango_attr_underline_new                (PangoUnderline              underline);
+PangoAttribute *        pango_attr_underline_new                (PangoLineStyle              style);
+
 PANGO_AVAILABLE_IN_1_8
 PangoAttribute *        pango_attr_underline_color_new          (PangoColor                 *color);
 
diff --git a/pango/pango-item.c b/pango/pango-item.c
index 120f1b2f..831ecec3 100644
--- a/pango/pango-item.c
+++ b/pango/pango-item.c
@@ -398,15 +398,15 @@ pango_item_get_properties (PangoItem      *item,
         case PANGO_ATTR_UNDERLINE:
           switch (attr->int_value)
             {
-            case PANGO_UNDERLINE_NONE:
+            case PANGO_LINE_STYLE_NONE:
               break;
-            case PANGO_UNDERLINE_SINGLE:
+            case PANGO_LINE_STYLE_SINGLE:
               properties->uline_single = TRUE;
               break;
-            case PANGO_UNDERLINE_DOUBLE:
+            case PANGO_LINE_STYLE_DOUBLE:
               properties->uline_double = TRUE;
               break;
-            case PANGO_UNDERLINE_ERROR:
+            case PANGO_LINE_STYLE_DOTTED:
               properties->uline_error = TRUE;
               break;
             default:
diff --git a/pango/pango-markup.c b/pango/pango-markup.c
index 3f55a17b..ec79aaa8 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -500,7 +500,7 @@ text_handler           (GMarkupParseContext *context G_GNUC_UNUSED,
                       /* Add the underline indicating the accelerator */
                       PangoAttribute *attr;
 
-                      attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
+                      attr = pango_attr_underline_new (PANGO_LINE_STYLE_SINGLE);
 
                       uline_index = md->index;
                       uline_len = g_utf8_next_char (p) - p;
@@ -1546,9 +1546,9 @@ span_parse_func     (MarkupData            *md G_GNUC_UNUSED,
 
   if (G_UNLIKELY (underline))
     {
-      PangoUnderline ul = PANGO_UNDERLINE_NONE;
+      PangoLineStyle ul = PANGO_LINE_STYLE_NONE;
 
-      if (!span_parse_enum ("underline", underline, PANGO_TYPE_UNDERLINE, (int*)(void*)&ul, line_number, 
error))
+      if (!span_parse_enum ("underline", underline, PANGO_TYPE_LINE_STYLE, (int*)(void*)&ul, line_number, 
error))
        goto error;
 
       add_attribute (tag, pango_attr_underline_new (ul));
@@ -1918,7 +1918,7 @@ u_parse_func        (MarkupData            *md G_GNUC_UNUSED,
                     GError               **error)
 {
   CHECK_NO_ATTRS("u");
-  add_attribute (tag, pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
+  add_attribute (tag, pango_attr_underline_new (PANGO_LINE_STYLE_SINGLE));
 
   return TRUE;
 }
diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c
index 90c0dee4..737ad508 100644
--- a/pango/pango-renderer.c
+++ b/pango/pango-renderer.c
@@ -43,7 +43,7 @@ struct _Point
 
 struct _LineState
 {
-  PangoUnderline underline;
+  PangoLineStyle underline;
   PangoUnderlinePosition underline_position;
   PangoRectangle underline_rect;
 
@@ -171,16 +171,16 @@ draw_underline (PangoRenderer *renderer,
                 LineState     *state)
 {
   PangoRectangle *rect = &state->underline_rect;
-  PangoUnderline underline = state->underline;
+  PangoLineStyle underline = state->underline;
 
-  state->underline = PANGO_UNDERLINE_NONE;
+  state->underline = PANGO_LINE_STYLE_NONE;
   state->underline_position = PANGO_UNDERLINE_POSITION_NORMAL;
 
   switch (underline)
     {
-    case PANGO_UNDERLINE_NONE:
+    case PANGO_LINE_STYLE_NONE:
       break;
-    case PANGO_UNDERLINE_DOUBLE:
+    case PANGO_LINE_STYLE_DOUBLE:
       pango_renderer_draw_rectangle (renderer,
                                      PANGO_RENDER_PART_UNDERLINE,
                                      rect->x,
@@ -188,7 +188,7 @@ draw_underline (PangoRenderer *renderer,
                                      rect->width,
                                      rect->height);
       G_GNUC_FALLTHROUGH;
-    case PANGO_UNDERLINE_SINGLE:
+    case PANGO_LINE_STYLE_SINGLE:
       pango_renderer_draw_rectangle (renderer,
                                      PANGO_RENDER_PART_UNDERLINE,
                                      rect->x,
@@ -196,7 +196,7 @@ draw_underline (PangoRenderer *renderer,
                                      rect->width,
                                      rect->height);
       break;
-    case PANGO_UNDERLINE_ERROR:
+    case PANGO_LINE_STYLE_DOTTED:
       pango_renderer_draw_error_underline (renderer,
                                            rect->x,
                                            rect->y,
@@ -266,7 +266,7 @@ handle_line_state_change (PangoRenderer  *renderer,
     return;
 
   if (part == PANGO_RENDER_PART_UNDERLINE &&
-      state->underline != PANGO_UNDERLINE_NONE)
+      state->underline != PANGO_LINE_STYLE_NONE)
     {
       PangoRectangle *rect = &state->underline_rect;
 
@@ -323,18 +323,18 @@ add_underline (PangoRenderer    *renderer,
 
   switch (renderer->underline)
     {
-    case PANGO_UNDERLINE_NONE:
+    case PANGO_LINE_STYLE_NONE:
       g_assert_not_reached ();
       break;
-    case PANGO_UNDERLINE_SINGLE:
+    case PANGO_LINE_STYLE_SINGLE:
       if (state->underline_position == PANGO_UNDERLINE_POSITION_UNDER)
         {
           new_rect.y += ink_rect->y + ink_rect->height + underline_thickness;
           break;
         }
       G_GNUC_FALLTHROUGH;
-    case PANGO_UNDERLINE_DOUBLE:
-    case PANGO_UNDERLINE_ERROR:
+    case PANGO_LINE_STYLE_DOUBLE:
+    case PANGO_LINE_STYLE_DOTTED:
       new_rect.y -= underline_position;
       if (state->underline == renderer->underline)
         {
@@ -490,7 +490,7 @@ pango_renderer_draw_line (PangoRenderer   *renderer,
   renderer->priv->line = line;
   renderer->priv->line_state = &state;
 
-  state.underline = PANGO_UNDERLINE_NONE;
+  state.underline = PANGO_LINE_STYLE_NONE;
   state.underline_position = PANGO_UNDERLINE_POSITION_NORMAL;
   state.overline = PANGO_OVERLINE_NONE;
   state.strikethrough = FALSE;
@@ -582,7 +582,7 @@ pango_renderer_draw_runs (PangoRenderer *renderer,
 
       pango_renderer_prepare_run (renderer, run);
 
-      if (renderer->underline != PANGO_UNDERLINE_NONE ||
+      if (renderer->underline != PANGO_LINE_STYLE_NONE ||
           renderer->priv->overline != PANGO_OVERLINE_NONE ||
           renderer->strikethrough)
         {
@@ -632,14 +632,14 @@ pango_renderer_draw_runs (PangoRenderer *renderer,
 
       pango_renderer_draw_glyph_item (renderer, text, glyph_item, x + x_off, y - y_off);
 
-      if (renderer->underline != PANGO_UNDERLINE_NONE ||
+      if (renderer->underline != PANGO_LINE_STYLE_NONE ||
           renderer->priv->overline != PANGO_OVERLINE_NONE ||
           renderer->strikethrough)
         {
           metrics = pango_font_get_metrics (item->analysis.font,
                                             item->analysis.language);
 
-          if (renderer->underline != PANGO_UNDERLINE_NONE)
+          if (renderer->underline != PANGO_LINE_STYLE_NONE)
             add_underline (renderer, renderer->priv->line_state, metrics,
                            x + x_off, y - y_off,
                            ink, logical);
@@ -657,8 +657,8 @@ pango_renderer_draw_runs (PangoRenderer *renderer,
           pango_font_metrics_unref (metrics);
         }
 
-      if (renderer->underline == PANGO_UNDERLINE_NONE &&
-          renderer->priv->line_state->underline != PANGO_UNDERLINE_NONE)
+      if (renderer->underline == PANGO_LINE_STYLE_NONE &&
+          renderer->priv->line_state->underline != PANGO_LINE_STYLE_NONE)
         draw_underline (renderer, renderer->priv->line_state);
 
       if (renderer->priv->overline == PANGO_OVERLINE_NONE &&
@@ -1407,7 +1407,7 @@ pango_renderer_default_prepare_run (PangoRenderer  *renderer,
 
   glyph_item = pango_run_get_glyph_item (run);
 
-  renderer->underline = PANGO_UNDERLINE_NONE;
+  renderer->underline = PANGO_LINE_STYLE_NONE;
   renderer->underline_position = PANGO_UNDERLINE_POSITION_NORMAL;
   renderer->priv->overline = PANGO_OVERLINE_NONE;
   renderer->strikethrough = FALSE;
diff --git a/pango/pango-renderer.h b/pango/pango-renderer.h
index 82e2dd88..ea5816f5 100644
--- a/pango/pango-renderer.h
+++ b/pango/pango-renderer.h
@@ -82,7 +82,7 @@ struct _PangoRenderer
   /*< private >*/
   GObject parent_instance;
 
-  PangoUnderline underline;
+  PangoLineStyle underline;
   PangoUnderlinePosition underline_position;
   gboolean strikethrough;
   int active_count;
diff --git a/pango/serializer.c b/pango/serializer.c
index b2ad6091..3801ba67 100644
--- a/pango/serializer.c
+++ b/pango/serializer.c
@@ -73,12 +73,11 @@ static const char *stretch_names[] = {
   NULL
 };
 
-static const char *underline_names[] = {
+static const char *line_style_names[] = {
   "none",
   "single",
   "double",
-  "low",
-  "error",
+  "dotted",
   NULL
 };
 
@@ -320,7 +319,7 @@ add_attribute (GtkJsonPrinter *printer,
           break;
 
         case PANGO_ATTR_UNDERLINE:
-          gtk_json_printer_add_string (printer, "value", underline_names[attr->int_value]);
+          gtk_json_printer_add_string (printer, "value", line_style_names[attr->int_value]);
           break;
 
         case PANGO_ATTR_UNDERLINE_POSITION:
@@ -1002,7 +1001,7 @@ attr_for_type (GtkJsonParser *parser,
       break;
 
     case PANGO_ATTR_UNDERLINE:
-      attr = pango_attr_underline_new ((PangoUnderline) parser_select_string (parser, underline_names));
+      attr = pango_attr_underline_new ((PangoLineStyle) parser_select_string (parser, line_style_names));
       break;
 
     case PANGO_ATTR_UNDERLINE_POSITION:
diff --git a/tests/testattributes.c b/tests/testattributes.c
index 40fee748..41b0d961 100644
--- a/tests/testattributes.c
+++ b/tests/testattributes.c
@@ -50,8 +50,8 @@ test_attributes_basic (void)
   desc = pango_font_description_from_string ("Computer Modern 12");
   test_copy (pango_attr_font_desc_new (desc));
   pango_font_description_free (desc);
-  test_copy (pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
-  test_copy (pango_attr_underline_new (PANGO_UNDERLINE_ERROR));
+  test_copy (pango_attr_underline_new (PANGO_LINE_STYLE_SINGLE));
+  test_copy (pango_attr_underline_new (PANGO_LINE_STYLE_DOTTED));
   test_copy (pango_attr_underline_color_new (&(PangoColor){100, 200, 300}));
   test_copy (pango_attr_overline_new (PANGO_OVERLINE_SINGLE));
   test_copy (pango_attr_overline_color_new (&(PangoColor){100, 200, 300}));
@@ -230,8 +230,8 @@ test_binding_helpers (void)
   desc = pango_font_description_from_string ("Computer Modern 12");
   test_binding (pango_attr_font_desc_new (desc));
   pango_font_description_free (desc);
-  test_binding (pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
-  test_binding (pango_attr_underline_new (PANGO_UNDERLINE_ERROR));
+  test_binding (pango_attr_underline_new (PANGO_LINE_STYLE_SINGLE));
+  test_binding (pango_attr_underline_new (PANGO_LINE_STYLE_DOTTED));
   test_binding (pango_attr_underline_color_new (&(PangoColor){100, 200, 300}));
   test_binding (pango_attr_overline_new (PANGO_OVERLINE_SINGLE));
   test_binding (pango_attr_overline_color_new (&(PangoColor){100, 200, 300}));


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