[pango/line-breaker: 33/33] The big rename, part 2




commit d8565ee95707e08c829905e7608e1e1e99e60fef
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jan 21 00:19:44 2022 -0500

    The big rename, part 2
    
    Follow-ups.

 examples/parshape.c        |  2 +-
 pango/pango-attributes.c   | 10 +++---
 pango/pango-layout.c       | 46 ++++++++++++------------
 pango/pango-layout.h       |  8 ++---
 pango/pango-line-breaker.c | 18 +++++-----
 pango/pango-line-breaker.h |  2 +-
 pango/pango-lines.c        |  2 +-
 pango/pango-types.h        | 88 ++++++++++++++++++++--------------------------
 pango/serializer.c         | 30 +++++-----------
 tests/testmisc.c           |  2 +-
 10 files changed, 90 insertions(+), 118 deletions(-)
---
diff --git a/examples/parshape.c b/examples/parshape.c
index 0a233f4d..b8380145 100644
--- a/examples/parshape.c
+++ b/examples/parshape.c
@@ -68,7 +68,7 @@ main (int argc, char *argv[])
 
       line = pango_line_breaker_next_line (breaker,
                                            x, width,
-                                           PANGO_LINE_WRAP_CHAR,
+                                           PANGO_WRAP_CHAR,
                                            PANGO_ELLIPSIZE_NONE);
 
       pango_line_get_extents (line, NULL, &ext);
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 60d14706..7aaa75fe 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -1485,9 +1485,8 @@ pango_attr_overline_color_new (guint16 red,
  * Modify the height of logical line extents by a factor.
  *
  * This affects the values returned by
- * [method@Pango.LayoutLine.get_extents],
- * [method@Pango.LayoutLine.get_pixel_extents] and
- * [method@Pango.LayoutIter.get_line_extents].
+ * [method Pango Line.get_extents] and
+ * [method@Pango.LineIter.get_line_extents].
  *
  *
  * Since: 1.50
@@ -1512,9 +1511,8 @@ pango_attr_line_height_new (double factor)
  * Override the height of logical line extents to be @height.
  *
  * This affects the values returned by
- * [method@Pango.LayoutLine.get_extents],
- * [method@Pango.LayoutLine.get_pixel_extents] and
- * [method@Pango.LayoutIter.get_line_extents].
+ * [method Pango Line.get_extents],
+ * [method@Pango.LineIter.get_line_extents].
  *
  * Since: 1.50
  */
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 3cf4b127..01317242 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -24,11 +24,11 @@ struct _PangoLayout
   int width;
   int height;
   PangoTabArray *tabs;
-  PangoLineWrapMode wrap;
+  PangoWrapMode wrap;
   int indent;
   guint serial;
   guint context_serial;
-  PangoAlignmentMode alignment;
+  PangoAlignment alignment;
   PangoEllipsizeMode ellipsize;
   gboolean auto_dir;
 
@@ -70,8 +70,8 @@ pango_layout_init (PangoLayout *layout)
   layout->width = -1;
   layout->height = -1;
   layout->indent = 0;
-  layout->wrap = PANGO_LINE_WRAP_WORD;
-  layout->alignment = PANGO_ALIGNMENT_LEFT;
+  layout->wrap = PANGO_WRAP_WORD;
+  layout->alignment = PANGO_ALIGN_LEFT;
   layout->ellipsize = PANGO_ELLIPSIZE_NONE;
   layout->line_spacing = 0.0;
   layout->auto_dir = TRUE;
@@ -355,11 +355,11 @@ pango_layout_class_init (PangoLayoutClass *class)
    * The wrap mode influences how Pango chooses line breaks
    * when text needs to be wrapped.
    *
-   * The default value is `PANGO_LINE_WRAP_WORD`.
+   * The default value is `PANGO_WRAP_WORD`.
    */
   props[PROP_WRAP] = g_param_spec_flags ("wrap", "wrap", "wrap",
-                                         PANGO_TYPE_LINE_WRAP_MODE,
-                                         PANGO_LINE_WRAP_WORD,
+                                         PANGO_TYPE_WRAP_MODE,
+                                         PANGO_WRAP_WORD,
                                          G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
 
   /**
@@ -387,8 +387,8 @@ pango_layout_class_init (PangoLayoutClass *class)
    * The default value is `PANGO_ALIGNMENT_LEFT`.
    */
   props[PROP_ALIGNMENT] = g_param_spec_enum ("alignment", "alignment", "alignment",
-                                             PANGO_TYPE_ALIGNMENT_MODE,
-                                             PANGO_ALIGNMENT_LEFT,
+                                             PANGO_TYPE_ALIGNMENT,
+                                             PANGO_ALIGN_LEFT,
                                              G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
 
   /**
@@ -494,7 +494,7 @@ get_effective_attributes (PangoLayout *layout)
 static gboolean
 ends_with_paragraph_separator (PangoLayout *layout)
 {
-  if (layout->wrap & PANGO_LINE_WRAP_NO_PARA)
+  if (layout->wrap & PANGO_WRAP_NO_PARA)
     return FALSE;
 
   return g_str_has_suffix (layout->text, "\n") ||
@@ -573,21 +573,21 @@ retry:
       offset = 0;
       switch (layout->alignment)
         {
-        case PANGO_ALIGNMENT_LEFT:
+        case PANGO_ALIGN_LEFT:
           break;
-        case PANGO_ALIGNMENT_CENTER:
+        case PANGO_ALIGN_CENTER:
           if (ext.width < width)
             offset = (width - ext.width) / 2;
           break;
-        case PANGO_ALIGNMENT_RIGHT:
+        case PANGO_ALIGN_RIGHT:
           if (ext.width < width)
             offset = width - ext.width;
           break;
-        case PANGO_ALIGNMENT_JUSTIFY:
+        case PANGO_ALIGN_JUSTIFY:
           if (!pango_line_ends_paragraph (line))
             line = pango_line_justify (line, width);
           break;
-        case PANGO_ALIGNMENT_JUSTIFY_ALL:
+        case PANGO_ALIGN_JUSTIFY_ALL:
           line = pango_line_justify (line, width);
           break;
         default: g_assert_not_reached ();
@@ -1069,8 +1069,8 @@ pango_layout_get_tabs (PangoLayout *layout)
  * The default value is %PANGO_WRAP_WORD.
  */
 void
-pango_layout_set_wrap (PangoLayout       *layout,
-                       PangoLineWrapMode  wrap)
+pango_layout_set_wrap (PangoLayout   *layout,
+                       PangoWrapMode  wrap)
 {
   g_return_if_fail (PANGO_IS_LAYOUT (layout));
 
@@ -1091,7 +1091,7 @@ pango_layout_set_wrap (PangoLayout       *layout,
  *
  * Return value: active wrap mode.
  */
-PangoLineWrapMode
+PangoWrapMode
 pango_layout_get_wrap (PangoLayout *layout)
 {
   g_return_val_if_fail (PANGO_IS_LAYOUT (layout), PANGO_WRAP_WORD);
@@ -1153,11 +1153,11 @@ pango_layout_get_indent (PangoLayout *layout)
  * Sets the alignment for the layout: how short lines are
  * positioned within the horizontal space available.
  *
- * The default alignment is `PANGO_ALIGNMENT_LEFT`.
+ * The default alignment is `PANGO_ALIGN_LEFT`.
  */
 void
-pango_layout_set_alignment (PangoLayout        *layout,
-                            PangoAlignmentMode  alignment)
+pango_layout_set_alignment (PangoLayout    *layout,
+                            PangoAlignment  alignment)
 {
   g_return_if_fail (PANGO_IS_LAYOUT (layout));
 
@@ -1179,10 +1179,10 @@ pango_layout_set_alignment (PangoLayout        *layout,
  *
  * Return value: the alignment
  */
-PangoAlignmentMode
+PangoAlignment
 pango_layout_get_alignment (PangoLayout *layout)
 {
-  g_return_val_if_fail (PANGO_IS_LAYOUT (layout), PANGO_ALIGNMENT_LEFT);
+  g_return_val_if_fail (PANGO_IS_LAYOUT (layout), PANGO_ALIGN_LEFT);
 
   return layout->alignment;
 }
diff --git a/pango/pango-layout.h b/pango/pango-layout.h
index 5bd94cd0..7eed4c52 100644
--- a/pango/pango-layout.h
+++ b/pango/pango-layout.h
@@ -90,10 +90,10 @@ PangoTabArray *         pango_layout_get_tabs       (PangoLayout
 
 PANGO_AVAILABLE_IN_ALL
 void                    pango_layout_set_wrap       (PangoLayout                  *layout,
-                                                     PangoLineWrapMode             wrap);
+                                                     PangoWrapMode                 wrap);
 
 PANGO_AVAILABLE_IN_ALL
-PangoLineWrapMode       pango_layout_get_wrap       (PangoLayout                  *layout);
+PangoWrapMode           pango_layout_get_wrap       (PangoLayout                  *layout);
 
 PANGO_AVAILABLE_IN_ALL
 void                    pango_layout_set_indent     (PangoLayout                  *layout,
@@ -104,10 +104,10 @@ int                     pango_layout_get_indent     (PangoLayout
 
 PANGO_AVAILABLE_IN_ALL
 void                    pango_layout_set_alignment  (PangoLayout                  *layout,
-                                                     PangoAlignmentMode            alignment);
+                                                     PangoAlignment                alignment);
 
 PANGO_AVAILABLE_IN_ALL
-PangoAlignmentMode      pango_layout_get_alignment  (PangoLayout                  *layout);
+PangoAlignment          pango_layout_get_alignment  (PangoLayout                  *layout);
 
 PANGO_AVAILABLE_IN_ALL
 void                    pango_layout_set_ellipsize  (PangoLayout                  *layout,
diff --git a/pango/pango-line-breaker.c b/pango/pango-line-breaker.c
index e6e4b60f..c97d1a0c 100644
--- a/pango/pango-line-breaker.c
+++ b/pango/pango-line-breaker.c
@@ -31,7 +31,7 @@
  * `PangoLine` objects for the text, one by one.
  *
  * `PangoLineBreaker` is meant to enable use cases like flowing text around images,
- * or shaped paragraphs. For simple formatting needs, [class@Pango.SimpleLayout]
+ * or shaped paragraphs. For simple formatting needs, [class@Pango.Layout]
  * is probably more convenient to use.
  */
 
@@ -63,7 +63,7 @@ struct _PangoLineBreaker
   PangoAttrList *render_attrs; /* Attributes to be re-added after line breaking */
 
   /* Arguments to next_line, for use while processing the next line */
-  PangoLineWrapMode line_wrap;
+  PangoWrapMode line_wrap;
   PangoEllipsizeMode line_ellipsize;
 
   int tab_width;                  /* Cached width of a tab. -1 == not yet calculated */
@@ -141,7 +141,7 @@ item_is_paragraph_separator (PangoLineBreaker *self,
 {
   gunichar ch;
 
-  if (self->line_wrap & PANGO_LINE_WRAP_NO_PARA)
+  if (self->line_wrap & PANGO_WRAP_NO_PARA)
     return FALSE;
 
   ch = g_utf8_get_char (self->data->text + item->offset);
@@ -869,11 +869,11 @@ shape_tab (PangoLineBreaker *self,
 static inline gboolean
 can_break_at (PangoLineBreaker  *self,
               gint               offset,
-              PangoLineWrapMode  wrap)
+              PangoWrapMode  wrap)
 {
   if (offset == self->data->n_chars)
     return TRUE;
-  else if ((wrap & ~PANGO_LINE_WRAP_NO_PARA) == PANGO_LINE_WRAP_CHAR)
+  else if ((wrap & ~PANGO_WRAP_NO_PARA) == PANGO_WRAP_CHAR)
     return self->data->log_attrs[offset].is_char_break;
   else
     return self->data->log_attrs[offset].is_line_break;
@@ -1251,7 +1251,7 @@ process_item (PangoLineBreaker *self,
   int processing_new_item;
   int num_chars;
   int orig_width;
-  PangoLineWrapMode wrap;
+  PangoWrapMode wrap;
   int break_num_chars;
   int break_width;
   int break_extra_width;
@@ -1499,13 +1499,13 @@ retry_break:
         width += self->log_widths[self->log_widths_offset + num_chars];
     }
 
-   if ((wrap & ~PANGO_LINE_WRAP_NO_PARA) == PANGO_LINE_WRAP_WORD_CHAR &&
+   if ((wrap & ~PANGO_WRAP_NO_PARA) == PANGO_WRAP_WORD_CHAR &&
        force_fit &&
        break_width + break_extra_width > self->remaining_width)
     {
       /* Try again, with looser conditions */
       DEBUG1 ("does not fit, try again with wrap-char");
-      wrap = PANGO_LINE_WRAP_CHAR;
+      wrap = PANGO_WRAP_CHAR;
       break_num_chars = item->num_chars;
       break_width = orig_width;
       break_extra_width = orig_extra_width;
@@ -2475,7 +2475,7 @@ PangoLine *
 pango_line_breaker_next_line (PangoLineBreaker   *self,
                               int                 x,
                               int                 width,
-                              PangoLineWrapMode   wrap,
+                              PangoWrapMode   wrap,
                               PangoEllipsizeMode  ellipsize)
 {
   PangoLine *line;
diff --git a/pango/pango-line-breaker.h b/pango/pango-line-breaker.h
index c847b503..050d98ff 100644
--- a/pango/pango-line-breaker.h
+++ b/pango/pango-line-breaker.h
@@ -47,7 +47,7 @@ PANGO_AVAILABLE_IN_ALL
 PangoLine *             pango_line_breaker_next_line    (PangoLineBreaker      *self,
                                                          int                    x,
                                                          int                    width,
-                                                         PangoLineWrapMode      wrap,
+                                                         PangoWrapMode          wrap,
                                                          PangoEllipsizeMode     ellipsize);
 
 PANGO_AVAILABLE_IN_ALL
diff --git a/pango/pango-lines.c b/pango/pango-lines.c
index 665a79f1..c9f789b6 100644
--- a/pango/pango-lines.c
+++ b/pango/pango-lines.c
@@ -761,7 +761,7 @@ pango_lines_get_cursor_pos (PangoLines     *lines,
  * Note that @idx is allowed to be @line->start_index + @line->length
  * for the position off the end of the last line.
  *
- * This is a variant of [method@Pango.Layout.get_cursor_pos] that applies
+ * This is a variant of [method@Pango.Lines.get_cursor_pos] that applies
  * font metric information about caret slope and offset to the positions
  * it returns.
  *
diff --git a/pango/pango-types.h b/pango/pango-types.h
index 147b158a..1d70114f 100644
--- a/pango/pango-types.h
+++ b/pango/pango-types.h
@@ -239,25 +239,47 @@ void pango_extents_to_pixels (PangoRectangle *inclusive,
 #include <pango/pango-script.h>
 #include <pango/pango-bidi-type.h>
 
+/**
+ * PangoEllipsizeMode:
+ * @PANGO_ELLIPSIZE_NONE: No ellipsization
+ * @PANGO_ELLIPSIZE_START: Omit characters at the start of the text
+ * @PANGO_ELLIPSIZE_MIDDLE: Omit characters in the middle of the text
+ * @PANGO_ELLIPSIZE_END: Omit characters at the end of the text
+ *
+ * `PangoEllipsizeMode` describes what sort of ellipsization
+ * should be applied to text.
+ *
+ * In the ellipsization process characters are removed from the
+ * text in order to make it fit to a given width and replaced
+ * with an ellipsis.
+ */
+typedef enum {
+  PANGO_ELLIPSIZE_NONE,
+  PANGO_ELLIPSIZE_START,
+  PANGO_ELLIPSIZE_MIDDLE,
+  PANGO_ELLIPSIZE_END
+} PangoEllipsizeMode;
+
 /**
  * PangoAlignment:
  * @PANGO_ALIGN_LEFT: Put all available space on the right
  * @PANGO_ALIGN_CENTER: Center the line within the available space
  * @PANGO_ALIGN_RIGHT: Put all available space on the left
+ * @PANGO_ALIGN_JUSTIFY: Justify the content to fill the available
+ *   space, unless the line ends the paragraph
+ * @PANGO_ALIGN_JUSTIFY_ALL: Justify the content to fill the available
+ *   space, even if the line ends the paragraph
  *
  * `PangoAlignment` describes how to align the lines of a `PangoLayout`
  * within the available space.
- *
- * If the `PangoLayout` is set to justify using [method@Pango.Layout.set_justify],
- * this only affects partial lines.
- *
- * See [method@Pango.Layout.set_auto_dir] for how text direction affects
- * the interpretation of `PangoAlignment` values.
  */
-typedef enum {
+typedef enum
+{
   PANGO_ALIGN_LEFT,
   PANGO_ALIGN_CENTER,
-  PANGO_ALIGN_RIGHT
+  PANGO_ALIGN_RIGHT,
+  PANGO_ALIGN_JUSTIFY,
+  PANGO_ALIGN_JUSTIFY_ALL,
 } PangoAlignment;
 
 /**
@@ -266,58 +288,24 @@ typedef enum {
  * @PANGO_WRAP_CHAR: wrap lines at character boundaries.
  * @PANGO_WRAP_WORD_CHAR: wrap lines at word boundaries, but fall back to
  *   character boundaries if there is not enough space for a full word.
+ * @PANGO_WRAP_NO_PARA: Don't treat paragraph separators as mandatory breaks
  *
- * `PangoWrapMode` describes how to wrap the lines of a `PangoLayout`
+ * `PangoWrapMode` flags describe how to wrap the lines of a `PangoLayout`
  * to the desired width.
  *
  * For @PANGO_WRAP_WORD, Pango uses break opportunities that are determined
  * by the Unicode line breaking algorithm. For @PANGO_WRAP_CHAR, Pango allows
  * breaking at grapheme boundaries that are determined by the Unicode text
  * segmentation algorithm.
- */
-typedef enum {
-  PANGO_WRAP_WORD,
-  PANGO_WRAP_CHAR,
-  PANGO_WRAP_WORD_CHAR,
-} PangoWrapMode;
-
-/**
- * PangoEllipsizeMode:
- * @PANGO_ELLIPSIZE_NONE: No ellipsization
- * @PANGO_ELLIPSIZE_START: Omit characters at the start of the text
- * @PANGO_ELLIPSIZE_MIDDLE: Omit characters in the middle of the text
- * @PANGO_ELLIPSIZE_END: Omit characters at the end of the text
  *
- * `PangoEllipsizeMode` describes what sort of ellipsization
- * should be applied to text.
- *
- * In the ellipsization process characters are removed from the
- * text in order to make it fit to a given width and replaced
- * with an ellipsis.
+ * `PANGO_WRAP_MODE_NO_PARA` can be added to any of the other wrap modes.
  */
 typedef enum {
-  PANGO_ELLIPSIZE_NONE,
-  PANGO_ELLIPSIZE_START,
-  PANGO_ELLIPSIZE_MIDDLE,
-  PANGO_ELLIPSIZE_END
-} PangoEllipsizeMode;
-
-
-typedef enum
-{
-  PANGO_ALIGNMENT_LEFT,
-  PANGO_ALIGNMENT_CENTER,
-  PANGO_ALIGNMENT_RIGHT,
-  PANGO_ALIGNMENT_JUSTIFY,
-  PANGO_ALIGNMENT_JUSTIFY_ALL,
-} PangoAlignmentMode;
-
-typedef enum {
-  PANGO_LINE_WRAP_WORD      = 1 << 0,
-  PANGO_LINE_WRAP_CHAR      = 1 << 1,
-  PANGO_LINE_WRAP_WORD_CHAR = PANGO_LINE_WRAP_WORD|PANGO_LINE_WRAP_CHAR,
-  PANGO_LINE_WRAP_NO_PARA   = 1 << 2,
-} PangoLineWrapMode;
+  PANGO_WRAP_WORD      = 1 << 0,
+  PANGO_WRAP_CHAR      = 1 << 1,
+  PANGO_WRAP_WORD_CHAR = PANGO_WRAP_WORD|PANGO_WRAP_CHAR,
+  PANGO_WRAP_NO_PARA   = 1 << 2,
+} PangoWrapMode;
 
 G_END_DECLS
 
diff --git a/pango/serializer.c b/pango/serializer.c
index 54e6f682..0ad06a6a 100644
--- a/pango/serializer.c
+++ b/pango/serializer.c
@@ -242,13 +242,6 @@ static const char *direction_names[] = {
 };
 
 static const char *alignment_names[] = {
-  "left",
-  "center",
-  "right",
-  NULL
-};
-
-static const char *alignment_names2[] = {
   "left",
   "center",
   "right",
@@ -257,13 +250,6 @@ static const char *alignment_names2[] = {
   NULL
 };
 
-static const char *wrap_names[] = {
-  "word",
-  "char",
-  "word-char",
-  NULL
-};
-
 static const char *ellipsize_names[] = {
   "none",
   "start",
@@ -273,13 +259,13 @@ static const char *ellipsize_names[] = {
 };
 
 static char *
-wrap_to_string (PangoLineWrapMode value)
+wrap_to_string (PangoWrapMode value)
 {
   GString *str;
   GFlagsClass *flags_class;
   GFlagsValue *flags_value;
 
-  flags_class = g_type_class_ref (PANGO_TYPE_LINE_WRAP_MODE);
+  flags_class = g_type_class_ref (PANGO_TYPE_WRAP_MODE);
 
   str = g_string_new (NULL);
   while ((str->len == 0 || value != 0) &&
@@ -298,14 +284,14 @@ wrap_to_string (PangoLineWrapMode value)
   return g_string_free (str, FALSE);
 }
 
-static PangoLineWrapMode
+static PangoWrapMode
 string_to_wrap (const char *str)
 {
   int value = 0;
 
-  pango_parse_flags (PANGO_TYPE_LINE_WRAP_MODE, str, &value, NULL);
+  pango_parse_flags (PANGO_TYPE_WRAP_MODE, str, &value, NULL);
 
-  return (PangoLineWrapMode) value;
+  return (PangoWrapMode) value;
 }
 
 /* }}} */
@@ -857,8 +843,8 @@ layout_to_json (GtkJsonPrinter            *printer,
   if (!pango_layout_get_auto_dir (layout))
     gtk_json_printer_add_boolean (printer, "auto-dir", FALSE);
 
-  if (pango_layout_get_alignment (layout) != PANGO_ALIGNMENT_LEFT)
-    gtk_json_printer_add_string (printer, "alignment", alignment_names2[pango_layout_get_alignment 
(layout)]);
+  if (pango_layout_get_alignment (layout) != PANGO_ALIGN_LEFT)
+    gtk_json_printer_add_string (printer, "alignment", alignment_names[pango_layout_get_alignment (layout)]);
 
   if (pango_layout_get_wrap (layout))
     {
@@ -1527,7 +1513,7 @@ json_parser_fill_layout (GtkJsonParser               *parser,
           break;
 
         case LAYOUT_ALIGNMENT:
-          pango_layout_set_alignment (layout, (PangoAlignment) parser_select_string (parser, 
alignment_names2));
+          pango_layout_set_alignment (layout, (PangoAlignment) parser_select_string (parser, 
alignment_names));
           break;
 
         case LAYOUT_WRAP:
diff --git a/tests/testmisc.c b/tests/testmisc.c
index 6b900244..a4183478 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -778,7 +778,7 @@ test_wrap_char (void)
   context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
   layout = pango_layout_new (context);
   pango_layout_set_text (layout, "Rows can have suffix widgets", -1);
-  pango_layout_set_wrap (layout, PANGO_LINE_WRAP_WORD_CHAR);
+  pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
 
   pango_layout_set_width (layout, 0);
   pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext);


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