[tepl/wip/utils-public] Utils: make str_middle_truncate() public



commit 655cde5144472d4ceac5b4f838f0a0155d0873b2
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Nov 4 12:49:24 2019 +0100

    Utils: make str_middle_truncate() public
    
    It will be used by gedit.

 tepl/tepl-tab-label.c |  2 +-
 tepl/tepl-utils.c     | 17 +++++++++++++++--
 tepl/tepl-utils.h     |  3 +--
 3 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/tepl/tepl-tab-label.c b/tepl/tepl-tab-label.c
index b8d5f07..e625406 100644
--- a/tepl/tepl-tab-label.c
+++ b/tepl/tepl-tab-label.c
@@ -82,7 +82,7 @@ update_label (TeplTabLabel *tab_label)
        /* A GtkNotebook tab label doesn't support well an ellipsizing GtkLabel.
         * So, ellipsize ourself.
         */
-       truncated_short_title = _tepl_utils_str_middle_truncate (short_title, MAX_LABEL_CHARS_LENGTH);
+       truncated_short_title = tepl_utils_str_middle_truncate (short_title, MAX_LABEL_CHARS_LENGTH);
 
        gtk_label_set_text (tab_label->priv->label, truncated_short_title);
 
diff --git a/tepl/tepl-utils.c b/tepl/tepl-utils.c
index 5652b4d..13f906e 100644
--- a/tepl/tepl-utils.c
+++ b/tepl/tepl-utils.c
@@ -93,9 +93,22 @@ str_truncate (const gchar *string,
        return g_string_free (truncated, FALSE);
 }
 
+/**
+ * tepl_utils_str_middle_truncate:
+ * @str: a UTF-8 string.
+ * @truncate_length: maximum length allowed for @str, in UTF-8 characters (not
+ *   bytes).
+ *
+ * If @str is longer than @truncate_length, then this function returns @str
+ * truncated in the middle with a “…” character. Otherwise it just returns a
+ * copy of @str.
+ *
+ * Returns: the truncated string. Free with g_free().
+ * Since: 4.4
+ */
 gchar *
-_tepl_utils_str_middle_truncate (const gchar *str,
-                                guint        truncate_length)
+tepl_utils_str_middle_truncate (const gchar *str,
+                               guint        truncate_length)
 {
        return str_truncate (str, truncate_length, TRUE);
 }
diff --git a/tepl/tepl-utils.h b/tepl/tepl-utils.h
index f1fd40b..9fbe09a 100644
--- a/tepl/tepl-utils.h
+++ b/tepl/tepl-utils.h
@@ -30,8 +30,7 @@ G_BEGIN_DECLS
 
 /* String utilities */
 
-G_GNUC_INTERNAL
-gchar *                _tepl_utils_str_middle_truncate                 (const gchar *str,
+gchar *                tepl_utils_str_middle_truncate                  (const gchar *str,
                                                                 guint        truncate_length);
 
 /* File utilities */


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