Implement start of Playback Engine, refactored most classes to leverage KotoCartographer, etc.
This commit is contained in:
parent
a77efdb0aa
commit
05d90afc58
25 changed files with 1015 additions and 304 deletions
|
@ -17,13 +17,16 @@
|
|||
|
||||
#include <glib-2.0/glib.h>
|
||||
#include <gtk-4.0/gtk/gtk.h>
|
||||
#include "../../koto-button.h"
|
||||
#include "../../db/cartographer.h"
|
||||
#include "../../indexer/structs.h"
|
||||
#include "../../koto-button.h"
|
||||
#include "album-view.h"
|
||||
#include "disc-view.h"
|
||||
#include "koto-config.h"
|
||||
#include "koto-utils.h"
|
||||
|
||||
extern KotoCartographer *koto_maps;
|
||||
|
||||
struct _KotoAlbumView {
|
||||
GObject parent_instance;
|
||||
KotoIndexedAlbum *album;
|
||||
|
@ -176,10 +179,15 @@ void koto_album_view_set_album(KotoAlbumView *self, KotoIndexedAlbum *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_files(album); // Get the tracks for this album
|
||||
GList *tracks = koto_indexed_album_get_tracks(album); // Get the tracks for this album
|
||||
|
||||
for (guint i = 0; i < g_list_length(tracks); i++) {
|
||||
KotoIndexedTrack *track = (KotoIndexedTrack*) g_list_nth_data(tracks, i); // Get the
|
||||
KotoIndexedTrack *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;
|
||||
}
|
||||
|
||||
guint *disc_number;
|
||||
g_object_get(track, "cd", &disc_number, NULL);
|
||||
gchar *disc_num_as_str = g_strdup_printf("%u", GPOINTER_TO_UINT(disc_number));
|
||||
|
|
|
@ -17,12 +17,15 @@
|
|||
|
||||
#include <glib-2.0/glib.h>
|
||||
#include <gtk-4.0/gtk/gtk.h>
|
||||
#include "../../db/cartographer.h"
|
||||
#include "../../indexer/structs.h"
|
||||
#include "album-view.h"
|
||||
#include "artist-view.h"
|
||||
#include "koto-config.h"
|
||||
#include "koto-utils.h"
|
||||
|
||||
extern KotoCartographer *koto_maps;
|
||||
|
||||
struct _KotoArtistView {
|
||||
GObject parent_instance;
|
||||
KotoIndexedArtist *artist;
|
||||
|
@ -160,8 +163,11 @@ void koto_artist_view_add_artist(KotoArtistView *self, KotoIndexedArtist *artist
|
|||
|
||||
GList *a;
|
||||
for (a = albums; a != NULL; a = a->next) {
|
||||
KotoIndexedAlbum *album = (KotoIndexedAlbum*) a->data;
|
||||
koto_artist_view_add_album(self, album); // Add the album
|
||||
KotoIndexedAlbum *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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,13 @@
|
|||
*/
|
||||
|
||||
#include <gtk-4.0/gtk/gtk.h>
|
||||
#include "../../db/cartographer.h"
|
||||
#include "../../indexer/structs.h"
|
||||
#include "../../koto-track-item.h"
|
||||
#include "disc-view.h"
|
||||
|
||||
extern KotoCartographer *koto_maps;
|
||||
|
||||
struct _KotoDiscView {
|
||||
GtkBox parent_instance;
|
||||
KotoIndexedAlbum *album;
|
||||
|
@ -138,25 +141,26 @@ void koto_disc_view_set_album(KotoDiscView *self, KotoIndexedAlbum *album) {
|
|||
|
||||
self->list = gtk_list_box_new(); // Create our list of our tracks
|
||||
gtk_list_box_set_selection_mode(GTK_LIST_BOX(self->list), GTK_SELECTION_MULTIPLE);
|
||||
gtk_list_box_set_sort_func(GTK_LIST_BOX(self->list), koto_album_view_sort_tracks, NULL, NULL); // Ensure we can sort our tracks
|
||||
gtk_widget_add_css_class(self->list, "track-list");
|
||||
gtk_widget_set_size_request(self->list, 600, -1);
|
||||
gtk_box_append(GTK_BOX(self), self->list);
|
||||
|
||||
GList *t;
|
||||
for (t = koto_indexed_album_get_files(self->album); t != NULL; t = t->next) { // For each file / track
|
||||
KotoIndexedTrack *track = (KotoIndexedTrack*) t->data;
|
||||
g_list_foreach(koto_indexed_album_get_tracks(self->album), koto_disc_view_list_tracks, self);
|
||||
}
|
||||
|
||||
guint *disc_number;
|
||||
g_object_get(track, "cd", &disc_number, NULL); // get the disc number
|
||||
void koto_disc_view_list_tracks(gpointer data, gpointer selfptr) {
|
||||
KotoDiscView *self = (KotoDiscView*) selfptr;
|
||||
KotoIndexedTrack *track = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) data); // Get the track by its UUID
|
||||
|
||||
if (GPOINTER_TO_UINT(self->disc_number) != GPOINTER_TO_UINT(disc_number)) { // Track does not belong to this CD
|
||||
continue;
|
||||
}
|
||||
guint *disc_number;
|
||||
g_object_get(track, "cd", &disc_number, NULL); // get the disc number
|
||||
|
||||
KotoTrackItem *track_item = koto_track_item_new(track); // Create our new track item
|
||||
gtk_list_box_prepend(GTK_LIST_BOX(self->list), GTK_WIDGET(track_item)); // Add to our tracks list box
|
||||
if (GPOINTER_TO_UINT(self->disc_number) != GPOINTER_TO_UINT(disc_number)) { // Track does not belong to this CD
|
||||
return;
|
||||
}
|
||||
|
||||
KotoTrackItem *track_item = koto_track_item_new(track); // Create our new track item
|
||||
gtk_list_box_append(GTK_LIST_BOX(self->list), GTK_WIDGET(track_item)); // Add to our tracks list box
|
||||
}
|
||||
|
||||
void koto_disc_view_set_disc_number(KotoDiscView *self, guint disc_number) {
|
||||
|
@ -176,38 +180,6 @@ void koto_disc_view_set_disc_label_visible(KotoDiscView *self, gboolean visible)
|
|||
(visible) ? gtk_widget_show(self->header) : gtk_widget_hide(self->header);
|
||||
}
|
||||
|
||||
int koto_album_view_sort_tracks(GtkListBoxRow *track1, GtkListBoxRow *track2, gpointer user_data) {
|
||||
(void) user_data;
|
||||
KotoTrackItem *track1_item = KOTO_TRACK_ITEM(gtk_list_box_row_get_child(track1));
|
||||
KotoTrackItem *track2_item = KOTO_TRACK_ITEM(gtk_list_box_row_get_child(track2));
|
||||
|
||||
KotoIndexedTrack *track1_file;
|
||||
KotoIndexedTrack *track2_file;
|
||||
|
||||
g_object_get(track1_item, "track", &track1_file, NULL);
|
||||
g_object_get(track2_item, "track", &track2_file, NULL);
|
||||
|
||||
guint16 *track1_pos;
|
||||
guint16 *track2_pos;
|
||||
|
||||
g_object_get(track1_file, "position", &track1_pos, NULL);
|
||||
g_object_get(track2_file, "position", &track2_pos, NULL);
|
||||
|
||||
if (track1_pos == track2_pos) { // Identical positions (like reported as 0)
|
||||
gchar *track1_name;
|
||||
gchar *track2_name;
|
||||
|
||||
g_object_get(track1_file, "parsed-name", &track1_name, NULL);
|
||||
g_object_get(track2_file, "parsed-name", &track2_name, NULL);
|
||||
|
||||
return g_utf8_collate(track1_name, track2_name);
|
||||
} else if (track1_pos < track2_pos) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
KotoDiscView* koto_disc_view_new(KotoIndexedAlbum *album, guint *disc_number) {
|
||||
return g_object_new(KOTO_TYPE_DISC_VIEW,
|
||||
"disc", disc_number,
|
||||
|
|
|
@ -28,9 +28,9 @@ G_BEGIN_DECLS
|
|||
G_DECLARE_FINAL_TYPE(KotoDiscView, koto_disc_view, KOTO, DISC_VIEW, GtkBox)
|
||||
|
||||
KotoDiscView* koto_disc_view_new(KotoIndexedAlbum *album, guint *disc);
|
||||
void koto_disc_view_list_tracks(gpointer data, gpointer selfptr);
|
||||
void koto_disc_view_set_album(KotoDiscView *self, KotoIndexedAlbum *album);
|
||||
void koto_disc_view_set_disc_label_visible(KotoDiscView *self, gboolean visible);
|
||||
void koto_disc_view_set_disc_number(KotoDiscView *self, guint disc_number);
|
||||
int koto_album_view_sort_tracks(GtkListBoxRow *track1, GtkListBoxRow *track2, gpointer user_data);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -17,11 +17,14 @@
|
|||
|
||||
#include <glib-2.0/glib.h>
|
||||
#include <gtk-4.0/gtk/gtk.h>
|
||||
#include "../../db/cartographer.h"
|
||||
#include "../../indexer/structs.h"
|
||||
#include "koto-button.h"
|
||||
#include "koto-config.h"
|
||||
#include "music-local.h"
|
||||
|
||||
extern KotoCartographer *koto_maps;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_LIB,
|
||||
|
@ -175,8 +178,11 @@ void koto_page_music_local_set_library(KotoPageMusicLocal *self, KotoIndexedLibr
|
|||
|
||||
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 = (KotoIndexedArtist*) artist_data; // Cast our data as a KotoIndexedArtist
|
||||
koto_page_music_local_add_artist(self, artist);
|
||||
KotoIndexedArtist *artist = koto_cartographer_get_artist_by_uuid(koto_maps, (gchar*) artist_data); // Cast our data as a KotoIndexedArtist
|
||||
|
||||
if (artist != NULL) {
|
||||
koto_page_music_local_add_artist(self, artist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue