[grilo-plugins/0.1.x] filesystem: Remove file extension from title
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins/0.1.x] filesystem: Remove file extension from title
- Date: Thu, 26 Apr 2012 17:44:03 +0000 (UTC)
commit 4768145056acd16e46b98dc65c4d86bc393ff8b4
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Thu Apr 26 15:30:23 2012 +0000
filesystem: Remove file extension from title
Set the title as the filename without extension.
Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>
src/media/filesystem/grl-filesystem.c | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/src/media/filesystem/grl-filesystem.c b/src/media/filesystem/grl-filesystem.c
index 2a47ea8..443f626 100644
--- a/src/media/filesystem/grl-filesystem.c
+++ b/src/media/filesystem/grl-filesystem.c
@@ -389,6 +389,7 @@ create_content (GrlMedia *content,
{
GrlMedia *media = NULL;
gchar *str;
+ gchar *extension;
const gchar *mime;
GError *error = NULL;
@@ -413,12 +414,20 @@ create_content (GrlMedia *content,
}
/* Title */
- str = g_strrstr (path, G_DIR_SEPARATOR_S);
+ str = g_strdup (g_strrstr (path, G_DIR_SEPARATOR_S));
if (!str) {
- str = (gchar *) path;
+ str = g_strdup (path);
}
+
+ /* Remove file extension */
+ extension = g_strrstr (str, ".");
+ if (extension) {
+ *extension = '\0';
+ }
+
grl_media_set_title (media, str);
g_error_free (error);
+ g_free (str);
} else {
mime = g_file_info_get_content_type (info);
@@ -444,8 +453,16 @@ create_content (GrlMedia *content,
}
/* Title */
- str = (gchar *) g_file_info_get_display_name (info);
+ str = g_strdup (g_file_info_get_display_name (info));
+
+ /* Remove file extension */
+ extension = g_strrstr (str, ".");
+ if (extension) {
+ *extension = '\0';
+ }
+
grl_media_set_title (media, str);
+ g_free (str);
/* Date */
GTimeVal time;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]