diff --git a/src/api.vala b/src/api.vala index 8402282..29d5ce9 100644 --- a/src/api.vala +++ b/src/api.vala @@ -209,129 +209,6 @@ public class Wavelet.Subsonic : Object { this.unwrap_response (reader); } - public signal void done_reloading (); - - private int remaining_artists; - private int remaining_albums; - - public async void reload () throws Error { - this.artist_list.remove_all (); - this.album_list.remove_all (); - this.song_list.remove_all (); - - this.remaining_artists = 0; - this.remaining_albums = 0; - - var msg = new Soup.Message ("GET", @"$(this.url)/rest/getArtists?f=json&$(this.parameters)"); - var bytes = yield this.session.send_and_read_async (msg, Priority.DEFAULT, null); - - var parser = new Json.Parser (); - parser.load_from_data ((string) bytes.get_data ()); - - var reader = new Json.Reader (parser.get_root ()); - this.unwrap_response (reader); - - reader.read_member ("artists"); - reader.read_member ("index"); - - for (int i = 0; i < reader.count_elements (); i += 1) { - //for (int i = 0; i < 1; i += 1) { - reader.read_element (i); - - reader.read_member ("name"); - var index = reader.get_string_value (); - reader.end_member (); - - reader.read_member ("artist"); - for (int j = 0; j < reader.count_elements (); j += 1) { - reader.read_element (j); - - var artist = new Artist (index, reader); - artist_list.append (artist); - - this.remaining_artists += 1; - reload_artist.begin (artist.id); - - reader.end_element (); - } - reader.end_member (); - - reader.end_element (); - - assert (reader.get_error () == null); - } - } - - private async void reload_artist (string artist_id) throws Error { - try { - var msg = new Soup.Message ("GET", @"$(this.url)/rest/getArtist?id=$(artist_id)&f=json&$(this.parameters)"); - var bytes = yield this.session.send_and_read_async (msg, Priority.DEFAULT, null); - assert (msg.get_status () == Soup.Status.OK); - - var parser = new Json.Parser (); - parser.load_from_data ((string) bytes.get_data()); - - var reader = new Json.Reader (parser.get_root ()); - this.unwrap_response (reader); - - reader.read_member ("artist"); - reader.read_member ("album"); - - for (int i = 0; i < reader.count_elements (); i += 1) { - reader.read_element (i); - - var album = new Album (reader); - album_list.append (album); - - this.remaining_albums += 1; - reload_album.begin (album.id); - - reader.end_element (); - } - - assert (reader.get_error () == null); - } catch (Error e) { - warning ("could not reload artist %s: %s\n", artist_id, e.message); - } finally { - this.remaining_artists -= 1; - } - } - - private async void reload_album (string album_id) throws Error { - try { - var msg = new Soup.Message ("GET", @"$(this.url)/rest/getAlbum?id=$(album_id)&f=json&$(this.parameters)"); - var bytes = yield this.session.send_and_read_async (msg, Priority.DEFAULT, null); - assert (msg.get_status () == Soup.Status.OK); - - var parser = new Json.Parser (); - parser.load_from_data ((string) bytes.get_data()); - - var reader = new Json.Reader(parser.get_root ()); - this.unwrap_response (reader); - - reader.read_member ("album"); - reader.read_member ("song"); - - for (int i = 0; i < reader.count_elements (); i += 1) { - reader.read_element (i); - - var song = new Song (reader); - song_list.append (song); - - reader.end_element (); - } - - assert (reader.get_error () == null); - } catch (Error e) { - warning ("could not reload album %s: %s\n", album_id, e.message); - } finally { - this.remaining_albums -= 1; - if (this.remaining_artists == 0 && this.remaining_albums == 0) { - this.done_reloading (); - } - } - } - public async void get_random_songs (string? parameters, SongCallback callback) throws Error { string str_parameters; if (parameters == null) { diff --git a/src/application.vala b/src/application.vala index 1d23983..4df0695 100644 --- a/src/application.vala +++ b/src/application.vala @@ -45,9 +45,6 @@ public class Wavelet.Application : Adw.Application { var win = new Wavelet.Window (this); win.present (); - win.artist_list.set_loading (); - win.song_list.set_loading (); - playbin = Gst.ElementFactory.make ("playbin3", null); assert (playbin != null); @@ -96,20 +93,9 @@ public class Wavelet.Application : Adw.Application { return true; }); - var next_queue = new AsyncQueue (); - win.setup.connected.connect ((api) => { public_api = api; - win.artist_list.model = api.artist_list; - win.song_list.model = api.song_list; - - api.done_reloading.connect (() => { - win.artist_list.set_ready (); - win.song_list.set_ready (); - }); - //api.reload.begin (); - win.shuffle_all_tracks.sensitive = true; win.shuffle_all_tracks.activated.connect (() => { win.shuffle_all_tracks.sensitive = false; diff --git a/src/artist_list.blp b/src/artist_list.blp deleted file mode 100644 index ff1433d..0000000 --- a/src/artist_list.blp +++ /dev/null @@ -1,37 +0,0 @@ -using Gtk 4.0; -using Adw 1; - -template $WaveletArtistList: Adw.NavigationPage { - title: _("Artists"); - - Adw.ToolbarView { - [top] - Adw.HeaderBar {} - - Stack stack { - StackPage { - name: "loading"; - - child: Adw.Spinner {}; - } - - StackPage { - name: "ready"; - - child: ScrolledWindow { - ListView list_view { - factory: BuilderListItemFactory { - template ListItem { - child: Label { - halign: start; - label: bind template.item as <$WaveletArtist>.name; - }; - } - }; - } - }; - } - } - } -} - diff --git a/src/artist_list.vala b/src/artist_list.vala deleted file mode 100644 index dbb16c9..0000000 --- a/src/artist_list.vala +++ /dev/null @@ -1,38 +0,0 @@ -/* artist_list.vala - * - * Copyright 2024 Erica Z - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -[GtkTemplate (ui = "/eu/callcc/Wavelet/artist_list.ui")] -public class Wavelet.ArtistList : Adw.NavigationPage { - [GtkChild] private unowned Gtk.Stack stack; - [GtkChild] private unowned Gtk.ListView list_view; - - public ListModel model { - set { this.list_view.model = new Gtk.SingleSelection (value); } - get { return ((Gtk.SingleSelection) this.list_view.model).model; } - } - - public void set_loading () { - this.stack.visible_child_name = "loading"; - } - - public void set_ready () { - this.stack.visible_child_name = "ready"; - } -} diff --git a/src/meson.build b/src/meson.build index 78d63d5..26fa848 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,11 +1,9 @@ wavelet_sources = [ 'api.vala', 'application.vala', - 'artist_list.vala', 'main.vala', 'play_queue.vala', 'setup.vala', - 'song_list.vala', 'window.vala', ] @@ -22,17 +20,13 @@ wavelet_deps = [ blueprints = custom_target('blueprints', input: files( - 'artist_list.blp', 'play_queue.blp', 'setup.blp', - 'song_list.blp', 'window.blp', ), output: [ - 'artist_list.ui', 'play_queue.ui', 'setup.ui', - 'song_list.ui', 'window.ui', ], command: [ diff --git a/src/song_list.blp b/src/song_list.blp deleted file mode 100644 index ad903de..0000000 --- a/src/song_list.blp +++ /dev/null @@ -1,56 +0,0 @@ -using Gtk 4.0; -using Adw 1; - -template $WaveletSongList: Adw.NavigationPage { - title: _("Songs"); - - Adw.ToolbarView { - [top] - Adw.HeaderBar {} - - Stack stack { - StackPage { - name: "loading"; - - child: Adw.Spinner {}; - } - - StackPage { - name: "ready"; - - child: ScrolledWindow { - ColumnView column_view { - ColumnViewColumn title_column { - title: "Title"; - resizable: true; - - factory: SignalListItemFactory {}; - } - - ColumnViewColumn album_column { - title: "Album"; - resizable: true; - - factory: SignalListItemFactory {}; - } - - ColumnViewColumn artist_column { - title: "Artist"; - resizable: true; - - factory: SignalListItemFactory {}; - } - - ColumnViewColumn track_column { - title: "#"; - resizable: true; - - factory: SignalListItemFactory {}; - } - } - }; - } - } - } -} - diff --git a/src/song_list.vala b/src/song_list.vala deleted file mode 100644 index 5151408..0000000 --- a/src/song_list.vala +++ /dev/null @@ -1,85 +0,0 @@ -/* song_list.vala - * - * Copyright 2024 Erica Z - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -[GtkTemplate (ui = "/eu/callcc/Wavelet/song_list.ui")] -public class Wavelet.SongList : Adw.NavigationPage { - [GtkChild] private unowned Gtk.Stack stack; - [GtkChild] private unowned Gtk.ColumnView column_view; - - [GtkChild] private unowned Gtk.ColumnViewColumn title_column; - [GtkChild] private unowned Gtk.ColumnViewColumn album_column; - [GtkChild] private unowned Gtk.ColumnViewColumn artist_column; - [GtkChild] private unowned Gtk.ColumnViewColumn track_column; - - public ListModel model { - set { - this.column_view.model = new Gtk.SingleSelection ( - new Gtk.SortListModel (value, this.column_view.sorter)); - } - } - - construct { - this.title_column.sorter = new Gtk.StringSorter ( - new Gtk.PropertyExpression (typeof (Song), null, "title")); - this.album_column.sorter = new Gtk.StringSorter ( - new Gtk.PropertyExpression (typeof (Song), null, "album")); - this.artist_column.sorter = new Gtk.StringSorter ( - new Gtk.PropertyExpression (typeof (Song), null, "artist")); - this.track_column.sorter = new Gtk.NumericSorter ( - new Gtk.PropertyExpression (typeof (Song), null, "track")); - - ((Gtk.SignalListItemFactory) this.title_column.factory).bind.connect ((item) => { - var list_item = (Gtk.ListItem) item; - var song = (Song) list_item.item; - list_item.child = new Gtk.Label (song.title) { - halign = Gtk.Align.START, - }; - }); - ((Gtk.SignalListItemFactory) this.album_column.factory).bind.connect ((item) => { - var list_item = (Gtk.ListItem) item; - var song = (Song) list_item.item; - list_item.child = new Gtk.Label (song.album) { - halign = Gtk.Align.START, - }; - }); - ((Gtk.SignalListItemFactory) this.artist_column.factory).bind.connect ((item) => { - var list_item = (Gtk.ListItem) item; - var song = (Song) list_item.item; - list_item.child = new Gtk.Label (song.artist) { - halign = Gtk.Align.START, - }; - }); - ((Gtk.SignalListItemFactory) this.track_column.factory).bind.connect ((item) => { - var list_item = (Gtk.ListItem) item; - var song = (Song) list_item.item; - list_item.child = new Gtk.Label (song.track.to_string ()) { - halign = Gtk.Align.START, - }; - }); - } - - public void set_loading () { - this.stack.visible_child_name = "loading"; - } - - public void set_ready () { - this.stack.visible_child_name = "ready"; - } -} diff --git a/src/wavelet.gresource.xml b/src/wavelet.gresource.xml index 1318bc3..1385809 100644 --- a/src/wavelet.gresource.xml +++ b/src/wavelet.gresource.xml @@ -1,11 +1,9 @@ - artist_list.ui gtk/help-overlay.ui play_queue.ui setup.ui - song_list.ui window.ui diff --git a/src/window.blp b/src/window.blp index 99f81ff..c09a8bb 100644 --- a/src/window.blp +++ b/src/window.blp @@ -74,20 +74,6 @@ template $WaveletWindow: Adw.ApplicationWindow { child: $WaveletSetup setup {}; } - StackPage { - name: "artist_list"; - title: _("Artists"); - - child: $WaveletArtistList artist_list {}; - } - - StackPage { - name: "song_list"; - title: _("Songs"); - - child: $WaveletSongList song_list {}; - } - StackPage { name: "play_queue"; title: _("Play queue"); diff --git a/src/window.vala b/src/window.vala index 3348a0f..06074d4 100644 --- a/src/window.vala +++ b/src/window.vala @@ -26,15 +26,11 @@ public class Wavelet.Window : Adw.ApplicationWindow { [GtkChild] private unowned Gtk.Stack stack; [GtkChild] public unowned Wavelet.Setup setup; - [GtkChild] public unowned Wavelet.ArtistList artist_list; - [GtkChild] public unowned Wavelet.SongList song_list; [GtkChild] public unowned Wavelet.PlayQueue play_queue; [GtkChild] public unowned Adw.ButtonRow shuffle_all_tracks; [GtkChild] public unowned Gtk.Button mute; - [GtkChild] private unowned Gtk.Label play_position_label; [GtkChild] public unowned Gtk.Scale play_position; - [GtkChild] private unowned Gtk.Label play_duration; public int play_position_ms { get; set; default = 0; } public int play_duration_ms { get; set; default = 1; }