[gnome-calendar] utils: Add auxiliary function to format display names
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] utils: Add auxiliary function to format display names
- Date: Sat, 13 Jul 2019 19:05:47 +0000 (UTC)
commit ff0644ad76bf9134f47e61d7971b5b67b8f035fd
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Jul 13 15:59:15 2019 -0300
utils: Add auxiliary function to format display names
This will be used by the web source discoverer to format
any URLs that contain a file name in their path.
src/utils/gcal-utils.c | 23 +++++++++++++++++++++++
src/utils/gcal-utils.h | 2 ++
2 files changed, 25 insertions(+)
---
diff --git a/src/utils/gcal-utils.c b/src/utils/gcal-utils.c
index 16dbe307..003a61f5 100644
--- a/src/utils/gcal-utils.c
+++ b/src/utils/gcal-utils.c
@@ -1240,3 +1240,26 @@ gcal_utils_launch_online_accounts_panel (GDBusConnection *connection,
NULL,
NULL);
}
+
+gchar*
+gcal_utils_format_filename_for_display (const gchar *filename)
+{
+ /*
+ * Foo_bar-something-cool.ics
+ */
+ g_autofree gchar *display_name = NULL;
+ gchar *file_extension;
+
+ display_name = g_strdup (filename);
+
+ /* Strip out the file extension */
+ file_extension = g_strrstr (display_name, ".");
+ if (file_extension)
+ *file_extension = '\0';
+
+ /* Replace underscores with spaces */
+ display_name = g_strdelimit (display_name, "_", ' ');
+ display_name = g_strstrip (display_name);
+
+ return g_steal_pointer (&display_name);
+}
diff --git a/src/utils/gcal-utils.h b/src/utils/gcal-utils.h
index 9dd751e4..5d01e3b9 100644
--- a/src/utils/gcal-utils.h
+++ b/src/utils/gcal-utils.h
@@ -126,4 +126,6 @@ void gcal_utils_launch_online_accounts_panel (GDBusConnectio
const gchar *action,
const gchar *arg);
+gchar* gcal_utils_format_filename_for_display (const gchar *filename);
+
#endif /* __GCAL_UTILS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]