annotate src/audacious/ui_albumart.c @ 3165:8775dfc57ead trunk

Remove mainwin_set_info_text() craq. Still some work to do.
author William Pitcock <nenolod@atheme-project.org>
date Wed, 25 Jul 2007 15:46:00 -0500
parents f1c756f39e6c
children f985357757e0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2442
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
1 /*
2894
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
2 * Audacious: A cross-platform multimedia player
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
3 * Copyright (c) 2007 William Pitcock, Tony Vroon, George Averill,
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
4 * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa.
2442
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
5 *
2894
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
6 * This program is free software; you can redistribute it and/or modify
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
7 * it under the terms of the GNU General Public License as published by
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 2894
diff changeset
8 * the Free Software Foundation; under version 3 of the License.
2442
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
9 *
2894
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
10 * This program is distributed in the hope that it will be useful,
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
13 * GNU General Public License for more details.
2442
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
14 *
2894
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
15 * You should have received a copy of the GNU General Public License
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 2894
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses>.
3123
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
17 *
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
18 * The Audacious team does not consider modular code linking to
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
19 * Audacious or using our public API to be a derived work.
2442
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
20 */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
21
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
23 # include "config.h"
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
24 #endif
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
25
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
26 #include <glib.h>
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
27 #include <glib/gi18n.h>
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
28 #include <gtk/gtk.h>
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
29 #include <string.h>
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
30
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
31 #include "titlestring.h"
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
32 #include "ui_fileinfopopup.h"
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
33 #include "main.h"
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
34 #include "ui_main.h"
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
35 #include "playlist.h"
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
36 #include "playback.h"
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
37
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
38 static gboolean
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
39 has_front_cover_extension(const gchar *name)
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
40 {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
41 char *ext;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
42
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
43 ext = strrchr(name, '.');
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
44 if (!ext) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
45 /* No file extension */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
46 return FALSE;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
47 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
48
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
49 return g_strcasecmp(ext, ".jpg") == 0 ||
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
50 g_strcasecmp(ext, ".jpeg") == 0 ||
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
51 g_strcasecmp(ext, ".png") == 0;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
52 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
53
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
54 static gboolean
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
55 cover_name_filter(const gchar *name, const gchar *filter, const gboolean ret_on_empty)
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
56 {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
57 gboolean result = FALSE;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
58 gchar **splitted;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
59 gchar *current;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
60 gchar *lname;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
61 gint i;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
62
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
63 if (!filter || strlen(filter) == 0) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
64 return ret_on_empty;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
65 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
66
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
67 splitted = g_strsplit(filter, ",", 0);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
68
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
69 lname = g_strdup(name);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
70 g_strdown(lname);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
71
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
72 for (i = 0; !result && (current = splitted[i]); i++) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
73 gchar *stripped = g_strstrip(g_strdup(current));
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
74 g_strdown(stripped);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
75
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
76 result = result || strstr(lname, stripped);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
77
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
78 g_free(stripped);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
79 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
80
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
81 g_free(lname);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
82 g_strfreev(splitted);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
83
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
84 return result;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
85 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
86
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
87 /* Check wether it's an image we want */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
88 static gboolean
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
89 is_front_cover_image(const gchar *imgfile)
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
90 {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
91 return cover_name_filter(imgfile, cfg.cover_name_include, TRUE) &&
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
92 !cover_name_filter(imgfile, cfg.cover_name_exclude, FALSE);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
93 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
94
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
95 static gboolean
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
96 is_file_image(const gchar *imgfile, const gchar *file_name)
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
97 {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
98 char *imgfile_ext, *file_name_ext;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
99 size_t imgfile_len, file_name_len;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
100
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
101 imgfile_ext = strrchr(imgfile, '.');
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
102 if (!imgfile_ext) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
103 /* No file extension */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
104 return FALSE;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
105 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
106
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
107 file_name_ext = strrchr(file_name, '.');
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
108 if (!file_name_ext) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
109 /* No file extension */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
110 return FALSE;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
111 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
112
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
113 imgfile_len = (imgfile_ext - imgfile);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
114 file_name_len = (file_name_ext - file_name);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
115
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
116 if (imgfile_len == file_name_len) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
117 return (g_ascii_strncasecmp(imgfile, file_name, imgfile_len) == 0);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
118 } else {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
119 return FALSE;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
120 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
121 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
122
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
123 gchar*
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
124 fileinfo_recursive_get_image(const gchar* path,
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
125 const gchar* file_name, gint depth)
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
126 {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
127 GDir *d;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
128
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
129 if (cfg.recurse_for_cover && depth > cfg.recurse_for_cover_depth)
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
130 return NULL;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
131
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
132 d = g_dir_open(path, 0, NULL);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
133
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
134 if (d) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
135 const gchar *f;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
136
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
137 if (cfg.use_file_cover && file_name) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
138 /* Look for images matching file name */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
139 while((f = g_dir_read_name(d))) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
140 gchar *newpath = g_strconcat(path, "/", f, NULL);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
141
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
142 if (!g_file_test(newpath, G_FILE_TEST_IS_DIR) &&
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
143 has_front_cover_extension(f) &&
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
144 is_file_image(f, file_name)) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
145 g_dir_close(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
146 return newpath;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
147 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
148
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
149 g_free(newpath);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
150 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
151 g_dir_rewind(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
152 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
153
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
154 /* Search for files using filter */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
155 while ((f = g_dir_read_name(d))) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
156 gchar *newpath = g_strconcat(path, "/", f, NULL);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
157
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
158 if (!g_file_test(newpath, G_FILE_TEST_IS_DIR) &&
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
159 has_front_cover_extension(f) &&
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
160 is_front_cover_image(f)) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
161 g_dir_close(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
162 return newpath;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
163 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
164
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
165 g_free(newpath);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
166 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
167 g_dir_rewind(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
168
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
169 /* checks whether recursive or not. */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
170 if (!cfg.recurse_for_cover) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
171 g_dir_close(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
172 return NULL;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
173 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
174
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
175 /* Descend into directories recursively. */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
176 while ((f = g_dir_read_name(d))) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
177 gchar *newpath = g_strconcat(path, "/", f, NULL);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
178
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
179 if(g_file_test(newpath, G_FILE_TEST_IS_DIR)) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
180 gchar *tmp = fileinfo_recursive_get_image(newpath,
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
181 NULL, depth + 1);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
182 if(tmp) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
183 g_free(newpath);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
184 g_dir_close(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
185 return tmp;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
186 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
187 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
188
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
189 g_free(newpath);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
190 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
191
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
192 g_dir_close(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
193 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
194
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
195 return NULL;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
196 }