1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- 2 * 3 * Copyright (C) 2003 Colin Walters <walters@rhythmbox.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 * The Rhythmbox authors hereby grant permission for non-GPL compatible 11 * GStreamer plugins to be used and distributed together with GStreamer 12 * and Rhythmbox. This permission is above and beyond the permissions granted 13 * by the GPL license by which Rhythmbox is covered. If you modify this code 14 * you may extend this exception to your version of the code, but you are not 15 * obligated to do so. If you do not wish to do so, delete this exception 16 * statement from your version. 17 * 18 * This program is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License 24 * along with this program; if not, write to the Free Software 25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 26 * 27 */ 28 29 #include <glib-object.h> 30 #include <glib.h> 31 #include <gtk/gtk.h> 32 33 #include <rhythmdb/rhythmdb.h> 34 35 #ifndef RHYTHMDB_QUERY_MODEL_H 36 #define RHYTHMDB_QUERY_MODEL_H 37 38 G_BEGIN_DECLS 39 40 #define RHYTHMDB_TYPE_QUERY_MODEL (rhythmdb_query_model_get_type ()) 41 #define RHYTHMDB_QUERY_MODEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), RHYTHMDB_TYPE_QUERY_MODEL, RhythmDBQueryModel)) 42 #define RHYTHMDB_QUERY_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), RHYTHMDB_TYPE_QUERY_MODEL, RhythmDBQueryModelClass)) 43 #define RHYTHMDB_IS_QUERY_MODEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), RHYTHMDB_TYPE_QUERY_MODEL)) 44 #define RHYTHMDB_IS_QUERY_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), RHYTHMDB_TYPE_QUERY_MODEL)) 45 #define RHYTHMDB_QUERY_MODEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), RHYTHMDB_TYPE_QUERY_MODEL, RhythmDBQueryModelClass)) 46 47 GType rhythmdb_query_model_limit_type_get_type (void); 48 #define RHYTHMDB_TYPE_QUERY_MODEL_LIMIT_TYPE (rhythmdb_query_model_limit_type_get_type ()) 49 50 typedef enum { 51 RHYTHMDB_QUERY_MODEL_LIMIT_NONE, 52 RHYTHMDB_QUERY_MODEL_LIMIT_COUNT, 53 RHYTHMDB_QUERY_MODEL_LIMIT_SIZE, 54 RHYTHMDB_QUERY_MODEL_LIMIT_TIME, 55 } RhythmDBQueryModelLimitType; 56 57 typedef struct _RhythmDBQueryModel RhythmDBQueryModel; 58 typedef struct _RhythmDBQueryModelClass RhythmDBQueryModelClass; 59 typedef struct _RhythmDBQueryModelPrivate RhythmDBQueryModelPrivate; 60 61 #define RHYTHMDB_QUERY_MODEL_SUGGESTED_UPDATE_CHUNK 1024 62 63 struct _RhythmDBQueryModel 64 { 65 GObject parent; 66 67 RhythmDBQueryModelPrivate *priv; 68 }; 69 70 struct _RhythmDBQueryModelClass 71 { 72 GObjectClass parent; 73 74 /* signals */ 75 void (*complete) (RhythmDBQueryModel *model); 76 void (*entry_prop_changed) (RhythmDBQueryModel *model, 77 RhythmDBEntry *entry, 78 RhythmDBPropType prop, 79 const GValue *old, 80 const GValue *new_value); 81 void (*non_entry_dropped) (RhythmDBQueryModel *model, 82 const char *uri, 83 int position); 84 void (*entry_removed) (RhythmDBQueryModel *model, 85 RhythmDBEntry *entry); 86 void (*post_entry_delete) (RhythmDBQueryModel *model, 87 RhythmDBEntry *entry); 88 gboolean (*filter_entry_drop) (RhythmDBQueryModel *model, 89 RhythmDBEntry *entry); 90 91 }; 92 93 GType rhythmdb_query_model_get_type (void); 94 95 RhythmDBQueryModel * rhythmdb_query_model_new (RhythmDB *db, 96 GPtrArray *query, 97 GCompareDataFunc sort_func, 98 gpointer sort_data, 99 GDestroyNotify sort_data_destroy, 100 gboolean sort_reverse); 101 102 RhythmDBQueryModel * rhythmdb_query_model_new_empty (RhythmDB *db); 103 104 RhythmDBQueryModel * rhythmdb_query_model_new_for_entry_type (RhythmDB *db, 105 RhythmDBEntryType *entry_type, 106 gboolean show_hidden); 107 108 void rhythmdb_query_model_copy_contents (RhythmDBQueryModel *dest, 109 RhythmDBQueryModel *src); 110 111 void rhythmdb_query_model_chain (RhythmDBQueryModel *model, 112 RhythmDBQueryModel *base, 113 gboolean import_entries); 114 115 void rhythmdb_query_model_add_entry (RhythmDBQueryModel *model, 116 RhythmDBEntry *entry, 117 gint index); 118 119 gboolean rhythmdb_query_model_remove_entry (RhythmDBQueryModel *model, 120 RhythmDBEntry *entry); 121 122 void rhythmdb_query_model_shuffle_entries (RhythmDBQueryModel *model); 123 124 void rhythmdb_query_model_move_entry (RhythmDBQueryModel *model, 125 RhythmDBEntry *entry, 126 gint index); 127 128 guint64 rhythmdb_query_model_get_size (RhythmDBQueryModel *model); 129 130 long rhythmdb_query_model_get_duration (RhythmDBQueryModel *model); 131 132 gboolean rhythmdb_query_model_entry_to_iter (RhythmDBQueryModel *model, 133 RhythmDBEntry *entry, 134 GtkTreeIter *iter); 135 136 gboolean rhythmdb_query_model_has_pending_changes (RhythmDBQueryModel *model); 137 138 RhythmDBEntry * rhythmdb_query_model_tree_path_to_entry (RhythmDBQueryModel *model, 139 GtkTreePath *path); 140 RhythmDBEntry * rhythmdb_query_model_iter_to_entry (RhythmDBQueryModel *model, 141 GtkTreeIter *entry_iter); 142 RhythmDBEntry * rhythmdb_query_model_get_next_from_entry (RhythmDBQueryModel *model, 143 RhythmDBEntry *entry); 144 RhythmDBEntry * rhythmdb_query_model_get_previous_from_entry (RhythmDBQueryModel *model, 145 RhythmDBEntry *entry); 146 char * rhythmdb_query_model_compute_status_normal (RhythmDBQueryModel *model, 147 const char *singular, 148 const char *plural); 149 150 void rhythmdb_query_model_set_sort_order (RhythmDBQueryModel *model, 151 GCompareDataFunc sort_func, 152 gpointer sort_data, 153 GDestroyNotify sort_data_destroy, 154 gboolean sort_reverse); 155 156 void rhythmdb_query_model_reapply_query (RhythmDBQueryModel *model, 157 gboolean filter); 158 159 gint rhythmdb_query_model_location_sort_func (RhythmDBEntry *a, 160 RhythmDBEntry *b, 161 gpointer data); 162 163 gint rhythmdb_query_model_string_sort_func (RhythmDBEntry *a, 164 RhythmDBEntry *b, 165 gpointer data); 166 167 gint rhythmdb_query_model_title_sort_func (RhythmDBEntry *a, 168 RhythmDBEntry *b, 169 gpointer data); 170 171 gint rhythmdb_query_model_album_sort_func (RhythmDBEntry *a, 172 RhythmDBEntry *b, 173 gpointer data); 174 175 gint rhythmdb_query_model_artist_sort_func (RhythmDBEntry *a, 176 RhythmDBEntry *b, 177 gpointer data); 178 179 gint rhythmdb_query_model_composer_sort_func (RhythmDBEntry *a, 180 RhythmDBEntry *b, 181 gpointer data); 182 183 gint rhythmdb_query_model_genre_sort_func (RhythmDBEntry *a, 184 RhythmDBEntry *b, 185 gpointer data); 186 187 gint rhythmdb_query_model_track_sort_func (RhythmDBEntry *a, 188 RhythmDBEntry *b, 189 gpointer data); 190 191 gint rhythmdb_query_model_double_ceiling_sort_func (RhythmDBEntry *a, 192 RhythmDBEntry *b, 193 gpointer data); 194 195 gint rhythmdb_query_model_ulong_sort_func (RhythmDBEntry *a, 196 RhythmDBEntry *b, 197 gpointer data); 198 199 gint rhythmdb_query_model_bitrate_sort_func (RhythmDBEntry *a, 200 RhythmDBEntry *b, 201 gpointer data); 202 203 gint rhythmdb_query_model_date_sort_func (RhythmDBEntry *a, 204 RhythmDBEntry *b, 205 gpointer data); 206 G_END_DECLS 207 208 #endif /* __RHYTHMDB_QUERY_MODEL_H */ 209