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:
Joshua Strobl 2021-05-27 16:58:28 +03:00
parent 8334323af8
commit bfe4891620
33 changed files with 146 additions and 623 deletions

View file

@ -153,14 +153,14 @@ sp_paren_brace = force # ignore/add/remove/force
sp_brace_brace = ignore # ignore/add/remove/force sp_brace_brace = ignore # ignore/add/remove/force
# Add or remove space before pointer star '*'. # Add or remove space before pointer star '*'.
sp_before_ptr_star = ignore # ignore/add/remove/force sp_before_ptr_star = force # ignore/add/remove/force
# Add or remove space before pointer star '*' that isn't followed by a # Add or remove space before pointer star '*' that isn't followed by a
# variable name. If set to ignore, sp_before_ptr_star is used instead. # variable name. If set to ignore, sp_before_ptr_star is used instead.
sp_before_unnamed_ptr_star = remove # ignore/add/remove/force sp_before_unnamed_ptr_star = remove # ignore/add/remove/force
# Add or remove space between pointer stars '*'. # Add or remove space between pointer stars '*'.
sp_between_ptr_star = ignore # ignore/add/remove/force sp_between_ptr_star = remove # ignore/add/remove/force
# Add or remove space after pointer star '*', if followed by a word. # Add or remove space after pointer star '*', if followed by a word.
# #

View file

@ -72,12 +72,11 @@ struct _KotoActionBarClass {
G_DEFINE_TYPE(KotoActionBar, koto_action_bar, G_TYPE_OBJECT); G_DEFINE_TYPE(KotoActionBar, koto_action_bar, G_TYPE_OBJECT);
KotoActionBar* action_bar; KotoActionBar * action_bar;
static void koto_action_bar_class_init(KotoActionBarClass * c) { static void koto_action_bar_class_init(KotoActionBarClass * c) {
GObjectClass * gobject_class = G_OBJECT_CLASS(c); GObjectClass * gobject_class = G_OBJECT_CLASS(c);
actionbar_signals[SIGNAL_CLOSED] = g_signal_new( actionbar_signals[SIGNAL_CLOSED] = g_signal_new(
"closed", "closed",
G_TYPE_FROM_CLASS(gobject_class), G_TYPE_FROM_CLASS(gobject_class),
@ -185,7 +184,6 @@ void koto_action_bar_handle_go_to_artist_button_clicked(
(void) button; (void) button;
KotoActionBar * self = data; KotoActionBar * self = data;
if (!KOTO_IS_ACTION_BAR(self)) { if (!KOTO_IS_ACTION_BAR(self)) {
return; return;
} }
@ -196,14 +194,12 @@ void koto_action_bar_handle_go_to_artist_button_clicked(
KotoTrack * 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_TRACK(selected_track)) { // Not a track if (!KOTO_IS_TRACK(selected_track)) { // Not a track
return; return;
} }
gchar * artist_uuid = NULL; gchar * artist_uuid = NULL;
g_object_get( g_object_get(
selected_track, selected_track,
"artist-uuid", "artist-uuid",
@ -222,7 +218,6 @@ void koto_action_bar_handle_playlists_button_clicked(
(void) button; (void) button;
KotoActionBar * self = data; KotoActionBar * self = data;
if (!KOTO_IS_ACTION_BAR(self)) { if (!KOTO_IS_ACTION_BAR(self)) {
return; return;
} }
@ -279,7 +274,6 @@ void koto_action_bar_handle_remove_from_playlist_button_clicked(
(void) button; (void) button;
KotoActionBar * self = data; KotoActionBar * self = data;
if (!KOTO_IS_ACTION_BAR(self)) { if (!KOTO_IS_ACTION_BAR(self)) {
return; return;
} }
@ -294,14 +288,12 @@ void koto_action_bar_handle_remove_from_playlist_button_clicked(
KotoPlaylist * playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, self->current_playlist_uuid); KotoPlaylist * playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, self->current_playlist_uuid);
if (!KOTO_IS_PLAYLIST(playlist)) { // Not a playlist if (!KOTO_IS_PLAYLIST(playlist)) { // Not a playlist
goto doclose; goto doclose;
} }
GList * cur_list; GList * cur_list;
for (cur_list = self->current_list; cur_list != NULL; cur_list = cur_list->next) { // For each KotoTrack for (cur_list = self->current_list; cur_list != NULL; cur_list = cur_list->next) { // For each KotoTrack
KotoTrack * track = cur_list->data; KotoTrack * track = cur_list->data;
koto_playlist_remove_track_by_uuid(playlist, koto_track_get_uuid(track)); // Remove this track koto_playlist_remove_track_by_uuid(playlist, koto_track_get_uuid(track)); // Remove this track
@ -371,7 +363,6 @@ void koto_action_bar_set_tracks_in_playlist_selection(
gboolean single_selected = g_list_length(tracks) == 1; gboolean single_selected = g_list_length(tracks) == 1;
koto_action_bar_toggle_go_to_artist_visibility(self, single_selected); koto_action_bar_toggle_go_to_artist_visibility(self, single_selected);
koto_action_bar_toggle_play_button_visibility(self, single_selected); koto_action_bar_toggle_play_button_visibility(self, single_selected);
gtk_widget_hide(GTK_WIDGET(self->playlists)); gtk_widget_hide(GTK_WIDGET(self->playlists));

View file

@ -107,7 +107,6 @@ static void koto_cover_art_button_init(KotoCoverArtButton * self) {
GtkWidget * controls = gtk_center_box_new(); // Create a center box for the controls GtkWidget * controls = gtk_center_box_new(); // Create a center box for the controls
self->play_pause_button = koto_button_new_with_icon("", "media-playback-start-symbolic", "media-playback-pause-symbolic", KOTO_BUTTON_PIXBUF_SIZE_NORMAL); self->play_pause_button = koto_button_new_with_icon("", "media-playback-start-symbolic", "media-playback-pause-symbolic", KOTO_BUTTON_PIXBUF_SIZE_NORMAL);
gtk_center_box_set_center_widget(GTK_CENTER_BOX(controls), GTK_WIDGET(self->play_pause_button)); gtk_center_box_set_center_widget(GTK_CENTER_BOX(controls), GTK_WIDGET(self->play_pause_button));
@ -117,7 +116,6 @@ static void koto_cover_art_button_init(KotoCoverArtButton * self) {
GtkEventController * motion_controller = gtk_event_controller_motion_new(); // Create our new motion event controller to track mouse leave and enter GtkEventController * motion_controller = gtk_event_controller_motion_new(); // Create our new motion event controller to track mouse leave and enter
g_signal_connect(motion_controller, "enter", G_CALLBACK(koto_cover_art_button_show_overlay_controls), self); g_signal_connect(motion_controller, "enter", G_CALLBACK(koto_cover_art_button_show_overlay_controls), self);
g_signal_connect(motion_controller, "leave", G_CALLBACK(koto_cover_art_button_hide_overlay_controls), self); g_signal_connect(motion_controller, "leave", G_CALLBACK(koto_cover_art_button_hide_overlay_controls), self);
gtk_widget_add_controller(self->main, motion_controller); gtk_widget_add_controller(self->main, motion_controller);
@ -146,7 +144,6 @@ static void koto_cover_art_button_set_property(
) { ) {
KotoCoverArtButton * self = KOTO_COVER_ART_BUTTON(obj); KotoCoverArtButton * self = KOTO_COVER_ART_BUTTON(obj);
switch (prop_id) { switch (prop_id) {
case PROP_ART_PATH: case PROP_ART_PATH:
koto_cover_art_button_set_art_path(self, (gchar*) g_value_get_string(val)); // Get the value and call our set_art_path with it koto_cover_art_button_set_art_path(self, (gchar*) g_value_get_string(val)); // Get the value and call our set_art_path with it
@ -168,8 +165,7 @@ void koto_cover_art_button_hide_overlay_controls(
gpointer data gpointer data
) { ) {
(void) controller; (void) controller;
KotoCoverArtButton* self = data; KotoCoverArtButton * self = data;
gtk_revealer_set_reveal_child(GTK_REVEALER(self->revealer), FALSE); gtk_revealer_set_reveal_child(GTK_REVEALER(self->revealer), FALSE);
} }
@ -243,8 +239,7 @@ void koto_cover_art_button_show_overlay_controls(
gpointer data gpointer data
) { ) {
(void) controller; (void) controller;
KotoCoverArtButton* self = data; KotoCoverArtButton * self = data;
gtk_revealer_set_reveal_child(GTK_REVEALER(self->revealer), TRUE); gtk_revealer_set_reveal_child(GTK_REVEALER(self->revealer), TRUE);
} }

View file

@ -40,6 +40,7 @@ struct _KotoCartographer {
GHashTable * albums; GHashTable * albums;
GHashTable * artists; GHashTable * artists;
GHashTable * artists_name_to_uuid;
GHashTable * playlists; GHashTable * playlists;
GHashTable * tracks; GHashTable * tracks;
}; };
@ -88,7 +89,6 @@ KotoCartographer * koto_maps = NULL;
static void koto_cartographer_class_init(KotoCartographerClass * c) { static void koto_cartographer_class_init(KotoCartographerClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
cartographer_signals[SIGNAL_ALBUM_ADDED] = g_signal_new( cartographer_signals[SIGNAL_ALBUM_ADDED] = g_signal_new(
@ -199,6 +199,7 @@ static void koto_cartographer_class_init(KotoCartographerClass * c) {
static void koto_cartographer_init(KotoCartographer * self) { static void koto_cartographer_init(KotoCartographer * self) {
self->albums = g_hash_table_new(g_str_hash, g_str_equal); self->albums = g_hash_table_new(g_str_hash, g_str_equal);
self->artists = g_hash_table_new(g_str_hash, g_str_equal); self->artists = g_hash_table_new(g_str_hash, g_str_equal);
self->artists_name_to_uuid = g_hash_table_new(g_str_hash, g_str_equal);
self->playlists = g_hash_table_new(g_str_hash, g_str_equal); self->playlists = g_hash_table_new(g_str_hash, g_str_equal);
self->tracks = g_hash_table_new(g_str_hash, g_str_equal); self->tracks = g_hash_table_new(g_str_hash, g_str_equal);
} }
@ -209,7 +210,6 @@ void koto_cartographer_add_album(
) { ) {
gchar * album_uuid = NULL; gchar * album_uuid = NULL;
g_object_get(album, "uuid", &album_uuid, NULL); g_object_get(album, "uuid", &album_uuid, NULL);
if ((album_uuid == NULL) || koto_cartographer_has_album_by_uuid(self, album_uuid)) { // Have the album or invalid UUID if ((album_uuid == NULL) || koto_cartographer_has_album_by_uuid(self, album_uuid)) { // Have the album or invalid UUID
@ -230,8 +230,11 @@ void koto_cartographer_add_artist(
KotoCartographer * self, KotoCartographer * self,
KotoArtist * artist KotoArtist * artist
) { ) {
gchar * artist_uuid = NULL; if (!KOTO_IS_ARTIST(artist)) { // Not an artist
return;
}
gchar * artist_uuid = NULL;
g_object_get(artist, "uuid", &artist_uuid, NULL); g_object_get(artist, "uuid", &artist_uuid, NULL);
@ -239,6 +242,8 @@ void koto_cartographer_add_artist(
return; return;
} }
g_hash_table_replace(self->artists_name_to_uuid, koto_artist_get_name(artist), koto_artist_get_uuid(artist)); // Add the UUID as a value with the key being the name of the artist
g_hash_table_replace(self->artists, artist_uuid, artist); g_hash_table_replace(self->artists, artist_uuid, artist);
g_signal_emit( g_signal_emit(
@ -288,7 +293,6 @@ void koto_cartographer_add_track(
) { ) {
gchar * track_uuid = NULL; gchar * track_uuid = NULL;
g_object_get(track, "uuid", &track_uuid, NULL); g_object_get(track, "uuid", &track_uuid, NULL);
if ((track_uuid == NULL) || koto_cartographer_has_track_by_uuid(self, track_uuid)) { // Have the track or invalid UUID if ((track_uuid == NULL) || koto_cartographer_has_track_by_uuid(self, track_uuid)) { // Have the track or invalid UUID
@ -307,15 +311,34 @@ void koto_cartographer_add_track(
KotoAlbum * koto_cartographer_get_album_by_uuid( KotoAlbum * koto_cartographer_get_album_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* album_uuid gchar * album_uuid
) { ) {
return g_hash_table_lookup(self->albums, album_uuid); return g_hash_table_lookup(self->albums, album_uuid);
} }
GHashTable * koto_cartographer_get_artists(KotoCartographer * self) {
return self->artists;
}
KotoArtist * koto_cartographer_get_artist_by_name(
KotoCartographer * self,
gchar * artist_name
) {
if (!koto_utils_is_string_valid(artist_name)) { // Not a valid name
return NULL;
}
return koto_cartographer_get_artist_by_uuid(self, g_hash_table_lookup(self->artists_name_to_uuid, artist_name));
}
KotoArtist * koto_cartographer_get_artist_by_uuid( KotoArtist * koto_cartographer_get_artist_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* artist_uuid gchar * artist_uuid
) { ) {
if (!koto_utils_is_string_valid(artist_uuid)) {
return NULL;
}
return g_hash_table_lookup(self->artists, artist_uuid); return g_hash_table_lookup(self->artists, artist_uuid);
} }
@ -325,14 +348,14 @@ GHashTable * koto_cartographer_get_playlists(KotoCartographer * self) {
KotoPlaylist * koto_cartographer_get_playlist_by_uuid( KotoPlaylist * koto_cartographer_get_playlist_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* playlist_uuid gchar * playlist_uuid
) { ) {
return g_hash_table_lookup(self->playlists, playlist_uuid); return g_hash_table_lookup(self->playlists, playlist_uuid);
} }
KotoTrack * koto_cartographer_get_track_by_uuid( KotoTrack * koto_cartographer_get_track_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* track_uuid gchar * track_uuid
) { ) {
return g_hash_table_lookup(self->tracks, track_uuid); return g_hash_table_lookup(self->tracks, track_uuid);
} }
@ -343,14 +366,13 @@ gboolean koto_cartographer_has_album(
) { ) {
gchar * album_uuid = NULL; gchar * album_uuid = NULL;
g_object_get(album, "uuid", &album_uuid, NULL); g_object_get(album, "uuid", &album_uuid, NULL);
return koto_cartographer_has_album_by_uuid(self, album_uuid); return koto_cartographer_has_album_by_uuid(self, album_uuid);
} }
gboolean koto_cartographer_has_album_by_uuid( gboolean koto_cartographer_has_album_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* album_uuid gchar * album_uuid
) { ) {
if (album_uuid == NULL) { if (album_uuid == NULL) {
return FALSE; return FALSE;
@ -365,14 +387,13 @@ gboolean koto_cartographer_has_artist(
) { ) {
gchar * artist_uuid = NULL; gchar * artist_uuid = NULL;
g_object_get(artist, "uuid", &artist_uuid, NULL); g_object_get(artist, "uuid", &artist_uuid, NULL);
return koto_cartographer_has_artist_by_uuid(self, artist_uuid); return koto_cartographer_has_artist_by_uuid(self, artist_uuid);
} }
gboolean koto_cartographer_has_artist_by_uuid( gboolean koto_cartographer_has_artist_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* artist_uuid gchar * artist_uuid
) { ) {
if (artist_uuid == NULL) { if (artist_uuid == NULL) {
return FALSE; return FALSE;
@ -387,14 +408,13 @@ gboolean koto_cartographer_has_playlist(
) { ) {
gchar * playlist_uuid = NULL; gchar * playlist_uuid = NULL;
g_object_get(playlist, "uuid", &playlist_uuid, NULL); g_object_get(playlist, "uuid", &playlist_uuid, NULL);
return koto_cartographer_has_playlist_by_uuid(self, playlist_uuid); return koto_cartographer_has_playlist_by_uuid(self, playlist_uuid);
} }
gboolean koto_cartographer_has_playlist_by_uuid( gboolean koto_cartographer_has_playlist_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* playlist_uuid gchar * playlist_uuid
) { ) {
if (playlist_uuid == NULL) { if (playlist_uuid == NULL) {
return FALSE; return FALSE;
@ -409,14 +429,13 @@ gboolean koto_cartographer_has_track(
) { ) {
gchar * track_uuid = NULL; gchar * track_uuid = NULL;
g_object_get(track, "uuid", &track_uuid, NULL); g_object_get(track, "uuid", &track_uuid, NULL);
return koto_cartographer_has_album_by_uuid(self, track_uuid); return koto_cartographer_has_album_by_uuid(self, track_uuid);
} }
gboolean koto_cartographer_has_track_by_uuid( gboolean koto_cartographer_has_track_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* track_uuid gchar * track_uuid
) { ) {
if (track_uuid == NULL) { if (track_uuid == NULL) {
return FALSE; return FALSE;
@ -431,14 +450,13 @@ void koto_cartographer_remove_album(
) { ) {
gchar * album_uuid = NULL; gchar * album_uuid = NULL;
g_object_get(album, "uuid", &album_uuid, NULL); g_object_get(album, "uuid", &album_uuid, NULL);
koto_cartographer_remove_album_by_uuid(self, album_uuid); koto_cartographer_remove_album_by_uuid(self, album_uuid);
} }
void koto_cartographer_remove_album_by_uuid( void koto_cartographer_remove_album_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* album_uuid gchar * album_uuid
) { ) {
if (album_uuid != NULL) { if (album_uuid != NULL) {
g_hash_table_remove(self->albums, album_uuid); g_hash_table_remove(self->albums, album_uuid);
@ -456,18 +474,25 @@ void koto_cartographer_remove_artist(
KotoCartographer * self, KotoCartographer * self,
KotoArtist * artist KotoArtist * artist
) { ) {
gchar * artist_uuid = NULL; if (!KOTO_IS_ARTIST(artist)) { // Not an artist
return;
}
gchar * artist_uuid = NULL;
g_object_get(artist, "uuid", &artist_uuid, NULL); g_object_get(artist, "uuid", &artist_uuid, NULL);
koto_cartographer_remove_artist_by_uuid(self, artist_uuid); koto_cartographer_remove_artist_by_uuid(self, artist_uuid);
g_hash_table_remove(self->artists_name_to_uuid, koto_artist_get_name(artist)); // Add the UUID as a value with the key being the name of the artist
} }
void koto_cartographer_remove_artist_by_uuid( void koto_cartographer_remove_artist_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* artist_uuid gchar * artist_uuid
) { ) {
if (artist_uuid == NULL) { if (!koto_utils_is_string_valid(artist_uuid)) { // Artist UUID not valid
return;
}
g_hash_table_remove(self->artists, artist_uuid); g_hash_table_remove(self->artists, artist_uuid);
g_signal_emit( g_signal_emit(
@ -476,7 +501,6 @@ void koto_cartographer_remove_artist_by_uuid(
0, 0,
artist_uuid artist_uuid
); );
}
} }
void koto_cartographer_remove_playlist( void koto_cartographer_remove_playlist(
@ -485,14 +509,13 @@ void koto_cartographer_remove_playlist(
) { ) {
gchar * playlist_uuid = NULL; gchar * playlist_uuid = NULL;
g_object_get(playlist, "uuid", &playlist_uuid, NULL); g_object_get(playlist, "uuid", &playlist_uuid, NULL);
koto_cartographer_remove_playlist_by_uuid(self, playlist_uuid); koto_cartographer_remove_playlist_by_uuid(self, playlist_uuid);
} }
void koto_cartographer_remove_playlist_by_uuid( void koto_cartographer_remove_playlist_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* playlist_uuid gchar * playlist_uuid
) { ) {
if (!koto_utils_is_string_valid(playlist_uuid)) { // Not a valid playlist UUID string if (!koto_utils_is_string_valid(playlist_uuid)) { // Not a valid playlist UUID string
return; return;
@ -520,14 +543,13 @@ void koto_cartographer_remove_track(
) { ) {
gchar * track_uuid = NULL; gchar * track_uuid = NULL;
g_object_get(track, "uuid", &track_uuid, NULL); g_object_get(track, "uuid", &track_uuid, NULL);
koto_cartographer_remove_track_by_uuid(self, track_uuid); koto_cartographer_remove_track_by_uuid(self, track_uuid);
} }
void koto_cartographer_remove_track_by_uuid( void koto_cartographer_remove_track_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* track_uuid gchar * track_uuid
) { ) {
if (track_uuid != NULL) { if (track_uuid != NULL) {
g_hash_table_remove(self->tracks, track_uuid); g_hash_table_remove(self->tracks, track_uuid);

View file

@ -67,24 +67,31 @@ void koto_cartographer_emit_playlist_added(
KotoAlbum * koto_cartographer_get_album_by_uuid( KotoAlbum * koto_cartographer_get_album_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* album_uuid gchar * album_uuid
);
GHashTable * koto_cartographer_get_artists(KotoCartographer * self);
KotoArtist * koto_cartographer_get_artist_by_name(
KotoCartographer * self,
gchar * artist_name
); );
KotoArtist * koto_cartographer_get_artist_by_uuid( KotoArtist * koto_cartographer_get_artist_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* artist_uuid gchar * artist_uuid
); );
KotoPlaylist * koto_cartographer_get_playlist_by_uuid( KotoPlaylist * koto_cartographer_get_playlist_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* playlist_uuid gchar * playlist_uuid
); );
GHashTable * koto_cartographer_get_playlists(KotoCartographer * self); GHashTable * koto_cartographer_get_playlists(KotoCartographer * self);
KotoTrack * koto_cartographer_get_track_by_uuid( KotoTrack * koto_cartographer_get_track_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* track_uuid gchar * track_uuid
); );
gboolean koto_cartographer_has_album( gboolean koto_cartographer_has_album(
@ -94,7 +101,7 @@ gboolean koto_cartographer_has_album(
gboolean koto_cartographer_has_album_by_uuid( gboolean koto_cartographer_has_album_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* album_uuid gchar * album_uuid
); );
gboolean koto_cartographer_has_artist( gboolean koto_cartographer_has_artist(
@ -104,7 +111,7 @@ gboolean koto_cartographer_has_artist(
gboolean koto_cartographer_has_artist_by_uuid( gboolean koto_cartographer_has_artist_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* artist_uuid gchar * artist_uuid
); );
gboolean koto_cartographer_has_playlist( gboolean koto_cartographer_has_playlist(
@ -114,7 +121,7 @@ gboolean koto_cartographer_has_playlist(
gboolean koto_cartographer_has_playlist_by_uuid( gboolean koto_cartographer_has_playlist_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* playlist_uuid gchar * playlist_uuid
); );
gboolean koto_cartographer_has_track( gboolean koto_cartographer_has_track(
@ -124,7 +131,7 @@ gboolean koto_cartographer_has_track(
gboolean koto_cartographer_has_track_by_uuid( gboolean koto_cartographer_has_track_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* track_uuid gchar * track_uuid
); );
void koto_cartographer_remove_album( void koto_cartographer_remove_album(
@ -134,7 +141,7 @@ void koto_cartographer_remove_album(
void koto_cartographer_remove_album_by_uuid( void koto_cartographer_remove_album_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* album_uuid gchar * album_uuid
); );
void koto_cartographer_remove_artist( void koto_cartographer_remove_artist(
@ -144,7 +151,7 @@ void koto_cartographer_remove_artist(
void koto_cartographer_remove_artist_by_uuid( void koto_cartographer_remove_artist_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* artist_uuid gchar * artist_uuid
); );
void koto_cartographer_remove_playlist( void koto_cartographer_remove_playlist(
@ -154,7 +161,7 @@ void koto_cartographer_remove_playlist(
void koto_cartographer_remove_playlist_by_uuid( void koto_cartographer_remove_playlist_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* playlist_uuid gchar * playlist_uuid
); );
void koto_cartographer_remove_track( void koto_cartographer_remove_track(
@ -164,7 +171,7 @@ void koto_cartographer_remove_track(
void koto_cartographer_remove_track_by_uuid( void koto_cartographer_remove_track_by_uuid(
KotoCartographer * self, KotoCartographer * self,
gchar* track_uuid gchar * track_uuid
); );
G_END_DECLS G_END_DECLS

View file

@ -77,7 +77,6 @@ static void koto_album_set_property(
static void koto_album_class_init(KotoAlbumClass * c) { static void koto_album_class_init(KotoAlbumClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
gobject_class->set_property = koto_album_set_property; gobject_class->set_property = koto_album_set_property;
gobject_class->get_property = koto_album_get_property; gobject_class->get_property = koto_album_get_property;
@ -148,10 +147,10 @@ void koto_album_add_track(
gchar * track_uuid; gchar * track_uuid;
g_object_get(track, "uuid", &track_uuid, NULL); g_object_get(track, "uuid", &track_uuid, NULL);
if (g_list_index(self->tracks, track_uuid) == -1) { if (g_list_index(self->tracks, track_uuid) == -1) {
koto_cartographer_add_track(koto_maps, track); // Add the track to cartographer
self->tracks = g_list_insert_sorted_with_data(self->tracks, track_uuid, koto_album_sort_tracks, NULL); self->tracks = g_list_insert_sorted_with_data(self->tracks, track_uuid, koto_album_sort_tracks, NULL);
} }
} }
@ -175,7 +174,6 @@ void koto_album_commit(KotoAlbum * self) {
gchar * commit_op_errmsg = NULL; gchar * commit_op_errmsg = NULL;
int rc = sqlite3_exec(koto_db, commit_op, 0, 0, &commit_op_errmsg); int rc = sqlite3_exec(koto_db, commit_op, 0, 0, &commit_op_errmsg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
g_warning("Failed to write our album to the database: %s", commit_op_errmsg); g_warning("Failed to write our album to the database: %s", commit_op_errmsg);
} }
@ -187,7 +185,6 @@ void koto_album_commit(KotoAlbum * self) {
void koto_album_find_album_art(KotoAlbum * self) { void koto_album_find_album_art(KotoAlbum * self) {
magic_t magic_cookie = magic_open(MAGIC_MIME); magic_t magic_cookie = magic_open(MAGIC_MIME);
if (magic_cookie == NULL) { if (magic_cookie == NULL) {
return; return;
} }
@ -199,14 +196,12 @@ void koto_album_find_album_art(KotoAlbum * self) {
DIR * dir = opendir(self->path); // Attempt to open our directory DIR * dir = opendir(self->path); // Attempt to open our directory
if (dir == NULL) { if (dir == NULL) {
return; return;
} }
struct dirent * entry; struct dirent * entry;
while ((entry = readdir(dir))) { while ((entry = readdir(dir))) {
if (entry->d_type != DT_REG) { // Not a regular file if (entry->d_type != DT_REG) { // Not a regular file
continue; // SKIP continue; // SKIP
@ -274,14 +269,12 @@ void koto_album_find_tracks(
DIR * dir = opendir(path); // Attempt to open our directory DIR * dir = opendir(path); // Attempt to open our directory
if (dir == NULL) { if (dir == NULL) {
return; return;
} }
struct dirent * entry; struct dirent * entry;
while ((entry = readdir(dir))) { while ((entry = readdir(dir))) {
if (g_str_has_prefix(entry->d_name, ".")) { // Reference to parent dir, self, or a hidden item if (g_str_has_prefix(entry->d_name, ".")) { // Reference to parent dir, self, or a hidden item
continue; // Skip continue; // Skip
@ -353,7 +346,6 @@ static void koto_album_get_property(
) { ) {
KotoAlbum * self = KOTO_ALBUM(obj); KotoAlbum * self = KOTO_ALBUM(obj);
switch (prop_id) { switch (prop_id) {
case PROP_UUID: case PROP_UUID:
g_value_set_string(val, self->uuid); g_value_set_string(val, self->uuid);
@ -387,7 +379,6 @@ static void koto_album_set_property(
) { ) {
KotoAlbum * self = KOTO_ALBUM(obj); KotoAlbum * self = KOTO_ALBUM(obj);
switch (prop_id) { switch (prop_id) {
case PROP_UUID: case PROP_UUID:
self->uuid = g_strdup(g_value_get_string(val)); self->uuid = g_strdup(g_value_get_string(val));
@ -489,7 +480,6 @@ void koto_album_remove_file(
gchar * track_uuid; gchar * track_uuid;
g_object_get(track, "parsed-name", &track_uuid, NULL); g_object_get(track, "parsed-name", &track_uuid, NULL);
self->tracks = g_list_remove(self->tracks, track_uuid); self->tracks = g_list_remove(self->tracks, track_uuid);
} }
@ -551,14 +541,12 @@ void koto_album_set_as_current_playlist(KotoAlbum * self) {
// e.g. first track (0) being added last is actually first in the playlist's tracks // e.g. first track (0) being added last is actually first in the playlist's tracks
GList * reversed_tracks = g_list_copy(self->tracks); // Copy our tracks so we can reverse the order GList * reversed_tracks = g_list_copy(self->tracks); // Copy our tracks so we can reverse the order
reversed_tracks = g_list_reverse(reversed_tracks); // Actually reverse it reversed_tracks = g_list_reverse(reversed_tracks); // Actually reverse it
GList * t; GList * t;
for (t = reversed_tracks; t != NULL; t = t->next) { // For each of the tracks for (t = reversed_tracks; t != NULL; t = t->next) { // For each of the tracks
gchar* track_uuid = t->data; gchar * track_uuid = t->data;
koto_playlist_add_track_by_uuid(new_album_playlist, track_uuid, FALSE, FALSE); // Add the UUID, skip commit to table since it is temporary koto_playlist_add_track_by_uuid(new_album_playlist, track_uuid, FALSE, FALSE); // Add the UUID, skip commit to table since it is temporary
} }
@ -578,7 +566,6 @@ gint koto_album_sort_tracks(
KotoTrack * track1 = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) track1_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); KotoTrack * track2 = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) track2_uuid);
if ((track1 == NULL) && (track2 == NULL)) { // Neither tracks actually exist if ((track1 == NULL) && (track2 == NULL)) { // Neither tracks actually exist
return 0; return 0;
} else if ((track1 != NULL) && (track2 == NULL)) { // Only track2 does not exist } else if ((track1 != NULL) && (track2 == NULL)) { // Only track2 does not exist
@ -590,7 +577,6 @@ gint koto_album_sort_tracks(
guint * track1_disc = (guint*) 1; guint * track1_disc = (guint*) 1;
guint * track2_disc = (guint*) 2; guint * track2_disc = (guint*) 2;
g_object_get(track1, "cd", &track1_disc, NULL); g_object_get(track1, "cd", &track1_disc, NULL);
g_object_get(track2, "cd", &track2_disc, NULL); g_object_get(track2, "cd", &track2_disc, NULL);
@ -603,7 +589,6 @@ gint koto_album_sort_tracks(
guint16 * track1_pos; guint16 * track1_pos;
guint16 * track2_pos; guint16 * track2_pos;
g_object_get(track1, "position", &track1_pos, NULL); g_object_get(track1, "position", &track1_pos, NULL);
g_object_get(track2, "position", &track2_pos, NULL); g_object_get(track2, "position", &track2_pos, NULL);
@ -624,7 +609,7 @@ gint koto_album_sort_tracks(
void koto_album_update_path( void koto_album_update_path(
KotoAlbum * self, KotoAlbum * self,
gchar* new_path gchar * new_path
) { ) {
if (!KOTO_IS_ALBUM(self)) { // Not an album if (!KOTO_IS_ALBUM(self)) { // Not an album
return; return;
@ -654,10 +639,9 @@ KotoAlbum * koto_album_new(
) { ) {
gchar * artist_uuid = NULL; gchar * artist_uuid = NULL;
g_object_get(artist, "uuid", &artist_uuid, NULL); g_object_get(artist, "uuid", &artist_uuid, NULL);
KotoAlbum* album = g_object_new( KotoAlbum * album = g_object_new(
KOTO_TYPE_ALBUM, KOTO_TYPE_ALBUM,
"artist-uuid", "artist-uuid",
artist_uuid, artist_uuid,
@ -670,7 +654,6 @@ KotoAlbum * koto_album_new(
NULL NULL
); );
koto_album_commit(album); koto_album_commit(album);
koto_album_find_tracks(album, NULL, NULL); // Scan for tracks now that we committed to the database (hopefully) koto_album_find_tracks(album, NULL, NULL); // Scan for tracks now that we committed to the database (hopefully)
@ -683,7 +666,6 @@ KotoAlbum * koto_album_new_with_uuid(
) { ) {
gchar * artist_uuid = NULL; gchar * artist_uuid = NULL;
g_object_get(artist, "uuid", &artist_uuid, NULL); g_object_get(artist, "uuid", &artist_uuid, NULL);
return g_object_new( return g_object_new(

View file

@ -64,7 +64,6 @@ static void koto_artist_set_property(
static void koto_artist_class_init(KotoArtistClass * c) { static void koto_artist_class_init(KotoArtistClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
gobject_class->set_property = koto_artist_set_property; gobject_class->set_property = koto_artist_set_property;
gobject_class->get_property = koto_artist_get_property; gobject_class->get_property = koto_artist_get_property;
@ -114,7 +113,6 @@ void koto_artist_commit(KotoArtist * self) {
gchar * commit_opt_errmsg = NULL; gchar * commit_opt_errmsg = NULL;
int rc = sqlite3_exec(koto_db, commit_op, 0, 0, &commit_opt_errmsg); int rc = sqlite3_exec(koto_db, commit_op, 0, 0, &commit_opt_errmsg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
g_warning("Failed to write our artist to the database: %s", commit_opt_errmsg); g_warning("Failed to write our artist to the database: %s", commit_opt_errmsg);
} }
@ -136,7 +134,6 @@ static void koto_artist_get_property(
) { ) {
KotoArtist * self = KOTO_ARTIST(obj); KotoArtist * self = KOTO_ARTIST(obj);
switch (prop_id) { switch (prop_id) {
case PROP_UUID: case PROP_UUID:
g_value_set_string(val, self->uuid); g_value_set_string(val, self->uuid);
@ -161,7 +158,6 @@ static void koto_artist_set_property(
) { ) {
KotoArtist * self = KOTO_ARTIST(obj); KotoArtist * self = KOTO_ARTIST(obj);
switch (prop_id) { switch (prop_id) {
case PROP_UUID: case PROP_UUID:
self->uuid = g_strdup(g_value_get_string(val)); self->uuid = g_strdup(g_value_get_string(val));
@ -193,7 +189,6 @@ void koto_artist_add_album(
gchar * uuid = g_strdup(album_uuid); // Duplicate our UUID gchar * uuid = g_strdup(album_uuid); // Duplicate our UUID
if (g_list_index(self->albums, uuid) == -1) { if (g_list_index(self->albums, uuid) == -1) {
self->albums = g_list_append(self->albums, uuid); // Push to end of list self->albums = g_list_append(self->albums, uuid); // Push to end of list
} }
@ -215,6 +210,10 @@ gchar * koto_artist_get_name(KotoArtist * self) {
return g_strdup(koto_utils_is_string_valid(self->artist_name) ? self->artist_name : ""); // Return artist name if set return g_strdup(koto_utils_is_string_valid(self->artist_name) ? self->artist_name : ""); // Return artist name if set
} }
gchar * koto_artist_get_uuid(KotoArtist * self) {
return self->uuid;
}
void koto_artist_remove_album( void koto_artist_remove_album(
KotoArtist * self, KotoArtist * self,
KotoAlbum * album KotoAlbum * album
@ -229,7 +228,6 @@ void koto_artist_remove_album(
gchar * album_uuid; gchar * album_uuid;
g_object_get(album, "uuid", &album_uuid, NULL); g_object_get(album, "uuid", &album_uuid, NULL);
self->albums = g_list_remove(self->albums, album_uuid); self->albums = g_list_remove(self->albums, album_uuid);
} }
@ -275,7 +273,7 @@ void koto_artist_set_artist_name(
} }
KotoArtist * koto_artist_new(gchar * path) { KotoArtist * koto_artist_new(gchar * path) {
KotoArtist* artist = g_object_new( KotoArtist * artist = g_object_new(
KOTO_TYPE_ARTIST, KOTO_TYPE_ARTIST,
"uuid", "uuid",
g_uuid_string_random(), g_uuid_string_random(),
@ -286,7 +284,6 @@ KotoArtist * koto_artist_new(gchar * path) {
NULL NULL
); );
koto_artist_commit(artist); // Commit the artist immediately to the database koto_artist_commit(artist); // Commit the artist immediately to the database
return artist; return artist;
} }

View file

@ -31,9 +31,17 @@ extern sqlite3 * koto_db;
struct _KotoLibrary { struct _KotoLibrary {
GObject parent_instance; GObject parent_instance;
gchar * path;
gchar * path; // Compat
gchar * directory;
gchar * name;
KotoLibraryType type;
gchar * uuid;
gboolean override_builtin;
magic_t magic_cookie; magic_t magic_cookie;
GHashTable * music_artists;
}; };
G_DEFINE_TYPE(KotoLibrary, koto_library, G_TYPE_OBJECT); G_DEFINE_TYPE(KotoLibrary, koto_library, G_TYPE_OBJECT);
@ -82,76 +90,7 @@ static void koto_library_class_init(KotoLibraryClass * c) {
} }
static void koto_library_init(KotoLibrary * self) { static void koto_library_init(KotoLibrary * self) {
self->music_artists = g_hash_table_new(g_str_hash, g_str_equal); (void) self;
}
void koto_library_add_artist(
KotoLibrary * self,
KotoArtist * artist
) {
if (artist == NULL) { // No artist
return;
}
koto_library_get_artists(self); // Call to generate if needed
gchar * artist_name;
gchar * artist_uuid;
g_object_get(artist, "name", &artist_name, "uuid", &artist_uuid, NULL);
if (g_hash_table_contains(self->music_artists, artist_name)) { // Already have the artist
g_free(artist_name);
return;
}
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)
}
KotoArtist * koto_library_get_artist(
KotoLibrary * self,
gchar * artist_name
) {
if (artist_name == NULL) {
return NULL;
}
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) {
KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid); // Return any artist from cartographer
return artist;
} else {
return NULL;
}
}
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);
}
return self->music_artists;
}
void koto_library_remove_artist(
KotoLibrary * self,
KotoArtist * artist
) {
if (artist == NULL) {
return;
}
koto_library_get_artists(self); // Call to generate if needed
gchar * artist_name;
g_object_get(artist, "name", &artist_name, NULL);
g_hash_table_remove(self->music_artists, artist_name); // Remove the artist
} }
static void koto_library_get_property( static void koto_library_get_property(
@ -162,7 +101,6 @@ static void koto_library_get_property(
) { ) {
KotoLibrary * self = KOTO_LIBRARY(obj); KotoLibrary * self = KOTO_LIBRARY(obj);
switch (prop_id) { switch (prop_id) {
case PROP_PATH: case PROP_PATH:
g_value_set_string(val, self->path); g_value_set_string(val, self->path);
@ -181,7 +119,6 @@ static void koto_library_set_property(
) { ) {
KotoLibrary * self = KOTO_LIBRARY(obj); KotoLibrary * self = KOTO_LIBRARY(obj);
switch (prop_id) { switch (prop_id) {
case PROP_PATH: case PROP_PATH:
koto_library_set_path(self, g_strdup(g_value_get_string(val))); koto_library_set_path(self, g_strdup(g_value_get_string(val)));
@ -219,10 +156,10 @@ int process_artists(
char ** fields, char ** fields,
char ** column_names char ** column_names
) { ) {
(void) data;
(void) num_columns; (void) num_columns;
(void) column_names; // Don't need any of the params (void) column_names; // Don't need any of the params
KotoLibrary * library = (KotoLibrary*) data;
gchar * artist_uuid = g_strdup(koto_utils_unquote_string(fields[0])); // First column is UUID 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_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 gchar * artist_name = g_strdup(koto_utils_unquote_string(fields[3])); // Fourth column is artist name
@ -238,11 +175,9 @@ int process_artists(
NULL); NULL);
koto_cartographer_add_artist(koto_maps, artist); // Add the artist to our global cartographer koto_cartographer_add_artist(koto_maps, artist); // Add the artist to our global cartographer
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 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
if (albums_rc != SQLITE_OK) { // Failed to get our albums if (albums_rc != SQLITE_OK) { // Failed to get our albums
g_critical("Failed to read our albums: %s", sqlite3_errmsg(koto_db)); g_critical("Failed to read our albums: %s", sqlite3_errmsg(koto_db));
return 1; return 1;
@ -274,7 +209,6 @@ int process_albums(
KotoAlbum * album = koto_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( g_object_set(
album, album,
"path", "path",
@ -290,7 +224,6 @@ int process_albums(
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 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
if (tracks_rc != SQLITE_OK) { // Failed to get our tracks if (tracks_rc != SQLITE_OK) { // Failed to get our tracks
g_critical("Failed to read our tracks: %s", sqlite3_errmsg(koto_db)); g_critical("Failed to read our tracks: %s", sqlite3_errmsg(koto_db));
return 1; return 1;
@ -324,7 +257,6 @@ int process_playlists(
KotoPlaylist * playlist = koto_playlist_new_with_uuid(playlist_uuid); // Create a playlist using the existing UUID KotoPlaylist * playlist = koto_playlist_new_with_uuid(playlist_uuid); // Create a playlist using the existing UUID
koto_playlist_set_name(playlist, playlist_name); // Add the playlist name koto_playlist_set_name(playlist, playlist_name); // Add the playlist name
koto_playlist_set_artwork(playlist, playlist_art_path); // Add the playlist art path koto_playlist_set_artwork(playlist, playlist_art_path); // Add the playlist art path
@ -332,7 +264,6 @@ int process_playlists(
int playlist_tracks_rc = sqlite3_exec(koto_db, g_strdup_printf("SELECT * FROM playlist_tracks WHERE playlist_id=\"%s\" ORDER BY position ASC", playlist_uuid), process_playlists_tracks, playlist, NULL); // Process our playlist tracks int playlist_tracks_rc = sqlite3_exec(koto_db, g_strdup_printf("SELECT * FROM playlist_tracks WHERE playlist_id=\"%s\" ORDER BY position ASC", playlist_uuid), process_playlists_tracks, playlist, NULL); // Process our playlist tracks
if (playlist_tracks_rc != SQLITE_OK) { // Failed to get our playlist tracks if (playlist_tracks_rc != SQLITE_OK) { // Failed to get our playlist tracks
g_critical("Failed to read our playlist tracks: %s", sqlite3_errmsg(koto_db)); g_critical("Failed to read our playlist tracks: %s", sqlite3_errmsg(koto_db));
return 1; return 1;
@ -364,7 +295,6 @@ int process_playlists_tracks(
KotoPlaylist * playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, playlist_uuid); // Get the playlist KotoPlaylist * playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, playlist_uuid); // Get the playlist
KotoTrack * 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)) { if (!KOTO_IS_PLAYLIST(playlist)) {
goto freeforret; goto freeforret;
} }
@ -399,10 +329,8 @@ int process_tracks(
KotoTrack * track = koto_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); 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_album_add_track(album, track); // Add the track koto_album_add_track(album, track); // Add the track
g_free(track_uuid); g_free(track_uuid);
@ -423,8 +351,6 @@ void read_from_db(KotoLibrary * self) {
return; return;
} }
g_hash_table_foreach(self->music_artists, output_artists, NULL);
int playlist_rc = sqlite3_exec(koto_db, "SELECT * FROM playlist_meta", process_playlists, self, NULL); // Process our playlists int playlist_rc = sqlite3_exec(koto_db, "SELECT * FROM playlist_meta", process_playlists, self, NULL); // Process our playlists
if (playlist_rc != SQLITE_OK) { // Failed to get our playlists if (playlist_rc != SQLITE_OK) { // Failed to get our playlists
@ -437,7 +363,6 @@ void start_indexing(KotoLibrary * self) {
struct stat library_stat; struct stat library_stat;
int success = stat(self->path, &library_stat); int success = stat(self->path, &library_stat);
if (success != 0) { // Failed to read the library path if (success != 0) { // Failed to read the library path
return; return;
} }
@ -460,7 +385,6 @@ void start_indexing(KotoLibrary * self) {
index_folder(self, self->path, 0); index_folder(self, self->path, 0);
magic_close(self->magic_cookie); magic_close(self->magic_cookie);
g_hash_table_foreach(self->music_artists, output_artists, NULL);
} }
KotoLibrary * koto_library_new(const gchar * path) { KotoLibrary * koto_library_new(const gchar * path) {
@ -481,14 +405,12 @@ void index_folder(
DIR * dir = opendir(path); // Attempt to open our directory DIR * dir = opendir(path); // Attempt to open our directory
if (dir == NULL) { if (dir == NULL) {
return; return;
} }
struct dirent * entry; struct dirent * entry;
while ((entry = readdir(dir))) { while ((entry = readdir(dir))) {
if (g_str_has_prefix(entry->d_name, ".")) { // A reference to parent dir, self, or a hidden item if (g_str_has_prefix(entry->d_name, ".")) { // A reference to parent dir, self, or a hidden item
continue; continue;
@ -509,14 +431,13 @@ void index_folder(
); );
koto_cartographer_add_artist(koto_maps, artist); // Add the artist to cartographer koto_cartographer_add_artist(koto_maps, artist); // Add the artist to cartographer
koto_library_add_artist(self, artist); // Add the artist
index_folder(self, full_path, depth); // Index this directory index_folder(self, full_path, depth); // Index this directory
g_free(artist_name); g_free(artist_name);
} else if (depth == 2) { // If we are following FOLDER/ARTIST/ALBUM then this would be album } 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 gchar * artist_name = g_path_get_basename(path); // Get the last entry from our path which is probably the artist
KotoArtist * artist = koto_library_get_artist(self, artist_name); // Get the artist KotoArtist * artist = koto_cartographer_get_artist_by_name(koto_maps, artist_name);
if (artist == NULL) { if (!KOTO_IS_ARTIST(artist)) { // Not an artist
continue; continue;
} }
@ -535,73 +456,3 @@ void index_folder(
closedir(dir); // Close the directory closedir(dir); // Close the directory
} }
void output_artists(
gpointer artist_key,
gpointer artist_ptr,
gpointer data
) {
(void) artist_ptr;
(void) data;
KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, (gchar*) artist_key);
if (artist == NULL) {
return;
}
gchar * artist_name;
g_object_get(artist, "name", &artist_name, NULL);
g_message("Artist: %s", artist_name);
GList * albums = koto_artist_get_albums(artist); // Get the albums for this artist
if (albums != NULL) {
g_message("Length of Albums: %d", g_list_length(albums));
}
GList * a;
for (a = albums; a != NULL; a = a->next) {
gchar * album_uuid = a->data;
KotoAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, album_uuid);
if (album == NULL) {
continue;
}
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_album_get_tracks(album), output_track, NULL);
}
}
void output_track(
gpointer data,
gpointer user_data
) {
(void) user_data;
KotoTrack * track = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) data);
if (track == NULL) {
return;
}
gchar * filepath;
gchar * parsed_name;
guint * pos;
g_object_get(track, "path", &filepath, "parsed-name", &parsed_name, "position", &pos, NULL);
g_debug("File Path: %s", filepath);
g_debug("Parsed Name: %s", parsed_name);
g_debug("Position: %d", GPOINTER_TO_INT(pos));
g_free(filepath);
g_free(parsed_name);
}

View file

@ -19,6 +19,12 @@
#include <glib-2.0/glib-object.h> #include <glib-2.0/glib-object.h>
#include <magic.h> #include <magic.h>
typedef enum {
KOTO_LIBRARY_TYPE_AUDIOBOOK = 1,
KOTO_LIBRARY_TYPE_MUSIC = 2,
KOTO_LIBRARY_TYPE_PODCAST = 3
} KotoLibraryType;
G_BEGIN_DECLS G_BEGIN_DECLS
/** /**
@ -47,23 +53,6 @@ G_DECLARE_FINAL_TYPE(KotoTrack, koto_track, KOTO, TRACK, GObject);
KotoLibrary * koto_library_new(const gchar * path); KotoLibrary * koto_library_new(const gchar * path);
void koto_library_add_artist(
KotoLibrary * self,
KotoArtist * artist
);
KotoArtist * koto_library_get_artist(
KotoLibrary * self,
gchar* artist_name
);
GHashTable * koto_library_get_artists(KotoLibrary * self);
void koto_library_remove_artist(
KotoLibrary * self,
KotoArtist * artist
);
void koto_library_set_path( void koto_library_set_path(
KotoLibrary * self, KotoLibrary * self,
gchar * path gchar * path
@ -114,11 +103,6 @@ void index_folder(
guint depth guint depth
); );
void output_track(
gpointer data,
gpointer user_data
);
/** /**
* Artist Functions * Artist Functions
**/ **/
@ -143,6 +127,8 @@ GList * koto_artist_get_albums(KotoArtist * self);
gchar * koto_artist_get_name(KotoArtist * self); gchar * koto_artist_get_name(KotoArtist * self);
gchar * koto_artist_get_uuid(KotoArtist * self);
void koto_artist_remove_album( void koto_artist_remove_album(
KotoArtist * self, KotoArtist * self,
KotoAlbum * album KotoAlbum * album
@ -163,12 +149,6 @@ void koto_artist_update_path(
gchar * new_path gchar * new_path
); );
void output_artists(
gpointer artist_key,
gpointer artist_ptr,
gpointer data
);
/** /**
* Album Functions * Album Functions
**/ **/

View file

@ -80,7 +80,6 @@ static void koto_track_set_property(
static void koto_track_class_init(KotoTrackClass * c) { static void koto_track_class_init(KotoTrackClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
gobject_class->set_property = koto_track_set_property; gobject_class->set_property = koto_track_set_property;
gobject_class->get_property = koto_track_get_property; gobject_class->get_property = koto_track_get_property;
@ -186,7 +185,6 @@ static void koto_track_get_property(
) { ) {
KotoTrack * self = KOTO_TRACK(obj); KotoTrack * self = KOTO_TRACK(obj);
switch (prop_id) { switch (prop_id) {
case PROP_ARTIST_UUID: case PROP_ARTIST_UUID:
g_value_set_string(val, self->artist_uuid); g_value_set_string(val, self->artist_uuid);
@ -229,7 +227,6 @@ static void koto_track_set_property(
) { ) {
KotoTrack * self = KOTO_TRACK(obj); KotoTrack * self = KOTO_TRACK(obj);
switch (prop_id) { switch (prop_id) {
case PROP_ARTIST_UUID: case PROP_ARTIST_UUID:
self->artist_uuid = g_strdup(g_value_get_string(val)); self->artist_uuid = g_strdup(g_value_get_string(val));
@ -270,7 +267,6 @@ static void koto_track_set_property(
} }
} }
void koto_track_commit(KotoTrack * self) { void koto_track_commit(KotoTrack * self) {
if ((self->artist_uuid == NULL) || (strcmp(self->artist_uuid, "") == 0)) { // No valid required artist UUID if ((self->artist_uuid == NULL) || (strcmp(self->artist_uuid, "") == 0)) { // No valid required artist UUID
return; return;
@ -297,7 +293,6 @@ void koto_track_commit(KotoTrack * self) {
gchar * commit_op_errmsg = NULL; gchar * commit_op_errmsg = NULL;
int rc = sqlite3_exec(koto_db, commit_op, 0, 0, &commit_op_errmsg); int rc = sqlite3_exec(koto_db, commit_op, 0, 0, &commit_op_errmsg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
g_warning("Failed to write our file to the database: %s", commit_op_errmsg); g_warning("Failed to write our file to the database: %s", commit_op_errmsg);
} }
@ -320,7 +315,6 @@ GVariant * koto_track_get_metadata_vardict(KotoTrack * self) {
KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, self->artist_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); 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); g_object_get(album, "art-path", &album_art_path, "name", &album_name, NULL);
g_object_get(artist, "name", &artist_name, NULL); g_object_get(artist, "name", &artist_name, NULL);
@ -352,7 +346,6 @@ GVariant * koto_track_get_metadata_vardict(KotoTrack * self) {
GVariant * metadata_ret = g_variant_builder_end(builder); GVariant * metadata_ret = g_variant_builder_end(builder);
return metadata_ret; return metadata_ret;
} }
@ -369,7 +362,6 @@ void koto_track_parse_name(KotoTrack * self) {
KotoArtist * artist = NULL; KotoArtist * artist = NULL;
artist = koto_cartographer_get_artist_by_uuid(koto_maps, self->artist_uuid); artist = koto_cartographer_get_artist_by_uuid(koto_maps, self->artist_uuid);
if (artist != NULL) { // If we have artist if (artist != NULL) { // If we have artist
@ -389,12 +381,10 @@ void koto_track_parse_name(KotoTrack * self) {
gchar * file_without_ext = koto_utils_get_filename_without_extension(copied_file_name); gchar * file_without_ext = koto_utils_get_filename_without_extension(copied_file_name);
g_free(copied_file_name); g_free(copied_file_name);
gchar ** split = g_regex_split_simple("^([\\d]+)", file_without_ext, G_REGEX_JAVASCRIPT_COMPAT, 0); gchar ** split = g_regex_split_simple("^([\\d]+)", file_without_ext, G_REGEX_JAVASCRIPT_COMPAT, 0);
if (g_strv_length(split) > 1) { // Has positional info at the beginning of the file if (g_strv_length(split) > 1) { // Has positional info at the beginning of the file
gchar * num = split[1]; gchar * num = split[1];
@ -443,7 +433,6 @@ void koto_track_remove_from_playlist(
gchar * commit_op_errmsg = NULL; gchar * commit_op_errmsg = NULL;
int rc = sqlite3_exec(koto_db, commit_op, 0, 0, &commit_op_errmsg); int rc = sqlite3_exec(koto_db, commit_op, 0, 0, &commit_op_errmsg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
g_warning("Failed to remove track from playlist: %s", commit_op_errmsg); g_warning("Failed to remove track from playlist: %s", commit_op_errmsg);
} }
@ -472,7 +461,6 @@ void koto_track_save_to_playlist(
gchar * commit_op_errmsg = NULL; gchar * commit_op_errmsg = NULL;
int rc = sqlite3_exec(koto_db, commit_op, 0, 0, &commit_op_errmsg); int rc = sqlite3_exec(koto_db, commit_op, 0, 0, &commit_op_errmsg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
g_warning("Failed to save track to playlist: %s", commit_op_errmsg); g_warning("Failed to save track to playlist: %s", commit_op_errmsg);
} }
@ -552,7 +540,6 @@ void koto_track_set_position(
void koto_track_update_metadata(KotoTrack * self) { void koto_track_update_metadata(KotoTrack * self) {
TagLib_File * t_file = taglib_file_new(self->path); // Get a taglib file for this file 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 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; self->acquired_metadata_from_id3 = TRUE;
TagLib_Tag * tag = taglib_file_tag(t_file); // Get our tag TagLib_Tag * tag = taglib_file_tag(t_file); // Get our tag
@ -596,7 +583,6 @@ KotoTrack * koto_track_new(
gchar * artist_uuid; gchar * artist_uuid;
gchar * album_uuid; gchar * album_uuid;
g_object_get(album, "artist-uuid", &artist_uuid, "uuid", &album_uuid, NULL); // Get the artist and album uuids from our Album g_object_get(album, "artist-uuid", &artist_uuid, "uuid", &album_uuid, NULL); // Get the artist and album uuids from our Album
KotoTrack * track = g_object_new( KotoTrack * track = g_object_new(
@ -616,7 +602,6 @@ KotoTrack * koto_track_new(
NULL NULL
); );
koto_track_commit(track); // Immediately commit to the database koto_track_commit(track); // Immediately commit to the database
return track; return track;
} }

View file

@ -210,7 +210,6 @@ static void koto_button_get_property(
) { ) {
KotoButton * self = KOTO_BUTTON(obj); KotoButton * self = KOTO_BUTTON(obj);
switch (prop_id) { switch (prop_id) {
case PROP_IMAGE_FILE_PATH: case PROP_IMAGE_FILE_PATH:
g_value_set_string(val, self->image_file_path); g_value_set_string(val, self->image_file_path);
@ -247,7 +246,6 @@ static void koto_button_set_property(
) { ) {
KotoButton * self = KOTO_BUTTON(obj); KotoButton * self = KOTO_BUTTON(obj);
switch (prop_id) { switch (prop_id) {
case PROP_PIX_SIZE: case PROP_PIX_SIZE:
koto_button_set_pixbuf_size(self, g_value_get_uint(val)); koto_button_set_pixbuf_size(self, g_value_get_uint(val));
@ -370,7 +368,6 @@ void koto_button_set_icon_name(
) { ) {
gchar * copied_icon_name = g_strdup(icon_name); gchar * copied_icon_name = g_strdup(icon_name);
if (for_alt) { // Is for the alternate icon if (for_alt) { // Is for the alternate icon
if ((self->alt_icon_name != NULL) && strcmp(icon_name, self->alt_icon_name) != 0) { // If the icons are different if ((self->alt_icon_name != NULL) && strcmp(icon_name, self->alt_icon_name) != 0) { // If the icons are different
g_free(self->alt_icon_name); g_free(self->alt_icon_name);
@ -387,7 +384,6 @@ void koto_button_set_icon_name(
gboolean hide_image = FALSE; gboolean hide_image = FALSE;
if (for_alt && self->currently_showing_alt && ((self->alt_icon_name == NULL) || strcmp(self->alt_icon_name, "") == 0)) { // For alt, alt is currently showing, and no longer have alt if (for_alt && self->currently_showing_alt && ((self->alt_icon_name == NULL) || strcmp(self->alt_icon_name, "") == 0)) { // For alt, alt is currently showing, and no longer have alt
hide_image = TRUE; hide_image = TRUE;
} else if (!for_alt && ((self->icon_name == NULL) || (strcmp(self->icon_name, "") == 0))) { // Not for alt, no icon } else if (!for_alt && ((self->icon_name == NULL) || (strcmp(self->icon_name, "") == 0))) { // Not for alt, no icon

View file

@ -73,7 +73,6 @@ static void koto_expander_set_property(
static void koto_expander_class_init(KotoExpanderClass * c) { static void koto_expander_class_init(KotoExpanderClass * c) {
GObjectClass * gobject_class = G_OBJECT_CLASS(c); GObjectClass * gobject_class = G_OBJECT_CLASS(c);
gobject_class->set_property = koto_expander_set_property; gobject_class->set_property = koto_expander_set_property;
gobject_class->get_property = koto_expander_get_property; gobject_class->get_property = koto_expander_get_property;
@ -120,7 +119,6 @@ static void koto_expander_get_property(
) { ) {
KotoExpander * self = KOTO_EXPANDER(obj); KotoExpander * self = KOTO_EXPANDER(obj);
switch (prop_id) { switch (prop_id) {
case PROP_HEADER_ICON_NAME: case PROP_HEADER_ICON_NAME:
g_value_set_string(val, self->icon_name); g_value_set_string(val, self->icon_name);
@ -148,7 +146,6 @@ static void koto_expander_set_property(
) { ) {
KotoExpander * self = KOTO_EXPANDER(obj); KotoExpander * self = KOTO_EXPANDER(obj);
if (!GTK_IS_WIDGET(self->header_button)) { // Header Button is not a widget if (!GTK_IS_WIDGET(self->header_button)) { // Header Button is not a widget
KotoButton * new_button = koto_button_new_with_icon(NULL, "emblem-favorite-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_SMALL); KotoButton * new_button = koto_button_new_with_icon(NULL, "emblem-favorite-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_SMALL);
@ -183,7 +180,6 @@ static void koto_expander_set_property(
static void koto_expander_init(KotoExpander * self) { static void koto_expander_init(KotoExpander * self) {
GtkStyleContext * style = gtk_widget_get_style_context(GTK_WIDGET(self)); GtkStyleContext * style = gtk_widget_get_style_context(GTK_WIDGET(self));
gtk_style_context_add_class(style, "expander"); gtk_style_context_add_class(style, "expander");
gtk_widget_set_hexpand((GTK_WIDGET(self)), TRUE); gtk_widget_set_hexpand((GTK_WIDGET(self)), TRUE);
@ -191,7 +187,6 @@ static void koto_expander_init(KotoExpander * self) {
GtkStyleContext * header_style = gtk_widget_get_style_context(self->header); GtkStyleContext * header_style = gtk_widget_get_style_context(self->header);
gtk_style_context_add_class(header_style, "expander-header"); gtk_style_context_add_class(header_style, "expander-header");
self->revealer = gtk_revealer_new(); self->revealer = gtk_revealer_new();
@ -265,12 +260,10 @@ void koto_expander_toggle_content(
(void) n_press; (void) n_press;
(void) x; (void) x;
(void) y; (void) y;
KotoExpander* self = data; KotoExpander * self = data;
koto_button_flip(KOTO_BUTTON(self->header_expand_button)); koto_button_flip(KOTO_BUTTON(self->header_expand_button));
GtkRevealer* rev = GTK_REVEALER(self->revealer); GtkRevealer * rev = GTK_REVEALER(self->revealer);
gtk_revealer_set_reveal_child(rev, !gtk_revealer_get_reveal_child(rev)); // Invert our values gtk_revealer_set_reveal_child(rev, !gtk_revealer_get_reveal_child(rev)); // Invert our values
} }

View file

@ -90,7 +90,6 @@ static void koto_nav_init(KotoNav * self) {
KotoButton * h_button = koto_button_new_with_icon("Home", "user-home-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_SMALL); KotoButton * h_button = koto_button_new_with_icon("Home", "user-home-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_SMALL);
if (h_button != NULL) { if (h_button != NULL) {
self->home_button = h_button; self->home_button = h_button;
gtk_box_append(GTK_BOX(self->content), GTK_WIDGET(self->home_button)); gtk_box_append(GTK_BOX(self->content), GTK_WIDGET(self->home_button));
@ -105,13 +104,11 @@ static void koto_nav_init(KotoNav * self) {
void koto_nav_create_audiobooks_section(KotoNav * self) { void koto_nav_create_audiobooks_section(KotoNav * self) {
KotoExpander * a_expander = koto_expander_new("ephy-bookmarks-symbolic", "Audiobooks"); KotoExpander * a_expander = koto_expander_new("ephy-bookmarks-symbolic", "Audiobooks");
self->audiobook_expander = a_expander; self->audiobook_expander = a_expander;
gtk_box_append(GTK_BOX(self->content), GTK_WIDGET(self->audiobook_expander)); gtk_box_append(GTK_BOX(self->content), GTK_WIDGET(self->audiobook_expander));
GtkWidget * new_content = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); GtkWidget * new_content = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
koto_expander_set_content(a_expander, new_content); koto_expander_set_content(a_expander, new_content);
self->audiobooks_local = koto_button_new_plain("Local Library"); self->audiobooks_local = koto_button_new_plain("Local Library");
@ -126,13 +123,11 @@ void koto_nav_create_audiobooks_section(KotoNav * self) {
void koto_nav_create_music_section(KotoNav * self) { void koto_nav_create_music_section(KotoNav * self) {
KotoExpander * m_expander = koto_expander_new("emblem-music-symbolic", "Music"); KotoExpander * m_expander = koto_expander_new("emblem-music-symbolic", "Music");
self->music_expander = m_expander; self->music_expander = m_expander;
gtk_box_append(GTK_BOX(self->content), GTK_WIDGET(self->music_expander)); gtk_box_append(GTK_BOX(self->content), GTK_WIDGET(self->music_expander));
GtkWidget * new_content = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); GtkWidget * new_content = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
self->music_local = koto_button_new_plain("Local Library"); self->music_local = koto_button_new_plain("Local Library");
self->music_radio = koto_button_new_plain("Radio"); self->music_radio = koto_button_new_plain("Radio");
@ -147,14 +142,12 @@ void koto_nav_create_playlist_section(KotoNav * self) {
KotoButton * playlist_add_button = koto_button_new_with_icon("", "list-add-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_SMALL); KotoButton * playlist_add_button = koto_button_new_with_icon("", "list-add-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_SMALL);
KotoExpander * pl_expander = koto_expander_new_with_button("playlist-symbolic", "Playlists", playlist_add_button); KotoExpander * pl_expander = koto_expander_new_with_button("playlist-symbolic", "Playlists", playlist_add_button);
self->playlists_expander = pl_expander; self->playlists_expander = pl_expander;
gtk_box_append(GTK_BOX(self->content), GTK_WIDGET(self->playlists_expander)); gtk_box_append(GTK_BOX(self->content), GTK_WIDGET(self->playlists_expander));
// TODO: Turn into ListBox to sort playlists // TODO: Turn into ListBox to sort playlists
GtkWidget * playlist_list = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); GtkWidget * playlist_list = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
koto_expander_set_content(self->playlists_expander, playlist_list); koto_expander_set_content(self->playlists_expander, playlist_list);
koto_button_add_click_handler(playlist_add_button, KOTO_BUTTON_CLICK_TYPE_PRIMARY, G_CALLBACK(koto_nav_handle_playlist_add_click), NULL); koto_button_add_click_handler(playlist_add_button, KOTO_BUTTON_CLICK_TYPE_PRIMARY, G_CALLBACK(koto_nav_handle_playlist_add_click), NULL);
@ -165,13 +158,11 @@ void koto_nav_create_playlist_section(KotoNav * self) {
void koto_nav_create_podcasts_section(KotoNav * self) { void koto_nav_create_podcasts_section(KotoNav * self) {
KotoExpander * p_expander = koto_expander_new("microphone-sensitivity-high-symbolic", "Podcasts"); KotoExpander * p_expander = koto_expander_new("microphone-sensitivity-high-symbolic", "Podcasts");
self->podcast_expander = p_expander; self->podcast_expander = p_expander;
gtk_box_append(GTK_BOX(self->content), GTK_WIDGET(self->podcast_expander)); gtk_box_append(GTK_BOX(self->content), GTK_WIDGET(self->podcast_expander));
GtkWidget * new_content = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); GtkWidget * new_content = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
self->podcasts_local = koto_button_new_plain("Library"); self->podcasts_local = koto_button_new_plain("Library");
self->podcasts_discover = koto_button_new_plain("Find New Podcasts"); self->podcasts_discover = koto_button_new_plain("Find New Podcasts");
@ -224,7 +215,6 @@ void koto_nav_handle_playlist_button_click(
(void) y; (void) y;
gchar * playlist_uuid = user_data; gchar * playlist_uuid = user_data;
koto_window_go_to_page(main_window, playlist_uuid); // Go to the playlist page koto_window_go_to_page(main_window, playlist_uuid); // Go to the playlist page
} }
@ -240,14 +230,12 @@ void koto_nav_handle_playlist_added(
KotoNav * self = user_data; KotoNav * self = user_data;
if (!KOTO_IS_NAV(self)) { if (!KOTO_IS_NAV(self)) {
return; return;
} }
gchar * playlist_uuid = koto_playlist_get_uuid(playlist); // Get the UUID for a playlist gchar * playlist_uuid = koto_playlist_get_uuid(playlist); // Get the UUID for a playlist
if (g_hash_table_contains(self->playlist_buttons, playlist_uuid)) { // Already added button if (g_hash_table_contains(self->playlist_buttons, playlist_uuid)) { // Already added button
g_free(playlist_uuid); g_free(playlist_uuid);
return; return;
@ -257,7 +245,6 @@ void koto_nav_handle_playlist_added(
gchar * playlist_art_path = koto_playlist_get_artwork(playlist); // Get any file path for it gchar * playlist_art_path = koto_playlist_get_artwork(playlist); // Get any file path for it
KotoButton * playlist_button = NULL; KotoButton * playlist_button = NULL;
if (koto_utils_is_string_valid(playlist_art_path)) { // Have a file associated if (koto_utils_is_string_valid(playlist_art_path)) { // Have a file associated
playlist_button = koto_button_new_with_file(playlist_name, playlist_art_path, KOTO_BUTTON_PIXBUF_SIZE_NORMAL); playlist_button = koto_button_new_with_file(playlist_name, playlist_art_path, KOTO_BUTTON_PIXBUF_SIZE_NORMAL);
} else { // No file associated } else { // No file associated
@ -290,7 +277,6 @@ void koto_nav_handle_playlist_modified(
KotoNav * self = user_data; KotoNav * self = user_data;
if (!KOTO_IS_NAV(self)) { if (!KOTO_IS_NAV(self)) {
return; return;
} }
@ -299,21 +285,18 @@ void koto_nav_handle_playlist_modified(
KotoButton * playlist_button = g_hash_table_lookup(self->playlist_buttons, playlist_uuid); KotoButton * playlist_button = g_hash_table_lookup(self->playlist_buttons, playlist_uuid);
if (!KOTO_IS_BUTTON(playlist_button)) { if (!KOTO_IS_BUTTON(playlist_button)) {
return; return;
} }
gchar * artwork = koto_playlist_get_artwork(playlist); // Get the artwork gchar * artwork = koto_playlist_get_artwork(playlist); // Get the artwork
if (koto_utils_is_string_valid(artwork)) { // Have valid artwork if (koto_utils_is_string_valid(artwork)) { // Have valid artwork
koto_button_set_file_path(playlist_button, artwork); // Update the artwork path koto_button_set_file_path(playlist_button, artwork); // Update the artwork path
} }
gchar * name = koto_playlist_get_name(playlist); // Get the name gchar * name = koto_playlist_get_name(playlist); // Get the name
if (koto_utils_is_string_valid(name)) { // Have valid name if (koto_utils_is_string_valid(name)) { // Have valid name
koto_button_set_text(playlist_button, name); // Update the button text koto_button_set_text(playlist_button, name); // Update the button text
} }
@ -333,14 +316,12 @@ void koto_nav_handle_playlist_removed(
KotoButton * playlist_btn = g_hash_table_lookup(self->playlist_buttons, playlist_uuid); // Get the playlist button KotoButton * playlist_btn = g_hash_table_lookup(self->playlist_buttons, playlist_uuid); // Get the playlist button
if (!KOTO_IS_BUTTON(playlist_btn)) { // Not a playlist button if (!KOTO_IS_BUTTON(playlist_btn)) { // Not a playlist button
return; return;
} }
GtkBox * playlist_expander_content = GTK_BOX(koto_expander_get_content(self->playlists_expander)); GtkBox * playlist_expander_content = GTK_BOX(koto_expander_get_content(self->playlists_expander));
gtk_box_remove(playlist_expander_content, GTK_WIDGET(playlist_btn)); // Remove the button gtk_box_remove(playlist_expander_content, GTK_WIDGET(playlist_btn)); // Remove the button
g_hash_table_remove(self->playlist_buttons, playlist_uuid); // Remove from the playlist buttons hash table g_hash_table_remove(self->playlist_buttons, playlist_uuid); // Remove from the playlist buttons hash table
} }

View file

@ -79,7 +79,6 @@ static void koto_playerbar_constructed(GObject * obj);
static void koto_playerbar_class_init(KotoPlayerBarClass * c) { static void koto_playerbar_class_init(KotoPlayerBarClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
gobject_class->constructed = koto_playerbar_constructed; gobject_class->constructed = koto_playerbar_constructed;
@ -100,7 +99,6 @@ static void koto_playerbar_constructed(GObject * obj) {
GtkGesture * press_controller = gtk_gesture_click_new(); // Create a new GtkGestureLongPress GtkGesture * press_controller = gtk_gesture_click_new(); // Create a new GtkGestureLongPress
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(press_controller), 1); // Set to left click gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(press_controller), 1); // Set to left click
g_signal_connect(press_controller, "begin", G_CALLBACK(koto_playerbar_handle_progressbar_gesture_begin), self); g_signal_connect(press_controller, "begin", G_CALLBACK(koto_playerbar_handle_progressbar_gesture_begin), self);
@ -178,15 +176,14 @@ void koto_playerbar_apply_configuration_state(
gtk_scale_button_set_value(GTK_SCALE_BUTTON(self->volume_button), config_last_used_volume); gtk_scale_button_set_value(GTK_SCALE_BUTTON(self->volume_button), config_last_used_volume);
} }
void koto_playerbar_create_playback_details(KotoPlayerBar* bar) { void koto_playerbar_create_playback_details(KotoPlayerBar * bar) {
bar->playback_details_section = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); bar->playback_details_section = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
GtkIconTheme * default_icon_theme = gtk_icon_theme_get_for_display(gdk_display_get_default()); // Get the icon theme for this display GtkIconTheme * default_icon_theme = gtk_icon_theme_get_for_display(gdk_display_get_default()); // Get the icon theme for this display
if (default_icon_theme != NULL) { if (default_icon_theme != NULL) {
gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(bar->main)); gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(bar->main));
GtkIconPaintable* audio_paintable = gtk_icon_theme_lookup_icon(default_icon_theme, "audio-x-generic-symbolic", NULL, 96, scale_factor, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_PRELOAD); GtkIconPaintable * audio_paintable = gtk_icon_theme_lookup_icon(default_icon_theme, "audio-x-generic-symbolic", NULL, 96, scale_factor, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_PRELOAD);
if (GTK_IS_ICON_PAINTABLE(audio_paintable)) { if (GTK_IS_ICON_PAINTABLE(audio_paintable)) {
if (GTK_IS_IMAGE(bar->artwork)) { if (GTK_IS_IMAGE(bar->artwork)) {
@ -216,7 +213,7 @@ void koto_playerbar_create_playback_details(KotoPlayerBar* bar) {
gtk_box_append(GTK_BOX(bar->playback_section), GTK_WIDGET(bar->playback_details_section)); gtk_box_append(GTK_BOX(bar->playback_section), GTK_WIDGET(bar->playback_details_section));
} }
void koto_playerbar_create_primary_controls(KotoPlayerBar* bar) { void koto_playerbar_create_primary_controls(KotoPlayerBar * bar) {
bar->back_button = koto_button_new_with_icon("", "media-skip-backward-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_NORMAL); bar->back_button = koto_button_new_with_icon("", "media-skip-backward-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_NORMAL);
bar->play_pause_button = koto_button_new_with_icon("", "media-playback-start-symbolic", "media-playback-pause-symbolic", KOTO_BUTTON_PIXBUF_SIZE_LARGE); // TODO: Have this take in a state and switch to a different icon if necessary bar->play_pause_button = koto_button_new_with_icon("", "media-playback-start-symbolic", "media-playback-pause-symbolic", KOTO_BUTTON_PIXBUF_SIZE_LARGE); // TODO: Have this take in a state and switch to a different icon if necessary
bar->forward_button = koto_button_new_with_icon("", "media-skip-forward-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_NORMAL); bar->forward_button = koto_button_new_with_icon("", "media-skip-forward-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_NORMAL);
@ -237,7 +234,7 @@ void koto_playerbar_create_primary_controls(KotoPlayerBar* bar) {
} }
} }
void koto_playerbar_create_secondary_controls(KotoPlayerBar* bar) { void koto_playerbar_create_secondary_controls(KotoPlayerBar * bar) {
bar->repeat_button = koto_button_new_with_icon("", "media-playlist-repeat-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_NORMAL); bar->repeat_button = koto_button_new_with_icon("", "media-playlist-repeat-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_NORMAL);
bar->shuffle_button = koto_button_new_with_icon("", "media-playlist-shuffle-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_NORMAL); bar->shuffle_button = koto_button_new_with_icon("", "media-playlist-shuffle-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_NORMAL);
bar->playlist_button = koto_button_new_with_icon("", "playlist-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_NORMAL); bar->playlist_button = koto_button_new_with_icon("", "playlist-symbolic", NULL, KOTO_BUTTON_PIXBUF_SIZE_NORMAL);
@ -316,7 +313,6 @@ void koto_playerbar_handle_is_playing(
KotoPlayerBar * bar = user_data; KotoPlayerBar * bar = user_data;
if (!KOTO_IS_PLAYERBAR(bar)) { if (!KOTO_IS_PLAYERBAR(bar)) {
return; return;
} }
@ -334,7 +330,6 @@ void koto_playerbar_handle_is_paused(
KotoPlayerBar * bar = user_data; KotoPlayerBar * bar = user_data;
if (!KOTO_IS_PLAYERBAR(bar)) { if (!KOTO_IS_PLAYERBAR(bar)) {
return; return;
} }
@ -355,7 +350,6 @@ void koto_playerbar_handle_playlist_button_clicked(
(void) y; (void) y;
KotoPlayerBar * self = data; KotoPlayerBar * self = data;
if (!KOTO_IS_PLAYERBAR(self)) { // Not a playerbar if (!KOTO_IS_PLAYERBAR(self)) { // Not a playerbar
return; return;
} }
@ -373,7 +367,6 @@ void koto_playerbar_handle_progressbar_gesture_begin(
(void) seq; (void) seq;
KotoPlayerBar * bar = data; KotoPlayerBar * bar = data;
if (!KOTO_IS_PLAYERBAR(bar)) { if (!KOTO_IS_PLAYERBAR(bar)) {
return; return;
} }
@ -390,7 +383,6 @@ void koto_playerbar_handle_progressbar_gesture_end(
(void) seq; (void) seq;
KotoPlayerBar * bar = data; KotoPlayerBar * bar = data;
if (!KOTO_IS_PLAYERBAR(bar)) { if (!KOTO_IS_PLAYERBAR(bar)) {
return; return;
} }
@ -410,7 +402,6 @@ void koto_playerbar_handle_progressbar_pressed(
(void) y; (void) y;
KotoPlayerBar * bar = data; KotoPlayerBar * bar = data;
if (!KOTO_IS_PLAYERBAR(bar)) { if (!KOTO_IS_PLAYERBAR(bar)) {
return; return;
} }
@ -424,7 +415,6 @@ void koto_playerbar_handle_progressbar_value_changed(
) { ) {
KotoPlayerBar * bar = data; KotoPlayerBar * bar = data;
if (!KOTO_IS_PLAYERBAR(bar)) { if (!KOTO_IS_PLAYERBAR(bar)) {
return; return;
} }
@ -435,7 +425,6 @@ void koto_playerbar_handle_progressbar_value_changed(
int desired_position = (int) gtk_range_get_value(progress_bar); int desired_position = (int) gtk_range_get_value(progress_bar);
koto_playback_engine_set_position(playback_engine, desired_position); // Update our position koto_playback_engine_set_position(playback_engine, desired_position); // Update our position
} }
@ -449,7 +438,6 @@ void koto_playerbar_handle_tick_duration(
KotoPlayerBar * bar = user_data; KotoPlayerBar * bar = user_data;
if (!KOTO_IS_PLAYERBAR(bar)) { if (!KOTO_IS_PLAYERBAR(bar)) {
return; return;
} }
@ -457,7 +445,6 @@ void koto_playerbar_handle_tick_duration(
koto_playerbar_set_progressbar_duration(bar, koto_playback_engine_get_duration(engine)); koto_playerbar_set_progressbar_duration(bar, koto_playback_engine_get_duration(engine));
} }
void koto_playerbar_handle_tick_track( void koto_playerbar_handle_tick_track(
KotoPlaybackEngine * engine, KotoPlaybackEngine * engine,
gpointer user_data gpointer user_data
@ -468,7 +455,6 @@ void koto_playerbar_handle_tick_track(
KotoPlayerBar * bar = user_data; KotoPlayerBar * bar = user_data;
if (!KOTO_IS_PLAYERBAR(bar)) { if (!KOTO_IS_PLAYERBAR(bar)) {
return; return;
} }
@ -488,7 +474,6 @@ void koto_playerbar_handle_track_repeat(
KotoPlayerBar * bar = user_data; KotoPlayerBar * bar = user_data;
if (!KOTO_IS_PLAYERBAR(bar)) { if (!KOTO_IS_PLAYERBAR(bar)) {
return; return;
} }
@ -510,7 +495,6 @@ void koto_playerbar_handle_track_shuffle(
KotoPlayerBar * bar = user_data; KotoPlayerBar * bar = user_data;
if (!KOTO_IS_PLAYERBAR(bar)) { if (!KOTO_IS_PLAYERBAR(bar)) {
return; return;
} }
@ -532,13 +516,13 @@ void koto_playerbar_handle_volume_button_change(
koto_playback_engine_set_volume(playback_engine, value); koto_playback_engine_set_volume(playback_engine, value);
} }
void koto_playerbar_reset_progressbar(KotoPlayerBar* bar) { void koto_playerbar_reset_progressbar(KotoPlayerBar * bar) {
gtk_range_set_range(GTK_RANGE(bar->progress_bar), 0, 0); // Reset range gtk_range_set_range(GTK_RANGE(bar->progress_bar), 0, 0); // Reset range
gtk_range_set_value(GTK_RANGE(bar->progress_bar), 0); // Set value to 0 gtk_range_set_value(GTK_RANGE(bar->progress_bar), 0); // Set value to 0
} }
void koto_playerbar_set_progressbar_duration( void koto_playerbar_set_progressbar_duration(
KotoPlayerBar* bar, KotoPlayerBar * bar,
gint64 duration gint64 duration
) { ) {
if (duration <= 0) { if (duration <= 0) {
@ -552,7 +536,7 @@ void koto_playerbar_set_progressbar_duration(
} }
void koto_playerbar_set_progressbar_value( void koto_playerbar_set_progressbar_value(
KotoPlayerBar* bar, KotoPlayerBar * bar,
double progress double progress
) { ) {
gtk_range_set_value(GTK_RANGE(bar->progress_bar), progress); gtk_range_set_value(GTK_RANGE(bar->progress_bar), progress);
@ -615,14 +599,12 @@ void koto_playerbar_update_track_info(
KotoPlayerBar * bar = user_data; KotoPlayerBar * bar = user_data;
if (!KOTO_IS_PLAYERBAR(bar)) { if (!KOTO_IS_PLAYERBAR(bar)) {
return; return;
} }
KotoTrack * 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_TRACK(current_track)) { if (!KOTO_IS_TRACK(current_track)) {
return; return;
} }
@ -631,13 +613,11 @@ void koto_playerbar_update_track_info(
gchar * artist_uuid = NULL; gchar * artist_uuid = NULL;
gchar * album_uuid = NULL; gchar * album_uuid = NULL;
g_object_get(current_track, "parsed-name", &track_name, "artist-uuid", &artist_uuid, "album-uuid", &album_uuid, NULL); g_object_get(current_track, "parsed-name", &track_name, "artist-uuid", &artist_uuid, "album-uuid", &album_uuid, NULL);
KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_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); KotoAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, album_uuid);
g_free(artist_uuid); g_free(artist_uuid);
g_free(album_uuid); g_free(album_uuid);
@ -677,6 +657,6 @@ void koto_playerbar_update_track_info(
} }
} }
GtkWidget * koto_playerbar_get_main(KotoPlayerBar* bar) { GtkWidget * koto_playerbar_get_main(KotoPlayerBar * bar) {
return bar->main; return bar->main;
} }

View file

@ -27,7 +27,7 @@ G_DECLARE_FINAL_TYPE(KotoPlayerBar, koto_playerbar, KOTO, PLAYERBAR, GObject)
#define KOTO_IS_PLAYERBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_PLAYERBAR)) #define KOTO_IS_PLAYERBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_PLAYERBAR))
KotoPlayerBar * koto_playerbar_new(void); KotoPlayerBar * koto_playerbar_new(void);
GtkWidget * koto_playerbar_get_main(KotoPlayerBar* bar); GtkWidget * koto_playerbar_get_main(KotoPlayerBar * bar);
void koto_playerbar_apply_configuration_state( void koto_playerbar_apply_configuration_state(
KotoConfig * config, KotoConfig * config,
@ -35,11 +35,11 @@ void koto_playerbar_apply_configuration_state(
KotoPlayerBar * self KotoPlayerBar * self
); );
void koto_playerbar_create_playback_details(KotoPlayerBar* bar); void koto_playerbar_create_playback_details(KotoPlayerBar * bar);
void koto_playerbar_create_primary_controls(KotoPlayerBar* bar); void koto_playerbar_create_primary_controls(KotoPlayerBar * bar);
void koto_playerbar_create_secondary_controls(KotoPlayerBar* bar); void koto_playerbar_create_secondary_controls(KotoPlayerBar * bar);
void koto_playerbar_go_backwards( void koto_playerbar_go_backwards(
GtkGestureClick * gesture, GtkGestureClick * gesture,
@ -131,15 +131,15 @@ void koto_playerbar_handle_volume_button_change(
gpointer user_data gpointer user_data
); );
void koto_playerbar_reset_progressbar(KotoPlayerBar* bar); void koto_playerbar_reset_progressbar(KotoPlayerBar * bar);
void koto_playerbar_set_progressbar_duration( void koto_playerbar_set_progressbar_duration(
KotoPlayerBar* bar, KotoPlayerBar * bar,
gint64 duration gint64 duration
); );
void koto_playerbar_set_progressbar_value( void koto_playerbar_set_progressbar_value(
KotoPlayerBar* bar, KotoPlayerBar * bar,
gdouble progress gdouble progress
); );

View file

@ -63,7 +63,6 @@ static void koto_track_item_set_property(
static void koto_track_item_class_init(KotoTrackItemClass * c) { static void koto_track_item_class_init(KotoTrackItemClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
gobject_class->set_property = koto_track_item_set_property; gobject_class->set_property = koto_track_item_set_property;
gobject_class->get_property = koto_track_item_get_property; gobject_class->get_property = koto_track_item_get_property;
@ -87,7 +86,6 @@ static void koto_track_item_get_property(
) { ) {
KotoTrackItem * self = KOTO_TRACK_ITEM(obj); KotoTrackItem * self = KOTO_TRACK_ITEM(obj);
switch (prop_id) { switch (prop_id) {
case PROP_TRACK: case PROP_TRACK:
g_value_set_object(val, self->track); g_value_set_object(val, self->track);
@ -106,7 +104,6 @@ static void koto_track_item_set_property(
) { ) {
KotoTrackItem * self = KOTO_TRACK_ITEM(obj); KotoTrackItem * self = KOTO_TRACK_ITEM(obj);
switch (prop_id) { switch (prop_id) {
case PROP_TRACK: case PROP_TRACK:
koto_track_item_set_track(self, (KotoTrack*) g_value_get_object(val)); koto_track_item_set_track(self, (KotoTrack*) g_value_get_object(val));
@ -143,7 +140,6 @@ void koto_track_item_set_track(
self->track = track; self->track = track;
gchar * track_name; gchar * track_name;
g_object_get(self->track, "parsed-name", &track_name, NULL); g_object_get(self->track, "parsed-name", &track_name, NULL);
gtk_label_set_text(GTK_LABEL(self->track_label), track_name); // Update the text gtk_label_set_text(GTK_LABEL(self->track_label), track_name); // Update the text
} }

View file

@ -21,7 +21,7 @@
extern GtkWindow * main_window; extern GtkWindow * main_window;
GtkFileChooserNative * koto_utils_create_image_file_chooser(gchar * file_chooser_label) { GtkFileChooserNative * koto_utils_create_image_file_chooser(gchar * file_chooser_label) {
GtkFileChooserNative* chooser = gtk_file_chooser_native_new( GtkFileChooserNative * chooser = gtk_file_chooser_native_new(
file_chooser_label, file_chooser_label,
main_window, main_window,
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_OPEN,
@ -31,7 +31,6 @@ GtkFileChooserNative * koto_utils_create_image_file_chooser(gchar * file_chooser
GtkFileFilter * image_filter = gtk_file_filter_new(); // Create our file filter GtkFileFilter * image_filter = gtk_file_filter_new(); // Create our file filter
gtk_file_filter_add_mime_type(image_filter, "image/*"); // Only allow for images gtk_file_filter_add_mime_type(image_filter, "image/*"); // Only allow for images
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(chooser), image_filter); // Only allow picking images gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(chooser), image_filter); // Only allow picking images
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(chooser), FALSE); gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(chooser), FALSE);
@ -45,8 +44,7 @@ GtkWidget * koto_utils_create_image_from_filepath(
guint width, guint width,
guint height guint height
) { ) {
GtkWidget* image = NULL; GtkWidget * image = NULL;
if ((filepath != NULL) && (strcmp(filepath, "") != 0)) { // If we have a filepath if ((filepath != NULL) && (strcmp(filepath, "") != 0)) { // If we have a filepath
if (g_file_test(filepath, G_FILE_TEST_EXISTS)) { // File exists if (g_file_test(filepath, G_FILE_TEST_EXISTS)) { // File exists
@ -73,11 +71,9 @@ gchar * koto_utils_get_filename_without_extension(gchar * filename) {
gchar * trimmed_file_name = g_strdup(filename); gchar * trimmed_file_name = g_strdup(filename);
gchar ** split = g_strsplit(filename, ".", -1); // Split every time we see . gchar ** split = g_strsplit(filename, ".", -1); // Split every time we see .
g_free(trimmed_file_name); g_free(trimmed_file_name);
guint len_of_extension_split = g_strv_length(split); guint len_of_extension_split = g_strv_length(split);
if (len_of_extension_split == 2) { // Only have two elements if (len_of_extension_split == 2) { // Only have two elements
trimmed_file_name = g_strdup(split[0]); // Get the first element trimmed_file_name = g_strdup(split[0]); // Get the first element
} else { } else {
@ -99,7 +95,6 @@ gchar * koto_utils_get_filename_without_extension(gchar * filename) {
gchar * stripped_file_name = g_strstrip(g_strdup(trimmed_file_name)); // Strip leading and trailing whitespace gchar * stripped_file_name = g_strstrip(g_strdup(trimmed_file_name)); // Strip leading and trailing whitespace
g_free(trimmed_file_name); g_free(trimmed_file_name);
return stripped_file_name; return stripped_file_name;
} }
@ -123,7 +118,6 @@ gchar * koto_utils_replace_string_all(
gchar * cleaned_string = ""; gchar * cleaned_string = "";
gchar ** split = g_strsplit(str, find, -1); // Split on find gchar ** split = g_strsplit(str, find, -1); // Split on find
for (guint i = 0; i < g_strv_length(split); i++) { // For each split for (guint i = 0; i < g_strv_length(split); i++) { // For each split
cleaned_string = g_strjoin(repl, cleaned_string, split[i], NULL); // Join the strings with our replace string cleaned_string = g_strjoin(repl, cleaned_string, split[i], NULL); // Join the strings with our replace string
} }
@ -135,7 +129,6 @@ gchar * koto_utils_replace_string_all(
gchar * koto_utils_unquote_string(gchar * s) { gchar * koto_utils_unquote_string(gchar * s) {
gchar * new_s = NULL; gchar * new_s = NULL;
if (g_str_has_prefix(s, "'") && g_str_has_suffix(s, "'")) { // Begins and ends with ' if (g_str_has_prefix(s, "'") && g_str_has_suffix(s, "'")) { // Begins and ends with '
new_s = g_utf8_substring(s, 1, g_utf8_strlen(s, -1) - 1); // Start at 1 and end at n-1 new_s = g_utf8_substring(s, 1, g_utf8_strlen(s, -1) - 1); // Start at 1 and end at n-1
} else { } else {
@ -144,7 +137,6 @@ gchar * koto_utils_unquote_string(gchar * s) {
gchar ** split_on_double_single = g_strsplit(new_s, "''", -1); // Split on instances of '' gchar ** split_on_double_single = g_strsplit(new_s, "''", -1); // Split on instances of ''
new_s = g_strjoinv("'", split_on_double_single); // Rejoin as ' new_s = g_strjoinv("'", split_on_double_single); // Rejoin as '
g_strfreev(split_on_double_single); // Free our array g_strfreev(split_on_double_single); // Free our array

View file

@ -240,7 +240,6 @@ void koto_window_handle_playlist_added(
gchar * playlist_uuid = koto_playlist_get_uuid(playlist); gchar * playlist_uuid = koto_playlist_get_uuid(playlist);
KotoPlaylistPage * playlist_page = koto_playlist_page_new(playlist_uuid); // Create our new Playlist Page KotoPlaylistPage * playlist_page = koto_playlist_page_new(playlist_uuid); // Create our new Playlist Page
koto_window_add_page(self, playlist_uuid, koto_playlist_page_get_main(playlist_page)); // Get the GtkScrolledWindow "main" content of the playlist page and add that as a page to our stack by the playlist UUID koto_window_add_page(self, playlist_uuid, koto_playlist_page_get_main(playlist_page)); // Get the GtkScrolledWindow "main" content of the playlist page and add that as a page to our stack by the playlist UUID
} }
@ -254,7 +253,6 @@ void koto_window_remove_page(
) { ) {
GtkWidget * page = gtk_stack_get_child_by_name(GTK_STACK(self->pages), page_name); GtkWidget * page = gtk_stack_get_child_by_name(GTK_STACK(self->pages), page_name);
if (GTK_IS_WIDGET(page)) { if (GTK_IS_WIDGET(page)) {
gtk_stack_remove(GTK_STACK(self->pages), page); gtk_stack_remove(GTK_STACK(self->pages), page);
} }
@ -290,7 +288,6 @@ void create_new_headerbar(KotoWindow * self) {
void load_library(KotoWindow * self) { void load_library(KotoWindow * self) {
KotoLibrary * lib = koto_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) { if (lib != NULL) {
self->library = lib; self->library = lib;
music_local_page = koto_page_music_local_new(); music_local_page = koto_page_music_local_new();
@ -299,7 +296,7 @@ void load_library(KotoWindow * self) {
koto_window_add_page(self, "music.local", GTK_WIDGET(music_local_page)); koto_window_add_page(self, "music.local", GTK_WIDGET(music_local_page));
koto_window_go_to_page(self, "music.local"); koto_window_go_to_page(self, "music.local");
gtk_widget_show(self->pages); // Do not remove this. Will cause sporadic hiding of the local page content otherwise. gtk_widget_show(self->pages); // Do not remove this. Will cause sporadic hiding of the local page content otherwise.
koto_page_music_local_set_library(music_local_page, self->library); koto_page_music_local_build_ui(music_local_page);
} }
g_thread_exit(0); g_thread_exit(0);
@ -308,14 +305,12 @@ void load_library(KotoWindow * self) {
void set_optimal_default_window_size(KotoWindow * self) { void set_optimal_default_window_size(KotoWindow * self) {
GdkDisplay * default_display = gdk_display_get_default(); GdkDisplay * default_display = gdk_display_get_default();
if (!GDK_IS_X11_DISPLAY(default_display)) { // Not an X11 display if (!GDK_IS_X11_DISPLAY(default_display)) { // Not an X11 display
return; return;
} }
GdkMonitor * default_monitor = gdk_x11_display_get_primary_monitor(GDK_X11_DISPLAY(default_display)); // Get primary monitor for the X11 GdkMonitor * default_monitor = gdk_x11_display_get_primary_monitor(GDK_X11_DISPLAY(default_display)); // Get primary monitor for the X11
if (!GDK_IS_X11_MONITOR(default_monitor)) { // Not an X11 Monitor if (!GDK_IS_X11_MONITOR(default_monitor)) { // Not an X11 Monitor
return; return;
} }
@ -324,7 +319,6 @@ void set_optimal_default_window_size(KotoWindow * self) {
0 0
}; };
gdk_monitor_get_geometry(default_monitor, &workarea); gdk_monitor_get_geometry(default_monitor, &workarea);
if (workarea.width <= 1280) { // Honestly how do you even get anything done? if (workarea.width <= 1280) { // Honestly how do you even get anything done?

View file

@ -69,7 +69,6 @@ static void koto_album_view_set_property(
static void koto_album_view_class_init(KotoAlbumViewClass * c) { static void koto_album_view_class_init(KotoAlbumViewClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
gobject_class->set_property = koto_album_view_set_property; gobject_class->set_property = koto_album_view_set_property;
gobject_class->get_property = koto_album_view_get_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); KotoAlbumView * self = KOTO_ALBUM_VIEW(obj);
switch (prop_id) { switch (prop_id) {
case PROP_ALBUM: case PROP_ALBUM:
g_value_set_object(val, self->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++) { 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 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; continue;
} }
@ -229,7 +227,6 @@ int koto_album_view_sort_discs(
guint disc1_num; guint disc1_num;
guint disc2_num; guint disc2_num;
g_object_get(disc1_item, "disc", &disc1_num, NULL); g_object_get(disc1_item, "disc", &disc1_num, NULL);
g_object_get(disc2_item, "disc", &disc2_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) n_press;
(void) x; (void) x;
(void) y; (void) y;
KotoAlbumView* self = data; KotoAlbumView * self = data;
koto_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
} }

View file

@ -69,7 +69,6 @@ static void koto_artist_view_set_property(
static void koto_artist_view_class_init(KotoArtistViewClass * c) { static void koto_artist_view_class_init(KotoArtistViewClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
gobject_class->constructed = koto_artist_view_constructed; gobject_class->constructed = koto_artist_view_constructed;
gobject_class->set_property = koto_artist_view_set_property; 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); KotoArtistView * self = KOTO_ARTIST_VIEW(obj);
switch (prop_id) { switch (prop_id) {
case PROP_ARTIST: case PROP_ARTIST:
g_value_set_object(val, self->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); KotoArtistView * self = KOTO_ARTIST_VIEW(obj);
switch (prop_id) { switch (prop_id) {
case PROP_ARTIST: case PROP_ARTIST:
koto_artist_view_add_artist(self, (KotoArtist*) g_value_get_object(val)); 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) { static void koto_artist_view_constructed(GObject * obj) {
KotoArtistView * self = KOTO_ARTIST_VIEW(obj); KotoArtistView * self = KOTO_ARTIST_VIEW(obj);
self->albums_to_component = g_hash_table_new(g_str_hash, g_str_equal); 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->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 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); 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_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 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 KotoAlbumView * album_view = koto_album_view_new(album); // Create our new album view
GtkWidget* album_view_main = koto_album_view_get_main(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 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; GList * a;
for (a = albums; a != NULL; a = a->next) { for (a = albums; a != NULL; a = a->next) {
KotoAlbum * 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);

View file

@ -65,7 +65,6 @@ static void koto_disc_view_set_property(
static void koto_disc_view_class_init(KotoDiscViewClass * c) { static void koto_disc_view_class_init(KotoDiscViewClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
gobject_class->set_property = koto_disc_view_set_property; gobject_class->set_property = koto_disc_view_set_property;
gobject_class->get_property = koto_disc_view_get_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); KotoDiscView * self = KOTO_DISC_VIEW(obj);
switch (prop_id) { switch (prop_id) {
case PROP_DISC: case PROP_DISC:
g_value_set_uint(val, GPOINTER_TO_UINT(self->disc_number)); 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); KotoDiscView * self = KOTO_DISC_VIEW(obj);
switch (prop_id) { switch (prop_id) {
case PROP_DISC: case PROP_DISC:
koto_disc_view_set_disc_number(self, g_value_get_uint(val)); 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"); GtkWidget * ico = gtk_image_new_from_icon_name("drive-optical-symbolic");
gtk_box_prepend(GTK_BOX(self->header), ico); gtk_box_prepend(GTK_BOX(self->header), ico);
self->label = gtk_label_new(NULL); // Create an empty label self->label = gtk_label_new(NULL); // Create an empty label
@ -175,7 +171,6 @@ void koto_disc_view_list_tracks(
guint * disc_number; guint * disc_number;
g_object_get(track, "cd", &disc_number, NULL); // get the 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 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 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 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 gchar * album_uuid = koto_album_get_album_uuid(self->album); // Get the UUID
if (!koto_utils_is_string_valid(album_uuid)) { // Not set if (!koto_utils_is_string_valid(album_uuid)) { // Not set
return; return;
} }
GList * selected_rows = gtk_list_box_get_selected_rows(box); // Get the selected rows GList * selected_rows = gtk_list_box_get_selected_rows(box); // Get the selected rows
if (g_list_length(selected_rows) == 0) { // No rows selected if (g_list_length(selected_rows) == 0) { // No rows selected
koto_action_bar_toggle_reveal(action_bar, FALSE); // Close the action bar koto_action_bar_toggle_reveal(action_bar, FALSE); // Close the action bar
return; return;
@ -212,7 +204,6 @@ void koto_disc_view_handle_selected_rows_changed(
GList * selected_tracks = NULL; // Create our list of KotoTracks GList * selected_tracks = NULL; // Create our list of KotoTracks
GList * cur_selected_rows; 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 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); 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 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); gchar * disc_label = g_strdup_printf("Disc %u", disc_number);
gtk_label_set_text(GTK_LABEL(self->label), disc_label); // Set the label gtk_label_set_text(GTK_LABEL(self->label), disc_label); // Set the label
g_free(disc_label); g_free(disc_label);

View file

@ -26,23 +26,12 @@
extern KotoCartographer * koto_maps; extern KotoCartographer * koto_maps;
enum {
PROP_0,
PROP_LIB,
N_PROPERTIES
};
static GParamSpec * props[N_PROPERTIES] = {
NULL,
};
struct _KotoPageMusicLocal { struct _KotoPageMusicLocal {
GtkBox parent_instance; GtkBox parent_instance;
GtkWidget * scrolled_window; GtkWidget * scrolled_window;
GtkWidget * artist_list; GtkWidget * artist_list;
GtkWidget * stack; GtkWidget * stack;
KotoLibrary * lib;
gboolean constructed; 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_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) { static void koto_page_music_local_class_init(KotoPageMusicLocalClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
gobject_class->constructed = koto_page_music_local_constructed; 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) { static void koto_page_music_local_init(KotoPageMusicLocal * self) {
self->lib = NULL;
self->constructed = FALSE; self->constructed = FALSE;
gtk_widget_add_css_class(GTK_WIDGET(self), "page-music-local"); 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) { static void koto_page_music_local_constructed(GObject * obj) {
KotoPageMusicLocal * self = KOTO_PAGE_MUSIC_LOCAL(obj); KotoPageMusicLocal * self = KOTO_PAGE_MUSIC_LOCAL(obj);
G_OBJECT_CLASS(koto_page_music_local_parent_class)->constructed(obj); G_OBJECT_CLASS(koto_page_music_local_parent_class)->constructed(obj);
self->constructed = TRUE; self->constructed = TRUE;
} }
@ -172,16 +94,13 @@ void koto_page_music_local_add_artist(
) { ) {
gchar * artist_name; gchar * artist_name;
g_object_get(artist, "name", &artist_name, NULL); g_object_get(artist, "name", &artist_name, NULL);
KotoButton * artist_button = koto_button_new_plain(artist_name); KotoButton * artist_button = koto_button_new_plain(artist_name);
gtk_list_box_prepend(GTK_LIST_BOX(self->artist_list), GTK_WIDGET(artist_button)); 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 KotoArtistView * artist_view = koto_artist_view_new(); // Create our new artist view
koto_artist_view_add_artist(artist_view, artist); // Add the artist 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); 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 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 if (!KOTO_IS_ARTIST(artist)) { // No artist for this UUID
return; return;
} }
gchar * artist_name = NULL; gchar * artist_name = NULL;
g_object_get( g_object_get(
artist, artist,
"name", "name",
@ -232,25 +149,11 @@ void koto_page_music_local_handle_artist_click(
gchar * artist_name; gchar * artist_name;
g_object_get(btn, "button-text", &artist_name, NULL); g_object_get(btn, "button-text", &artist_name, NULL);
koto_page_music_local_go_to_artist_by_name(self, artist_name); koto_page_music_local_go_to_artist_by_name(self, artist_name);
} }
void koto_page_music_local_set_library( void koto_page_music_local_build_ui(KotoPageMusicLocal * self) {
KotoPageMusicLocal * self,
KotoLibrary * lib
) {
if (lib == NULL) {
return;
}
if (self->lib != NULL) { // If lib is already set
g_free(self->lib);
}
self->lib = lib;
if (!self->constructed) { if (!self->constructed) {
return; return;
} }
@ -259,14 +162,13 @@ void koto_page_music_local_set_library(
gpointer artist_key; gpointer artist_key;
gpointer artist_data; 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); 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 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); koto_page_music_local_add_artist(self, artist);
} }
} }
@ -284,7 +186,6 @@ int koto_page_music_local_sort_artists(
gchar * artist1_text; gchar * artist1_text;
gchar * artist2_text; gchar * artist2_text;
g_object_get(artist1_btn, "button-text", &artist1_text, NULL); g_object_get(artist1_btn, "button-text", &artist1_text, NULL);
g_object_get(artist2_btn, "button-text", &artist2_text, NULL); g_object_get(artist2_btn, "button-text", &artist2_text, NULL);

View file

@ -50,10 +50,7 @@ void koto_page_music_local_go_to_artist_by_uuid(
gchar * artist_uuid gchar * artist_uuid
); );
void koto_page_music_local_set_library( void koto_page_music_local_build_ui(KotoPageMusicLocal * self);
KotoPageMusicLocal * self,
KotoLibrary * lib
);
int koto_page_music_local_sort_artists( int koto_page_music_local_sort_artists(
GtkListBoxRow * artist1, GtkListBoxRow * artist1,

View file

@ -101,7 +101,6 @@ static void koto_playlist_page_set_property(
static void koto_playlist_page_class_init(KotoPlaylistPageClass * c) { static void koto_playlist_page_class_init(KotoPlaylistPageClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
gobject_class->get_property = koto_playlist_page_get_property; gobject_class->get_property = koto_playlist_page_get_property;
gobject_class->set_property = koto_playlist_page_set_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); KotoPlaylistPage * self = KOTO_PLAYLIST_PAGE(obj);
switch (prop_id) { switch (prop_id) {
case PROP_PLAYLIST_UUID: case PROP_PLAYLIST_UUID:
g_value_set_string(val, self->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); KotoPlaylistPage * self = KOTO_PLAYLIST_PAGE(obj);
switch (prop_id) { switch (prop_id) {
case PROP_PLAYLIST_UUID: 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 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 KotoTrack * track = gtk_list_item_get_item(item); // Get the track UUID from our model
if (!KOTO_IS_TRACK(track)) { if (!KOTO_IS_TRACK(track)) {
return; return;
} }
@ -254,7 +250,6 @@ void koto_playlist_page_bind_track_item(
gchar * album_uuid = NULL; gchar * album_uuid = NULL;
gchar * artist_uuid = NULL; gchar * artist_uuid = NULL;
g_object_get( g_object_get(
track, track,
"parsed-name", "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); 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_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 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); KotoAlbum * album = koto_cartographer_get_album_by_uuid(koto_maps, album_uuid);
if (KOTO_IS_ALBUM(album)) { 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 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); KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid);
if (KOTO_IS_ARTIST(artist)) { 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 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; (void) bar;
KotoPlaylistPage * self = data; KotoPlaylistPage * self = data;
if (!KOTO_IS_PLAYLIST(self->playlist)) { // No playlist set if (!KOTO_IS_PLAYLIST(self->playlist)) { // No playlist set
return; return;
} }
@ -348,7 +339,6 @@ void koto_playlist_page_handle_cover_art_clicked(
(void) y; (void) y;
KotoPlaylistPage * self = user_data; KotoPlaylistPage * self = user_data;
if (!KOTO_IS_PLAYLIST(self->playlist)) { // No playlist set if (!KOTO_IS_PLAYLIST(self->playlist)) { // No playlist set
return; return;
} }
@ -369,7 +359,6 @@ void koto_playlist_page_handle_edit_button_clicked(
(void) y; (void) y;
KotoPlaylistPage * self = user_data; KotoPlaylistPage * self = user_data;
koto_create_modify_playlist_dialog_set_playlist_uuid(playlist_create_modify_dialog, koto_playlist_get_uuid(self->playlist)); 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"); koto_window_show_dialog(main_window, "create-modify-playlist");
} }
@ -384,21 +373,18 @@ void koto_playlist_page_handle_playlist_modified(
KotoPlaylistPage * self = user_data; KotoPlaylistPage * self = user_data;
if (!KOTO_IS_PLAYLIST_PAGE(self)) { if (!KOTO_IS_PLAYLIST_PAGE(self)) {
return; return;
} }
gchar * artwork = koto_playlist_get_artwork(playlist); // Get the artwork gchar * artwork = koto_playlist_get_artwork(playlist); // Get the artwork
if (koto_utils_is_string_valid(artwork)) { // Have valid 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 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 gchar * name = koto_playlist_get_name(playlist); // Get the name
if (koto_utils_is_string_valid(name)) { // Have valid 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 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; (void) y;
KotoPlaylistPage * self = user_data; KotoPlaylistPage * self = user_data;
gtk_widget_add_css_class(GTK_WIDGET(self->track_album_button), "active"); 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_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); 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; (void) y;
KotoPlaylistPage * self = user_data; KotoPlaylistPage * self = user_data;
gtk_widget_add_css_class(GTK_WIDGET(self->track_artist_button), "active"); 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_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); 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; (void) y;
KotoPlaylistPage * self = user_data; KotoPlaylistPage * self = user_data;
gtk_widget_add_css_class(GTK_WIDGET(self->track_title_button), "active"); 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_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); 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); KotoPreferredModelType current_model = koto_playlist_get_current_model(self->playlist);
if (current_model == KOTO_PREFERRED_MODEL_TYPE_DEFAULT) { // Set to newest currently 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_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) 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; (void) position;
KotoPlaylistPage * self = user_data; KotoPlaylistPage * self = user_data;
if (n_items == 0) { // No items selected if (n_items == 0) { // No items selected
koto_action_bar_toggle_reveal(action_bar, FALSE); // Hide the action bar koto_action_bar_toggle_reveal(action_bar, FALSE); // Hide the action bar
return; return;
@ -508,7 +489,6 @@ void koto_playlist_page_handle_tracks_selected(
guint first_track_pos; guint first_track_pos;
if (!gtk_bitset_iter_init_first(&iter, selected_items_bitset, &first_track_pos)) { // Failed to get the first item if (!gtk_bitset_iter_init_first(&iter, selected_items_bitset, &first_track_pos)) { // Failed to get the first item
return; return;
} }
@ -517,7 +497,6 @@ void koto_playlist_page_handle_tracks_selected(
gboolean have_more_items = TRUE; gboolean have_more_items = TRUE;
while (have_more_items) { // While we are able to get selected items while (have_more_items) { // While we are able to get selected items
guint track_pos; guint track_pos;
have_more_items = gtk_bitset_iter_next(&iter, &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; 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 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 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 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 self->uuid = g_strdup(playlist_uuid); // Duplicate the playlist UUID
KotoPlaylist * playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, self->uuid); KotoPlaylist * playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, self->uuid);
self->playlist = playlist; self->playlist = playlist;
koto_playlist_page_set_playlist_model(self, KOTO_PREFERRED_MODEL_TYPE_DEFAULT); // TODO: Enable this to be changed 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 koto_playlist_page_update_header(self); // Update our header
@ -606,19 +583,16 @@ void koto_playlist_page_setup_track_item(
(void) factory; (void) factory;
KotoPlaylistPage * self = user_data; KotoPlaylistPage * self = user_data;
if (!KOTO_IS_PLAYLIST_PAGE(self)) { if (!KOTO_IS_PLAYLIST_PAGE(self)) {
return; return;
} }
GtkWidget * item_content = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); // Have a horizontal box for our content 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"); gtk_widget_add_css_class(item_content, "track-list-columned-item");
GtkWidget * track_number = gtk_label_new(NULL); // Our track number GtkWidget * track_number = gtk_label_new(NULL); // Our track number
gtk_label_set_xalign(GTK_LABEL(track_number), 0); gtk_label_set_xalign(GTK_LABEL(track_number), 0);
gtk_widget_add_css_class(track_number, "track-column-number"); gtk_widget_add_css_class(track_number, "track-column-number");
gtk_widget_set_halign(track_number, GTK_ALIGN_END); 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 GtkWidget * track_name = gtk_label_new(NULL); // Our track name
gtk_label_set_xalign(GTK_LABEL(track_name), 0); gtk_label_set_xalign(GTK_LABEL(track_name), 0);
gtk_widget_add_css_class(track_name, "track-column-name"); gtk_widget_add_css_class(track_name, "track-column-name");
gtk_widget_set_halign(track_name, GTK_ALIGN_START); 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 GtkWidget * track_album = gtk_label_new(NULL); // Our track album
gtk_label_set_xalign(GTK_LABEL(track_album), 0); gtk_label_set_xalign(GTK_LABEL(track_album), 0);
gtk_widget_add_css_class(track_album, "track-column-album"); gtk_widget_add_css_class(track_album, "track-column-album");
gtk_widget_set_halign(track_album, GTK_ALIGN_START); 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 GtkWidget * track_artist = gtk_label_new(NULL); // Our track artist
gtk_label_set_xalign(GTK_LABEL(track_artist), 0); gtk_label_set_xalign(GTK_LABEL(track_artist), 0);
gtk_widget_add_css_class(track_artist, "track-column-artist"); gtk_widget_add_css_class(track_artist, "track-column-artist");
gtk_widget_set_halign(track_artist, GTK_ALIGN_START); gtk_widget_set_halign(track_artist, GTK_ALIGN_START);
@ -676,7 +647,6 @@ void koto_playlist_page_update_header(KotoPlaylistPage * self) {
gboolean ephemeral = TRUE; gboolean ephemeral = TRUE;
g_object_get( g_object_get(
self->playlist, self->playlist,
"ephemeral", "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 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 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 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); gchar * artwork = koto_playlist_get_artwork(self->playlist);
if (koto_utils_is_string_valid(artwork)) { // Have artwork if (koto_utils_is_string_valid(artwork)) { // Have artwork
koto_cover_art_button_set_art_path(self->playlist_image, artwork); // Update our 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 KotoPreferredModelType current_model = koto_playlist_get_current_model(self->playlist); // Get the current model
if (current_model == KOTO_PREFERRED_MODEL_TYPE_OLDEST_FIRST) { if (current_model == KOTO_PREFERRED_MODEL_TYPE_OLDEST_FIRST) {
koto_button_show_image(self->track_num_button, TRUE); // Immediately use pan-up-symbolic koto_button_show_image(self->track_num_button, TRUE); // Immediately use pan-up-symbolic
} }

View file

@ -32,7 +32,7 @@ G_DECLARE_FINAL_TYPE(KotoPlaylistPage, koto_playlist_page, KOTO, PLAYLIST_PAGE,
KotoPlaylistPage * koto_playlist_page_new(gchar * playlist_uuid); KotoPlaylistPage * koto_playlist_page_new(gchar * playlist_uuid);
void koto_playlist_page_add_track( void koto_playlist_page_add_track(
KotoPlaylistPage* self, KotoPlaylistPage * self,
const gchar * track_uuid const gchar * track_uuid
); );

View file

@ -275,7 +275,6 @@ void koto_playback_engine_apply_configuration_state(
void koto_playback_engine_backwards(KotoPlaybackEngine * self) { void koto_playback_engine_backwards(KotoPlaybackEngine * self) {
KotoPlaylist * playlist = koto_current_playlist_get_playlist(current_playlist); // Get the current playlist KotoPlaylist * playlist = koto_current_playlist_get_playlist(current_playlist); // Get the current playlist
if (!KOTO_IS_PLAYLIST(playlist)) { // If we do not have a playlist currently if (!KOTO_IS_PLAYLIST(playlist)) { // If we do not have a playlist currently
return; return;
} }
@ -338,7 +337,6 @@ KotoTrack * koto_playback_engine_get_current_track(KotoPlaybackEngine * self) {
gint64 koto_playback_engine_get_duration(KotoPlaybackEngine * self) { gint64 koto_playback_engine_get_duration(KotoPlaybackEngine * self) {
gint64 duration = 0; gint64 duration = 0;
if (gst_element_query(self->player, self->duration_query)) { // Able to query our duration if (gst_element_query(self->player, self->duration_query)) { // Able to query our duration
gst_query_parse_duration(self->duration_query, NULL, &duration); // Get the duration gst_query_parse_duration(self->duration_query, NULL, &duration); // Get the duration
duration = duration / GST_SECOND; // Divide by NS to get seconds duration = duration / GST_SECOND; // Divide by NS to get seconds
@ -351,7 +349,6 @@ gdouble koto_playback_engine_get_progress(KotoPlaybackEngine * self) {
gdouble progress = 0.0; gdouble progress = 0.0;
gint64 gstprog = 0; gint64 gstprog = 0;
if (gst_element_query(self->playbin, self->position_query)) { // Able to get our position if (gst_element_query(self->playbin, self->position_query)) { // Able to get our position
gst_query_parse_position(self->position_query, NULL, &gstprog); // Get the progress gst_query_parse_position(self->position_query, NULL, &gstprog); // Get the progress
@ -389,7 +386,6 @@ gboolean koto_playback_engine_monitor_changed(
(void) bus; (void) bus;
KotoPlaybackEngine * self = user_data; KotoPlaybackEngine * self = user_data;
switch (GST_MESSAGE_TYPE(msg)) { switch (GST_MESSAGE_TYPE(msg)) {
case GST_MESSAGE_ASYNC_DONE: case GST_MESSAGE_ASYNC_DONE:
case GST_MESSAGE_DURATION_CHANGED: { // Duration changed case GST_MESSAGE_DURATION_CHANGED: { // Duration changed
@ -575,7 +571,6 @@ void koto_playback_engine_stop(KotoPlaybackEngine * self) {
gst_element_set_state(self->player, GST_STATE_NULL); gst_element_set_state(self->player, GST_STATE_NULL);
GstPad * pad = gst_element_get_static_pad(self->player, "sink"); // Get the static pad of the audio element GstPad * pad = gst_element_get_static_pad(self->player, "sink"); // Get the static pad of the audio element
if (!GST_IS_PAD(pad)) { if (!GST_IS_PAD(pad)) {
return; return;
} }
@ -595,7 +590,6 @@ void koto_playback_engine_toggle(KotoPlaybackEngine * self) {
gboolean koto_playback_engine_tick_duration(gpointer user_data) { gboolean koto_playback_engine_tick_duration(gpointer user_data) {
KotoPlaybackEngine * self = user_data; KotoPlaybackEngine * self = user_data;
if (self->is_playing) { // Is playing if (self->is_playing) { // Is playing
g_signal_emit(self, playback_engine_signals[SIGNAL_TICK_DURATION], 0); // Emit our 1s track tick g_signal_emit(self, playback_engine_signals[SIGNAL_TICK_DURATION], 0); // Emit our 1s track tick
} else { // Not playing so exiting timer } else { // Not playing so exiting timer

View file

@ -91,7 +91,6 @@ void handle_media_keys_signal(
gchar * application_name = NULL; gchar * application_name = NULL;
gchar * key = NULL; gchar * key = NULL;
g_variant_get(parameters, "(ss)", &application_name, &key); g_variant_get(parameters, "(ss)", &application_name, &key);
if (g_strcmp0(application_name, koto_rev_dns) != 0) { // Not for Koto if (g_strcmp0(application_name, koto_rev_dns) != 0) { // Not for Koto
@ -140,7 +139,6 @@ void release_media_keys() {
GVariant * params = g_variant_new_string(g_strdup(koto_rev_dns)); GVariant * params = g_variant_new_string(g_strdup(koto_rev_dns));
g_dbus_proxy_call( g_dbus_proxy_call(
media_keys_proxy, media_keys_proxy,
"ReleaseMediaPlayerKeys", "ReleaseMediaPlayerKeys",
@ -160,7 +158,6 @@ void setup_mediakeys_interface() {
GDBusConnection * bus; GDBusConnection * bus;
GError * error = NULL; GError * error = NULL;
bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error); bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
if (bus == NULL) { // Failed to get session bus if (bus == NULL) { // Failed to get session bus
@ -196,7 +193,6 @@ void setup_mediakeys_interface() {
GtkEventController * focus_controller = gtk_event_controller_focus_new(); // Create a new focus controller GtkEventController * focus_controller = gtk_event_controller_focus_new(); // Create a new focus controller
g_signal_connect(focus_controller, "enter", G_CALLBACK(handle_window_enter), NULL); g_signal_connect(focus_controller, "enter", G_CALLBACK(handle_window_enter), NULL);
g_signal_connect(focus_controller, "leave", G_CALLBACK(handle_window_leave), NULL); g_signal_connect(focus_controller, "leave", G_CALLBACK(handle_window_leave), NULL);
gtk_widget_add_controller(GTK_WIDGET(main_window), focus_controller); gtk_widget_add_controller(GTK_WIDGET(main_window), focus_controller);

View file

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
#include <glib-2.0/glib.h> #include <glib-2.0/glib.h>
#include <gstreamer-1.0/gst/gst.h> #include <gstreamer-1.0/gst/gst.h>
#include "../koto-utils.h" #include "../koto-utils.h"
@ -32,7 +31,6 @@ gboolean koto_playback_engine_gst_caps_iter(
(void) user_data; (void) user_data;
gchar * caps_name = (gchar*) gst_structure_get_name(structure); // Get the name, typically a mimetype gchar * caps_name = (gchar*) gst_structure_get_name(structure); // Get the name, typically a mimetype
if (g_str_has_prefix(caps_name, "unknown")) { // Is unknown if (g_str_has_prefix(caps_name, "unknown")) { // Is unknown
return TRUE; return TRUE;
} }
@ -55,7 +53,6 @@ void koto_playback_engine_gst_pad_iter(
(void) user_data; (void) user_data;
GstStaticPadTemplate * templ = list_data; GstStaticPadTemplate * templ = list_data;
if (templ->direction == GST_PAD_SINK) { // Is a sink pad if (templ->direction == GST_PAD_SINK) { // Is a sink pad
GstCaps * capabilities = gst_static_pad_template_get_caps(templ); // Get the capabilities GstCaps * capabilities = gst_static_pad_template_get_caps(templ); // Get the capabilities
gst_caps_foreach(capabilities, koto_playback_engine_gst_caps_iter, NULL); // Iterate over and add to mimes gst_caps_foreach(capabilities, koto_playback_engine_gst_caps_iter, NULL); // Iterate over and add to mimes
@ -70,7 +67,6 @@ void koto_playback_engine_get_supported_mimetypes() {
GList * ele; GList * ele;
for (ele = elements; ele != NULL; ele = ele->next) { // For each of the elements for (ele = elements; ele != NULL; ele = ele->next) { // For each of the elements
// GList of GstStaticPadTemplate // GList of GstStaticPadTemplate
GList * static_pads = (GList*) gst_element_factory_get_static_pad_templates(ele->data); // Get the pads GList * static_pads = (GList*) gst_element_factory_get_static_pad_templates(ele->data); // Get the pads

View file

@ -164,7 +164,6 @@ GVariant * handle_get_property(
(void) user_data; (void) user_data;
GVariant * ret; GVariant * ret;
ret = NULL; ret = NULL;
if (g_strcmp0(property_name, "CanQuit") == 0) { // If property is CanQuit if (g_strcmp0(property_name, "CanQuit") == 0) { // If property is CanQuit
@ -298,7 +297,6 @@ gboolean handle_set_property(
void koto_update_mpris_playback_state(GstState state) { void koto_update_mpris_playback_state(GstState state) {
GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY); GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
if (state == GST_STATE_PLAYING) { if (state == GST_STATE_PLAYING) {
g_variant_builder_add(builder, "{sv}", "PlaybackStatus", g_variant_new_string("Playing")); g_variant_builder_add(builder, "{sv}", "PlaybackStatus", g_variant_new_string("Playing"));
} else if (state == GST_STATE_PAUSED) { } else if (state == GST_STATE_PAUSED) {
@ -325,7 +323,6 @@ void koto_update_mpris_info_for_track(KotoTrack * track) {
GVariant * metadata = koto_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); koto_update_mpris_info_for_track_with_metadata(track, metadata);
} }
@ -339,7 +336,6 @@ void koto_update_mpris_info_for_track_with_metadata(
GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY); GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
g_variant_builder_add(builder, "{sv}", "Metadata", metadata); g_variant_builder_add(builder, "{sv}", "Metadata", metadata);
g_dbus_connection_emit_signal( g_dbus_connection_emit_signal(

View file

@ -72,7 +72,6 @@ void koto_add_remove_track_popover_add_playlist(
gchar * playlist_uuid = koto_playlist_get_uuid(playlist); // Get the UUID of the playlist gchar * playlist_uuid = koto_playlist_get_uuid(playlist); // Get the UUID of the playlist
if (GTK_IS_CHECK_BUTTON(g_hash_table_lookup(self->playlist_uuid_to_checkbox, playlist_uuid))) { // Already have a check button for this if (GTK_IS_CHECK_BUTTON(g_hash_table_lookup(self->playlist_uuid_to_checkbox, playlist_uuid))) { // Already have a check button for this
g_free(playlist_uuid); g_free(playlist_uuid);
return; return;
@ -80,13 +79,11 @@ void koto_add_remove_track_popover_add_playlist(
GtkWidget * playlist_button = gtk_check_button_new_with_label(koto_playlist_get_name(playlist)); // Create our GtkCheckButton GtkWidget * playlist_button = gtk_check_button_new_with_label(koto_playlist_get_name(playlist)); // Create our GtkCheckButton
g_hash_table_insert(self->checkbox_to_playlist_uuid, playlist_button, playlist_uuid); g_hash_table_insert(self->checkbox_to_playlist_uuid, playlist_button, playlist_uuid);
g_hash_table_insert(self->playlist_uuid_to_checkbox, playlist_uuid, playlist_button); g_hash_table_insert(self->playlist_uuid_to_checkbox, playlist_uuid, playlist_button);
gulong playlist_sig_id = g_signal_connect(playlist_button, "toggled", G_CALLBACK(koto_add_remove_track_popover_handle_checkbutton_toggle), self); gulong playlist_sig_id = g_signal_connect(playlist_button, "toggled", G_CALLBACK(koto_add_remove_track_popover_handle_checkbutton_toggle), self);
g_hash_table_insert(self->checkbox_to_signal_ids, playlist_button, GUINT_TO_POINTER(playlist_sig_id)); // Add our GSignal handler ID g_hash_table_insert(self->checkbox_to_signal_ids, playlist_button, GUINT_TO_POINTER(playlist_sig_id)); // Add our GSignal handler ID
gtk_list_box_append(GTK_LIST_BOX(self->list_box), playlist_button); // Add the playlist to the list box gtk_list_box_append(GTK_LIST_BOX(self->list_box), playlist_button); // Add the playlist to the list box
@ -117,7 +114,6 @@ void koto_add_remove_track_popover_remove_playlist(
GtkCheckButton * btn = GTK_CHECK_BUTTON(g_hash_table_lookup(self->playlist_uuid_to_checkbox, playlist_uuid)); // Get the check button GtkCheckButton * btn = GTK_CHECK_BUTTON(g_hash_table_lookup(self->playlist_uuid_to_checkbox, playlist_uuid)); // Get the check button
if (GTK_IS_CHECK_BUTTON(btn)) { // Is a check button if (GTK_IS_CHECK_BUTTON(btn)) { // Is a check button
g_hash_table_remove(self->checkbox_to_playlist_uuid, btn); // Remove uuid based on btn g_hash_table_remove(self->checkbox_to_playlist_uuid, btn); // Remove uuid based on btn
gtk_list_box_remove(GTK_LIST_BOX(self->list_box), GTK_WIDGET(btn)); // Remove the button from the list box gtk_list_box_remove(GTK_LIST_BOX(self->list_box), GTK_WIDGET(btn)); // Remove the button from the list box
@ -132,7 +128,6 @@ void koto_add_remove_track_popover_handle_checkbutton_toggle(
) { ) {
KotoAddRemoveTrackPopover * self = user_data; KotoAddRemoveTrackPopover * self = user_data;
if (!KOTO_JS_ADD_REMOVE_TRACK_POPOVER(self)) { if (!KOTO_JS_ADD_REMOVE_TRACK_POPOVER(self)) {
return; return;
} }
@ -142,14 +137,12 @@ void koto_add_remove_track_popover_handle_checkbutton_toggle(
KotoPlaylist * playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, playlist_uuid); // Get the playlist KotoPlaylist * playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, playlist_uuid); // Get the playlist
if (!KOTO_IS_PLAYLIST(playlist)) { // Failed to get the playlist if (!KOTO_IS_PLAYLIST(playlist)) { // Failed to get the playlist
return; return;
} }
GList * pos; GList * pos;
for (pos = self->tracks; pos != NULL; pos = pos->next) { // Iterate over our KotoTracks for (pos = self->tracks; pos != NULL; pos = pos->next) { // Iterate over our KotoTracks
KotoTrack * track = pos->data; KotoTrack * track = pos->data;
@ -177,7 +170,6 @@ void koto_add_remove_track_popover_handle_playlist_added(
(void) carto; (void) carto;
KotoAddRemoveTrackPopover * self = user_data; KotoAddRemoveTrackPopover * self = user_data;
if (!KOTO_JS_ADD_REMOVE_TRACK_POPOVER(self)) { if (!KOTO_JS_ADD_REMOVE_TRACK_POPOVER(self)) {
return; return;
} }
@ -213,8 +205,7 @@ void koto_add_remove_track_popover_set_pointing_to_widget(
return; return;
} }
GtkWidget* existing_parent = gtk_widget_get_parent(GTK_WIDGET(self)); GtkWidget * existing_parent = gtk_widget_get_parent(GTK_WIDGET(self));
if (existing_parent != NULL) { if (existing_parent != NULL) {
g_object_ref(GTK_WIDGET(self)); // Increment widget ref since unparent will do an unref g_object_ref(GTK_WIDGET(self)); // Increment widget ref since unparent will do an unref
@ -235,7 +226,6 @@ void koto_add_remove_track_popover_set_tracks(
gint tracks_len = g_list_length(tracks); gint tracks_len = g_list_length(tracks);
if (tracks_len == 0) { // No tracks if (tracks_len == 0) { // No tracks
return; return;
} }
@ -245,7 +235,6 @@ void koto_add_remove_track_popover_set_tracks(
GHashTableIter playlists_iter; GHashTableIter playlists_iter;
gpointer uuid, playlist_ptr; gpointer uuid, playlist_ptr;
g_hash_table_iter_init(&playlists_iter, playlists); // Init our HashTable iterator g_hash_table_iter_init(&playlists_iter, playlists); // Init our HashTable iterator
while (g_hash_table_iter_next(&playlists_iter, &uuid, &playlist_ptr)) { // While we are iterating through our playlists while (g_hash_table_iter_next(&playlists_iter, &uuid, &playlist_ptr)) { // While we are iterating through our playlists

View file

@ -37,7 +37,6 @@ static GParamSpec * dialog_props[N_PROPS] = {
NULL, NULL,
}; };
struct _KotoCreateModifyPlaylistDialog { struct _KotoCreateModifyPlaylistDialog {
GtkBox parent_instance; GtkBox parent_instance;
GtkWidget * playlist_image; GtkWidget * playlist_image;
@ -70,7 +69,6 @@ static void koto_create_modify_playlist_dialog_set_property(
static void koto_create_modify_playlist_dialog_class_init(KotoCreateModifyPlaylistDialogClass * c) { static void koto_create_modify_playlist_dialog_class_init(KotoCreateModifyPlaylistDialogClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
gobject_class->set_property = koto_create_modify_playlist_dialog_set_property; gobject_class->set_property = koto_create_modify_playlist_dialog_set_property;
gobject_class->get_property = koto_create_modify_playlist_dialog_get_property; gobject_class->get_property = koto_create_modify_playlist_dialog_get_property;
@ -99,13 +97,11 @@ static void koto_create_modify_playlist_dialog_init(KotoCreateModifyPlaylistDial
GtkDropTarget * target = gtk_drop_target_new(G_TYPE_FILE, GDK_ACTION_COPY); GtkDropTarget * target = gtk_drop_target_new(G_TYPE_FILE, GDK_ACTION_COPY);
g_signal_connect(GTK_EVENT_CONTROLLER(target), "drop", G_CALLBACK(koto_create_modify_playlist_dialog_handle_drop), self); g_signal_connect(GTK_EVENT_CONTROLLER(target), "drop", G_CALLBACK(koto_create_modify_playlist_dialog_handle_drop), self);
gtk_widget_add_controller(self->playlist_image, GTK_EVENT_CONTROLLER(target)); gtk_widget_add_controller(self->playlist_image, GTK_EVENT_CONTROLLER(target));
GtkGesture * image_click_controller = gtk_gesture_click_new(); // Create a click gesture for the image clicking GtkGesture * image_click_controller = gtk_gesture_click_new(); // Create a click gesture for the image clicking
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(image_click_controller), 1); // Only allow left click gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(image_click_controller), 1); // Only allow left click
g_signal_connect(GTK_EVENT_CONTROLLER(image_click_controller), "pressed", G_CALLBACK(koto_create_modify_playlist_dialog_handle_image_click), self); g_signal_connect(GTK_EVENT_CONTROLLER(image_click_controller), "pressed", G_CALLBACK(koto_create_modify_playlist_dialog_handle_image_click), self);
@ -132,7 +128,6 @@ static void koto_create_modify_playlist_dialog_get_property(
) { ) {
KotoCreateModifyPlaylistDialog * self = KOTO_CREATE_MODIFY_PLAYLIST_DIALOG(obj); KotoCreateModifyPlaylistDialog * self = KOTO_CREATE_MODIFY_PLAYLIST_DIALOG(obj);
switch (prop_id) { switch (prop_id) {
case PROP_PLAYLIST_UUID: case PROP_PLAYLIST_UUID:
g_value_set_string(val, (self->playlist_uuid != NULL) ? g_strdup(self->playlist_uuid) : NULL); g_value_set_string(val, (self->playlist_uuid != NULL) ? g_strdup(self->playlist_uuid) : NULL);
@ -151,7 +146,6 @@ static void koto_create_modify_playlist_dialog_set_property(
) { ) {
KotoCreateModifyPlaylistDialog * self = KOTO_CREATE_MODIFY_PLAYLIST_DIALOG(obj); KotoCreateModifyPlaylistDialog * self = KOTO_CREATE_MODIFY_PLAYLIST_DIALOG(obj);
(void) self; (void) self;
(void) val; (void) val;
@ -177,7 +171,6 @@ void koto_create_modify_playlist_dialog_handle_chooser_response(
KotoCreateModifyPlaylistDialog * self = user_data; KotoCreateModifyPlaylistDialog * self = user_data;
if (!KOTO_IS_CURRENT_MODIFY_PLAYLIST(self)) { if (!KOTO_IS_CURRENT_MODIFY_PLAYLIST(self)) {
return; return;
} }
@ -185,7 +178,6 @@ void koto_create_modify_playlist_dialog_handle_chooser_response(
GFile * file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(native)); GFile * file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(native));
gchar * file_path = g_file_get_path(file); // Get the absolute path gchar * file_path = g_file_get_path(file); // Get the absolute path
if (file_path != NULL) { if (file_path != NULL) {
self->playlist_image_path = g_strdup(file_path); self->playlist_image_path = g_strdup(file_path);
gtk_image_set_from_file(GTK_IMAGE(self->playlist_image), self->playlist_image_path); // Set the file path gtk_image_set_from_file(GTK_IMAGE(self->playlist_image), self->playlist_image_path); // Set the file path
@ -204,7 +196,6 @@ void koto_create_modify_playlist_dialog_handle_create_click(
KotoCreateModifyPlaylistDialog * self = user_data; KotoCreateModifyPlaylistDialog * self = user_data;
if (!KOTO_IS_CURRENT_MODIFY_PLAYLIST(self)) { if (!KOTO_IS_CURRENT_MODIFY_PLAYLIST(self)) {
return; return;
} }
@ -217,7 +208,6 @@ void koto_create_modify_playlist_dialog_handle_create_click(
KotoPlaylist * playlist = NULL; KotoPlaylist * playlist = NULL;
gboolean modify_existing_playlist = koto_utils_is_string_valid(self->playlist_uuid); gboolean modify_existing_playlist = koto_utils_is_string_valid(self->playlist_uuid);
if (modify_existing_playlist) { // Modifying an existing playlist if (modify_existing_playlist) { // Modifying an existing playlist
playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, self->playlist_uuid); playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, self->playlist_uuid);
} else { // Creating a new playlist } else { // Creating a new playlist
@ -258,7 +248,6 @@ gboolean koto_create_modify_playlist_dialog_handle_drop(
KotoCreateModifyPlaylistDialog * self = user_data; KotoCreateModifyPlaylistDialog * self = user_data;
if (!KOTO_IS_CURRENT_MODIFY_PLAYLIST(self)) { // No dialog if (!KOTO_IS_CURRENT_MODIFY_PLAYLIST(self)) { // No dialog
return FALSE; return FALSE;
} }
@ -266,7 +255,6 @@ gboolean koto_create_modify_playlist_dialog_handle_drop(
GFile * dropped_file = g_value_get_object(val); // Get the GValue GFile * dropped_file = g_value_get_object(val); // Get the GValue
gchar * file_path = g_file_get_path(dropped_file); // Get the absolute path gchar * file_path = g_file_get_path(dropped_file); // Get the absolute path
g_object_unref(dropped_file); // Unref the file g_object_unref(dropped_file); // Unref the file
if (file_path == NULL) { if (file_path == NULL) {
@ -275,7 +263,6 @@ gboolean koto_create_modify_playlist_dialog_handle_drop(
magic_t magic_cookie = magic_open(MAGIC_MIME); magic_t magic_cookie = magic_open(MAGIC_MIME);
if (magic_cookie == NULL) { if (magic_cookie == NULL) {
return FALSE; return FALSE;
} }
@ -286,7 +273,6 @@ gboolean koto_create_modify_playlist_dialog_handle_drop(
const char * mime_type = magic_file(magic_cookie, file_path); const char * mime_type = magic_file(magic_cookie, file_path);
if ((mime_type != NULL) && g_str_has_prefix(mime_type, "image/")) { // Is an image if ((mime_type != NULL) && g_str_has_prefix(mime_type, "image/")) { // Is an image
self->playlist_image_path = g_strdup(file_path); self->playlist_image_path = g_strdup(file_path);
gtk_image_set_from_file(GTK_IMAGE(self->playlist_image), self->playlist_image_path); // Set the file path gtk_image_set_from_file(GTK_IMAGE(self->playlist_image), self->playlist_image_path); // Set the file path
@ -313,8 +299,7 @@ void koto_create_modify_playlist_dialog_handle_image_click(
KotoCreateModifyPlaylistDialog * self = user_data; KotoCreateModifyPlaylistDialog * self = user_data;
GtkFileChooserNative* chooser = koto_utils_create_image_file_chooser("Choose playlist image"); GtkFileChooserNative * chooser = koto_utils_create_image_file_chooser("Choose playlist image");
g_signal_connect(chooser, "response", G_CALLBACK(koto_create_modify_playlist_dialog_handle_chooser_response), self); g_signal_connect(chooser, "response", G_CALLBACK(koto_create_modify_playlist_dialog_handle_chooser_response), self);
gtk_native_dialog_show(GTK_NATIVE_DIALOG(chooser)); // Show our file chooser gtk_native_dialog_show(GTK_NATIVE_DIALOG(chooser)); // Show our file chooser
@ -341,7 +326,6 @@ void koto_create_modify_playlist_dialog_set_playlist_uuid(
KotoPlaylist * playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, playlist_uuid); KotoPlaylist * playlist = koto_cartographer_get_playlist_by_uuid(koto_maps, playlist_uuid);
if (!KOTO_IS_PLAYLIST(playlist)) { if (!KOTO_IS_PLAYLIST(playlist)) {
return; return;
} }
@ -352,7 +336,6 @@ void koto_create_modify_playlist_dialog_set_playlist_uuid(
gchar * art = koto_playlist_get_artwork(playlist); gchar * art = koto_playlist_get_artwork(playlist);
if (!koto_utils_is_string_valid(art)) { // If art is not defined if (!koto_utils_is_string_valid(art)) { // If art is not defined
gtk_image_set_from_icon_name(GTK_IMAGE(self->playlist_image), "insert-image-symbolic"); // Reset the image gtk_image_set_from_icon_name(GTK_IMAGE(self->playlist_image), "insert-image-symbolic"); // Reset the image
} else { } else {

View file

@ -54,7 +54,6 @@ static void koto_current_playlist_set_property(
static void koto_current_playlist_class_init(KotoCurrentPlaylistClass * c) { static void koto_current_playlist_class_init(KotoCurrentPlaylistClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
gobject_class->set_property = koto_current_playlist_set_property; gobject_class->set_property = koto_current_playlist_set_property;
gobject_class->get_property = koto_current_playlist_get_property; gobject_class->get_property = koto_current_playlist_get_property;
@ -82,7 +81,6 @@ void koto_current_playlist_get_property(
) { ) {
KotoCurrentPlaylist * self = KOTO_CURRENT_PLAYLIST(obj); KotoCurrentPlaylist * self = KOTO_CURRENT_PLAYLIST(obj);
switch (prop_id) { switch (prop_id) {
case PROP_CURRENT_PLAYLIST: case PROP_CURRENT_PLAYLIST:
g_value_set_object(val, self->current_playlist); g_value_set_object(val, self->current_playlist);
@ -101,7 +99,6 @@ void koto_current_playlist_set_property(
) { ) {
KotoCurrentPlaylist * self = KOTO_CURRENT_PLAYLIST(obj); KotoCurrentPlaylist * self = KOTO_CURRENT_PLAYLIST(obj);
switch (prop_id) { switch (prop_id) {
case PROP_CURRENT_PLAYLIST: case PROP_CURRENT_PLAYLIST:
koto_current_playlist_set_playlist(self, (KotoPlaylist*) g_value_get_object(val)); koto_current_playlist_set_playlist(self, (KotoPlaylist*) g_value_get_object(val));

View file

@ -107,7 +107,6 @@ static void koto_playlist_set_property(
static void koto_playlist_class_init(KotoPlaylistClass * c) { static void koto_playlist_class_init(KotoPlaylistClass * c) {
GObjectClass * gobject_class; GObjectClass * gobject_class;
gobject_class = G_OBJECT_CLASS(c); gobject_class = G_OBJECT_CLASS(c);
gobject_class->set_property = koto_playlist_set_property; gobject_class->set_property = koto_playlist_set_property;
gobject_class->get_property = koto_playlist_get_property; gobject_class->get_property = koto_playlist_get_property;
@ -213,7 +212,6 @@ static void koto_playlist_get_property(
) { ) {
KotoPlaylist * self = KOTO_PLAYLIST(obj); KotoPlaylist * self = KOTO_PLAYLIST(obj);
switch (prop_id) { switch (prop_id) {
case PROP_UUID: case PROP_UUID:
g_value_set_string(val, self->uuid); g_value_set_string(val, self->uuid);
@ -244,7 +242,6 @@ static void koto_playlist_set_property(
) { ) {
KotoPlaylist * self = KOTO_PLAYLIST(obj); KotoPlaylist * self = KOTO_PLAYLIST(obj);
switch (prop_id) { switch (prop_id) {
case PROP_UUID: case PROP_UUID:
koto_playlist_set_uuid(self, g_value_get_string(val)); koto_playlist_set_uuid(self, g_value_get_string(val));
@ -378,7 +375,6 @@ void koto_playlist_commit(KotoPlaylist * self) {
gchar * commit_op_errmsg = NULL; gchar * commit_op_errmsg = NULL;
int rc = sqlite3_exec(koto_db, commit_op, 0, 0, &commit_op_errmsg); int rc = sqlite3_exec(koto_db, commit_op, 0, 0, &commit_op_errmsg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
g_warning("Failed to save playlist: %s", commit_op_errmsg); g_warning("Failed to save playlist: %s", commit_op_errmsg);
} else { // Successfully saved our playlist } else { // Successfully saved our playlist
@ -395,7 +391,6 @@ void koto_playlist_commit_tracks(
) { ) {
KotoTrack * 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 if (track == NULL) { // Not a track
KotoPlaylist * self = user_data; KotoPlaylist * self = user_data;
gchar * playlist_uuid = self->uuid; // Get the playlist UUID gchar * playlist_uuid = self->uuid; // Get the playlist UUID
@ -457,7 +452,6 @@ gint koto_playlist_get_position_of_track(
gint position = -1; gint position = -1;
guint found_pos = 0; guint found_pos = 0;
if (g_list_store_find(self->store, track, &found_pos)) { // Found the item if (g_list_store_find(self->store, track, &found_pos)) { // Found the item
position = (gint) found_pos; // Cast our found position from guint to gint position = (gint) found_pos; // Cast our found position from guint to gint
} }
@ -473,7 +467,7 @@ gchar * koto_playlist_get_random_track(KotoPlaylist * self) {
track_uuid = g_list_nth_data(self->sorted_tracks->head, 0); // Get the first track_uuid = g_list_nth_data(self->sorted_tracks->head, 0); // Get the first
g_queue_clear(self->played_tracks); // Clear our played tracks g_queue_clear(self->played_tracks); // Clear our played tracks
} else { // Have not played all tracks } else { // Have not played all tracks
GRand* rando_calrissian = g_rand_new(); // Create a new RNG GRand * rando_calrissian = g_rand_new(); // Create a new RNG
guint attempt = 0; guint attempt = 0;
while (track_uuid == NULL) { // Haven't selected a track yet while (track_uuid == NULL) { // Haven't selected a track yet
@ -556,14 +550,12 @@ gchar * koto_playlist_go_to_previous(KotoPlaylist * self) {
KotoTrack * 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_TRACK(track)) { if (!KOTO_IS_TRACK(track)) {
return NULL; return NULL;
} }
gint pos_of_song = koto_playlist_get_position_of_track(self, track); // Get the position of the current track based on the current model gint pos_of_song = koto_playlist_get_position_of_track(self, track); // Get the position of the current track based on the current model
if (pos_of_song == 0) { if (pos_of_song == 0) {
return NULL; return NULL;
} }
@ -597,7 +589,6 @@ gint koto_playlist_model_sort_by_uuid(
KotoTrack * first_track = koto_cartographer_get_track_by_uuid(koto_maps, (gchar*) first_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); 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); return koto_playlist_model_sort_by_track(first_track, second_track, data_list);
} }
@ -609,11 +600,10 @@ gint koto_playlist_model_sort_by_track(
KotoTrack * first_track = (KotoTrack*) first_item; KotoTrack * first_track = (KotoTrack*) first_item;
KotoTrack * second_track = (KotoTrack*) second_item; KotoTrack * second_track = (KotoTrack*) second_item;
GList* ptr_list = data_list; 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 KotoPlaylist * self = g_list_nth_data(ptr_list, 0); // First item in the GPtrArray is a pointer to our playlist
KotoPreferredModelType model = GPOINTER_TO_UINT(g_list_nth_data(ptr_list, 1)); // Second item in the GPtrArray is a pointer to our KotoPreferredModelType KotoPreferredModelType model = GPOINTER_TO_UINT(g_list_nth_data(ptr_list, 1)); // Second item in the GPtrArray is a pointer to our KotoPreferredModelType
if ( if (
(model == KOTO_PREFERRED_MODEL_TYPE_DEFAULT) || // Newest first model (model == KOTO_PREFERRED_MODEL_TYPE_DEFAULT) || // Newest first model
(model == KOTO_PREFERRED_MODEL_TYPE_OLDEST_FIRST) // Oldest first (model == KOTO_PREFERRED_MODEL_TYPE_OLDEST_FIRST) // Oldest first
@ -761,14 +751,12 @@ void koto_playlist_remove_track_by_uuid(
KotoTrack * 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_TRACK(track)) { // Is not a track if (!KOTO_IS_TRACK(track)) { // Is not a track
return; return;
} }
guint position = 0; guint position = 0;
if (g_list_store_find(self->store, track, &position)) { // Got the position if (g_list_store_find(self->store, track, &position)) { // Got the position
g_list_store_remove(self->store, position); // Remove from the store g_list_store_remove(self->store, position); // Remove from the store
} }
@ -793,7 +781,6 @@ void koto_playlist_set_artwork(
magic_t cookie = magic_open(MAGIC_MIME); // Create our magic cookie so we can validate if what we are setting is an image magic_t cookie = magic_open(MAGIC_MIME); // Create our magic cookie so we can validate if what we are setting is an image
if (cookie == NULL) { // Failed to allocate if (cookie == NULL) { // Failed to allocate
return; return;
} }
@ -804,7 +791,6 @@ void koto_playlist_set_artwork(
const gchar * mime_type = magic_file(cookie, path); // Get the mimetype for this file const gchar * mime_type = magic_file(cookie, path); // Get the mimetype for this file
if ((mime_type == NULL) || !g_str_has_prefix(mime_type, "image/")) { // Failed to get our mimetype or not an image if ((mime_type == NULL) || !g_str_has_prefix(mime_type, "image/")) { // Failed to get our mimetype or not an image
goto free_cookie; goto free_cookie;
} }
@ -891,7 +877,6 @@ void koto_playlist_tracks_queue_push_to_store(
gchar * track_uuid = (gchar*) data; gchar * track_uuid = (gchar*) data;
KotoTrack * 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_TRACK(track)) { // Not a track if (!KOTO_IS_TRACK(track)) { // Not a track
return; return;
} }