[tepl] Utils: uncomment str_end_truncate() and make it public
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] Utils: uncomment str_end_truncate() and make it public
- Date: Mon, 4 Nov 2019 14:25:17 +0000 (UTC)
commit 8d445fc761114f81dcb1d538940bb9f12c785de2
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Nov 4 15:16:19 2019 +0100
Utils: uncomment str_end_truncate() and make it public
It will be used by gedit.
docs/reference/tepl-4.0-sections.txt | 1 +
tepl/tepl-utils.c | 16 ++++++++++++----
tepl/tepl-utils.h | 3 +++
3 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/docs/reference/tepl-4.0-sections.txt b/docs/reference/tepl-4.0-sections.txt
index a5ec35f..72d8933 100644
--- a/docs/reference/tepl-4.0-sections.txt
+++ b/docs/reference/tepl-4.0-sections.txt
@@ -388,6 +388,7 @@ tepl_notebook_get_type
<SECTION>
<FILE>utils</FILE>
tepl_utils_str_middle_truncate
+tepl_utils_str_end_truncate
</SECTION>
<SECTION>
diff --git a/tepl/tepl-utils.c b/tepl/tepl-utils.c
index 401b3ee..a59ae8c 100644
--- a/tepl/tepl-utils.c
+++ b/tepl/tepl-utils.c
@@ -113,15 +113,23 @@ tepl_utils_str_middle_truncate (const gchar *str,
return str_truncate (str, truncate_length, TRUE);
}
-#if 0
-/* Not yet used in Tepl. */
+/**
+ * tepl_utils_str_end_truncate:
+ * @str: a UTF-8 string.
+ * @truncate_length: maximum length allowed for @str, in UTF-8 characters (not
+ * bytes).
+ *
+ * Like tepl_utils_str_middle_truncate() but the “…” character is at the end.
+ *
+ * Returns: the truncated string. Free with g_free().
+ * Since: 4.4
+ */
gchar *
-_tepl_utils_str_end_truncate (const gchar *str,
+tepl_utils_str_end_truncate (const gchar *str,
guint truncate_length)
{
return str_truncate (str, truncate_length, FALSE);
}
-#endif
/*
* _tepl_utils_replace_home_dir_with_tilde:
diff --git a/tepl/tepl-utils.h b/tepl/tepl-utils.h
index 9fbe09a..117b18d 100644
--- a/tepl/tepl-utils.h
+++ b/tepl/tepl-utils.h
@@ -33,6 +33,9 @@ G_BEGIN_DECLS
gchar * tepl_utils_str_middle_truncate (const gchar *str,
guint truncate_length);
+gchar * tepl_utils_str_end_truncate (const gchar *str,
+ guint truncate_length);
+
/* File utilities */
G_GNUC_INTERNAL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]