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.
This commit is contained in:
Georges Basile Stavracas Neto
2019-07-13 16:04:31 -03:00
parent 371fdbc881
commit ff0644ad76
2 changed files with 25 additions and 0 deletions
+23
View File
@@ -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);
}
+2
View File
@@ -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__ */