Start cleanup of KotoLibrary logic and decoupling other components like Music Local from a specific library.
Fix the displaying of discs and tracks in an album on initial index due to missing cartographer add track call. Cleanup lots of double empty newlines. Updated ptr spacing in uncrustify config to enforce consistency in pointer char (`*`) spacing.
This commit is contained in:
parent
8334323af8
commit
bfe4891620
33 changed files with 146 additions and 623 deletions
|
@ -69,7 +69,6 @@ static void koto_album_view_set_property(
|
|||
static void koto_album_view_class_init(KotoAlbumViewClass * c) {
|
||||
GObjectClass * gobject_class;
|
||||
|
||||
|
||||
gobject_class = G_OBJECT_CLASS(c);
|
||||
gobject_class->set_property = koto_album_view_set_property;
|
||||
gobject_class->get_property = koto_album_view_get_property;
|
||||
|
@ -126,7 +125,6 @@ static void koto_album_view_get_property(
|
|||
) {
|
||||
KotoAlbumView * self = KOTO_ALBUM_VIEW(obj);
|
||||
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_ALBUM:
|
||||
g_value_set_object(val, self->album);
|
||||
|
@ -189,7 +187,7 @@ void koto_album_view_set_album(
|
|||
for (guint i = 0; i < g_list_length(tracks); i++) {
|
||||
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
|
||||
if (!KOTO_IS_TRACK(track)) { // Track doesn't exist
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -229,7 +227,6 @@ int koto_album_view_sort_discs(
|
|||
guint disc1_num;
|
||||
guint disc2_num;
|
||||
|
||||
|
||||
g_object_get(disc1_item, "disc", &disc1_num, NULL);
|
||||
g_object_get(disc2_item, "disc", &disc2_num, NULL);
|
||||
|
||||
|
@ -253,7 +250,7 @@ void koto_album_view_toggle_album_playback(
|
|||
(void) n_press;
|
||||
(void) x;
|
||||
(void) y;
|
||||
KotoAlbumView* self = data;
|
||||
KotoAlbumView * self = data;
|
||||
|
||||
koto_album_set_as_current_playlist(self->album); // Set as the current playlist
|
||||
}
|
||||
|
|
|
@ -69,7 +69,6 @@ static void koto_artist_view_set_property(
|
|||
static void koto_artist_view_class_init(KotoArtistViewClass * c) {
|
||||
GObjectClass * gobject_class;
|
||||
|
||||
|
||||
gobject_class = G_OBJECT_CLASS(c);
|
||||
gobject_class->constructed = koto_artist_view_constructed;
|
||||
gobject_class->set_property = koto_artist_view_set_property;
|
||||
|
@ -94,7 +93,6 @@ static void koto_artist_view_get_property(
|
|||
) {
|
||||
KotoArtistView * self = KOTO_ARTIST_VIEW(obj);
|
||||
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_ARTIST:
|
||||
g_value_set_object(val, self->artist);
|
||||
|
@ -113,7 +111,6 @@ static void koto_artist_view_set_property(
|
|||
) {
|
||||
KotoArtistView * self = KOTO_ARTIST_VIEW(obj);
|
||||
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_ARTIST:
|
||||
koto_artist_view_add_artist(self, (KotoArtist*) g_value_get_object(val));
|
||||
|
@ -132,7 +129,6 @@ static void koto_artist_view_init(KotoArtistView * self) {
|
|||
static void koto_artist_view_constructed(GObject * obj) {
|
||||
KotoArtistView * self = KOTO_ARTIST_VIEW(obj);
|
||||
|
||||
|
||||
self->albums_to_component = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
self->scrolled_window = gtk_scrolled_window_new(); // Create our scrolled window
|
||||
self->content = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); // Create our content as a GtkBox
|
||||
|
@ -174,13 +170,11 @@ void koto_artist_view_add_album(
|
|||
|
||||
GtkWidget * art_image = koto_utils_create_image_from_filepath(album_art, "audio-x-generic-symbolic", 220, 220);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
KotoAlbumView * album_view = koto_album_view_new(album); // Create our new album view
|
||||
GtkWidget * album_view_main = koto_album_view_get_main(album_view);
|
||||
|
||||
gtk_flow_box_insert(GTK_FLOW_BOX(self->album_list), album_view_main, -1); // Append the album view to the album list
|
||||
}
|
||||
|
@ -203,7 +197,6 @@ void koto_artist_view_add_artist(
|
|||
|
||||
GList * a;
|
||||
|
||||
|
||||
for (a = albums; a != NULL; a = a->next) {
|
||||
KotoAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, (gchar*) a->data);
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ static void koto_disc_view_set_property(
|
|||
static void koto_disc_view_class_init(KotoDiscViewClass * c) {
|
||||
GObjectClass * gobject_class;
|
||||
|
||||
|
||||
gobject_class = G_OBJECT_CLASS(c);
|
||||
gobject_class->set_property = koto_disc_view_set_property;
|
||||
gobject_class->get_property = koto_disc_view_get_property;
|
||||
|
@ -99,7 +98,6 @@ static void koto_disc_view_get_property(
|
|||
) {
|
||||
KotoDiscView * self = KOTO_DISC_VIEW(obj);
|
||||
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_DISC:
|
||||
g_value_set_uint(val, GPOINTER_TO_UINT(self->disc_number));
|
||||
|
@ -121,7 +119,6 @@ static void koto_disc_view_set_property(
|
|||
) {
|
||||
KotoDiscView * self = KOTO_DISC_VIEW(obj);
|
||||
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_DISC:
|
||||
koto_disc_view_set_disc_number(self, g_value_get_uint(val));
|
||||
|
@ -144,7 +141,6 @@ static void koto_disc_view_init(KotoDiscView * self) {
|
|||
|
||||
GtkWidget * ico = gtk_image_new_from_icon_name("drive-optical-symbolic");
|
||||
|
||||
|
||||
gtk_box_prepend(GTK_BOX(self->header), ico);
|
||||
|
||||
self->label = gtk_label_new(NULL); // Create an empty label
|
||||
|
@ -175,7 +171,6 @@ void koto_disc_view_list_tracks(
|
|||
|
||||
guint * disc_number;
|
||||
|
||||
|
||||
g_object_get(track, "cd", &disc_number, NULL); // get the disc number
|
||||
|
||||
if (GPOINTER_TO_UINT(self->disc_number) != GPOINTER_TO_UINT(disc_number)) { // Track does not belong to this CD
|
||||
|
@ -184,7 +179,6 @@ void koto_disc_view_list_tracks(
|
|||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -196,14 +190,12 @@ void koto_disc_view_handle_selected_rows_changed(
|
|||
|
||||
gchar * album_uuid = koto_album_get_album_uuid(self->album); // Get the UUID
|
||||
|
||||
|
||||
if (!koto_utils_is_string_valid(album_uuid)) { // Not set
|
||||
return;
|
||||
}
|
||||
|
||||
GList * selected_rows = gtk_list_box_get_selected_rows(box); // Get the selected rows
|
||||
|
||||
|
||||
if (g_list_length(selected_rows) == 0) { // No rows selected
|
||||
koto_action_bar_toggle_reveal(action_bar, FALSE); // Close the action bar
|
||||
return;
|
||||
|
@ -212,7 +204,6 @@ void koto_disc_view_handle_selected_rows_changed(
|
|||
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 KotoTrack to our list
|
||||
|
@ -253,7 +244,6 @@ void koto_disc_view_set_disc_number(
|
|||
|
||||
gchar * disc_label = g_strdup_printf("Disc %u", disc_number);
|
||||
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(self->label), disc_label); // Set the label
|
||||
|
||||
g_free(disc_label);
|
||||
|
|
|
@ -26,23 +26,12 @@
|
|||
|
||||
extern KotoCartographer * koto_maps;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_LIB,
|
||||
N_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec * props[N_PROPERTIES] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
struct _KotoPageMusicLocal {
|
||||
GtkBox parent_instance;
|
||||
GtkWidget * scrolled_window;
|
||||
GtkWidget * artist_list;
|
||||
GtkWidget * stack;
|
||||
|
||||
KotoLibrary * lib;
|
||||
gboolean constructed;
|
||||
};
|
||||
|
||||
|
@ -56,80 +45,14 @@ KotoPageMusicLocal * music_local_page;
|
|||
|
||||
static void koto_page_music_local_constructed(GObject * obj);
|
||||
|
||||
static void koto_page_music_local_get_property(
|
||||
GObject * obj,
|
||||
guint prop_id,
|
||||
GValue * val,
|
||||
GParamSpec * spec
|
||||
);
|
||||
|
||||
static void koto_page_music_local_set_property(
|
||||
GObject * obj,
|
||||
guint prop_id,
|
||||
const GValue * val,
|
||||
GParamSpec * spec
|
||||
);
|
||||
|
||||
static void koto_page_music_local_class_init(KotoPageMusicLocalClass * c) {
|
||||
GObjectClass * gobject_class;
|
||||
|
||||
|
||||
gobject_class = G_OBJECT_CLASS(c);
|
||||
gobject_class->constructed = koto_page_music_local_constructed;
|
||||
gobject_class->set_property = koto_page_music_local_set_property;
|
||||
gobject_class->get_property = koto_page_music_local_get_property;
|
||||
|
||||
props[PROP_LIB] = g_param_spec_object(
|
||||
"lib",
|
||||
"Library",
|
||||
"Library",
|
||||
KOTO_TYPE_LIBRARY,
|
||||
G_PARAM_CONSTRUCT | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_READWRITE
|
||||
);
|
||||
|
||||
g_object_class_install_properties(gobject_class, N_PROPERTIES, props);
|
||||
}
|
||||
|
||||
static void koto_page_music_local_get_property(
|
||||
GObject * obj,
|
||||
guint prop_id,
|
||||
GValue * val,
|
||||
GParamSpec * spec
|
||||
) {
|
||||
KotoPageMusicLocal * self = KOTO_PAGE_MUSIC_LOCAL(obj);
|
||||
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_LIB:
|
||||
g_value_set_object(val, self->lib);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void koto_page_music_local_set_property(
|
||||
GObject * obj,
|
||||
guint prop_id,
|
||||
const GValue * val,
|
||||
GParamSpec * spec
|
||||
) {
|
||||
KotoPageMusicLocal * self = KOTO_PAGE_MUSIC_LOCAL(obj);
|
||||
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_LIB:
|
||||
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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void koto_page_music_local_init(KotoPageMusicLocal * self) {
|
||||
self->lib = NULL;
|
||||
self->constructed = FALSE;
|
||||
|
||||
gtk_widget_add_css_class(GTK_WIDGET(self), "page-music-local");
|
||||
|
@ -161,7 +84,6 @@ static void koto_page_music_local_init(KotoPageMusicLocal * self) {
|
|||
static void koto_page_music_local_constructed(GObject * obj) {
|
||||
KotoPageMusicLocal * self = KOTO_PAGE_MUSIC_LOCAL(obj);
|
||||
|
||||
|
||||
G_OBJECT_CLASS(koto_page_music_local_parent_class)->constructed(obj);
|
||||
self->constructed = TRUE;
|
||||
}
|
||||
|
@ -172,16 +94,13 @@ void koto_page_music_local_add_artist(
|
|||
) {
|
||||
gchar * artist_name;
|
||||
|
||||
|
||||
g_object_get(artist, "name", &artist_name, NULL);
|
||||
KotoButton * artist_button = koto_button_new_plain(artist_name);
|
||||
|
||||
|
||||
gtk_list_box_prepend(GTK_LIST_BOX(self->artist_list), GTK_WIDGET(artist_button));
|
||||
|
||||
KotoArtistView * artist_view = koto_artist_view_new(); // Create our new artist view
|
||||
|
||||
|
||||
koto_artist_view_add_artist(artist_view, artist); // Add the artist
|
||||
gtk_stack_add_named(GTK_STACK(self->stack), koto_artist_view_get_main(artist_view), artist_name);
|
||||
}
|
||||
|
@ -199,14 +118,12 @@ void koto_page_music_local_go_to_artist_by_uuid(
|
|||
) {
|
||||
KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid); // Get the artist
|
||||
|
||||
|
||||
if (!KOTO_IS_ARTIST(artist)) { // No artist for this UUID
|
||||
return;
|
||||
}
|
||||
|
||||
gchar * artist_name = NULL;
|
||||
|
||||
|
||||
g_object_get(
|
||||
artist,
|
||||
"name",
|
||||
|
@ -232,25 +149,11 @@ void koto_page_music_local_handle_artist_click(
|
|||
|
||||
gchar * artist_name;
|
||||
|
||||
|
||||
g_object_get(btn, "button-text", &artist_name, NULL);
|
||||
koto_page_music_local_go_to_artist_by_name(self, artist_name);
|
||||
}
|
||||
|
||||
void koto_page_music_local_set_library(
|
||||
KotoPageMusicLocal * self,
|
||||
KotoLibrary * lib
|
||||
) {
|
||||
if (lib == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->lib != NULL) { // If lib is already set
|
||||
g_free(self->lib);
|
||||
}
|
||||
|
||||
self->lib = lib;
|
||||
|
||||
void koto_page_music_local_build_ui(KotoPageMusicLocal * self) {
|
||||
if (!self->constructed) {
|
||||
return;
|
||||
}
|
||||
|
@ -259,14 +162,13 @@ void koto_page_music_local_set_library(
|
|||
gpointer artist_key;
|
||||
gpointer artist_data;
|
||||
|
||||
GHashTable * artists = koto_library_get_artists(self->lib); // Get the artists
|
||||
|
||||
GHashTable * artists = koto_cartographer_get_artists(koto_maps); // Get all 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
|
||||
KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, (gchar*) artist_data); // Cast our data as a KotoArtist
|
||||
KotoArtist * artist = artist_data; // Cast our artist_data as an artist
|
||||
|
||||
if (artist != NULL) {
|
||||
if (KOTO_IS_ARTIST(artist)) { // Is an artist
|
||||
koto_page_music_local_add_artist(self, artist);
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +186,6 @@ int koto_page_music_local_sort_artists(
|
|||
gchar * artist1_text;
|
||||
gchar * artist2_text;
|
||||
|
||||
|
||||
g_object_get(artist1_btn, "button-text", &artist1_text, NULL);
|
||||
g_object_get(artist2_btn, "button-text", &artist2_text, NULL);
|
||||
|
||||
|
|
|
@ -50,10 +50,7 @@ void koto_page_music_local_go_to_artist_by_uuid(
|
|||
gchar * artist_uuid
|
||||
);
|
||||
|
||||
void koto_page_music_local_set_library(
|
||||
KotoPageMusicLocal * self,
|
||||
KotoLibrary * lib
|
||||
);
|
||||
void koto_page_music_local_build_ui(KotoPageMusicLocal * self);
|
||||
|
||||
int koto_page_music_local_sort_artists(
|
||||
GtkListBoxRow * artist1,
|
||||
|
|
|
@ -101,7 +101,6 @@ static void koto_playlist_page_set_property(
|
|||
static void koto_playlist_page_class_init(KotoPlaylistPageClass * c) {
|
||||
GObjectClass * gobject_class;
|
||||
|
||||
|
||||
gobject_class = G_OBJECT_CLASS(c);
|
||||
gobject_class->get_property = koto_playlist_page_get_property;
|
||||
gobject_class->set_property = koto_playlist_page_set_property;
|
||||
|
@ -201,7 +200,6 @@ static void koto_playlist_page_get_property(
|
|||
) {
|
||||
KotoPlaylistPage * self = KOTO_PLAYLIST_PAGE(obj);
|
||||
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PLAYLIST_UUID:
|
||||
g_value_set_string(val, self->uuid);
|
||||
|
@ -220,7 +218,6 @@ static void koto_playlist_page_set_property(
|
|||
) {
|
||||
KotoPlaylistPage * self = KOTO_PLAYLIST_PAGE(obj);
|
||||
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PLAYLIST_UUID:
|
||||
koto_playlist_page_set_playlist_uuid(self, g_strdup(g_value_get_string(val))); // Call to our playlist UUID set function
|
||||
|
@ -245,7 +242,6 @@ void koto_playlist_page_bind_track_item(
|
|||
|
||||
KotoTrack * track = gtk_list_item_get_item(item); // Get the track UUID from our model
|
||||
|
||||
|
||||
if (!KOTO_IS_TRACK(track)) {
|
||||
return;
|
||||
}
|
||||
|
@ -254,7 +250,6 @@ void koto_playlist_page_bind_track_item(
|
|||
gchar * album_uuid = NULL;
|
||||
gchar * artist_uuid = NULL;
|
||||
|
||||
|
||||
g_object_get(
|
||||
track,
|
||||
"parsed-name",
|
||||
|
@ -268,20 +263,17 @@ void koto_playlist_page_bind_track_item(
|
|||
|
||||
guint track_position = koto_playlist_get_position_of_track(self->playlist, track);
|
||||
|
||||
|
||||
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
|
||||
|
||||
KotoAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, album_uuid);
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid);
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
|
@ -326,7 +318,6 @@ void koto_playlist_page_handle_action_bar_closed(
|
|||
(void) bar;
|
||||
KotoPlaylistPage * self = data;
|
||||
|
||||
|
||||
if (!KOTO_IS_PLAYLIST(self->playlist)) { // No playlist set
|
||||
return;
|
||||
}
|
||||
|
@ -348,7 +339,6 @@ void koto_playlist_page_handle_cover_art_clicked(
|
|||
(void) y;
|
||||
KotoPlaylistPage * self = user_data;
|
||||
|
||||
|
||||
if (!KOTO_IS_PLAYLIST(self->playlist)) { // No playlist set
|
||||
return;
|
||||
}
|
||||
|
@ -369,7 +359,6 @@ void koto_playlist_page_handle_edit_button_clicked(
|
|||
(void) y;
|
||||
KotoPlaylistPage * self = user_data;
|
||||
|
||||
|
||||
koto_create_modify_playlist_dialog_set_playlist_uuid(playlist_create_modify_dialog, koto_playlist_get_uuid(self->playlist));
|
||||
koto_window_show_dialog(main_window, "create-modify-playlist");
|
||||
}
|
||||
|
@ -384,21 +373,18 @@ void koto_playlist_page_handle_playlist_modified(
|
|||
|
||||
KotoPlaylistPage * self = user_data;
|
||||
|
||||
|
||||
if (!KOTO_IS_PLAYLIST_PAGE(self)) {
|
||||
return;
|
||||
}
|
||||
|
||||
gchar * artwork = koto_playlist_get_artwork(playlist); // Get the artwork
|
||||
|
||||
|
||||
if (koto_utils_is_string_valid(artwork)) { // Have valid artwork
|
||||
koto_cover_art_button_set_art_path(self->playlist_image, artwork); // Update our Koto Cover Art Button
|
||||
}
|
||||
|
||||
gchar * name = koto_playlist_get_name(playlist); // Get the name
|
||||
|
||||
|
||||
if (koto_utils_is_string_valid(name)) { // Have valid name
|
||||
gtk_label_set_label(GTK_LABEL(self->name_label), name); // Update the name label
|
||||
}
|
||||
|
@ -417,7 +403,6 @@ void koto_playlist_page_handle_track_album_clicked(
|
|||
(void) y;
|
||||
KotoPlaylistPage * self = user_data;
|
||||
|
||||
|
||||
gtk_widget_add_css_class(GTK_WIDGET(self->track_album_button), "active");
|
||||
koto_button_hide_image(self->track_num_button); // Go back to hiding the image
|
||||
koto_playlist_page_set_playlist_model(self, KOTO_PREFERRED_MODEL_TYPE_SORT_BY_ALBUM);
|
||||
|
@ -436,7 +421,6 @@ void koto_playlist_page_handle_track_artist_clicked(
|
|||
(void) y;
|
||||
KotoPlaylistPage * self = user_data;
|
||||
|
||||
|
||||
gtk_widget_add_css_class(GTK_WIDGET(self->track_artist_button), "active");
|
||||
koto_button_hide_image(self->track_num_button); // Go back to hiding the image
|
||||
koto_playlist_page_set_playlist_model(self, KOTO_PREFERRED_MODEL_TYPE_SORT_BY_ARTIST);
|
||||
|
@ -455,7 +439,6 @@ void koto_playlist_page_handle_track_name_clicked(
|
|||
(void) y;
|
||||
KotoPlaylistPage * self = user_data;
|
||||
|
||||
|
||||
gtk_widget_add_css_class(GTK_WIDGET(self->track_title_button), "active");
|
||||
koto_button_hide_image(self->track_num_button); // Go back to hiding the image
|
||||
koto_playlist_page_set_playlist_model(self, KOTO_PREFERRED_MODEL_TYPE_SORT_BY_TRACK_NAME);
|
||||
|
@ -476,7 +459,6 @@ void koto_playlist_page_handle_track_num_clicked(
|
|||
|
||||
KotoPreferredModelType current_model = koto_playlist_get_current_model(self->playlist);
|
||||
|
||||
|
||||
if (current_model == KOTO_PREFERRED_MODEL_TYPE_DEFAULT) { // Set to newest currently
|
||||
koto_playlist_page_set_playlist_model(self, KOTO_PREFERRED_MODEL_TYPE_OLDEST_FIRST); // Sort reversed (oldest)
|
||||
koto_button_show_image(self->track_num_button, TRUE); // Use inverted value (pan-up-symbolic)
|
||||
|
@ -495,7 +477,6 @@ void koto_playlist_page_handle_tracks_selected(
|
|||
(void) position;
|
||||
KotoPlaylistPage * self = user_data;
|
||||
|
||||
|
||||
if (n_items == 0) { // No items selected
|
||||
koto_action_bar_toggle_reveal(action_bar, FALSE); // Hide the action bar
|
||||
return;
|
||||
|
@ -508,7 +489,6 @@ void koto_playlist_page_handle_tracks_selected(
|
|||
|
||||
guint first_track_pos;
|
||||
|
||||
|
||||
if (!gtk_bitset_iter_init_first(&iter, selected_items_bitset, &first_track_pos)) { // Failed to get the first item
|
||||
return;
|
||||
}
|
||||
|
@ -517,7 +497,6 @@ void koto_playlist_page_handle_tracks_selected(
|
|||
|
||||
gboolean have_more_items = TRUE;
|
||||
|
||||
|
||||
while (have_more_items) { // While we are able to get selected items
|
||||
guint track_pos;
|
||||
have_more_items = gtk_bitset_iter_next(&iter, &track_pos);
|
||||
|
@ -528,7 +507,6 @@ void koto_playlist_page_handle_tracks_selected(
|
|||
|
||||
GList * cur_pos_list;
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
|
@ -561,7 +539,6 @@ void koto_playlist_page_set_playlist_uuid(
|
|||
self->uuid = g_strdup(playlist_uuid); // Duplicate the playlist UUID
|
||||
KotoPlaylist * playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, self->uuid);
|
||||
|
||||
|
||||
self->playlist = playlist;
|
||||
koto_playlist_page_set_playlist_model(self, KOTO_PREFERRED_MODEL_TYPE_DEFAULT); // TODO: Enable this to be changed
|
||||
koto_playlist_page_update_header(self); // Update our header
|
||||
|
@ -606,19 +583,16 @@ void koto_playlist_page_setup_track_item(
|
|||
(void) factory;
|
||||
KotoPlaylistPage * self = user_data;
|
||||
|
||||
|
||||
if (!KOTO_IS_PLAYLIST_PAGE(self)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GtkWidget * item_content = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); // Have a horizontal box for our content
|
||||
|
||||
|
||||
gtk_widget_add_css_class(item_content, "track-list-columned-item");
|
||||
|
||||
GtkWidget * track_number = gtk_label_new(NULL); // Our track number
|
||||
|
||||
|
||||
gtk_label_set_xalign(GTK_LABEL(track_number), 0);
|
||||
gtk_widget_add_css_class(track_number, "track-column-number");
|
||||
gtk_widget_set_halign(track_number, GTK_ALIGN_END);
|
||||
|
@ -629,7 +603,6 @@ void koto_playlist_page_setup_track_item(
|
|||
|
||||
GtkWidget * track_name = gtk_label_new(NULL); // Our track name
|
||||
|
||||
|
||||
gtk_label_set_xalign(GTK_LABEL(track_name), 0);
|
||||
gtk_widget_add_css_class(track_name, "track-column-name");
|
||||
gtk_widget_set_halign(track_name, GTK_ALIGN_START);
|
||||
|
@ -640,7 +613,6 @@ void koto_playlist_page_setup_track_item(
|
|||
|
||||
GtkWidget * track_album = gtk_label_new(NULL); // Our track album
|
||||
|
||||
|
||||
gtk_label_set_xalign(GTK_LABEL(track_album), 0);
|
||||
gtk_widget_add_css_class(track_album, "track-column-album");
|
||||
gtk_widget_set_halign(track_album, GTK_ALIGN_START);
|
||||
|
@ -652,7 +624,6 @@ void koto_playlist_page_setup_track_item(
|
|||
|
||||
GtkWidget * track_artist = gtk_label_new(NULL); // Our track artist
|
||||
|
||||
|
||||
gtk_label_set_xalign(GTK_LABEL(track_artist), 0);
|
||||
gtk_widget_add_css_class(track_artist, "track-column-artist");
|
||||
gtk_widget_set_halign(track_artist, GTK_ALIGN_START);
|
||||
|
@ -676,7 +647,6 @@ void koto_playlist_page_update_header(KotoPlaylistPage * self) {
|
|||
|
||||
gboolean ephemeral = TRUE;
|
||||
|
||||
|
||||
g_object_get(
|
||||
self->playlist,
|
||||
"ephemeral",
|
||||
|
@ -689,19 +659,16 @@ void koto_playlist_page_update_header(KotoPlaylistPage * self) {
|
|||
gtk_label_set_text(GTK_LABEL(self->name_label), koto_playlist_get_name(self->playlist)); // Set the name label to our playlist name
|
||||
guint track_count = koto_playlist_get_length(self->playlist); // Get the number of tracks
|
||||
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(self->tracks_count_label), g_strdup_printf(track_count != 1 ? "%u tracks" : "%u track", track_count)); // Set the text to "N tracks" where N is the number
|
||||
|
||||
gchar * artwork = koto_playlist_get_artwork(self->playlist);
|
||||
|
||||
|
||||
if (koto_utils_is_string_valid(artwork)) { // Have artwork
|
||||
koto_cover_art_button_set_art_path(self->playlist_image, artwork); // Update our artwork
|
||||
}
|
||||
|
||||
KotoPreferredModelType current_model = koto_playlist_get_current_model(self->playlist); // Get the current model
|
||||
|
||||
|
||||
if (current_model == KOTO_PREFERRED_MODEL_TYPE_OLDEST_FIRST) {
|
||||
koto_button_show_image(self->track_num_button, TRUE); // Immediately use pan-up-symbolic
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ G_DECLARE_FINAL_TYPE(KotoPlaylistPage, koto_playlist_page, KOTO, PLAYLIST_PAGE,
|
|||
KotoPlaylistPage * koto_playlist_page_new(gchar * playlist_uuid);
|
||||
|
||||
void koto_playlist_page_add_track(
|
||||
KotoPlaylistPage* self,
|
||||
KotoPlaylistPage * self,
|
||||
const gchar * track_uuid
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue