removed unused widgets

This commit is contained in:
me 2024-10-11 19:37:45 +00:00
parent 7d7d4c4fc1
commit 4f2ce1c340
10 changed files with 0 additions and 379 deletions

View file

@ -209,129 +209,6 @@ public class Wavelet.Subsonic : Object {
this.unwrap_response (reader); 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 { public async void get_random_songs (string? parameters, SongCallback callback) throws Error {
string str_parameters; string str_parameters;
if (parameters == null) { if (parameters == null) {

View file

@ -45,9 +45,6 @@ public class Wavelet.Application : Adw.Application {
var win = new Wavelet.Window (this); var win = new Wavelet.Window (this);
win.present (); win.present ();
win.artist_list.set_loading ();
win.song_list.set_loading ();
playbin = Gst.ElementFactory.make ("playbin3", null); playbin = Gst.ElementFactory.make ("playbin3", null);
assert (playbin != null); assert (playbin != null);
@ -96,20 +93,9 @@ public class Wavelet.Application : Adw.Application {
return true; return true;
}); });
var next_queue = new AsyncQueue<string?> ();
win.setup.connected.connect ((api) => { win.setup.connected.connect ((api) => {
public_api = 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.sensitive = true;
win.shuffle_all_tracks.activated.connect (() => { win.shuffle_all_tracks.activated.connect (() => {
win.shuffle_all_tracks.sensitive = false; win.shuffle_all_tracks.sensitive = false;

View file

@ -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;
};
}
};
}
};
}
}
}
}

View file

@ -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 <https://www.gnu.org/licenses/>.
*
* 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";
}
}

View file

@ -1,11 +1,9 @@
wavelet_sources = [ wavelet_sources = [
'api.vala', 'api.vala',
'application.vala', 'application.vala',
'artist_list.vala',
'main.vala', 'main.vala',
'play_queue.vala', 'play_queue.vala',
'setup.vala', 'setup.vala',
'song_list.vala',
'window.vala', 'window.vala',
] ]
@ -22,17 +20,13 @@ wavelet_deps = [
blueprints = custom_target('blueprints', blueprints = custom_target('blueprints',
input: files( input: files(
'artist_list.blp',
'play_queue.blp', 'play_queue.blp',
'setup.blp', 'setup.blp',
'song_list.blp',
'window.blp', 'window.blp',
), ),
output: [ output: [
'artist_list.ui',
'play_queue.ui', 'play_queue.ui',
'setup.ui', 'setup.ui',
'song_list.ui',
'window.ui', 'window.ui',
], ],
command: [ command: [

View file

@ -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 {};
}
}
};
}
}
}
}

View file

@ -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 <https://www.gnu.org/licenses/>.
*
* 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";
}
}

View file

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<gresources> <gresources>
<gresource prefix="/eu/callcc/Wavelet"> <gresource prefix="/eu/callcc/Wavelet">
<file preprocess="xml-stripblanks">artist_list.ui</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file> <file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
<file preprocess="xml-stripblanks">play_queue.ui</file> <file preprocess="xml-stripblanks">play_queue.ui</file>
<file preprocess="xml-stripblanks">setup.ui</file> <file preprocess="xml-stripblanks">setup.ui</file>
<file preprocess="xml-stripblanks">song_list.ui</file>
<file preprocess="xml-stripblanks">window.ui</file> <file preprocess="xml-stripblanks">window.ui</file>
</gresource> </gresource>
</gresources> </gresources>

View file

@ -74,20 +74,6 @@ template $WaveletWindow: Adw.ApplicationWindow {
child: $WaveletSetup setup {}; child: $WaveletSetup setup {};
} }
StackPage {
name: "artist_list";
title: _("Artists");
child: $WaveletArtistList artist_list {};
}
StackPage {
name: "song_list";
title: _("Songs");
child: $WaveletSongList song_list {};
}
StackPage { StackPage {
name: "play_queue"; name: "play_queue";
title: _("Play queue"); title: _("Play queue");

View file

@ -26,15 +26,11 @@ public class Wavelet.Window : Adw.ApplicationWindow {
[GtkChild] private unowned Gtk.Stack stack; [GtkChild] private unowned Gtk.Stack stack;
[GtkChild] public unowned Wavelet.Setup setup; [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 Wavelet.PlayQueue play_queue;
[GtkChild] public unowned Adw.ButtonRow shuffle_all_tracks; [GtkChild] public unowned Adw.ButtonRow shuffle_all_tracks;
[GtkChild] public unowned Gtk.Button mute; [GtkChild] public unowned Gtk.Button mute;
[GtkChild] private unowned Gtk.Label play_position_label;
[GtkChild] public unowned Gtk.Scale play_position; [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_position_ms { get; set; default = 0; }
public int play_duration_ms { get; set; default = 1; } public int play_duration_ms { get; set; default = 1; }