Mercurial > audlegacy
annotate audacious/playlist_container.c @ 1850:1014e22133e2 trunk
[svn] - the default for mainwinTextVisible() should be FALSE.
author | nenolod |
---|---|
date | Mon, 09 Oct 2006 03:20:36 -0700 |
parents | 7ea3c9610ca0 |
children | f18a5b617c34 |
rev | line source |
---|---|
1548 | 1 /* |
2 * Audacious: A cross-platform multimedia player | |
3 * Copyright (c) 2006 William Pitcock, Tony Vroon, George Averill, | |
4 * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa. | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 */ | |
20 | |
21 #include <glib.h> | |
1549 | 22 #include <string.h> |
1548 | 23 #include "playlist_container.h" |
24 | |
25 /* | |
26 * PlaylistContainer objects handle the import and export of Playlist | |
27 * data. Basically, a PlaylistContainer acts as a filter for a PlaylistEntry. | |
28 */ | |
29 | |
30 static GList *registered_plcs = NULL; | |
31 | |
32 void playlist_container_register(PlaylistContainer *plc) | |
33 { | |
34 registered_plcs = g_list_append(registered_plcs, plc); | |
35 } | |
36 | |
37 void playlist_container_unregister(PlaylistContainer *plc) | |
38 { | |
39 registered_plcs = g_list_remove(registered_plcs, plc); | |
40 } | |
1549 | 41 |
42 PlaylistContainer *playlist_container_find(char *ext) | |
43 { | |
44 GList *node; | |
45 PlaylistContainer *plc; | |
46 | |
1606
7ea3c9610ca0
[svn] - playlist_container_find() must check if ext is 1, besides NULL.
yaz
parents:
1552
diff
changeset
|
47 /* check ext neither is NULL nor 1 (in a consequence of optimization). */ |
7ea3c9610ca0
[svn] - playlist_container_find() must check if ext is 1, besides NULL.
yaz
parents:
1552
diff
changeset
|
48 g_return_val_if_fail(ext != NULL && ext != (void *)1, NULL); |
1549 | 49 |
50 for (node = registered_plcs; node != NULL; node = g_list_next(node)) { | |
51 plc = PLAYLIST_CONTAINER(node->data); | |
52 | |
53 if (!g_strcasecmp(plc->ext, ext)) | |
54 return plc; | |
55 } | |
56 | |
57 return NULL; | |
58 } | |
59 | |
1550 | 60 void playlist_container_read(char *filename, gint pos) |
1549 | 61 { |
62 char *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ | |
63 PlaylistContainer *plc = playlist_container_find(ext); | |
64 | |
65 if (plc->plc_read == NULL) | |
1550 | 66 return; |
1549 | 67 |
1551 | 68 plc->plc_read(filename, pos); |
1549 | 69 } |
70 | |
1550 | 71 void playlist_container_write(char *filename, gint pos) |
1549 | 72 { |
73 char *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ | |
74 PlaylistContainer *plc = playlist_container_find(ext); | |
75 | |
76 if (plc->plc_write == NULL) | |
77 return; | |
78 | |
1550 | 79 plc->plc_write(filename, pos); |
1549 | 80 } |
1550 | 81 |
1552 | 82 gboolean is_playlist_name(char *filename) |
83 { | |
84 char *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ | |
85 PlaylistContainer *plc = playlist_container_find(ext); | |
86 | |
87 if (plc != NULL) | |
88 return TRUE; | |
89 | |
90 return FALSE; | |
91 } |