some changes
This commit is contained in:
parent
5e7a7e3391
commit
577b3c5c4d
8 changed files with 210 additions and 8 deletions
43
src/api.vala
43
src/api.vala
|
@ -19,7 +19,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
errordomain SubsonicError {
|
errordomain SubsonicError {
|
||||||
FAILED
|
ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Wavelet.Artist : Object, Json.Serializable {
|
public class Wavelet.Artist : Object, Json.Serializable {
|
||||||
|
@ -107,6 +107,45 @@ public class Wavelet.Song : Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct Wavelet.API.PlayQueue {
|
||||||
|
public string current;
|
||||||
|
public int64 position;
|
||||||
|
public DateTime changed;
|
||||||
|
public string changed_by;
|
||||||
|
public ListStore songs;
|
||||||
|
|
||||||
|
internal PlayQueue.from_reader (Json.Reader reader) {
|
||||||
|
reader.read_member ("current");
|
||||||
|
this.current = reader.get_string_value ();
|
||||||
|
reader.end_member ();
|
||||||
|
|
||||||
|
reader.read_member ("position");
|
||||||
|
this.position = reader.get_int_value ();
|
||||||
|
reader.end_member ();
|
||||||
|
|
||||||
|
reader.read_member ("changed");
|
||||||
|
this.changed = new DateTime.from_iso8601 (reader.get_string_value (), null);
|
||||||
|
reader.end_member ();
|
||||||
|
|
||||||
|
reader.read_member ("changed_by");
|
||||||
|
this.changed_by = reader.get_string_value ();
|
||||||
|
reader.end_member ();
|
||||||
|
|
||||||
|
print("%s %lli %s %s\n",this.current, this.position, this.changed, this.changed_by);
|
||||||
|
|
||||||
|
this.songs = new ListStore (typeof (Song));
|
||||||
|
|
||||||
|
reader.read_member ("song");
|
||||||
|
for (int i = 0; i < reader.count_elements (); i += 1) {
|
||||||
|
reader.read_element (i);
|
||||||
|
this.songs.append (new Song (reader));
|
||||||
|
reader.end_element ();
|
||||||
|
}
|
||||||
|
reader.end_member ();
|
||||||
|
assert (reader.get_error () == null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class Wavelet.Subsonic : Object {
|
public class Wavelet.Subsonic : Object {
|
||||||
public ListStore artist_list;
|
public ListStore artist_list;
|
||||||
public ListStore album_list;
|
public ListStore album_list;
|
||||||
|
@ -146,7 +185,7 @@ public class Wavelet.Subsonic : Object {
|
||||||
reader.end_member ();
|
reader.end_member ();
|
||||||
reader.read_member ("error");
|
reader.read_member ("error");
|
||||||
reader.read_member ("message");
|
reader.read_member ("message");
|
||||||
throw new SubsonicError.FAILED (reader.get_string_value () ?? "???");
|
throw new SubsonicError.ERROR (reader.get_string_value () ?? "???");
|
||||||
}
|
}
|
||||||
reader.end_member();
|
reader.end_member();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ wavelet_sources = [
|
||||||
'application.vala',
|
'application.vala',
|
||||||
'artist_list.vala',
|
'artist_list.vala',
|
||||||
'main.vala',
|
'main.vala',
|
||||||
|
'play_queue.vala',
|
||||||
'setup.vala',
|
'setup.vala',
|
||||||
'song_list.vala',
|
'song_list.vala',
|
||||||
'window.vala',
|
'window.vala',
|
||||||
|
|
29
src/play_queue.ui
Normal file
29
src/play_queue.ui
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk" version="4.0"/>
|
||||||
|
<requires lib="Adw" version="1.0"/>
|
||||||
|
<template class="WaveletPlayQueue" parent="AdwNavigationPage">
|
||||||
|
<property name="title" translatable="true">Play queue</property>
|
||||||
|
<child>
|
||||||
|
<object class="AdwToolbarView">
|
||||||
|
<child type="top">
|
||||||
|
<object class="AdwHeaderBar"></object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkScrolledWindow">
|
||||||
|
<child>
|
||||||
|
<object class="GtkListView" id="list_view">
|
||||||
|
<style><class name="view"/></style>
|
||||||
|
<property name="factory">
|
||||||
|
<object class="GtkBuilderListItemFactory">
|
||||||
|
<property name="resource">/eu/callcc/Wavelet/play_queue_song.ui</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</template>
|
||||||
|
</interface>
|
41
src/play_queue.vala
Normal file
41
src/play_queue.vala
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/* play_queue.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/play_queue.ui")]
|
||||||
|
public class Wavelet.PlayQueue : Adw.NavigationPage {
|
||||||
|
[GtkChild] private unowned Gtk.ListView list_view;
|
||||||
|
|
||||||
|
private ListStore songs;
|
||||||
|
private uint current;
|
||||||
|
|
||||||
|
construct {
|
||||||
|
this.songs = new ListStore (typeof (Song));
|
||||||
|
this.list_view.model = new Gtk.NoSelection (this.songs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear () {
|
||||||
|
this.songs.remove_all ();
|
||||||
|
this.current = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void queue (Song song) {
|
||||||
|
this.songs.append (song);
|
||||||
|
}
|
||||||
|
}
|
17
src/play_queue_song.ui
Normal file
17
src/play_queue_song.ui
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk" version="4.0"/>
|
||||||
|
<requires lib="Adw" version="1.0"/>
|
||||||
|
<template class="GtkListItem">
|
||||||
|
<property name="child">
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<binding name="label">
|
||||||
|
<lookup type="WaveletSong" name="name">
|
||||||
|
<lookup name="item">GtkListItem</lookup>
|
||||||
|
</lookup>
|
||||||
|
</binding>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</template>
|
||||||
|
</interface>
|
|
@ -4,6 +4,8 @@
|
||||||
<file preprocess="xml-stripblanks">artist_list.ui</file>
|
<file preprocess="xml-stripblanks">artist_list.ui</file>
|
||||||
<file preprocess="xml-stripblanks">artist_list_artist.ui</file>
|
<file preprocess="xml-stripblanks">artist_list_artist.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_song.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">song_list.ui</file>
|
||||||
<file preprocess="xml-stripblanks">song_list_song.ui</file>
|
<file preprocess="xml-stripblanks">song_list_song.ui</file>
|
||||||
|
|
|
@ -8,9 +8,11 @@
|
||||||
<property name="default-width">800</property>
|
<property name="default-width">800</property>
|
||||||
<property name="default-height">600</property>
|
<property name="default-height">600</property>
|
||||||
<property name="content">
|
<property name="content">
|
||||||
<object class="AdwToolbarView">
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwOverlaySplitView">
|
<object class="AdwOverlaySplitView">
|
||||||
|
<property name="vexpand">true</property>
|
||||||
<child type="sidebar">
|
<child type="sidebar">
|
||||||
<object class="AdwNavigationPage">
|
<object class="AdwNavigationPage">
|
||||||
<property name="width-request">100</property>
|
<property name="width-request">100</property>
|
||||||
|
@ -18,13 +20,57 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwToolbarView">
|
<object class="AdwToolbarView">
|
||||||
<child type="top">
|
<child type="top">
|
||||||
<object class="AdwHeaderBar"></object>
|
<object class="AdwHeaderBar">
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkStackSidebar">
|
|
||||||
<property name="stack">stack</property>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<property name="content">
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkListBox" id="sidebar">
|
||||||
|
<style><class name="navigation-sidebar"/></style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkListBoxRow" id="sidebar_setup">
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label">Setup</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkListBoxRow" id="sidebar_play_queue">
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label">Play queue</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSeparator">
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkListBox">
|
||||||
|
<property name="selection-mode">none</property>
|
||||||
|
<style><class name="navigation-sidebar"/></style>
|
||||||
|
<child>
|
||||||
|
<object class="AdwButtonRow">
|
||||||
|
<property name="title">Shuffle all tracks</property>
|
||||||
|
<property name="start-icon-name">media-playlist-shuffle</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -58,6 +104,15 @@
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkStackPage">
|
||||||
|
<property name="name">play_queue</property>
|
||||||
|
<property name="title">Play queue</property>
|
||||||
|
<property name="child">
|
||||||
|
<object class="WaveletPlayQueue" id="play_queue"/>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -20,11 +20,29 @@
|
||||||
|
|
||||||
[GtkTemplate (ui = "/eu/callcc/Wavelet/window.ui")]
|
[GtkTemplate (ui = "/eu/callcc/Wavelet/window.ui")]
|
||||||
public class Wavelet.Window : Adw.ApplicationWindow {
|
public class Wavelet.Window : Adw.ApplicationWindow {
|
||||||
|
[GtkChild] private unowned Gtk.ListBox sidebar;
|
||||||
|
[GtkChild] private unowned Gtk.ListBoxRow sidebar_setup;
|
||||||
|
[GtkChild] private unowned Gtk.ListBoxRow sidebar_play_queue;
|
||||||
|
[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.ArtistList artist_list;
|
||||||
[GtkChild] public unowned Wavelet.SongList song_list;
|
[GtkChild] public unowned Wavelet.SongList song_list;
|
||||||
|
[GtkChild] public unowned Wavelet.PlayQueue play_queue;
|
||||||
|
|
||||||
public Window (Gtk.Application app) {
|
public Window (Gtk.Application app) {
|
||||||
Object (application: app);
|
Object (application: app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
construct {
|
||||||
|
this.sidebar.row_activated.connect ((row) => {
|
||||||
|
if (row == this.sidebar_setup) {
|
||||||
|
this.stack.set_visible_child_name("setup");
|
||||||
|
} else if (row == this.sidebar_play_queue) {
|
||||||
|
this.stack.set_visible_child_name("play_queue");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.sidebar.select_row (this.sidebar.get_row_at_index (0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue