Convert from CSS to SCSS. Make a multitude of refinements to styling along the way.

Remove unused glade UI file. Added CSS classes to various components. Fix some alignment issues. Renamed our albums_strip to favorites_list.

Implement recursive file parsing in KotoIndexedAlbum with the intent of using it for "discs" / CD, useful for albums like Foo Fighters: In Your Honor that have 2 or more CDs. Still need to work on refining this further.

Add stub function in our album view for a planned separation of the track listing so we can do it based on discs and other depth-of-3 sub-folders.
This commit is contained in:
Joshua Strobl 2021-02-25 18:15:36 +02:00
parent 588a68b2cc
commit 56dd6b45b4
27 changed files with 359 additions and 104 deletions

View file

@ -32,6 +32,7 @@ struct _KotoAlbumView {
GtkWidget *tracks;
GtkWidget *album_label;
GHashTable *cd_to_track_listbox;
};
G_DEFINE_TYPE(KotoAlbumView, koto_album_view, G_TYPE_OBJECT);
@ -64,12 +65,15 @@ static void koto_album_view_class_init(KotoAlbumViewClass *c) {
}
static void koto_album_view_init(KotoAlbumView *self) {
self->cd_to_track_listbox = g_hash_table_new(g_str_hash, g_str_equal);
self->main = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_add_css_class(self->main, "album-view");
gtk_widget_set_can_focus(self->main, FALSE);
self->album_tracks_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
self->tracks = gtk_list_box_new(); // Create our list of our tracks
gtk_list_box_set_sort_func(GTK_LIST_BOX(self->tracks), koto_album_view_sort_tracks, NULL, NULL); // Ensure we can sort our tracks
gtk_widget_add_css_class(self->tracks, "track-list");
gtk_widget_set_size_request(self->tracks, 600, -1);
gtk_box_append(GTK_BOX(self->main), self->album_tracks_box); // Add the tracks box to the art info combo box
@ -106,6 +110,10 @@ static void koto_album_view_set_property(GObject *obj, guint prop_id, const GVal
}
}
void koto_album_view_add_track_to_listbox(KotoIndexedAlbum *self, KotoIndexedFile *file) {
(void) self; (void) file;
}
void koto_album_view_set_album(KotoAlbumView *self, KotoIndexedAlbum *album) {
if (album == NULL) {
return;
@ -115,6 +123,7 @@ void koto_album_view_set_album(KotoAlbumView *self, KotoIndexedAlbum *album) {
gchar *album_art = koto_indexed_album_get_album_art(self->album); // Get the art for the album
GtkWidget *art_image = koto_utils_create_image_from_filepath(album_art, "audio-x-generic-symbolic", 220, 220);
gtk_widget_set_valign(art_image, GTK_ALIGN_START); // Align to top of list for album
gtk_box_prepend(GTK_BOX(self->main), art_image); // Prepend the image to the art info box
@ -122,6 +131,7 @@ void koto_album_view_set_album(KotoAlbumView *self, KotoIndexedAlbum *album) {
g_object_get(album, "name", &album_name, NULL); // Get the album name
self->album_label = gtk_label_new(album_name);
gtk_widget_set_halign(self->album_label, GTK_ALIGN_START);
gtk_box_prepend(GTK_BOX(self->album_tracks_box), self->album_label); // Prepend our new label to the album + tracks box
GList *t;

View file

@ -30,6 +30,7 @@ G_DECLARE_FINAL_TYPE(KotoAlbumView, koto_album_view, KOTO, ALBUM_VIEW, GObject)
KotoAlbumView* koto_album_view_new(KotoIndexedAlbum *album);
GtkWidget* koto_album_view_get_main(KotoAlbumView *self);
void koto_album_view_add_track_to_listbox(KotoIndexedAlbum *self, KotoIndexedFile *file);
void koto_album_view_set_album(KotoAlbumView *self, KotoIndexedAlbum *album);
int koto_album_view_sort_tracks(GtkListBoxRow *track1, GtkListBoxRow *track2, gpointer user_data);

View file

@ -29,7 +29,7 @@ struct _KotoArtistView {
KotoIndexedArtist *artist;
GtkWidget *scrolled_window;
GtkWidget *content;
GtkWidget *albums_strip;
GtkWidget *favorites_list;
GtkWidget *album_list;
GHashTable *albums_to_component;
@ -108,19 +108,26 @@ static void koto_artist_view_constructed(GObject *obj) {
gtk_scrolled_window_set_propagate_natural_height(GTK_SCROLLED_WINDOW(self->scrolled_window), TRUE);
gtk_scrolled_window_set_propagate_natural_width(GTK_SCROLLED_WINDOW(self->scrolled_window), TRUE);
gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(self->scrolled_window), self->content); // Add the content as the widget for the scrolled window
gtk_widget_add_css_class(GTK_WIDGET(self->scrolled_window), "artist-view");
gtk_widget_add_css_class(GTK_WIDGET(self->content), "artist-view-content");
self->albums_strip = gtk_flow_box_new(); // Create our album strip
gtk_flow_box_set_activate_on_single_click(GTK_FLOW_BOX(self->albums_strip), TRUE);
gtk_flow_box_set_selection_mode(GTK_FLOW_BOX(self->albums_strip), GTK_SELECTION_NONE);
self->favorites_list = gtk_flow_box_new(); // Create our favorites list
gtk_flow_box_set_activate_on_single_click(GTK_FLOW_BOX(self->favorites_list), TRUE);
gtk_flow_box_set_selection_mode(GTK_FLOW_BOX(self->favorites_list), GTK_SELECTION_NONE);
gtk_flow_box_set_min_children_per_line(GTK_FLOW_BOX(self->favorites_list), 6);
gtk_flow_box_set_max_children_per_line(GTK_FLOW_BOX(self->favorites_list), 6);
gtk_widget_add_css_class(GTK_WIDGET(self->favorites_list), "album-strip");
gtk_widget_set_halign(self->favorites_list, GTK_ALIGN_START);
self->album_list = gtk_flow_box_new(); // Create our list of albums as a flow box
self->album_list = gtk_flow_box_new(); // Create our list of our albums
gtk_flow_box_set_activate_on_single_click(GTK_FLOW_BOX(self->album_list), FALSE);
gtk_flow_box_set_selection_mode(GTK_FLOW_BOX(self->album_list), GTK_SELECTION_NONE);
gtk_widget_add_css_class(self->album_list, "album-list");
gtk_box_prepend(GTK_BOX(self->content), self->albums_strip); // Add the strip
gtk_box_prepend(GTK_BOX(self->content), self->favorites_list); // Add the strip
gtk_box_append(GTK_BOX(self->content), self->album_list); // Add the list
gtk_widget_set_hexpand(GTK_WIDGET(self->albums_strip), TRUE);
gtk_widget_set_hexpand(GTK_WIDGET(self->favorites_list), TRUE);
gtk_widget_set_hexpand(GTK_WIDGET(self->album_list), TRUE);
G_OBJECT_CLASS (koto_artist_view_parent_class)->constructed (obj);
@ -131,7 +138,8 @@ void koto_artist_view_add_album(KotoArtistView *self, KotoIndexedAlbum *album) {
gchar *album_art = koto_indexed_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);
gtk_flow_box_insert(GTK_FLOW_BOX(self->albums_strip), art_image, -1); // Append the album art
gtk_widget_set_halign(art_image, GTK_ALIGN_START); // Align to start
gtk_flow_box_insert(GTK_FLOW_BOX(self->favorites_list), art_image, -1); // Append the album art
KotoAlbumView* album_view = koto_album_view_new(album); // Create our new album view
GtkWidget* album_view_main = koto_album_view_get_main(album_view);