[grilo-plugins] filesystem: Remove file extension from title



commit 97ca3f2c6ef0b54ea9f70b84a374f46f17fc02da
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 b17caf3..8961af2 100644
--- a/src/media/filesystem/grl-filesystem.c
+++ b/src/media/filesystem/grl-filesystem.c
@@ -393,6 +393,7 @@ create_content (GrlMedia *content,
 {
   GrlMedia *media = NULL;
   gchar *str;
+  gchar *extension;
   const gchar *mime;
   GError *error = NULL;
 
@@ -417,12 +418,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);
 
@@ -448,8 +457,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]