1 /* 2 * Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org> 3 * Copyright (C) 2003 Colin Walters <walters@gnome.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 #ifndef __RB_SOURCE_H 30 #define __RB_SOURCE_H 31 32 #include <gtk/gtk.h> 33 34 #include <sources/rb-display-page.h> 35 #include <sources/rb-source-search.h> 36 #include <widgets/rb-entry-view.h> 37 #include <widgets/rb-search-entry.h> 38 #include <shell/rb-shell-preferences.h> 39 #include <shell/rb-track-transfer-batch.h> 40 41 G_BEGIN_DECLS 42 43 typedef enum { 44 RB_SOURCE_EOF_ERROR, 45 RB_SOURCE_EOF_STOP, 46 RB_SOURCE_EOF_RETRY, 47 RB_SOURCE_EOF_NEXT, 48 } RBSourceEOFType; 49 50 typedef enum { 51 RB_SOURCE_LOAD_STATUS_NOT_LOADED, 52 RB_SOURCE_LOAD_STATUS_WAITING, 53 RB_SOURCE_LOAD_STATUS_LOADING, 54 RB_SOURCE_LOAD_STATUS_LOADED 55 } RBSourceLoadStatus; 56 57 typedef struct _RBSource RBSource; 58 typedef struct _RBSourceClass RBSourceClass; 59 typedef struct _RBSourcePrivate RBSourcePrivate; 60 61 GType rb_source_eof_type_get_type (void); 62 #define RB_TYPE_SOURCE_EOF_TYPE (rb_source_eof_type_get_type()) 63 64 GType rb_source_load_status_get_type (void); 65 #define RB_TYPE_SOURCE_LOAD_STATUS (rb_source_load_status_get_type()) 66 67 #define RB_TYPE_SOURCE (rb_source_get_type ()) 68 #define RB_SOURCE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), RB_TYPE_SOURCE, RBSource)) 69 #define RB_SOURCE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), RB_TYPE_SOURCE, RBSourceClass)) 70 #define RB_IS_SOURCE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), RB_TYPE_SOURCE)) 71 #define RB_IS_SOURCE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), RB_TYPE_SOURCE)) 72 #define RB_SOURCE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), RB_TYPE_SOURCE, RBSourceClass)) 73 74 typedef gboolean (*RBSourceFeatureFunc) (RBSource *source); 75 typedef const char * (*RBSourceStringFunc) (RBSource *source); 76 typedef void (*RBSourceAddCallback) (RBSource *source, const char *uri, gpointer data); 77 78 struct _RBSource 79 { 80 RBDisplayPage parent; 81 RBSourcePrivate *priv; 82 }; 83 84 struct _RBSourceClass 85 { 86 RBDisplayPageClass parent; 87 88 /* signals */ 89 void (*filter_changed) (RBSource *source); 90 void (*reset_filters) (RBSource *source); 91 92 /* methods */ 93 94 RBEntryView * (*get_entry_view) (RBSource *source); 95 GList * (*get_property_views) (RBSource *source); 96 97 gboolean (*can_rename) (RBSource *source); 98 99 void (*search) (RBSource *source, RBSourceSearch *search, const char *cur_text, const char *new_text); 100 101 gboolean (*can_cut) (RBSource *source); 102 gboolean (*can_delete) (RBSource *source); 103 gboolean (*can_move_to_trash) (RBSource *source); 104 gboolean (*can_copy) (RBSource *source); 105 gboolean (*can_paste) (RBSource *source); 106 gboolean (*can_add_to_queue) (RBSource *source); 107 108 GList * (*cut) (RBSource *source); 109 GList * (*copy) (RBSource *source); 110 RBTrackTransferBatch *(*paste) (RBSource *source, GList *entries); 111 void (*delete_selected) (RBSource *source); 112 void (*add_to_queue) (RBSource *source, RBSource *queue); 113 void (*move_to_trash) (RBSource *source); 114 115 void (*song_properties) (RBSource *source); 116 117 gboolean (*try_playlist) (RBSource *source); 118 guint (*want_uri) (RBSource *source, const char *uri); 119 void (*add_uri) (RBSource *source, 120 const char *uri, 121 const char *title, 122 const char *genre, 123 RBSourceAddCallback callback, 124 gpointer data, 125 GDestroyNotify destroy_data); 126 gboolean (*uri_is_source) (RBSource *source, const char *uri); 127 128 gboolean (*can_pause) (RBSource *source); 129 RBSourceEOFType (*handle_eos) (RBSource *source); 130 void (*get_playback_status) (RBSource *source, char **text, float *progress); 131 132 char * (*get_delete_label) (RBSource *source); 133 }; 134 135 GType rb_source_get_type (void); 136 137 void rb_source_notify_filter_changed (RBSource *source); 138 139 void rb_source_update_play_statistics(RBSource *source, RhythmDB *db, 140 RhythmDBEntry *entry); 141 142 /* general interface */ 143 144 RBEntryView * rb_source_get_entry_view (RBSource *source); 145 146 GList * rb_source_get_property_views (RBSource *source); 147 148 gboolean rb_source_can_rename (RBSource *source); 149 150 void rb_source_search (RBSource *source, 151 RBSourceSearch *search, 152 const char *cur_text, 153 const char *new_text); 154 155 gboolean rb_source_can_cut (RBSource *source); 156 gboolean rb_source_can_delete (RBSource *source); 157 gboolean rb_source_can_move_to_trash (RBSource *source); 158 gboolean rb_source_can_copy (RBSource *source); 159 gboolean rb_source_can_paste (RBSource *source); 160 gboolean rb_source_can_add_to_queue (RBSource *source); 161 gboolean rb_source_can_show_properties (RBSource *source); 162 163 GList * rb_source_cut (RBSource *source); 164 GList * rb_source_copy (RBSource *source); 165 RBTrackTransferBatch *rb_source_paste (RBSource *source, GList *entries); 166 void rb_source_delete_selected (RBSource *source); 167 void rb_source_add_to_queue (RBSource *source, RBSource *queue); 168 void rb_source_move_to_trash (RBSource *source); 169 170 void rb_source_song_properties (RBSource *source); 171 172 gboolean rb_source_try_playlist (RBSource *source); 173 guint rb_source_want_uri (RBSource *source, const char *uri); 174 gboolean rb_source_uri_is_source (RBSource *source, const char *uri); 175 void rb_source_add_uri (RBSource *source, 176 const char *uri, 177 const char *title, 178 const char *genre, 179 RBSourceAddCallback callback, 180 gpointer data, 181 GDestroyNotify destroy_data); 182 183 gboolean rb_source_can_pause (RBSource *source); 184 RBSourceEOFType rb_source_handle_eos (RBSource *source); 185 186 char * rb_source_get_delete_label (RBSource *source); 187 188 GList * rb_source_gather_selected_properties (RBSource *source, RhythmDBPropType prop); 189 190 void rb_source_set_hidden_when_empty (RBSource *source, 191 gboolean hidden); 192 void rb_source_get_playback_status (RBSource *source, 193 char **text, 194 float *progress); 195 196 /* Protected methods, should only be used by objects inheriting from RBSource */ 197 198 gboolean _rb_source_check_entry_type (RBSource *source, 199 RhythmDBEntry *entry); 200 201 void rb_source_bind_settings (RBSource *source, 202 GtkWidget *entry_view, 203 GtkWidget *paned, 204 GtkWidget *browser, 205 gboolean sort_order); 206 void rb_source_notify_playback_status_changed (RBSource *source); 207 208 G_END_DECLS 209 210 #endif /* __RB_SOURCE_H */ 211