diff --git a/src/components/koto-action-bar.c b/src/components/koto-action-bar.c index 3f96979..592b52b 100644 --- a/src/components/koto-action-bar.c +++ b/src/components/koto-action-bar.c @@ -192,10 +192,10 @@ void koto_action_bar_handle_go_to_artist_button_clicked( return; } - KotoIndexedTrack * selected_track = g_list_nth_data(self->current_list, 0); // Get the first item + KotoTrack * selected_track = g_list_nth_data(self->current_list, 0); // Get the first item - if (!KOTO_IS_INDEXED_TRACK(selected_track)) { // Not a track + if (!KOTO_IS_TRACK(selected_track)) { // Not a track return; } @@ -250,14 +250,14 @@ void koto_action_bar_handle_play_track_button_clicked( goto doclose; } - KotoIndexedTrack * track = g_list_nth_data(self->current_list, 0); // Get the first track + KotoTrack * track = g_list_nth_data(self->current_list, 0); // Get the first track - if (!KOTO_IS_INDEXED_TRACK(track)) { // Not a track + if (!KOTO_IS_TRACK(track)) { // Not a track goto doclose; } - koto_playback_engine_set_track_by_uuid(playback_engine, koto_indexed_track_get_uuid(track)); // Set the track to play + koto_playback_engine_set_track_by_uuid(playback_engine, koto_track_get_uuid(track)); // Set the track to play doclose: koto_action_bar_close(self); @@ -293,9 +293,9 @@ void koto_action_bar_handle_remove_from_playlist_button_clicked( GList * cur_list; - for (cur_list = self->current_list; cur_list != NULL; cur_list = cur_list->next) { // For each KotoIndexedTrack - KotoIndexedTrack * track = cur_list->data; - koto_playlist_remove_track_by_uuid(playlist, koto_indexed_track_get_uuid(track)); // Remove this track + for (cur_list = self->current_list; cur_list != NULL; cur_list = cur_list->next) { // For each KotoTrack + KotoTrack * track = cur_list->data; + koto_playlist_remove_track_by_uuid(playlist, koto_track_get_uuid(track)); // Remove this track } doclose: diff --git a/src/db/cartographer.c b/src/db/cartographer.c index f7af98e..606bcad 100644 --- a/src/db/cartographer.c +++ b/src/db/cartographer.c @@ -48,19 +48,19 @@ struct _KotoCartographerClass { void (* album_added) ( KotoCartographer * cartographer, - KotoIndexedAlbum * album + KotoAlbum * album ); void (* album_removed) ( KotoCartographer * cartographer, - KotoIndexedAlbum * album + KotoAlbum * album ); void (* artist_added) ( KotoCartographer * cartographer, - KotoIndexedArtist * artist + KotoArtist * artist ); void (* artist_removed) ( KotoCartographer * cartographer, - KotoIndexedArtist * artist + KotoArtist * artist ); void (* playlist_added) ( KotoCartographer * cartographer, @@ -72,11 +72,11 @@ struct _KotoCartographerClass { ); void (* track_added) ( KotoCartographer * cartographer, - KotoIndexedTrack * track + KotoTrack * track ); void (* track_removed) ( KotoCartographer * cartographer, - KotoIndexedTrack * track + KotoTrack * track ); }; @@ -100,7 +100,7 @@ static void koto_cartographer_class_init(KotoCartographerClass * c) { NULL, G_TYPE_NONE, 1, - KOTO_TYPE_INDEXED_ALBUM + KOTO_TYPE_ALBUM ); cartographer_signals[SIGNAL_ALBUM_REMOVED] = g_signal_new( @@ -126,7 +126,7 @@ static void koto_cartographer_class_init(KotoCartographerClass * c) { NULL, G_TYPE_NONE, 1, - KOTO_TYPE_INDEXED_ARTIST + KOTO_TYPE_ARTIST ); cartographer_signals[SIGNAL_ARTIST_REMOVED] = g_signal_new( @@ -178,7 +178,7 @@ static void koto_cartographer_class_init(KotoCartographerClass * c) { NULL, G_TYPE_NONE, 1, - KOTO_TYPE_INDEXED_TRACK + KOTO_TYPE_TRACK ); cartographer_signals[SIGNAL_TRACK_REMOVED] = g_signal_new( @@ -204,7 +204,7 @@ static void koto_cartographer_init(KotoCartographer * self) { void koto_cartographer_add_album( KotoCartographer * self, - KotoIndexedAlbum * album + KotoAlbum * album ) { gchar * album_uuid = NULL; @@ -227,7 +227,7 @@ void koto_cartographer_add_album( void koto_cartographer_add_artist( KotoCartographer * self, - KotoIndexedArtist * artist + KotoArtist * artist ) { gchar * artist_uuid = NULL; @@ -284,7 +284,7 @@ void koto_cartographer_emit_playlist_added( void koto_cartographer_add_track( KotoCartographer * self, - KotoIndexedTrack * track + KotoTrack * track ) { gchar * track_uuid = NULL; @@ -305,14 +305,14 @@ void koto_cartographer_add_track( ); } -KotoIndexedAlbum * koto_cartographer_get_album_by_uuid( +KotoAlbum * koto_cartographer_get_album_by_uuid( KotoCartographer * self, gchar* album_uuid ) { return g_hash_table_lookup(self->albums, album_uuid); } -KotoIndexedArtist * koto_cartographer_get_artist_by_uuid( +KotoArtist * koto_cartographer_get_artist_by_uuid( KotoCartographer * self, gchar* artist_uuid ) { @@ -330,7 +330,7 @@ KotoPlaylist * koto_cartographer_get_playlist_by_uuid( return g_hash_table_lookup(self->playlists, playlist_uuid); } -KotoIndexedTrack * koto_cartographer_get_track_by_uuid( +KotoTrack * koto_cartographer_get_track_by_uuid( KotoCartographer * self, gchar* track_uuid ) { @@ -339,7 +339,7 @@ KotoIndexedTrack * koto_cartographer_get_track_by_uuid( gboolean koto_cartographer_has_album( KotoCartographer * self, - KotoIndexedAlbum * album + KotoAlbum * album ) { gchar * album_uuid = NULL; @@ -361,7 +361,7 @@ gboolean koto_cartographer_has_album_by_uuid( gboolean koto_cartographer_has_artist( KotoCartographer * self, - KotoIndexedArtist * artist + KotoArtist * artist ) { gchar * artist_uuid = NULL; @@ -405,7 +405,7 @@ gboolean koto_cartographer_has_playlist_by_uuid( gboolean koto_cartographer_has_track( KotoCartographer * self, - KotoIndexedTrack * track + KotoTrack * track ) { gchar * track_uuid = NULL; @@ -427,7 +427,7 @@ gboolean koto_cartographer_has_track_by_uuid( void koto_cartographer_remove_album( KotoCartographer * self, - KotoIndexedAlbum * album + KotoAlbum * album ) { gchar * album_uuid = NULL; @@ -454,7 +454,7 @@ void koto_cartographer_remove_album_by_uuid( void koto_cartographer_remove_artist( KotoCartographer * self, - KotoIndexedArtist * artist + KotoArtist * artist ) { gchar * artist_uuid = NULL; @@ -508,7 +508,7 @@ void koto_cartographer_remove_playlist_by_uuid( void koto_cartographer_remove_track( KotoCartographer * self, - KotoIndexedTrack * track + KotoTrack * track ) { gchar * track_uuid = NULL; diff --git a/src/db/cartographer.h b/src/db/cartographer.h index 90bfa24..e46e2c2 100644 --- a/src/db/cartographer.h +++ b/src/db/cartographer.h @@ -42,12 +42,12 @@ KotoCartographer * koto_cartographer_new(); void koto_cartographer_add_album( KotoCartographer * self, - KotoIndexedAlbum * album + KotoAlbum * album ); void koto_cartographer_add_artist( KotoCartographer * self, - KotoIndexedArtist * artist + KotoArtist * artist ); void koto_cartographer_add_playlist( @@ -57,7 +57,7 @@ void koto_cartographer_add_playlist( void koto_cartographer_add_track( KotoCartographer * self, - KotoIndexedTrack * track + KotoTrack * track ); void koto_cartographer_emit_playlist_added( @@ -65,12 +65,12 @@ void koto_cartographer_emit_playlist_added( KotoCartographer * self ); -KotoIndexedAlbum * koto_cartographer_get_album_by_uuid( +KotoAlbum * koto_cartographer_get_album_by_uuid( KotoCartographer * self, gchar* album_uuid ); -KotoIndexedArtist * koto_cartographer_get_artist_by_uuid( +KotoArtist * koto_cartographer_get_artist_by_uuid( KotoCartographer * self, gchar* artist_uuid ); @@ -82,14 +82,14 @@ KotoPlaylist * koto_cartographer_get_playlist_by_uuid( GHashTable * koto_cartographer_get_playlists(KotoCartographer * self); -KotoIndexedTrack * koto_cartographer_get_track_by_uuid( +KotoTrack * koto_cartographer_get_track_by_uuid( KotoCartographer * self, gchar* track_uuid ); gboolean koto_cartographer_has_album( KotoCartographer * self, - KotoIndexedAlbum * album + KotoAlbum * album ); gboolean koto_cartographer_has_album_by_uuid( @@ -99,7 +99,7 @@ gboolean koto_cartographer_has_album_by_uuid( gboolean koto_cartographer_has_artist( KotoCartographer * self, - KotoIndexedArtist * artist + KotoArtist * artist ); gboolean koto_cartographer_has_artist_by_uuid( @@ -119,7 +119,7 @@ gboolean koto_cartographer_has_playlist_by_uuid( gboolean koto_cartographer_has_track( KotoCartographer * self, - KotoIndexedTrack * track + KotoTrack * track ); gboolean koto_cartographer_has_track_by_uuid( @@ -129,7 +129,7 @@ gboolean koto_cartographer_has_track_by_uuid( void koto_cartographer_remove_album( KotoCartographer * self, - KotoIndexedAlbum * album + KotoAlbum * album ); void koto_cartographer_remove_album_by_uuid( @@ -139,7 +139,7 @@ void koto_cartographer_remove_album_by_uuid( void koto_cartographer_remove_artist( KotoCartographer * self, - KotoIndexedArtist * artist + KotoArtist * artist ); void koto_cartographer_remove_artist_by_uuid( @@ -159,7 +159,7 @@ void koto_cartographer_remove_playlist_by_uuid( void koto_cartographer_remove_track( KotoCartographer * self, - KotoIndexedTrack * track + KotoTrack * track ); void koto_cartographer_remove_track_by_uuid( diff --git a/src/indexer/album.c b/src/indexer/album.c index 42affa8..11ab013 100644 --- a/src/indexer/album.c +++ b/src/indexer/album.c @@ -29,7 +29,7 @@ extern KotoCartographer * koto_maps; extern KotoCurrentPlaylist * current_playlist; extern sqlite3 * koto_db; -struct _KotoIndexedAlbum { +struct _KotoAlbum { GObject parent_instance; gchar * uuid; gchar * path; @@ -43,7 +43,7 @@ struct _KotoIndexedAlbum { gboolean do_initial_index; }; -G_DEFINE_TYPE(KotoIndexedAlbum, koto_indexed_album, G_TYPE_OBJECT); +G_DEFINE_TYPE(KotoAlbum, koto_album, G_TYPE_OBJECT); enum { PROP_0, @@ -60,27 +60,27 @@ static GParamSpec * props[N_PROPERTIES] = { NULL, }; -static void koto_indexed_album_get_property( +static void koto_album_get_property( GObject * obj, guint prop_id, GValue * val, GParamSpec * spec ); -static void koto_indexed_album_set_property( +static void koto_album_set_property( GObject * obj, guint prop_id, const GValue * val, GParamSpec * spec ); -static void koto_indexed_album_class_init(KotoIndexedAlbumClass * c) { +static void koto_album_class_init(KotoAlbumClass * c) { GObjectClass * gobject_class; gobject_class = G_OBJECT_CLASS(c); - gobject_class->set_property = koto_indexed_album_set_property; - gobject_class->get_property = koto_indexed_album_get_property; + gobject_class->set_property = koto_album_set_property; + gobject_class->get_property = koto_album_get_property; props[PROP_UUID] = g_param_spec_string( "uuid", @@ -133,14 +133,14 @@ static void koto_indexed_album_class_init(KotoIndexedAlbumClass * c) { g_object_class_install_properties(gobject_class, N_PROPERTIES, props); } -static void koto_indexed_album_init(KotoIndexedAlbum * self) { +static void koto_album_init(KotoAlbum * self) { self->has_album_art = FALSE; self->tracks = NULL; } -void koto_indexed_album_add_track( - KotoIndexedAlbum * self, - KotoIndexedTrack * track +void koto_album_add_track( + KotoAlbum * self, + KotoTrack * track ) { if (track == NULL) { // Not a file return; @@ -152,13 +152,13 @@ void koto_indexed_album_add_track( g_object_get(track, "uuid", &track_uuid, NULL); if (g_list_index(self->tracks, track_uuid) == -1) { - self->tracks = g_list_insert_sorted_with_data(self->tracks, track_uuid, koto_indexed_album_sort_tracks, NULL); + self->tracks = g_list_insert_sorted_with_data(self->tracks, track_uuid, koto_album_sort_tracks, NULL); } } -void koto_indexed_album_commit(KotoIndexedAlbum * self) { +void koto_album_commit(KotoAlbum * self) { if (self->art_path == NULL) { // If art_path isn't defined when committing - koto_indexed_album_set_album_art(self, ""); // Set to an empty string + koto_album_set_album_art(self, ""); // Set to an empty string } gchar * commit_op = g_strdup_printf( @@ -184,7 +184,7 @@ void koto_indexed_album_commit(KotoIndexedAlbum * self) { g_free(commit_op_errmsg); } -void koto_indexed_album_find_album_art(KotoIndexedAlbum * self) { +void koto_album_find_album_art(KotoAlbum * self) { magic_t magic_cookie = magic_open(MAGIC_MIME); @@ -233,7 +233,7 @@ void koto_indexed_album_find_album_art(KotoIndexedAlbum * self) { (g_strrstr(lower_art, "Small") == NULL) && // Not Small (g_strrstr(lower_art, "back") == NULL) // Not back ) { - koto_indexed_album_set_album_art(self, full_path); + koto_album_set_album_art(self, full_path); g_free(album_art_no_ext); g_free(lower_art); break; @@ -250,8 +250,8 @@ void koto_indexed_album_find_album_art(KotoIndexedAlbum * self) { magic_close(magic_cookie); } -void koto_indexed_album_find_tracks( - KotoIndexedAlbum * self, +void koto_album_find_tracks( + KotoAlbum * self, magic_t magic_cookie, const gchar * path ) { @@ -290,7 +290,7 @@ void koto_indexed_album_find_tracks( gchar * full_path = g_strdup_printf("%s%s%s", path, G_DIR_SEPARATOR_S, entry->d_name); if (entry->d_type == DT_DIR) { // If this is a directory - koto_indexed_album_find_tracks(self, magic_cookie, full_path); // Recursively find tracks + koto_album_find_tracks(self, magic_cookie, full_path); // Recursively find tracks g_free(full_path); continue; } @@ -334,10 +334,10 @@ void koto_indexed_album_find_tracks( g_strfreev(possible_cd_split); g_free(appended_slash_to_path); - KotoIndexedTrack * track = koto_indexed_track_new(self, full_path, cd); + KotoTrack * track = koto_track_new(self, full_path, cd); if (track != NULL) { // Is a file - koto_indexed_album_add_track(self, track); // Add our file + koto_album_add_track(self, track); // Add our file } } @@ -345,13 +345,13 @@ void koto_indexed_album_find_tracks( } } -static void koto_indexed_album_get_property( +static void koto_album_get_property( GObject * obj, guint prop_id, GValue * val, GParamSpec * spec ) { - KotoIndexedAlbum * self = KOTO_INDEXED_ALBUM(obj); + KotoAlbum * self = KOTO_ALBUM(obj); switch (prop_id) { @@ -368,7 +368,7 @@ static void koto_indexed_album_get_property( g_value_set_string(val, self->name); break; case PROP_ART_PATH: - g_value_set_string(val, koto_indexed_album_get_album_art(self)); + g_value_set_string(val, koto_album_get_album_art(self)); break; case PROP_ARTIST_UUID: g_value_set_string(val, self->artist_uuid); @@ -379,13 +379,13 @@ static void koto_indexed_album_get_property( } } -static void koto_indexed_album_set_property( +static void koto_album_set_property( GObject * obj, guint prop_id, const GValue * val, GParamSpec * spec ) { - KotoIndexedAlbum * self = KOTO_INDEXED_ALBUM(obj); + KotoAlbum * self = KOTO_ALBUM(obj); switch (prop_id) { @@ -397,16 +397,16 @@ static void koto_indexed_album_set_property( self->do_initial_index = g_value_get_boolean(val); break; case PROP_PATH: // Path to the album - koto_indexed_album_update_path(self, (gchar*) g_value_get_string(val)); + koto_album_update_path(self, (gchar*) g_value_get_string(val)); break; case PROP_ALBUM_NAME: // Name of album - koto_indexed_album_set_album_name(self, g_value_get_string(val)); + koto_album_set_album_name(self, g_value_get_string(val)); break; case PROP_ART_PATH: // Path to art - koto_indexed_album_set_album_art(self, g_value_get_string(val)); + koto_album_set_album_art(self, g_value_get_string(val)); break; case PROP_ARTIST_UUID: - koto_indexed_album_set_artist_uuid(self, g_value_get_string(val)); + koto_album_set_artist_uuid(self, g_value_get_string(val)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec); @@ -414,16 +414,16 @@ static void koto_indexed_album_set_property( } } -gchar * koto_indexed_album_get_album_art(KotoIndexedAlbum * self) { - if (!KOTO_IS_INDEXED_ALBUM(self)) { // Not an album +gchar * koto_album_get_album_art(KotoAlbum * self) { + if (!KOTO_IS_ALBUM(self)) { // Not an album return g_strdup(""); } return g_strdup((self->has_album_art && koto_utils_is_string_valid(self->art_path)) ? self->art_path : ""); } -gchar * koto_indexed_album_get_album_name(KotoIndexedAlbum * self) { - if (!KOTO_IS_INDEXED_ALBUM(self)) { // Not an album +gchar * koto_album_get_album_name(KotoAlbum * self) { + if (!KOTO_IS_ALBUM(self)) { // Not an album return NULL; } @@ -434,8 +434,8 @@ gchar * koto_indexed_album_get_album_name(KotoIndexedAlbum * self) { return g_strdup(self->name); // Return duplicate of the name } -gchar * koto_indexed_album_get_album_uuid(KotoIndexedAlbum * self) { - if (!KOTO_IS_INDEXED_ALBUM(self)) { // Not an album +gchar * koto_album_get_album_uuid(KotoAlbum * self) { + if (!KOTO_IS_ALBUM(self)) { // Not an album return NULL; } @@ -446,19 +446,19 @@ gchar * koto_indexed_album_get_album_uuid(KotoIndexedAlbum * self) { return g_strdup(self->uuid); // Return a duplicate of the UUID } -GList * koto_indexed_album_get_tracks(KotoIndexedAlbum * self) { - if (!KOTO_IS_INDEXED_ALBUM(self)) { // Not an album +GList * koto_album_get_tracks(KotoAlbum * self) { + if (!KOTO_IS_ALBUM(self)) { // Not an album return NULL; } return self->tracks; // Return } -void koto_indexed_album_set_album_art( - KotoIndexedAlbum * self, +void koto_album_set_album_art( + KotoAlbum * self, const gchar * album_art ) { - if (!KOTO_IS_INDEXED_ALBUM(self)) { // Not an album + if (!KOTO_IS_ALBUM(self)) { // Not an album return; } @@ -475,11 +475,11 @@ void koto_indexed_album_set_album_art( self->has_album_art = TRUE; } -void koto_indexed_album_remove_file( - KotoIndexedAlbum * self, - KotoIndexedTrack * track +void koto_album_remove_file( + KotoAlbum * self, + KotoTrack * track ) { - if (!KOTO_IS_INDEXED_ALBUM(self)) { // Not an album + if (!KOTO_IS_ALBUM(self)) { // Not an album return; } @@ -494,11 +494,11 @@ void koto_indexed_album_remove_file( self->tracks = g_list_remove(self->tracks, track_uuid); } -void koto_indexed_album_set_album_name( - KotoIndexedAlbum * self, +void koto_album_set_album_name( + KotoAlbum * self, const gchar * album_name ) { - if (!KOTO_IS_INDEXED_ALBUM(self)) { // Not an album + if (!KOTO_IS_ALBUM(self)) { // Not an album return; } @@ -513,11 +513,11 @@ void koto_indexed_album_set_album_name( self->name = g_strdup(album_name); } -void koto_indexed_album_set_artist_uuid( - KotoIndexedAlbum * self, +void koto_album_set_artist_uuid( + KotoAlbum * self, const gchar * artist_uuid ) { - if (!KOTO_IS_INDEXED_ALBUM(self)) { // Not an album + if (!KOTO_IS_ALBUM(self)) { // Not an album return; } @@ -532,8 +532,8 @@ void koto_indexed_album_set_artist_uuid( self->artist_uuid = g_strdup(artist_uuid); } -void koto_indexed_album_set_as_current_playlist(KotoIndexedAlbum * self) { - if (!KOTO_IS_INDEXED_ALBUM(self)) { // Not an album +void koto_album_set_as_current_playlist(KotoAlbum * self) { + if (!KOTO_IS_ALBUM(self)) { // Not an album return; } @@ -570,14 +570,14 @@ void koto_indexed_album_set_as_current_playlist(KotoIndexedAlbum * self) { koto_current_playlist_set_playlist(current_playlist, new_album_playlist); // Set our new current playlist } -gint koto_indexed_album_sort_tracks( +gint koto_album_sort_tracks( gconstpointer track1_uuid, gconstpointer track2_uuid, gpointer user_data ) { (void) user_data; - KotoIndexedTrack * track1 = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) track1_uuid); - KotoIndexedTrack * track2 = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) track2_uuid); + KotoTrack * track1 = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) track1_uuid); + KotoTrack * track2 = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) track2_uuid); if ((track1 == NULL) && (track2 == NULL)) { // Neither tracks actually exist @@ -623,11 +623,11 @@ gint koto_indexed_album_sort_tracks( } } -void koto_indexed_album_update_path( - KotoIndexedAlbum * self, +void koto_album_update_path( + KotoAlbum * self, gchar* new_path ) { - if (!KOTO_IS_INDEXED_ALBUM(self)) { // Not an album + if (!KOTO_IS_ALBUM(self)) { // Not an album return; } @@ -640,17 +640,17 @@ void koto_indexed_album_update_path( } self->path = g_strdup(new_path); - koto_indexed_album_set_album_name(self, g_path_get_basename(self->path)); // Update our album name based on the base name + koto_album_set_album_name(self, g_path_get_basename(self->path)); // Update our album name based on the base name if (!self->do_initial_index) { // Not doing our initial index return; } - koto_indexed_album_find_album_art(self); // Update our path for the album art + koto_album_find_album_art(self); // Update our path for the album art } -KotoIndexedAlbum * koto_indexed_album_new( - KotoIndexedArtist * artist, +KotoAlbum * koto_album_new( + KotoArtist * artist, const gchar * path ) { gchar * artist_uuid = NULL; @@ -658,8 +658,8 @@ KotoIndexedAlbum * koto_indexed_album_new( g_object_get(artist, "uuid", &artist_uuid, NULL); - KotoIndexedAlbum* album = g_object_new( - KOTO_TYPE_INDEXED_ALBUM, + KotoAlbum* album = g_object_new( + KOTO_TYPE_ALBUM, "artist-uuid", artist_uuid, "uuid", @@ -672,14 +672,14 @@ KotoIndexedAlbum * koto_indexed_album_new( ); - koto_indexed_album_commit(album); - koto_indexed_album_find_tracks(album, NULL, NULL); // Scan for tracks now that we committed to the database (hopefully) + koto_album_commit(album); + koto_album_find_tracks(album, NULL, NULL); // Scan for tracks now that we committed to the database (hopefully) return album; } -KotoIndexedAlbum * koto_indexed_album_new_with_uuid( - KotoIndexedArtist * artist, +KotoAlbum * koto_album_new_with_uuid( + KotoArtist * artist, const gchar * uuid ) { gchar * artist_uuid = NULL; @@ -688,7 +688,7 @@ KotoIndexedAlbum * koto_indexed_album_new_with_uuid( g_object_get(artist, "uuid", &artist_uuid, NULL); return g_object_new( - KOTO_TYPE_INDEXED_ALBUM, + KOTO_TYPE_ALBUM, "artist-uuid", artist, "uuid", diff --git a/src/indexer/artist.c b/src/indexer/artist.c index 4587bca..dd0b485 100644 --- a/src/indexer/artist.c +++ b/src/indexer/artist.c @@ -23,7 +23,7 @@ extern sqlite3 * koto_db; -struct _KotoIndexedArtist { +struct _KotoArtist { GObject parent_instance; gchar * uuid; gchar * path; @@ -33,7 +33,7 @@ struct _KotoIndexedArtist { GList * albums; }; -G_DEFINE_TYPE(KotoIndexedArtist, koto_indexed_artist, G_TYPE_OBJECT); +G_DEFINE_TYPE(KotoArtist, koto_artist, G_TYPE_OBJECT); enum { PROP_0, @@ -47,27 +47,27 @@ static GParamSpec * props[N_PROPERTIES] = { NULL, }; -static void koto_indexed_artist_get_property( +static void koto_artist_get_property( GObject * obj, guint prop_id, GValue * val, GParamSpec * spec ); -static void koto_indexed_artist_set_property( +static void koto_artist_set_property( GObject * obj, guint prop_id, const GValue * val, GParamSpec * spec ); -static void koto_indexed_artist_class_init(KotoIndexedArtistClass * c) { +static void koto_artist_class_init(KotoArtistClass * c) { GObjectClass * gobject_class; gobject_class = G_OBJECT_CLASS(c); - gobject_class->set_property = koto_indexed_artist_set_property; - gobject_class->get_property = koto_indexed_artist_get_property; + gobject_class->set_property = koto_artist_set_property; + gobject_class->get_property = koto_artist_get_property; props[PROP_UUID] = g_param_spec_string( "uuid", @@ -96,7 +96,7 @@ static void koto_indexed_artist_class_init(KotoIndexedArtistClass * c) { g_object_class_install_properties(gobject_class, N_PROPERTIES, props); } -void koto_indexed_artist_commit(KotoIndexedArtist * self) { +void koto_artist_commit(KotoArtist * self) { if ((self->uuid == NULL) || strcmp(self->uuid, "")) { // UUID not set self->uuid = g_strdup(g_uuid_string_random()); } @@ -123,18 +123,18 @@ void koto_indexed_artist_commit(KotoIndexedArtist * self) { g_free(commit_opt_errmsg); } -static void koto_indexed_artist_init(KotoIndexedArtist * self) { +static void koto_artist_init(KotoArtist * self) { self->has_artist_art = FALSE; self->albums = NULL; // Create a new GList } -static void koto_indexed_artist_get_property( +static void koto_artist_get_property( GObject * obj, guint prop_id, GValue * val, GParamSpec * spec ) { - KotoIndexedArtist * self = KOTO_INDEXED_ARTIST(obj); + KotoArtist * self = KOTO_ARTIST(obj); switch (prop_id) { @@ -153,13 +153,13 @@ static void koto_indexed_artist_get_property( } } -static void koto_indexed_artist_set_property( +static void koto_artist_set_property( GObject * obj, guint prop_id, const GValue * val, GParamSpec * spec ) { - KotoIndexedArtist * self = KOTO_INDEXED_ARTIST(obj); + KotoArtist * self = KOTO_ARTIST(obj); switch (prop_id) { @@ -168,10 +168,10 @@ static void koto_indexed_artist_set_property( g_object_notify_by_pspec(G_OBJECT(self), props[PROP_UUID]); break; case PROP_PATH: - koto_indexed_artist_update_path(self, (gchar*) g_value_get_string(val)); + koto_artist_update_path(self, (gchar*) g_value_get_string(val)); break; case PROP_ARTIST_NAME: - koto_indexed_artist_set_artist_name(self, (gchar*) g_value_get_string(val)); + koto_artist_set_artist_name(self, (gchar*) g_value_get_string(val)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec); @@ -179,11 +179,11 @@ static void koto_indexed_artist_set_property( } } -void koto_indexed_artist_add_album( - KotoIndexedArtist * self, +void koto_artist_add_album( + KotoArtist * self, gchar * album_uuid ) { - if (!KOTO_IS_INDEXED_ARTIST(self)) { // Not an artist + if (!KOTO_IS_ARTIST(self)) { // Not an artist return; } @@ -199,31 +199,31 @@ void koto_indexed_artist_add_album( } } -GList * koto_indexed_artist_get_albums(KotoIndexedArtist * self) { - if (!KOTO_IS_INDEXED_ARTIST(self)) { // Not an artist +GList * koto_artist_get_albums(KotoArtist * self) { + if (!KOTO_IS_ARTIST(self)) { // Not an artist return NULL; } return g_list_copy(self->albums); } -gchar * koto_indexed_artist_get_name(KotoIndexedArtist * self) { - if (!KOTO_IS_INDEXED_ARTIST(self)) { // Not an artist +gchar * koto_artist_get_name(KotoArtist * self) { + if (!KOTO_IS_ARTIST(self)) { // Not an artist return g_strdup(""); } return g_strdup(koto_utils_is_string_valid(self->artist_name) ? self->artist_name : ""); // Return artist name if set } -void koto_indexed_artist_remove_album( - KotoIndexedArtist * self, - KotoIndexedAlbum * album +void koto_artist_remove_album( + KotoArtist * self, + KotoAlbum * album ) { - if (!KOTO_IS_INDEXED_ARTIST(self)) { // Not an artist + if (!KOTO_IS_ARTIST(self)) { // Not an artist return; } - if (!KOTO_INDEXED_ALBUM(album)) { // No album defined + if (!KOTO_ALBUM(album)) { // No album defined return; } @@ -234,11 +234,11 @@ void koto_indexed_artist_remove_album( self->albums = g_list_remove(self->albums, album_uuid); } -void koto_indexed_artist_update_path( - KotoIndexedArtist * self, +void koto_artist_update_path( + KotoArtist * self, gchar * new_path ) { - if (!KOTO_IS_INDEXED_ARTIST(self)) { // Not an artist + if (!KOTO_IS_ARTIST(self)) { // Not an artist return; } @@ -254,11 +254,11 @@ void koto_indexed_artist_update_path( g_object_notify_by_pspec(G_OBJECT(self), props[PROP_PATH]); } -void koto_indexed_artist_set_artist_name( - KotoIndexedArtist * self, +void koto_artist_set_artist_name( + KotoArtist * self, gchar * artist_name ) { - if (!KOTO_IS_INDEXED_ARTIST(self)) { // Not an artist + if (!KOTO_IS_ARTIST(self)) { // Not an artist return; } @@ -274,9 +274,9 @@ void koto_indexed_artist_set_artist_name( g_object_notify_by_pspec(G_OBJECT(self), props[PROP_ARTIST_NAME]); } -KotoIndexedArtist * koto_indexed_artist_new(gchar * path) { - KotoIndexedArtist* artist = g_object_new( - KOTO_TYPE_INDEXED_ARTIST, +KotoArtist * koto_artist_new(gchar * path) { + KotoArtist* artist = g_object_new( + KOTO_TYPE_ARTIST, "uuid", g_uuid_string_random(), "path", @@ -287,13 +287,13 @@ KotoIndexedArtist * koto_indexed_artist_new(gchar * path) { ); - koto_indexed_artist_commit(artist); // Commit the artist immediately to the database + koto_artist_commit(artist); // Commit the artist immediately to the database return artist; } -KotoIndexedArtist * koto_indexed_artist_new_with_uuid(const gchar * uuid) { +KotoArtist * koto_artist_new_with_uuid(const gchar * uuid) { return g_object_new( - KOTO_TYPE_INDEXED_ARTIST, + KOTO_TYPE_ARTIST, "uuid", g_strdup(uuid), NULL diff --git a/src/indexer/file-indexer.c b/src/indexer/file-indexer.c index 4e579ca..e7a8bd8 100644 --- a/src/indexer/file-indexer.c +++ b/src/indexer/file-indexer.c @@ -29,14 +29,14 @@ extern KotoCartographer * koto_maps; extern sqlite3 * koto_db; -struct _KotoIndexedLibrary { +struct _KotoLibrary { GObject parent_instance; gchar * path; magic_t magic_cookie; GHashTable * music_artists; }; -G_DEFINE_TYPE(KotoIndexedLibrary, koto_indexed_library, G_TYPE_OBJECT); +G_DEFINE_TYPE(KotoLibrary, koto_library, G_TYPE_OBJECT); enum { PROP_0, @@ -48,27 +48,27 @@ static GParamSpec * props[N_PROPERTIES] = { NULL, }; -static void koto_indexed_library_get_property( +static void koto_library_get_property( GObject * obj, guint prop_id, GValue * val, GParamSpec * spec ); -static void koto_indexed_library_set_property( +static void koto_library_set_property( GObject * obj, guint prop_id, const GValue * val, GParamSpec * spec ); -static void koto_indexed_library_class_init(KotoIndexedLibraryClass * c) { +static void koto_library_class_init(KotoLibraryClass * c) { GObjectClass * gobject_class; gobject_class = G_OBJECT_CLASS(c); - gobject_class->set_property = koto_indexed_library_set_property; - gobject_class->get_property = koto_indexed_library_get_property; + gobject_class->set_property = koto_library_set_property; + gobject_class->get_property = koto_library_get_property; props[PROP_PATH] = g_param_spec_string( "path", @@ -82,19 +82,19 @@ static void koto_indexed_library_class_init(KotoIndexedLibraryClass * c) { taglib_id3v2_set_default_text_encoding(TagLib_ID3v2_UTF8); // Ensure our id3v2 text encoding is UTF-8 } -static void koto_indexed_library_init(KotoIndexedLibrary * self) { +static void koto_library_init(KotoLibrary * self) { self->music_artists = g_hash_table_new(g_str_hash, g_str_equal); } -void koto_indexed_library_add_artist( - KotoIndexedLibrary * self, - KotoIndexedArtist * artist +void koto_library_add_artist( + KotoLibrary * self, + KotoArtist * artist ) { if (artist == NULL) { // No artist return; } - koto_indexed_library_get_artists(self); // Call to generate if needed + koto_library_get_artists(self); // Call to generate if needed gchar * artist_name; gchar * artist_uuid; @@ -110,28 +110,28 @@ void koto_indexed_library_add_artist( g_hash_table_insert(self->music_artists, artist_name, artist_uuid); // Add the artist by its name (this needs to be done so we can get the artist when doing the depth of 2 indexing for the album) } -KotoIndexedArtist * koto_indexed_library_get_artist( - KotoIndexedLibrary * self, +KotoArtist * koto_library_get_artist( + KotoLibrary * self, gchar * artist_name ) { if (artist_name == NULL) { return NULL; } - koto_indexed_library_get_artists(self); // Call to generate if needed + koto_library_get_artists(self); // Call to generate if needed gchar * artist_uuid = g_hash_table_lookup(self->music_artists, artist_name); // Get the UUID from our music artists if (artist_uuid != NULL) { - KotoIndexedArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid); // Return any artist from cartographer + KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid); // Return any artist from cartographer return artist; } else { return NULL; } } -GHashTable * koto_indexed_library_get_artists(KotoIndexedLibrary * self) { +GHashTable * koto_library_get_artists(KotoLibrary * self) { if (self->music_artists == NULL) { // Not a HashTable self->music_artists = g_hash_table_new(g_str_hash, g_str_equal); } @@ -139,15 +139,15 @@ GHashTable * koto_indexed_library_get_artists(KotoIndexedLibrary * self) { return self->music_artists; } -void koto_indexed_library_remove_artist( - KotoIndexedLibrary * self, - KotoIndexedArtist * artist +void koto_library_remove_artist( + KotoLibrary * self, + KotoArtist * artist ) { if (artist == NULL) { return; } - koto_indexed_library_get_artists(self); // Call to generate if needed + koto_library_get_artists(self); // Call to generate if needed gchar * artist_name; @@ -157,13 +157,13 @@ void koto_indexed_library_remove_artist( g_hash_table_remove(self->music_artists, artist_name); // Remove the artist } -static void koto_indexed_library_get_property( +static void koto_library_get_property( GObject * obj, guint prop_id, GValue * val, GParamSpec * spec ) { - KotoIndexedLibrary * self = KOTO_INDEXED_LIBRARY(obj); + KotoLibrary * self = KOTO_LIBRARY(obj); switch (prop_id) { @@ -176,18 +176,18 @@ static void koto_indexed_library_get_property( } } -static void koto_indexed_library_set_property( +static void koto_library_set_property( GObject * obj, guint prop_id, const GValue * val, GParamSpec * spec ) { - KotoIndexedLibrary * self = KOTO_INDEXED_LIBRARY(obj); + KotoLibrary * self = KOTO_LIBRARY(obj); switch (prop_id) { case PROP_PATH: - koto_indexed_library_set_path(self, g_strdup(g_value_get_string(val))); + koto_library_set_path(self, g_strdup(g_value_get_string(val))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec); @@ -195,8 +195,8 @@ static void koto_indexed_library_set_property( } } -void koto_indexed_library_set_path( - KotoIndexedLibrary * self, +void koto_library_set_path( + KotoLibrary * self, gchar * path ) { if (path == NULL) { @@ -225,12 +225,12 @@ int process_artists( (void) num_columns; (void) column_names; // Don't need any of the params - KotoIndexedLibrary * library = (KotoIndexedLibrary*) data; + KotoLibrary * library = (KotoLibrary*) data; gchar * artist_uuid = g_strdup(koto_utils_unquote_string(fields[0])); // First column is UUID gchar * artist_path = g_strdup(koto_utils_unquote_string(fields[1])); // Second column is path gchar * artist_name = g_strdup(koto_utils_unquote_string(fields[3])); // Fourth column is artist name - KotoIndexedArtist * artist = koto_indexed_artist_new_with_uuid(artist_uuid); // Create our artist with the UUID + KotoArtist * artist = koto_artist_new_with_uuid(artist_uuid); // Create our artist with the UUID g_object_set( @@ -242,7 +242,7 @@ int process_artists( NULL); koto_cartographer_add_artist(koto_maps, artist); // Add the artist to our global cartographer - koto_indexed_library_add_artist(library, artist); + koto_library_add_artist(library, artist); int albums_rc = sqlite3_exec(koto_db, g_strdup_printf("SELECT * FROM albums WHERE artist_id=\"%s\"", artist_uuid), process_albums, artist, NULL); // Process our albums @@ -268,7 +268,7 @@ int process_albums( (void) num_columns; (void) column_names; // Don't need these - KotoIndexedArtist * artist = (KotoIndexedArtist*) data; + KotoArtist * artist = (KotoArtist*) data; gchar * album_uuid = g_strdup(koto_utils_unquote_string(fields[0])); gchar * path = g_strdup(koto_utils_unquote_string(fields[1])); @@ -276,7 +276,7 @@ int process_albums( gchar * album_name = g_strdup(koto_utils_unquote_string(fields[3])); gchar * album_art = (fields[4] != NULL) ? g_strdup(koto_utils_unquote_string(fields[4])) : NULL; - KotoIndexedAlbum * album = koto_indexed_album_new_with_uuid(artist, album_uuid); // Create our album + KotoAlbum * album = koto_album_new_with_uuid(artist, album_uuid); // Create our album g_object_set( @@ -290,7 +290,7 @@ int process_albums( NULL); koto_cartographer_add_album(koto_maps, album); // Add the album to our global cartographer - koto_indexed_artist_add_album(artist, album_uuid); // Add the album + koto_artist_add_album(artist, album_uuid); // Add the album int tracks_rc = sqlite3_exec(koto_db, g_strdup_printf("SELECT * FROM tracks WHERE album_id=\"%s\"", album_uuid), process_tracks, album, NULL); // Process our tracks @@ -366,7 +366,7 @@ int process_playlists_tracks( gboolean current = g_strcmp0(koto_utils_unquote_string(fields[3]), "0"); KotoPlaylist * playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, playlist_uuid); // Get the playlist - KotoIndexedTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, track_uuid); // Get the track + KotoTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, track_uuid); // Get the track if (!KOTO_IS_PLAYLIST(playlist)) { @@ -391,7 +391,7 @@ int process_tracks( (void) num_columns; (void) column_names; // Don't need these - KotoIndexedAlbum * album = (KotoIndexedAlbum*) data; + KotoAlbum * album = (KotoAlbum*) data; gchar * track_uuid = g_strdup(koto_utils_unquote_string(fields[0])); gchar * path = g_strdup(koto_utils_unquote_string(fields[1])); gchar * artist_uuid = g_strdup(koto_utils_unquote_string(fields[3])); @@ -401,13 +401,13 @@ int process_tracks( guint * disc_num = (guint*) g_ascii_strtoull(fields[7], NULL, 10); guint * position = (guint*) g_ascii_strtoull(fields[8], NULL, 10); - KotoIndexedTrack * track = koto_indexed_track_new_with_uuid(track_uuid); // Create our file + KotoTrack * track = koto_track_new_with_uuid(track_uuid); // Create our file g_object_set(track, "artist-uuid", artist_uuid, "album-uuid", album_uuid, "path", path, "file-name", file_name, "parsed-name", name, "cd", disc_num, "position", position, NULL); koto_cartographer_add_track(koto_maps, track); // Add the track to cartographer - koto_indexed_album_add_track(album, track); // Add the track + koto_album_add_track(album, track); // Add the track g_free(track_uuid); g_free(path); @@ -419,7 +419,7 @@ int process_tracks( return 0; } -void read_from_db(KotoIndexedLibrary * self) { +void read_from_db(KotoLibrary * self) { int artists_rc = sqlite3_exec(koto_db, "SELECT * FROM artists", process_artists, self, NULL); // Process our artists @@ -439,7 +439,7 @@ void read_from_db(KotoIndexedLibrary * self) { } } -void start_indexing(KotoIndexedLibrary * self) { +void start_indexing(KotoLibrary * self) { struct stat library_stat; int success = stat(self->path, &library_stat); @@ -469,9 +469,9 @@ void start_indexing(KotoIndexedLibrary * self) { g_hash_table_foreach(self->music_artists, output_artists, NULL); } -KotoIndexedLibrary * koto_indexed_library_new(const gchar * path) { +KotoLibrary * koto_library_new(const gchar * path) { return g_object_new( - KOTO_TYPE_INDEXED_LIBRARY, + KOTO_TYPE_LIBRARY, "path", path, NULL @@ -479,7 +479,7 @@ KotoIndexedLibrary * koto_indexed_library_new(const gchar * path) { } void index_folder( - KotoIndexedLibrary * self, + KotoLibrary * self, gchar * path, guint depth ) { @@ -504,7 +504,7 @@ void index_folder( if (entry->d_type == DT_DIR) { // Directory if (depth == 1) { // If we are following FOLDER/ARTIST/ALBUM then this would be artist - KotoIndexedArtist * artist = koto_indexed_artist_new(full_path); // Attempt to get the artist + KotoArtist * artist = koto_artist_new(full_path); // Attempt to get the artist gchar * artist_name; g_object_get( @@ -515,23 +515,23 @@ void index_folder( ); koto_cartographer_add_artist(koto_maps, artist); // Add the artist to cartographer - koto_indexed_library_add_artist(self, artist); // Add the artist + koto_library_add_artist(self, artist); // Add the artist index_folder(self, full_path, depth); // Index this directory g_free(artist_name); } else if (depth == 2) { // If we are following FOLDER/ARTIST/ALBUM then this would be album gchar * artist_name = g_path_get_basename(path); // Get the last entry from our path which is probably the artist - KotoIndexedArtist * artist = koto_indexed_library_get_artist(self, artist_name); // Get the artist + KotoArtist * artist = koto_library_get_artist(self, artist_name); // Get the artist if (artist == NULL) { continue; } - KotoIndexedAlbum * album = koto_indexed_album_new(artist, full_path); + KotoAlbum * album = koto_album_new(artist, full_path); koto_cartographer_add_album(koto_maps, album); // Add our album to the cartographer gchar * album_uuid = NULL; g_object_get(album, "uuid", &album_uuid, NULL); - koto_indexed_artist_add_album(artist, album_uuid); // Add the album + koto_artist_add_album(artist, album_uuid); // Add the album g_free(artist_name); } } @@ -549,7 +549,7 @@ void output_artists( ) { (void) artist_ptr; (void) data; - KotoIndexedArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, (gchar*) artist_key); + KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, (gchar*) artist_key); if (artist == NULL) { @@ -562,7 +562,7 @@ void output_artists( g_object_get(artist, "name", &artist_name, NULL); g_debug("Artist: %s", artist_name); - GList * albums = koto_indexed_artist_get_albums(artist); // Get the albums for this artist + GList * albums = koto_artist_get_albums(artist); // Get the albums for this artist if (albums != NULL) { @@ -574,19 +574,19 @@ void output_artists( for (a = albums; a != NULL; a = a->next) { gchar * album_uuid = a->data; - KotoIndexedAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, album_uuid); + KotoAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, album_uuid); if (album == NULL) { continue; } - gchar * artwork = koto_indexed_album_get_album_art(album); + gchar * artwork = koto_album_get_album_art(album); gchar * album_name; g_object_get(album, "name", &album_name, NULL); g_debug("Album Art: %s", artwork); g_debug("Album Name: %s", album_name); - g_list_foreach(koto_indexed_album_get_tracks(album), output_track, NULL); + g_list_foreach(koto_album_get_tracks(album), output_track, NULL); } } @@ -596,7 +596,7 @@ void output_track( ) { (void) user_data; - KotoIndexedTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) data); + KotoTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) data); if (track == NULL) { diff --git a/src/indexer/structs.h b/src/indexer/structs.h index f288805..fa3771f 100644 --- a/src/indexer/structs.h +++ b/src/indexer/structs.h @@ -25,47 +25,47 @@ G_BEGIN_DECLS * Type Definition **/ -#define KOTO_TYPE_INDEXED_LIBRARY koto_indexed_library_get_type() -G_DECLARE_FINAL_TYPE(KotoIndexedLibrary, koto_indexed_library, KOTO, INDEXED_LIBRARY, GObject); -#define KOTO_IS_INDEXED_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_INDEXED_LIBRARY)) +#define KOTO_TYPE_LIBRARY koto_library_get_type() +G_DECLARE_FINAL_TYPE(KotoLibrary, koto_library, KOTO, LIBRARY, GObject); +#define KOTO_IS_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_LIBRARY)) -#define KOTO_TYPE_INDEXED_ARTIST koto_indexed_artist_get_type() -G_DECLARE_FINAL_TYPE(KotoIndexedArtist, koto_indexed_artist, KOTO, INDEXED_ARTIST, GObject); -#define KOTO_IS_INDEXED_ARTIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_INDEXED_ARTIST)) +#define KOTO_TYPE_ARTIST koto_artist_get_type() +G_DECLARE_FINAL_TYPE(KotoArtist, koto_artist, KOTO, ARTIST, GObject); +#define KOTO_IS_ARTIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_ARTIST)) -#define KOTO_TYPE_INDEXED_ALBUM koto_indexed_album_get_type() -G_DECLARE_FINAL_TYPE(KotoIndexedAlbum, koto_indexed_album, KOTO, INDEXED_ALBUM, GObject); -#define KOTO_IS_INDEXED_ALBUM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_INDEXED_ALBUM)) +#define KOTO_TYPE_ALBUM koto_album_get_type() +G_DECLARE_FINAL_TYPE(KotoAlbum, koto_album, KOTO, ALBUM, GObject); +#define KOTO_IS_ALBUM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_ALBUM)) -#define KOTO_TYPE_INDEXED_TRACK koto_indexed_track_get_type() -G_DECLARE_FINAL_TYPE(KotoIndexedTrack, koto_indexed_track, KOTO, INDEXED_TRACK, GObject); -#define KOTO_IS_INDEXED_TRACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_INDEXED_TRACK)) +#define KOTO_TYPE_TRACK koto_track_get_type() +G_DECLARE_FINAL_TYPE(KotoTrack, koto_track, KOTO, TRACK, GObject); +#define KOTO_IS_TRACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_TRACK)) /** * Library Functions **/ -KotoIndexedLibrary * koto_indexed_library_new(const gchar * path); +KotoLibrary * koto_library_new(const gchar * path); -void koto_indexed_library_add_artist( - KotoIndexedLibrary * self, - KotoIndexedArtist * artist +void koto_library_add_artist( + KotoLibrary * self, + KotoArtist * artist ); -KotoIndexedArtist * koto_indexed_library_get_artist( - KotoIndexedLibrary * self, +KotoArtist * koto_library_get_artist( + KotoLibrary * self, gchar* artist_name ); -GHashTable * koto_indexed_library_get_artists(KotoIndexedLibrary * self); +GHashTable * koto_library_get_artists(KotoLibrary * self); -void koto_indexed_library_remove_artist( - KotoIndexedLibrary * self, - KotoIndexedArtist * artist +void koto_library_remove_artist( + KotoLibrary * self, + KotoArtist * artist ); -void koto_indexed_library_set_path( - KotoIndexedLibrary * self, +void koto_library_set_path( + KotoLibrary * self, gchar * path ); @@ -104,12 +104,12 @@ int process_tracks( char ** column_names ); -void read_from_db(KotoIndexedLibrary * self); +void read_from_db(KotoLibrary * self); -void start_indexing(KotoIndexedLibrary * self); +void start_indexing(KotoLibrary * self); void index_folder( - KotoIndexedLibrary * self, + KotoLibrary * self, gchar * path, guint depth ); @@ -123,43 +123,43 @@ void output_track( * Artist Functions **/ -KotoIndexedArtist * koto_indexed_artist_new(gchar * path); +KotoArtist * koto_artist_new(gchar * path); -KotoIndexedArtist * koto_indexed_artist_new_with_uuid(const gchar * uuid); +KotoArtist * koto_artist_new_with_uuid(const gchar * uuid); -void koto_indexed_artist_add_album( - KotoIndexedArtist * self, +void koto_artist_add_album( + KotoArtist * self, gchar * album_uuid ); -void koto_indexed_artist_commit(KotoIndexedArtist * self); +void koto_artist_commit(KotoArtist * self); -guint koto_indexed_artist_find_album_with_name( +guint koto_artist_find_album_with_name( gconstpointer * album_data, gconstpointer * album_name_data ); -GList * koto_indexed_artist_get_albums(KotoIndexedArtist * self); +GList * koto_artist_get_albums(KotoArtist * self); -gchar * koto_indexed_artist_get_name(KotoIndexedArtist * self); +gchar * koto_artist_get_name(KotoArtist * self); -void koto_indexed_artist_remove_album( - KotoIndexedArtist * self, - KotoIndexedAlbum * album +void koto_artist_remove_album( + KotoArtist * self, + KotoAlbum * album ); -void koto_indexed_artist_remove_album_by_name( - KotoIndexedArtist * self, +void koto_artist_remove_album_by_name( + KotoArtist * self, gchar * album_name ); -void koto_indexed_artist_set_artist_name( - KotoIndexedArtist * self, +void koto_artist_set_artist_name( + KotoArtist * self, gchar * artist_name ); -void koto_indexed_artist_update_path( - KotoIndexedArtist * self, +void koto_artist_update_path( + KotoArtist * self, gchar * new_path ); @@ -173,67 +173,67 @@ void output_artists( * Album Functions **/ -KotoIndexedAlbum * koto_indexed_album_new( - KotoIndexedArtist * artist, +KotoAlbum * koto_album_new( + KotoArtist * artist, const gchar * path ); -KotoIndexedAlbum * koto_indexed_album_new_with_uuid( - KotoIndexedArtist * artist, +KotoAlbum * koto_album_new_with_uuid( + KotoArtist * artist, const gchar * uuid ); -void koto_indexed_album_add_track( - KotoIndexedAlbum * self, - KotoIndexedTrack * track +void koto_album_add_track( + KotoAlbum * self, + KotoTrack * track ); -void koto_indexed_album_commit(KotoIndexedAlbum * self); +void koto_album_commit(KotoAlbum * self); -void koto_indexed_album_find_album_art(KotoIndexedAlbum * self); +void koto_album_find_album_art(KotoAlbum * self); -void koto_indexed_album_find_tracks( - KotoIndexedAlbum * self, +void koto_album_find_tracks( + KotoAlbum * self, magic_t magic_cookie, const gchar * path ); -gchar * koto_indexed_album_get_album_art(KotoIndexedAlbum * self); +gchar * koto_album_get_album_art(KotoAlbum * self); -gchar * koto_indexed_album_get_album_name(KotoIndexedAlbum * self); +gchar * koto_album_get_album_name(KotoAlbum * self); -gchar * koto_indexed_album_get_album_uuid(KotoIndexedAlbum * self); +gchar * koto_album_get_album_uuid(KotoAlbum * self); -GList * koto_indexed_album_get_tracks(KotoIndexedAlbum * self); +GList * koto_album_get_tracks(KotoAlbum * self); -void koto_indexed_album_remove_file( - KotoIndexedAlbum * self, - KotoIndexedTrack * track +void koto_album_remove_file( + KotoAlbum * self, + KotoTrack * track ); -void koto_indexed_album_set_album_art( - KotoIndexedAlbum * self, +void koto_album_set_album_art( + KotoAlbum * self, const gchar * album_art ); -void koto_indexed_album_set_album_name( - KotoIndexedAlbum * self, +void koto_album_set_album_name( + KotoAlbum * self, const gchar * album_name ); -void koto_indexed_album_set_artist_uuid( - KotoIndexedAlbum * self, +void koto_album_set_artist_uuid( + KotoAlbum * self, const gchar * artist_uuid ); -void koto_indexed_album_set_as_current_playlist(KotoIndexedAlbum * self); +void koto_album_set_as_current_playlist(KotoAlbum * self); -void koto_indexed_album_update_path( - KotoIndexedAlbum * self, +void koto_album_update_path( + KotoAlbum * self, gchar * path ); -gint koto_indexed_album_sort_tracks( +gint koto_album_sort_tracks( gconstpointer track1_uuid, gconstpointer track2_uuid, gpointer user_data @@ -243,57 +243,57 @@ gint koto_indexed_album_sort_tracks( * File / Track Functions **/ -KotoIndexedTrack * koto_indexed_track_new( - KotoIndexedAlbum * album, +KotoTrack * koto_track_new( + KotoAlbum * album, const gchar * path, guint * cd ); -KotoIndexedTrack * koto_indexed_track_new_with_uuid(const gchar * uuid); +KotoTrack * koto_track_new_with_uuid(const gchar * uuid); -void koto_indexed_track_commit(KotoIndexedTrack * self); +void koto_track_commit(KotoTrack * self); -GVariant * koto_indexed_track_get_metadata_vardict(KotoIndexedTrack * self); +GVariant * koto_track_get_metadata_vardict(KotoTrack * self); -gchar * koto_indexed_track_get_uuid(KotoIndexedTrack * self); +gchar * koto_track_get_uuid(KotoTrack * self); -void koto_indexed_track_parse_name(KotoIndexedTrack * self); +void koto_track_parse_name(KotoTrack * self); -void koto_indexed_track_remove_from_playlist( - KotoIndexedTrack * self, +void koto_track_remove_from_playlist( + KotoTrack * self, gchar * playlist_uuid ); -void koto_indexed_track_save_to_playlist( - KotoIndexedTrack * self, +void koto_track_save_to_playlist( + KotoTrack * self, gchar * playlist_uuid, gint current ); -void koto_indexed_track_set_file_name( - KotoIndexedTrack * self, +void koto_track_set_file_name( + KotoTrack * self, gchar * new_file_name ); -void koto_indexed_track_set_cd( - KotoIndexedTrack * self, +void koto_track_set_cd( + KotoTrack * self, guint cd ); -void koto_indexed_track_set_parsed_name( - KotoIndexedTrack * self, +void koto_track_set_parsed_name( + KotoTrack * self, gchar * new_parsed_name ); -void koto_indexed_track_set_position( - KotoIndexedTrack * self, +void koto_track_set_position( + KotoTrack * self, guint pos ); -void koto_indexed_track_update_metadata(KotoIndexedTrack * self); +void koto_track_update_metadata(KotoTrack * self); -void koto_indexed_track_update_path( - KotoIndexedTrack * self, +void koto_track_update_path( + KotoTrack * self, const gchar * new_path ); diff --git a/src/indexer/track.c b/src/indexer/track.c index 9c56c8e..05a64dd 100644 --- a/src/indexer/track.c +++ b/src/indexer/track.c @@ -25,7 +25,7 @@ extern KotoCartographer * koto_maps; extern sqlite3 * koto_db; -struct _KotoIndexedTrack { +struct _KotoTrack { GObject parent_instance; gchar * artist_uuid; gchar * album_uuid; @@ -42,7 +42,7 @@ struct _KotoIndexedTrack { gboolean do_initial_index; }; -G_DEFINE_TYPE(KotoIndexedTrack, koto_indexed_track, G_TYPE_OBJECT); +G_DEFINE_TYPE(KotoTrack, koto_track, G_TYPE_OBJECT); enum { PROP_0, @@ -63,27 +63,27 @@ static GParamSpec * props[N_PROPERTIES] = { NULL }; -static void koto_indexed_track_get_property( +static void koto_track_get_property( GObject * obj, guint prop_id, GValue * val, GParamSpec * spec ); -static void koto_indexed_track_set_property( +static void koto_track_set_property( GObject * obj, guint prop_id, const GValue * val, GParamSpec * spec ); -static void koto_indexed_track_class_init(KotoIndexedTrackClass * c) { +static void koto_track_class_init(KotoTrackClass * c) { GObjectClass * gobject_class; gobject_class = G_OBJECT_CLASS(c); - gobject_class->set_property = koto_indexed_track_set_property; - gobject_class->get_property = koto_indexed_track_get_property; + gobject_class->set_property = koto_track_set_property; + gobject_class->get_property = koto_track_get_property; props[PROP_ARTIST_UUID] = g_param_spec_string( "artist-uuid", @@ -174,17 +174,17 @@ static void koto_indexed_track_class_init(KotoIndexedTrackClass * c) { g_object_class_install_properties(gobject_class, N_PROPERTIES, props); } -static void koto_indexed_track_init(KotoIndexedTrack * self) { +static void koto_track_init(KotoTrack * self) { self->acquired_metadata_from_id3 = FALSE; } -static void koto_indexed_track_get_property( +static void koto_track_get_property( GObject * obj, guint prop_id, GValue * val, GParamSpec * spec ) { - KotoIndexedTrack * self = KOTO_INDEXED_TRACK(obj); + KotoTrack * self = KOTO_TRACK(obj); switch (prop_id) { @@ -221,13 +221,13 @@ static void koto_indexed_track_get_property( } } -static void koto_indexed_track_set_property( +static void koto_track_set_property( GObject * obj, guint prop_id, const GValue * val, GParamSpec * spec ) { - KotoIndexedTrack * self = KOTO_INDEXED_TRACK(obj); + KotoTrack * self = KOTO_TRACK(obj); switch (prop_id) { @@ -247,19 +247,19 @@ static void koto_indexed_track_set_property( self->do_initial_index = g_value_get_boolean(val); break; case PROP_PATH: - koto_indexed_track_update_path(self, g_value_get_string(val)); // Update the path + koto_track_update_path(self, g_value_get_string(val)); // Update the path break; case PROP_FILE_NAME: - koto_indexed_track_set_file_name(self, g_strdup(g_value_get_string(val))); // Update the file name + koto_track_set_file_name(self, g_strdup(g_value_get_string(val))); // Update the file name break; case PROP_PARSED_NAME: - koto_indexed_track_set_parsed_name(self, g_strdup(g_value_get_string(val))); + koto_track_set_parsed_name(self, g_strdup(g_value_get_string(val))); break; case PROP_CD: - koto_indexed_track_set_cd(self, g_value_get_uint(val)); + koto_track_set_cd(self, g_value_get_uint(val)); break; case PROP_POSITION: - koto_indexed_track_set_position(self, g_value_get_uint(val)); + koto_track_set_position(self, g_value_get_uint(val)); break; case PROP_PLAYBACK_POSITION: self->playback_position = GUINT_TO_POINTER(g_value_get_uint(val)); @@ -271,7 +271,7 @@ static void koto_indexed_track_set_property( } -void koto_indexed_track_commit(KotoIndexedTrack * self) { +void koto_track_commit(KotoTrack * self) { if ((self->artist_uuid == NULL) || (strcmp(self->artist_uuid, "") == 0)) { // No valid required artist UUID return; } @@ -306,8 +306,8 @@ void koto_indexed_track_commit(KotoIndexedTrack * self) { g_free(commit_op_errmsg); } -GVariant * koto_indexed_track_get_metadata_vardict(KotoIndexedTrack * self) { - if (!KOTO_IS_INDEXED_TRACK(self)) { +GVariant * koto_track_get_metadata_vardict(KotoTrack * self) { + if (!KOTO_IS_TRACK(self)) { return NULL; } @@ -317,8 +317,8 @@ GVariant * koto_indexed_track_get_metadata_vardict(KotoIndexedTrack * self) { gchar * album_name = NULL; gchar * artist_name = NULL; - KotoIndexedArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, self->artist_uuid); - KotoIndexedAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, self->album_uuid); + KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, self->artist_uuid); + KotoAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, self->album_uuid); g_object_get(album, "art-path", &album_art_path, "name", &album_name, NULL); @@ -356,18 +356,18 @@ GVariant * koto_indexed_track_get_metadata_vardict(KotoIndexedTrack * self) { return metadata_ret; } -gchar * koto_indexed_track_get_uuid(KotoIndexedTrack * self) { - if (!KOTO_IS_INDEXED_TRACK(self)) { +gchar * koto_track_get_uuid(KotoTrack * self) { + if (!KOTO_IS_TRACK(self)) { return NULL; } return self->uuid; // Do not return a duplicate since otherwise comparison refs fail due to pointer positions being different } -void koto_indexed_track_parse_name(KotoIndexedTrack * self) { +void koto_track_parse_name(KotoTrack * self) { gchar * copied_file_name = g_strdelimit(g_strdup(self->file_name), "_", ' '); // Replace _ with whitespace for starters - KotoIndexedArtist * artist = NULL; + KotoArtist * artist = NULL; artist = koto_cartographer_get_artist_by_uuid(koto_maps, self->artist_uuid); @@ -402,12 +402,12 @@ void koto_indexed_track_parse_name(KotoIndexedTrack * self) { file_without_ext = g_strdup(split[2]); // Set to our second item which is the rest of the song name without the prefixed numbers if ((strcmp(num, "0") == 0) || (strcmp(num, "00") == 0)) { // Is exactly zero - koto_indexed_track_set_position(self, 0); // Set position to 0 + koto_track_set_position(self, 0); // Set position to 0 } else { // Either starts with 0 (like 09) or doesn't start with it at all guint64 potential_pos = g_ascii_strtoull(num, NULL, 10); // Attempt to convert if (potential_pos != 0) { // Got a legitimate position - koto_indexed_track_set_position(self, potential_pos); + koto_track_set_position(self, potential_pos); } } } @@ -422,15 +422,15 @@ void koto_indexed_track_parse_name(KotoIndexedTrack * self) { file_without_ext = g_strjoinv("", split); // Remove entirely g_strfreev(split); - koto_indexed_track_set_parsed_name(self, file_without_ext); + koto_track_set_parsed_name(self, file_without_ext); g_free(file_without_ext); } -void koto_indexed_track_remove_from_playlist( - KotoIndexedTrack * self, +void koto_track_remove_from_playlist( + KotoTrack * self, gchar * playlist_uuid ) { - if (!KOTO_IS_INDEXED_TRACK(self)) { + if (!KOTO_IS_TRACK(self)) { return; } @@ -452,12 +452,12 @@ void koto_indexed_track_remove_from_playlist( g_free(commit_op_errmsg); } -void koto_indexed_track_save_to_playlist( - KotoIndexedTrack * self, +void koto_track_save_to_playlist( + KotoTrack * self, gchar * playlist_uuid, gint current ) { - if (!KOTO_IS_INDEXED_TRACK(self)) { + if (!KOTO_IS_TRACK(self)) { return; } @@ -481,8 +481,8 @@ void koto_indexed_track_save_to_playlist( g_free(commit_op_errmsg); } -void koto_indexed_track_set_file_name( - KotoIndexedTrack * self, +void koto_track_set_file_name( + KotoTrack * self, gchar * new_file_name ) { if (new_file_name == NULL) { @@ -501,12 +501,12 @@ void koto_indexed_track_set_file_name( g_object_notify_by_pspec(G_OBJECT(self), props[PROP_FILE_NAME]); if (!self->acquired_metadata_from_id3 && self->do_initial_index) { // Haven't acquired our information from ID3 - koto_indexed_track_parse_name(self); // Update our parsed name + koto_track_parse_name(self); // Update our parsed name } } -void koto_indexed_track_set_cd( - KotoIndexedTrack * self, +void koto_track_set_cd( + KotoTrack * self, guint cd ) { if (cd == 0) { // No change really @@ -517,8 +517,8 @@ void koto_indexed_track_set_cd( g_object_notify_by_pspec(G_OBJECT(self), props[PROP_CD]); } -void koto_indexed_track_set_parsed_name( - KotoIndexedTrack * self, +void koto_track_set_parsed_name( + KotoTrack * self, gchar * new_parsed_name ) { if (new_parsed_name == NULL) { @@ -537,8 +537,8 @@ void koto_indexed_track_set_parsed_name( g_object_notify_by_pspec(G_OBJECT(self), props[PROP_PARSED_NAME]); } -void koto_indexed_track_set_position( - KotoIndexedTrack * self, +void koto_track_set_position( + KotoTrack * self, guint pos ) { if (pos == 0) { // No position change really @@ -549,26 +549,26 @@ void koto_indexed_track_set_position( g_object_notify_by_pspec(G_OBJECT(self), props[PROP_POSITION]); } -void koto_indexed_track_update_metadata(KotoIndexedTrack * self) { +void koto_track_update_metadata(KotoTrack * self) { TagLib_File * t_file = taglib_file_new(self->path); // Get a taglib file for this file if ((t_file != NULL) && taglib_file_is_valid(t_file)) { // If we got the taglib file and it is valid self->acquired_metadata_from_id3 = TRUE; TagLib_Tag * tag = taglib_file_tag(t_file); // Get our tag - koto_indexed_track_set_parsed_name(self, taglib_tag_title(tag)); // Set the title of the file - koto_indexed_track_set_position(self, (uint) taglib_tag_track(tag)); // Get the track, convert to uint and cast as a pointer - koto_indexed_track_set_file_name(self, g_path_get_basename(self->path)); // Update our file name + koto_track_set_parsed_name(self, taglib_tag_title(tag)); // Set the title of the file + koto_track_set_position(self, (uint) taglib_tag_track(tag)); // Get the track, convert to uint and cast as a pointer + koto_track_set_file_name(self, g_path_get_basename(self->path)); // Update our file name } else { - koto_indexed_track_set_file_name(self, g_path_get_basename(self->path)); // Update our file name + koto_track_set_file_name(self, g_path_get_basename(self->path)); // Update our file name } taglib_tag_free_strings(); // Free strings taglib_file_free(t_file); // Free the file } -void koto_indexed_track_update_path( - KotoIndexedTrack * self, +void koto_track_update_path( + KotoTrack * self, const gchar * new_path ) { if (new_path == NULL) { @@ -582,14 +582,14 @@ void koto_indexed_track_update_path( self->path = g_strdup(new_path); // Duplicate the path and set it if (self->do_initial_index) { - koto_indexed_track_update_metadata(self); // Attempt to get ID3 info + koto_track_update_metadata(self); // Attempt to get ID3 info } g_object_notify_by_pspec(G_OBJECT(self), props[PROP_PATH]); } -KotoIndexedTrack * koto_indexed_track_new( - KotoIndexedAlbum * album, +KotoTrack * koto_track_new( + KotoAlbum * album, const gchar * path, guint * cd ) { @@ -599,8 +599,8 @@ KotoIndexedTrack * koto_indexed_track_new( g_object_get(album, "artist-uuid", &artist_uuid, "uuid", &album_uuid, NULL); // Get the artist and album uuids from our Album - KotoIndexedTrack * track = g_object_new( - KOTO_TYPE_INDEXED_TRACK, + KotoTrack * track = g_object_new( + KOTO_TYPE_TRACK, "artist-uuid", artist_uuid, "album-uuid", @@ -617,13 +617,13 @@ KotoIndexedTrack * koto_indexed_track_new( ); - koto_indexed_track_commit(track); // Immediately commit to the database + koto_track_commit(track); // Immediately commit to the database return track; } -KotoIndexedTrack * koto_indexed_track_new_with_uuid(const gchar * uuid) { +KotoTrack * koto_track_new_with_uuid(const gchar * uuid) { return g_object_new( - KOTO_TYPE_INDEXED_TRACK, + KOTO_TYPE_TRACK, "uuid", g_strdup(uuid), NULL diff --git a/src/koto-playerbar.c b/src/koto-playerbar.c index 583c660..580f1d9 100644 --- a/src/koto-playerbar.c +++ b/src/koto-playerbar.c @@ -598,10 +598,10 @@ void koto_playerbar_update_track_info( return; } - KotoIndexedTrack * current_track = koto_playback_engine_get_current_track(playback_engine); // Get the current track from the playback engine + KotoTrack * current_track = koto_playback_engine_get_current_track(playback_engine); // Get the current track from the playback engine - if (!KOTO_IS_INDEXED_TRACK(current_track)) { + if (!KOTO_IS_TRACK(current_track)) { return; } @@ -612,8 +612,8 @@ void koto_playerbar_update_track_info( g_object_get(current_track, "parsed-name", &track_name, "artist-uuid", &artist_uuid, "album-uuid", &album_uuid, NULL); - KotoIndexedArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid); - KotoIndexedAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, album_uuid); + KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid); + KotoAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, album_uuid); g_free(artist_uuid); @@ -623,7 +623,7 @@ void koto_playerbar_update_track_info( gtk_label_set_text(GTK_LABEL(bar->playback_title), track_name); // Set the label } - if (KOTO_IS_INDEXED_ARTIST(artist)) { + if (KOTO_IS_ARTIST(artist)) { gchar * artist_name = NULL; g_object_get(artist, "name", &artist_name, NULL); @@ -635,7 +635,7 @@ void koto_playerbar_update_track_info( } } - if (KOTO_IS_INDEXED_ALBUM(album)) { + if (KOTO_IS_ALBUM(album)) { gchar * album_name = NULL; gchar * art_path = NULL; g_object_get(album, "name", &album_name, "art-path", &art_path, NULL); // Get album name and art path diff --git a/src/koto-track-item.c b/src/koto-track-item.c index 96b7bf4..d9106f1 100644 --- a/src/koto-track-item.c +++ b/src/koto-track-item.c @@ -25,7 +25,7 @@ extern KotoAddRemoveTrackPopover * koto_add_remove_track_popup; struct _KotoTrackItem { GtkBox parent_instance; - KotoIndexedTrack * track; + KotoTrack * track; GtkWidget * track_label; }; @@ -72,7 +72,7 @@ static void koto_track_item_class_init(KotoTrackItemClass * c) { "track", "Track", "Track", - KOTO_TYPE_INDEXED_TRACK, + KOTO_TYPE_TRACK, G_PARAM_CONSTRUCT | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_READWRITE ); @@ -109,7 +109,7 @@ static void koto_track_item_set_property( switch (prop_id) { case PROP_TRACK: - koto_track_item_set_track(self, (KotoIndexedTrack*) g_value_get_object(val)); + koto_track_item_set_track(self, (KotoTrack*) g_value_get_object(val)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec); @@ -128,13 +128,13 @@ static void koto_track_item_init(KotoTrackItem * self) { gtk_box_prepend(GTK_BOX(self), self->track_label); } -KotoIndexedTrack * koto_track_item_get_track(KotoTrackItem * self) { +KotoTrack * koto_track_item_get_track(KotoTrackItem * self) { return self->track; } void koto_track_item_set_track( KotoTrackItem * self, - KotoIndexedTrack * track + KotoTrack * track ) { if (track == NULL) { // Not a track return; @@ -148,7 +148,7 @@ void koto_track_item_set_track( gtk_label_set_text(GTK_LABEL(self->track_label), track_name); // Update the text } -KotoTrackItem * koto_track_item_new(KotoIndexedTrack * track) { +KotoTrackItem * koto_track_item_new(KotoTrack * track) { return g_object_new( KOTO_TYPE_TRACK_ITEM, "track", diff --git a/src/koto-track-item.h b/src/koto-track-item.h index 2152116..757e307 100644 --- a/src/koto-track-item.h +++ b/src/koto-track-item.h @@ -27,7 +27,7 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(KotoTrackItem, koto_track_item, KOTO, TRACK_ITEM, GtkBox) -KotoTrackItem* koto_track_item_new(KotoIndexedTrack * track); +KotoTrackItem* koto_track_item_new(KotoTrack * track); void koto_track_item_handle_add_to_playlist_button_click( GtkGestureClick * gesture, int n_press, @@ -36,11 +36,11 @@ void koto_track_item_handle_add_to_playlist_button_click( gpointer user_data ); -KotoIndexedTrack * koto_track_item_get_track(KotoTrackItem * self); +KotoTrack * koto_track_item_get_track(KotoTrackItem * self); void koto_track_item_set_track( KotoTrackItem * self, - KotoIndexedTrack * track + KotoTrack * track ); G_END_DECLS diff --git a/src/koto-window.c b/src/koto-window.c index 9c5ccf6..7a5b703 100644 --- a/src/koto-window.c +++ b/src/koto-window.c @@ -41,7 +41,7 @@ extern KotoPlaybackEngine * playback_engine; struct _KotoWindow { GtkApplicationWindow parent_instance; - KotoIndexedLibrary * library; + KotoLibrary * library; KotoCurrentPlaylist * current_playlist; KotoDialogContainer * dialogs; @@ -222,7 +222,7 @@ void create_new_headerbar(KotoWindow * self) { } void load_library(KotoWindow * self) { - KotoIndexedLibrary * lib = koto_indexed_library_new(g_get_user_special_dir(G_USER_DIRECTORY_MUSIC)); + KotoLibrary * lib = koto_library_new(g_get_user_special_dir(G_USER_DIRECTORY_MUSIC)); if (lib != NULL) { diff --git a/src/pages/music/album-view.c b/src/pages/music/album-view.c index 40b95fa..bcd17e1 100644 --- a/src/pages/music/album-view.c +++ b/src/pages/music/album-view.c @@ -29,7 +29,7 @@ extern KotoCartographer * koto_maps; struct _KotoAlbumView { GObject parent_instance; - KotoIndexedAlbum * album; + KotoAlbum * album; GtkWidget * main; GtkWidget * album_tracks_box; GtkWidget * discs; @@ -81,7 +81,7 @@ static void koto_album_view_class_init(KotoAlbumViewClass * c) { "album", "Album", "Album", - KOTO_TYPE_INDEXED_ALBUM, + KOTO_TYPE_ALBUM, G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_READWRITE ); @@ -172,7 +172,7 @@ static void koto_album_view_set_property( switch (prop_id) { case PROP_ALBUM: - koto_album_view_set_album(self, (KotoIndexedAlbum*) g_value_get_object(val)); + koto_album_view_set_album(self, (KotoAlbum*) g_value_get_object(val)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec); @@ -181,8 +181,8 @@ static void koto_album_view_set_property( } void koto_album_view_add_track_to_listbox( - KotoIndexedAlbum * self, - KotoIndexedTrack * track + KotoAlbum * self, + KotoTrack * track ) { (void) self; (void) track; @@ -201,7 +201,7 @@ void koto_album_view_hide_overlay_controls( void koto_album_view_set_album( KotoAlbumView * self, - KotoIndexedAlbum * album + KotoAlbum * album ) { if (album == NULL) { return; @@ -209,7 +209,7 @@ void koto_album_view_set_album( self->album = album; - gchar * album_art = koto_indexed_album_get_album_art(self->album); // Get the art for the album + gchar * album_art = koto_album_get_album_art(self->album); // Get the art for the album gtk_image_set_from_file(GTK_IMAGE(self->album_overlay_art), album_art); @@ -224,11 +224,11 @@ void koto_album_view_set_album( gtk_box_prepend(GTK_BOX(self->album_tracks_box), self->album_label); // Prepend our new label to the album + tracks box GHashTable * discs = g_hash_table_new(g_str_hash, g_str_equal); - GList * tracks = koto_indexed_album_get_tracks(album); // Get the tracks for this album + GList * tracks = koto_album_get_tracks(album); // Get the tracks for this album for (guint i = 0; i < g_list_length(tracks); i++) { - KotoIndexedTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) g_list_nth_data(tracks, i)); // Get the track by its UUID + KotoTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) g_list_nth_data(tracks, i)); // Get the track by its UUID if (track == NULL) { // Track doesn't exist continue; @@ -309,9 +309,9 @@ void koto_album_view_toggle_album_playback( koto_button_show_image(KOTO_BUTTON(self->play_pause_button), TRUE); - koto_indexed_album_set_as_current_playlist(self->album); // Set as the current playlist + koto_album_set_as_current_playlist(self->album); // Set as the current playlist } -KotoAlbumView * koto_album_view_new(KotoIndexedAlbum * album) { +KotoAlbumView * koto_album_view_new(KotoAlbum * album) { return g_object_new(KOTO_TYPE_ALBUM_VIEW, "album", album, NULL); } diff --git a/src/pages/music/album-view.h b/src/pages/music/album-view.h index 72c8c41..0d8610f 100644 --- a/src/pages/music/album-view.h +++ b/src/pages/music/album-view.h @@ -27,12 +27,12 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(KotoAlbumView, koto_album_view, KOTO, ALBUM_VIEW, GObject) -KotoAlbumView* koto_album_view_new(KotoIndexedAlbum * album); +KotoAlbumView* koto_album_view_new(KotoAlbum * album); GtkWidget * koto_album_view_get_main(KotoAlbumView * self); void koto_album_view_add_track_to_listbox( - KotoIndexedAlbum * self, - KotoIndexedTrack * track + KotoAlbum * self, + KotoTrack * track ); void koto_album_view_hide_overlay_controls( @@ -42,7 +42,7 @@ void koto_album_view_hide_overlay_controls( void koto_album_view_set_album( KotoAlbumView * self, - KotoIndexedAlbum * album + KotoAlbum * album ); void koto_album_view_show_overlay_controls( diff --git a/src/pages/music/artist-view.c b/src/pages/music/artist-view.c index a424dcf..b693bb4 100644 --- a/src/pages/music/artist-view.c +++ b/src/pages/music/artist-view.c @@ -28,7 +28,7 @@ extern KotoCartographer * koto_maps; struct _KotoArtistView { GObject parent_instance; - KotoIndexedArtist * artist; + KotoArtist * artist; GtkWidget * scrolled_window; GtkWidget * content; GtkWidget * favorites_list; @@ -79,7 +79,7 @@ static void koto_artist_view_class_init(KotoArtistViewClass * c) { "artist", "Artist", "Artist", - KOTO_TYPE_INDEXED_ARTIST, + KOTO_TYPE_ARTIST, G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_READWRITE ); @@ -116,7 +116,7 @@ static void koto_artist_view_set_property( switch (prop_id) { case PROP_ARTIST: - koto_artist_view_add_artist(self, (KotoIndexedArtist*) g_value_get_object(val)); + koto_artist_view_add_artist(self, (KotoArtist*) g_value_get_object(val)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec); @@ -168,9 +168,9 @@ static void koto_artist_view_constructed(GObject * obj) { void koto_artist_view_add_album( KotoArtistView * self, - KotoIndexedAlbum * album + KotoAlbum * album ) { - gchar * album_art = koto_indexed_album_get_album_art(album); // Get the art for the album + gchar * album_art = koto_album_get_album_art(album); // Get the art for the album GtkWidget * art_image = koto_utils_create_image_from_filepath(album_art, "audio-x-generic-symbolic", 220, 220); @@ -187,7 +187,7 @@ void koto_artist_view_add_album( void koto_artist_view_add_artist( KotoArtistView * self, - KotoIndexedArtist * artist + KotoArtist * artist ) { if (artist == NULL) { return; @@ -199,13 +199,13 @@ void koto_artist_view_add_artist( return; } - GList * albums = koto_indexed_artist_get_albums(self->artist); // Get the albums + GList * albums = koto_artist_get_albums(self->artist); // Get the albums GList * a; for (a = albums; a != NULL; a = a->next) { - KotoIndexedAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, (gchar*) a->data); + KotoAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, (gchar*) a->data); if (album != NULL) { koto_artist_view_add_album(self, album); // Add the album diff --git a/src/pages/music/artist-view.h b/src/pages/music/artist-view.h index 820351d..3601a32 100644 --- a/src/pages/music/artist-view.h +++ b/src/pages/music/artist-view.h @@ -30,12 +30,12 @@ G_DECLARE_FINAL_TYPE(KotoArtistView, koto_artist_view, KOTO, ARTIST_VIEW, GObjec KotoArtistView* koto_artist_view_new(); void koto_artist_view_add_album( KotoArtistView * self, - KotoIndexedAlbum * album + KotoAlbum * album ); void koto_artist_view_add_artist( KotoArtistView * self, - KotoIndexedArtist * artist + KotoArtist * artist ); GtkWidget * koto_artist_view_get_main(KotoArtistView * self); diff --git a/src/pages/music/disc-view.c b/src/pages/music/disc-view.c index eb9dcba..96c8486 100644 --- a/src/pages/music/disc-view.c +++ b/src/pages/music/disc-view.c @@ -28,7 +28,7 @@ extern KotoCartographer * koto_maps; struct _KotoDiscView { GtkBox parent_instance; - KotoIndexedAlbum * album; + KotoAlbum * album; GtkWidget * header; GtkWidget * label; GtkWidget * list; @@ -84,7 +84,7 @@ static void koto_disc_view_class_init(KotoDiscViewClass * c) { "album", "Album", "Album", - KOTO_TYPE_INDEXED_ALBUM, + KOTO_TYPE_ALBUM, G_PARAM_CONSTRUCT | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_READWRITE ); @@ -127,7 +127,7 @@ static void koto_disc_view_set_property( koto_disc_view_set_disc_number(self, g_value_get_uint(val)); break; case PROP_ALBUM: - koto_disc_view_set_album(self, (KotoIndexedAlbum*) g_value_get_object(val)); + koto_disc_view_set_album(self, (KotoAlbum*) g_value_get_object(val)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec); @@ -171,7 +171,7 @@ void koto_disc_view_list_tracks( gpointer selfptr ) { KotoDiscView * self = (KotoDiscView*) selfptr; - KotoIndexedTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) data); // Get the track by its UUID + KotoTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) data); // Get the track by its UUID guint * disc_number; @@ -194,7 +194,7 @@ void koto_disc_view_handle_selected_rows_changed( ) { KotoDiscView * self = user_data; - gchar * album_uuid = koto_indexed_album_get_album_uuid(self->album); // Get the UUID + gchar * album_uuid = koto_album_get_album_uuid(self->album); // Get the UUID if (!koto_utils_is_string_valid(album_uuid)) { // Not set @@ -209,13 +209,13 @@ void koto_disc_view_handle_selected_rows_changed( return; } - GList * selected_tracks = NULL; // Create our list of KotoIndexedTracks + GList * selected_tracks = NULL; // Create our list of KotoTracks GList * cur_selected_rows; for (cur_selected_rows = selected_rows; cur_selected_rows != NULL; cur_selected_rows = cur_selected_rows->next) { // Iterate over the rows KotoTrackItem * track_item = (KotoTrackItem*) gtk_list_box_row_get_child(cur_selected_rows->data); - selected_tracks = g_list_append(selected_tracks, koto_track_item_get_track(track_item)); // Add the KotoIndexedTrack to our list + selected_tracks = g_list_append(selected_tracks, koto_track_item_get_track(track_item)); // Add the KotoTrack to our list } g_list_free(cur_selected_rows); @@ -226,7 +226,7 @@ void koto_disc_view_handle_selected_rows_changed( void koto_disc_view_set_album( KotoDiscView * self, - KotoIndexedAlbum * album + KotoAlbum * album ) { if (album == NULL) { return; @@ -238,7 +238,7 @@ void koto_disc_view_set_album( self->album = album; - g_list_foreach(koto_indexed_album_get_tracks(self->album), koto_disc_view_list_tracks, self); + g_list_foreach(koto_album_get_tracks(self->album), koto_disc_view_list_tracks, self); } void koto_disc_view_set_disc_number( @@ -267,7 +267,7 @@ void koto_disc_view_set_disc_label_visible( } KotoDiscView * koto_disc_view_new( - KotoIndexedAlbum * album, + KotoAlbum * album, guint * disc_number ) { return g_object_new( diff --git a/src/pages/music/disc-view.h b/src/pages/music/disc-view.h index c7e4209..31462b5 100644 --- a/src/pages/music/disc-view.h +++ b/src/pages/music/disc-view.h @@ -27,7 +27,7 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(KotoDiscView, koto_disc_view, KOTO, DISC_VIEW, GtkBox) -KotoDiscView* koto_disc_view_new(KotoIndexedAlbum * album, guint * disc); +KotoDiscView* koto_disc_view_new(KotoAlbum * album, guint * disc); void koto_disc_view_handle_selected_rows_changed( GtkListBox * box, gpointer user_data @@ -40,7 +40,7 @@ void koto_disc_view_list_tracks( void koto_disc_view_set_album( KotoDiscView * self, - KotoIndexedAlbum * album + KotoAlbum * album ); void koto_disc_view_set_disc_label_visible( diff --git a/src/pages/music/music-local.c b/src/pages/music/music-local.c index 9763769..e732c46 100644 --- a/src/pages/music/music-local.c +++ b/src/pages/music/music-local.c @@ -42,7 +42,7 @@ struct _KotoPageMusicLocal { GtkWidget * artist_list; GtkWidget * stack; - KotoIndexedLibrary * lib; + KotoLibrary * lib; gboolean constructed; }; @@ -83,7 +83,7 @@ static void koto_page_music_local_class_init(KotoPageMusicLocalClass * c) { "lib", "Library", "Library", - KOTO_TYPE_INDEXED_LIBRARY, + KOTO_TYPE_LIBRARY, G_PARAM_CONSTRUCT | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_READWRITE ); @@ -120,7 +120,7 @@ static void koto_page_music_local_set_property( switch (prop_id) { case PROP_LIB: - koto_page_music_local_set_library(self, (KotoIndexedLibrary*) g_value_get_object(val)); + koto_page_music_local_set_library(self, (KotoLibrary*) g_value_get_object(val)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec); @@ -168,7 +168,7 @@ static void koto_page_music_local_constructed(GObject * obj) { void koto_page_music_local_add_artist( KotoPageMusicLocal * self, - KotoIndexedArtist * artist + KotoArtist * artist ) { gchar * artist_name; @@ -197,10 +197,10 @@ void koto_page_music_local_go_to_artist_by_uuid( KotoPageMusicLocal * self, gchar * artist_uuid ) { - KotoIndexedArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid); // Get the artist + KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid); // Get the artist - if (!KOTO_IS_INDEXED_ARTIST(artist)) { // No artist for this UUID + if (!KOTO_IS_ARTIST(artist)) { // No artist for this UUID return; } @@ -239,7 +239,7 @@ void koto_page_music_local_handle_artist_click( void koto_page_music_local_set_library( KotoPageMusicLocal * self, - KotoIndexedLibrary * lib + KotoLibrary * lib ) { if (lib == NULL) { return; @@ -259,12 +259,12 @@ void koto_page_music_local_set_library( gpointer artist_key; gpointer artist_data; - GHashTable * artists = koto_indexed_library_get_artists(self->lib); // Get the artists + GHashTable * artists = koto_library_get_artists(self->lib); // Get the artists g_hash_table_iter_init(&artist_list_iter, artists); while (g_hash_table_iter_next(&artist_list_iter, &artist_key, &artist_data)) { // For each of the music artists - KotoIndexedArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, (gchar*) artist_data); // Cast our data as a KotoIndexedArtist + KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, (gchar*) artist_data); // Cast our data as a KotoArtist if (artist != NULL) { koto_page_music_local_add_artist(self, artist); diff --git a/src/pages/music/music-local.h b/src/pages/music/music-local.h index 11a5ae3..34378be 100644 --- a/src/pages/music/music-local.h +++ b/src/pages/music/music-local.h @@ -31,7 +31,7 @@ G_DECLARE_FINAL_TYPE(KotoPageMusicLocal, koto_page_music_local, KOTO, PAGE_MUSIC KotoPageMusicLocal* koto_page_music_local_new(); void koto_page_music_local_add_artist( KotoPageMusicLocal * self, - KotoIndexedArtist * artist + KotoArtist * artist ); void koto_page_music_local_handle_artist_click( @@ -52,7 +52,7 @@ void koto_page_music_local_go_to_artist_by_uuid( void koto_page_music_local_set_library( KotoPageMusicLocal * self, - KotoIndexedLibrary * lib + KotoLibrary * lib ); int koto_page_music_local_sort_artists( diff --git a/src/pages/playlist/list.c b/src/pages/playlist/list.c index 1e59af4..76b7360 100644 --- a/src/pages/playlist/list.c +++ b/src/pages/playlist/list.c @@ -245,10 +245,10 @@ void koto_playlist_page_bind_track_item( GtkWidget * track_album_label = gtk_widget_get_next_sibling(track_name_label); GtkWidget * track_artist_label = gtk_widget_get_next_sibling(track_album_label); - KotoIndexedTrack * track = gtk_list_item_get_item(item); // Get the track UUID from our model + KotoTrack * track = gtk_list_item_get_item(item); // Get the track UUID from our model - if (!KOTO_IS_INDEXED_TRACK(track)) { + if (!KOTO_IS_TRACK(track)) { return; } @@ -274,18 +274,18 @@ void koto_playlist_page_bind_track_item( gtk_label_set_label(GTK_LABEL(track_position_label), g_strdup_printf("%u", track_position)); // Set the track position gtk_label_set_label(GTK_LABEL(track_name_label), track_name); // Set our track name - KotoIndexedAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, album_uuid); + KotoAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, album_uuid); - if (KOTO_IS_INDEXED_ALBUM(album)) { - gtk_label_set_label(GTK_LABEL(track_album_label), koto_indexed_album_get_album_name(album)); // Get the name of the album and set it to the label + if (KOTO_IS_ALBUM(album)) { + gtk_label_set_label(GTK_LABEL(track_album_label), koto_album_get_album_name(album)); // Get the name of the album and set it to the label } - KotoIndexedArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid); + KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid); - if (KOTO_IS_INDEXED_ARTIST(artist)) { - gtk_label_set_label(GTK_LABEL(track_artist_label), koto_indexed_artist_get_name(artist)); // Get the name of the artist and set it to the label + if (KOTO_IS_ARTIST(artist)) { + gtk_label_set_label(GTK_LABEL(track_artist_label), koto_artist_get_name(artist)); // Get the name of the artist and set it to the label } } @@ -532,7 +532,7 @@ void koto_playlist_page_handle_tracks_selected( for (cur_pos_list = selected_tracks_pos; cur_pos_list != NULL; cur_pos_list = cur_pos_list->next) { // Iterate over every position that we accumulated - KotoIndexedTrack * selected_track = g_list_model_get_item(self->model, GPOINTER_TO_UINT(cur_pos_list->data)); // Get the KotoIndexedTrack in the GListModel for this current position + KotoTrack * selected_track = g_list_model_get_item(self->model, GPOINTER_TO_UINT(cur_pos_list->data)); // Get the KotoTrack in the GListModel for this current position selected_tracks = g_list_append(selected_tracks, selected_track); // Add to selected tracks } diff --git a/src/playback/engine.c b/src/playback/engine.c index 8ec2173..cefda87 100644 --- a/src/playback/engine.c +++ b/src/playback/engine.c @@ -57,7 +57,7 @@ struct _KotoPlaybackEngine { GstQuery * duration_query; GstQuery * position_query; - KotoIndexedTrack * current_track; + KotoTrack * current_track; gboolean is_muted; gboolean is_repeat_enabled; @@ -271,7 +271,7 @@ void koto_playback_engine_forwards(KotoPlaybackEngine * self) { } } -KotoIndexedTrack * koto_playback_engine_get_current_track(KotoPlaybackEngine * self) { +KotoTrack * koto_playback_engine_get_current_track(KotoPlaybackEngine * self) { return self->current_track; } @@ -436,10 +436,10 @@ void koto_playback_engine_set_track_by_uuid( return; } - KotoIndexedTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, track_uuid); // Get the track from cartographer + KotoTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, track_uuid); // Get the track from cartographer - if (!KOTO_IS_INDEXED_TRACK(track)) { // Not a track + if (!KOTO_IS_TRACK(track)) { // Not a track return; } @@ -464,7 +464,7 @@ void koto_playback_engine_set_track_by_uuid( koto_playback_engine_set_position(self, 0); koto_playback_engine_set_volume(self, self->volume); // Re-enforce our volume on the updated playbin - GVariant * metadata = koto_indexed_track_get_metadata_vardict(track); // Get the GVariantBuilder variable dict for the metadata + GVariant * metadata = koto_track_get_metadata_vardict(track); // Get the GVariantBuilder variable dict for the metadata GVariantDict * metadata_dict = g_variant_dict_new(metadata); diff --git a/src/playback/engine.h b/src/playback/engine.h index 1465760..4f99c3b 100644 --- a/src/playback/engine.h +++ b/src/playback/engine.h @@ -49,7 +49,7 @@ void koto_playback_engine_current_playlist_changed(); void koto_playback_engine_forwards(KotoPlaybackEngine * self); -KotoIndexedTrack * koto_playback_engine_get_current_track(KotoPlaybackEngine * self); +KotoTrack * koto_playback_engine_get_current_track(KotoPlaybackEngine * self); gint64 koto_playback_engine_get_duration(KotoPlaybackEngine * self); diff --git a/src/playback/mpris.c b/src/playback/mpris.c index f208afb..21c1a09 100644 --- a/src/playback/mpris.c +++ b/src/playback/mpris.c @@ -212,10 +212,10 @@ GVariant * handle_get_property( } if (g_strcmp0(property_name, "Metadata") == 0) { // Metadata - KotoIndexedTrack * current_track = koto_playback_engine_get_current_track(playback_engine); + KotoTrack * current_track = koto_playback_engine_get_current_track(playback_engine); - if (KOTO_IS_INDEXED_TRACK(current_track)) { // Currently playing a track - ret = koto_indexed_track_get_metadata_vardict(current_track); + if (KOTO_IS_TRACK(current_track)) { // Currently playing a track + ret = koto_track_get_metadata_vardict(current_track); } else { // No track GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE_VARDICT); // Create an empty builder ret = g_variant_builder_end(builder); // return the vardict @@ -226,8 +226,8 @@ GVariant * handle_get_property( (g_strcmp0(property_name, "CanPlay") == 0) || (g_strcmp0(property_name, "CanPause") == 0) ) { - KotoIndexedTrack * current_track = koto_playback_engine_get_current_track(playback_engine); - ret = g_variant_new_boolean(KOTO_IS_INDEXED_TRACK(current_track)); + KotoTrack * current_track = koto_playback_engine_get_current_track(playback_engine); + ret = g_variant_new_boolean(KOTO_IS_TRACK(current_track)); } if (g_strcmp0(property_name, "CanSeek") == 0) { // Can control position over mpris @@ -316,22 +316,22 @@ void koto_update_mpris_playback_state(GstState state) { ); } -void koto_update_mpris_info_for_track(KotoIndexedTrack * track) { - if (!KOTO_IS_INDEXED_TRACK(track)) { +void koto_update_mpris_info_for_track(KotoTrack * track) { + if (!KOTO_IS_TRACK(track)) { return; } - GVariant * metadata = koto_indexed_track_get_metadata_vardict(track); // Get the GVariantBuilder variable dict for the metadata + GVariant * metadata = koto_track_get_metadata_vardict(track); // Get the GVariantBuilder variable dict for the metadata koto_update_mpris_info_for_track_with_metadata(track, metadata); } void koto_update_mpris_info_for_track_with_metadata( - KotoIndexedTrack * track, + KotoTrack * track, GVariant * metadata ) { - if (!KOTO_IS_INDEXED_TRACK(track)) { + if (!KOTO_IS_TRACK(track)) { return; } diff --git a/src/playback/mpris.h b/src/playback/mpris.h index 78e9fa6..6662a7b 100644 --- a/src/playback/mpris.h +++ b/src/playback/mpris.h @@ -23,10 +23,10 @@ void koto_update_mpris_playback_state(GstState state); -void koto_update_mpris_info_for_track(KotoIndexedTrack * track); +void koto_update_mpris_info_for_track(KotoTrack * track); void koto_update_mpris_info_for_track_with_metadata( - KotoIndexedTrack * track, + KotoTrack * track, GVariant * metadata ); diff --git a/src/playlist/add-remove-track-popover.c b/src/playlist/add-remove-track-popover.c index 14cc7ed..1c3c4c8 100644 --- a/src/playlist/add-remove-track-popover.c +++ b/src/playlist/add-remove-track-popover.c @@ -150,14 +150,14 @@ void koto_add_remove_track_popover_handle_checkbutton_toggle( GList * pos; - for (pos = self->tracks; pos != NULL; pos = pos->next) { // Iterate over our KotoIndexedTracks - KotoIndexedTrack * track = pos->data; + for (pos = self->tracks; pos != NULL; pos = pos->next) { // Iterate over our KotoTracks + KotoTrack * track = pos->data; - if (!KOTO_INDEXED_TRACK(track)) { // Not a track + if (!KOTO_TRACK(track)) { // Not a track continue; // Skip this } - gchar * track_uuid = koto_indexed_track_get_uuid(track); // Get the track + gchar * track_uuid = koto_track_get_uuid(track); // Get the track if (should_add) { // Should be adding koto_playlist_add_track_by_uuid(playlist, track_uuid, FALSE, TRUE); // Add the track to the playlist @@ -263,9 +263,9 @@ void koto_add_remove_track_popover_set_tracks( } } } else { - KotoIndexedTrack * track = g_list_nth_data(self->tracks, 0); // Get the first track + KotoTrack * track = g_list_nth_data(self->tracks, 0); // Get the first track - if (KOTO_IS_INDEXED_TRACK(track)) { + if (KOTO_IS_TRACK(track)) { gint pos = koto_playlist_get_position_of_track(playlist, track); should_be_checked = (pos != -1); } diff --git a/src/playlist/playlist.c b/src/playlist/playlist.c index 8560992..a666ef1 100644 --- a/src/playlist/playlist.c +++ b/src/playlist/playlist.c @@ -278,7 +278,7 @@ static void koto_playlist_init(KotoPlaylist * self) { self->tracks = g_queue_new(); // Set as an empty GQueue self->played_tracks = g_queue_new(); // Set as an empty GQueue self->sorted_tracks = g_queue_new(); // Set as an empty GQueue - self->store = g_list_store_new(KOTO_TYPE_INDEXED_TRACK); + self->store = g_list_store_new(KOTO_TYPE_TRACK); } void koto_playlist_add_to_played_tracks( @@ -294,11 +294,11 @@ void koto_playlist_add_to_played_tracks( void koto_playlist_add_track( KotoPlaylist * self, - KotoIndexedTrack * track, + KotoTrack * track, gboolean current, gboolean commit_to_table ) { - koto_playlist_add_track_by_uuid(self, koto_indexed_track_get_uuid(track), current, commit_to_table); + koto_playlist_add_track_by_uuid(self, koto_track_get_uuid(track), current, commit_to_table); } void koto_playlist_add_track_by_uuid( @@ -307,10 +307,10 @@ void koto_playlist_add_track_by_uuid( gboolean current, gboolean commit_to_table ) { - KotoIndexedTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, uuid); // Get the track + KotoTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, uuid); // Get the track - if (!KOTO_IS_INDEXED_TRACK(track)) { + if (!KOTO_IS_TRACK(track)) { return; } @@ -333,7 +333,7 @@ void koto_playlist_add_track_by_uuid( } if (commit_to_table) { - koto_indexed_track_save_to_playlist(track, self->uuid, (g_strcmp0(self->current_uuid, uuid) == 0) ? 1 : 0); // Call to save the playlist to the track + koto_track_save_to_playlist(track, self->uuid, (g_strcmp0(self->current_uuid, uuid) == 0) ? 1 : 0); // Call to save the playlist to the track } if (current && (g_queue_get_length(self->tracks) > 1)) { // Is current and NOT the first item @@ -400,7 +400,7 @@ void koto_playlist_commit_tracks( gpointer data, gpointer user_data ) { - KotoIndexedTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, data); // Get the track + KotoTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, data); // Get the track if (track == NULL) { // Not a track @@ -408,7 +408,7 @@ void koto_playlist_commit_tracks( gchar * playlist_uuid = self->uuid; // Get the playlist UUID gchar * current_track = g_queue_peek_nth(self->tracks, self->current_position); // Get the UUID of the current track - //koto_indexed_track_save_to_playlist(track, playlist_uuid, (data == current_track) ? 1 : 0); // Call to save the playlist to the track + //koto_track_save_to_playlist(track, playlist_uuid, (data == current_track) ? 1 : 0); // Call to save the playlist to the track g_free(playlist_uuid); g_free(current_track); } @@ -447,7 +447,7 @@ gchar * koto_playlist_get_name(KotoPlaylist * self) { gint koto_playlist_get_position_of_track( KotoPlaylist * self, - KotoIndexedTrack * track + KotoTrack * track ) { if (!KOTO_IS_PLAYLIST(self)) { return -1; @@ -457,7 +457,7 @@ gint koto_playlist_get_position_of_track( return -1; } - if (!KOTO_IS_INDEXED_TRACK(track)) { + if (!KOTO_IS_TRACK(track)) { return -1; } @@ -532,9 +532,9 @@ gchar * koto_playlist_go_to_next(KotoPlaylist * self) { if (!koto_utils_is_string_valid(self->current_uuid)) { // No valid UUID yet self->current_position++; } else { // Have a UUID currently - KotoIndexedTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, self->current_uuid); + KotoTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, self->current_uuid); - if (!KOTO_IS_INDEXED_TRACK(track)) { + if (!KOTO_IS_TRACK(track)) { return NULL; } @@ -562,10 +562,10 @@ gchar * koto_playlist_go_to_previous(KotoPlaylist * self) { return NULL; } - KotoIndexedTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, self->current_uuid); + KotoTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, self->current_uuid); - if (!KOTO_IS_INDEXED_TRACK(track)) { + if (!KOTO_IS_TRACK(track)) { return NULL; } @@ -602,8 +602,8 @@ gint koto_playlist_model_sort_by_uuid( gconstpointer second_item, gpointer data_list ) { - KotoIndexedTrack * first_track = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) first_item); - KotoIndexedTrack * second_track = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) second_item); + KotoTrack * first_track = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) first_item); + KotoTrack * second_track = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) second_item); return koto_playlist_model_sort_by_track(first_track, second_track, data_list); @@ -614,8 +614,8 @@ gint koto_playlist_model_sort_by_track( gconstpointer second_item, gpointer data_list ) { - KotoIndexedTrack * first_track = (KotoIndexedTrack*) first_item; - KotoIndexedTrack * second_track = (KotoIndexedTrack*) second_item; + KotoTrack * first_track = (KotoTrack*) first_item; + KotoTrack * second_track = (KotoTrack*) second_item; GList* ptr_list = data_list; KotoPlaylist * self = g_list_nth_data(ptr_list, 0); // First item in the GPtrArray is a pointer to our playlist @@ -626,8 +626,8 @@ gint koto_playlist_model_sort_by_track( (model == KOTO_PREFERRED_MODEL_TYPE_DEFAULT) || // Newest first model (model == KOTO_PREFERRED_MODEL_TYPE_OLDEST_FIRST) // Oldest first ) { - gint first_track_pos = g_queue_index(self->tracks, koto_indexed_track_get_uuid(first_track)); - gint second_track_pos = g_queue_index(self->tracks, koto_indexed_track_get_uuid(second_track)); + gint first_track_pos = g_queue_index(self->tracks, koto_track_get_uuid(first_track)); + gint second_track_pos = g_queue_index(self->tracks, koto_track_get_uuid(second_track)); if (first_track_pos == -1) { // First track isn't in tracks return 1; @@ -668,17 +668,17 @@ gint koto_playlist_model_sort_by_track( return 0; // Don't get too granular, just consider them equal } - KotoIndexedAlbum * first_album = koto_cartographer_get_album_by_uuid(koto_maps, first_album_uuid); - KotoIndexedAlbum * second_album = koto_cartographer_get_album_by_uuid(koto_maps, second_album_uuid); + KotoAlbum * first_album = koto_cartographer_get_album_by_uuid(koto_maps, first_album_uuid); + KotoAlbum * second_album = koto_cartographer_get_album_by_uuid(koto_maps, second_album_uuid); g_free(first_album_uuid); g_free(second_album_uuid); - if (!KOTO_IS_INDEXED_ALBUM(first_album) && !KOTO_IS_INDEXED_ALBUM(second_album)) { // Neither are valid albums + if (!KOTO_IS_ALBUM(first_album) && !KOTO_IS_ALBUM(second_album)) { // Neither are valid albums return 0; // Just consider them as equal } - return g_utf8_collate(koto_indexed_album_get_album_name(first_album), koto_indexed_album_get_album_name(second_album)); + return g_utf8_collate(koto_album_get_album_name(first_album), koto_album_get_album_name(second_album)); } if (model == KOTO_PREFERRED_MODEL_TYPE_SORT_BY_ARTIST) { // Sort by artist name @@ -699,17 +699,17 @@ gint koto_playlist_model_sort_by_track( NULL ); - KotoIndexedArtist * first_artist = koto_cartographer_get_artist_by_uuid(koto_maps, first_artist_uuid); - KotoIndexedArtist * second_artist = koto_cartographer_get_artist_by_uuid(koto_maps, second_artist_uuid); + KotoArtist * first_artist = koto_cartographer_get_artist_by_uuid(koto_maps, first_artist_uuid); + KotoArtist * second_artist = koto_cartographer_get_artist_by_uuid(koto_maps, second_artist_uuid); g_free(first_artist_uuid); g_free(second_artist_uuid); - if (!KOTO_IS_INDEXED_ARTIST(first_artist) && !KOTO_IS_INDEXED_ARTIST(second_artist)) { // Neither are valid artists + if (!KOTO_IS_ARTIST(first_artist) && !KOTO_IS_ARTIST(second_artist)) { // Neither are valid artists return 0; // Just consider them as equal } - return g_utf8_collate(koto_indexed_artist_get_name(first_artist), koto_indexed_artist_get_name(second_artist)); + return g_utf8_collate(koto_artist_get_name(first_artist), koto_artist_get_name(second_artist)); } if (model == KOTO_PREFERRED_MODEL_TYPE_SORT_BY_TRACK_NAME) { // Track name @@ -769,10 +769,10 @@ void koto_playlist_remove_track_by_uuid( g_queue_pop_nth(self->sorted_tracks, file_index_in_sorted); // Remove nth where it is the index in sorted tracks } - KotoIndexedTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, uuid); // Get the track + KotoTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, uuid); // Get the track - if (!KOTO_IS_INDEXED_TRACK(track)) { // Is not a track + if (!KOTO_IS_TRACK(track)) { // Is not a track return; } @@ -783,7 +783,7 @@ void koto_playlist_remove_track_by_uuid( g_list_store_remove(self->store, position); // Remove from the store } - koto_indexed_track_remove_from_playlist(track, self->uuid); + koto_track_remove_from_playlist(track, self->uuid); g_signal_emit( self, @@ -899,10 +899,10 @@ void koto_playlist_tracks_queue_push_to_store( gpointer user_data ) { gchar * track_uuid = (gchar*) data; - KotoIndexedTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, track_uuid); + KotoTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, track_uuid); - if (!KOTO_IS_INDEXED_TRACK(track)) { // Not a track + if (!KOTO_IS_TRACK(track)) { // Not a track return; } diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index 4a277be..997aa54 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -59,7 +59,7 @@ void koto_playlist_add_to_played_tracks( void koto_playlist_add_track( KotoPlaylist * self, - KotoIndexedTrack * track, + KotoTrack * track, gboolean current, gboolean commit_to_table ); @@ -102,7 +102,7 @@ gchar * koto_playlist_get_name(KotoPlaylist * self); gint koto_playlist_get_position_of_track( KotoPlaylist * self, - KotoIndexedTrack * track + KotoTrack * track ); GListStore * koto_playlist_get_store(KotoPlaylist * self);