ncmpc  0.29
filelist.h
Go to the documentation of this file.
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2017 The Music Player Daemon Project
3  * Project homepage: http://musicpd.org
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef FILELIST_H
21 #define FILELIST_H
22 
23 #include "Compiler.h"
24 
25 #include <glib.h>
26 
27 struct mpd_connection;
28 struct mpd_song;
29 
31  guint flags;
32  struct mpd_entity *entity;
33 };
34 
35 struct filelist {
36  /* the list */
37  GPtrArray *entries;
38 };
39 
40 struct filelist *
41 filelist_new(void);
42 
43 void
45 
46 static inline guint
47 filelist_length(const struct filelist *filelist)
48 {
49  return filelist->entries->len;
50 }
51 
52 static inline gboolean
53 filelist_is_empty(const struct filelist *filelist)
54 {
55  return filelist_length(filelist) == 0;
56 }
57 
59 static inline struct filelist_entry *
60 filelist_get(const struct filelist *filelist, guint i)
61 {
62  return g_ptr_array_index(filelist->entries, i);
63 }
64 
65 struct filelist_entry *
66 filelist_append(struct filelist *filelist, struct mpd_entity *entity);
67 
68 void
69 filelist_move(struct filelist *filelist, struct filelist *from);
70 
72 gint
73 compare_filelist_entry_path(gconstpointer filelist_entry1,
74  gconstpointer filelist_entry2);
75 
76 /* Sorts the whole filelist, at the moment used by filelist_search */
77 void
78 filelist_sort_all(struct filelist *filelist, GCompareFunc compare_func);
79 
80 /* Only sorts the directories and playlist files.
81  * The songs stay in the order it came from mpd. */
82 void
83 filelist_sort_dir_play(struct filelist *filelist, GCompareFunc compare_func);
84 
88 void
90 
92 int
93 filelist_find_song(const struct filelist *flist, const struct mpd_song *song);
94 
96 int
97 filelist_find_directory(const struct filelist *filelist, const char *name);
98 
104 void
105 filelist_recv(struct filelist *filelist, struct mpd_connection *connection);
106 
111 struct filelist *
112 filelist_new_recv(struct mpd_connection *connection);
113 
114 #endif
gcc_pure int filelist_find_song(const struct filelist *flist, const struct mpd_song *song)
guint flags
Definition: filelist.h:31
struct mpd_entity * entity
Definition: filelist.h:32
gcc_pure int filelist_find_directory(const struct filelist *filelist, const char *name)
Definition: filelist.h:30
void filelist_recv(struct filelist *filelist, struct mpd_connection *connection)
struct filelist * filelist_new_recv(struct mpd_connection *connection)
Definition: filelist.h:35
struct filelist_entry * filelist_append(struct filelist *filelist, struct mpd_entity *entity)
void filelist_sort_dir_play(struct filelist *filelist, GCompareFunc compare_func)
gcc_pure gint compare_filelist_entry_path(gconstpointer filelist_entry1, gconstpointer filelist_entry2)
GPtrArray * entries
Definition: filelist.h:37
void filelist_move(struct filelist *filelist, struct filelist *from)
#define gcc_pure
Definition: Compiler.h:100
void filelist_sort_all(struct filelist *filelist, GCompareFunc compare_func)
void filelist_free(struct filelist *filelist)
void filelist_no_duplicates(struct filelist *filelist)
struct filelist * filelist_new(void)