Mercurial > audlegacy
changeset 3096:8e4da6a4ab91
- make jump to track more friendly to file:// scheme.
- fix a memory leak.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Wed, 18 Jul 2007 21:42:58 +0900 |
parents | 5a7dea5211f3 |
children | bb1fa0aed8f4 |
files | src/audacious/ui_jumptotrack.c |
diffstat | 1 files changed, 38 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/ui_jumptotrack.c Tue Jul 17 18:33:49 2007 +0900 +++ b/src/audacious/ui_jumptotrack.c Wed Jul 18 21:42:58 2007 +0900 @@ -277,21 +277,24 @@ PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); if (entry->title) - desc_buf = g_strdup(entry->title); - else if (strchr(entry->filename, '/')) - desc_buf = str_to_utf8(strrchr(entry->filename, '/') + 1); - else - desc_buf = str_to_utf8(entry->filename); + desc_buf = g_strdup(entry->title); + else { + gchar *realfn = NULL; + realfn = g_filename_from_uri(entry->filename, NULL, NULL); + if (strchr(realfn ? realfn : entry->filename, '/')) + desc_buf = str_to_utf8(strrchr(realfn ? realfn : entry->filename, '/') + 1); + else + desc_buf = str_to_utf8(realfn ? realfn : entry->filename); + g_free(realfn); realfn = NULL; + } gtk_list_store_append(GTK_LIST_STORE(store), &iter); gtk_list_store_set(GTK_LIST_STORE(store), &iter, 0, row, 1, desc_buf, -1); row++; - if(desc_buf) { - g_free(desc_buf); - desc_buf = NULL; - } + g_free(desc_buf); + desc_buf = NULL; } gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); @@ -350,13 +353,17 @@ playlist_glist = g_list_next(playlist_glist)) { PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); - const gchar *title=NULL; - gchar *filename = NULL; - filename = str_to_utf8(entry->filename); + gchar *title = NULL; + if (entry->title) - title = entry->title; - else - title = filename; + title = g_strdup(entry->title); + else { + gchar *realfn = NULL; + realfn = g_filename_from_uri(entry->filename, NULL, NULL); + title = str_to_utf8(realfn ? realfn : entry->filename); + g_free(realfn); realfn = NULL; + } + /*we are matching all the path not just the filename or title*/ /* Compare the reg.expressions to the string - if all the @@ -379,21 +386,21 @@ if (match) { if (entry->title) - title = g_strdup(entry->title); - else if (strchr(entry->filename, '/')) - title = str_to_utf8(strrchr(entry->filename, '/') + 1); - else - title = str_to_utf8(entry->filename); - + title = g_strdup(entry->title); + else { + gchar *realfn = NULL; + realfn = g_filename_from_uri(entry->filename, NULL, NULL); + if (strchr(realfn ? realfn : entry->filename, '/')) + title = str_to_utf8(strrchr(realfn ? realfn : entry->filename, '/') + 1); + else + title = str_to_utf8(realfn ? realfn : entry->filename); + g_free(realfn); realfn = NULL; + } gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, song_index + 1 , 1, title, -1); } song_index++; - - if (filename) { - g_free(filename); - filename = NULL; - } + g_free(title); title = NULL; } PLAYLIST_UNLOCK(playlist->mutex); @@ -449,18 +456,16 @@ PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); if (entry->title) - desc_buf = g_strdup(entry->title); - else if (strchr(entry->filename, '/')) { + desc_buf = g_strdup(entry->title); + else { gchar *realfn = NULL; realfn = g_filename_from_uri(entry->filename, NULL, NULL); - if(realfn) - desc_buf = str_to_utf8(strrchr(realfn, '/') + 1); + if (strchr(realfn ? realfn : entry->filename, '/')) + desc_buf = str_to_utf8(strrchr(realfn ? realfn : entry->filename, '/') + 1); else - desc_buf = str_to_utf8(strrchr(entry->filename, '/') + 1); + desc_buf = str_to_utf8(realfn ? realfn : entry->filename); g_free(realfn); realfn = NULL; } - else - desc_buf = str_to_utf8(entry->filename); gtk_list_store_append(GTK_LIST_STORE(jtf_store), &iter); gtk_list_store_set(GTK_LIST_STORE(jtf_store), &iter,