2024-10-06 11:21:53 +00:00
|
|
|
/* window.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/window.ui")]
|
|
|
|
public class Wavelet.Window : Adw.ApplicationWindow {
|
2024-10-10 09:53:52 +00:00
|
|
|
[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;
|
|
|
|
|
2024-10-06 11:21:53 +00:00
|
|
|
[GtkChild] public unowned Wavelet.Setup setup;
|
|
|
|
[GtkChild] public unowned Wavelet.ArtistList artist_list;
|
|
|
|
[GtkChild] public unowned Wavelet.SongList song_list;
|
2024-10-10 09:53:52 +00:00
|
|
|
[GtkChild] public unowned Wavelet.PlayQueue play_queue;
|
2024-10-10 10:51:12 +00:00
|
|
|
[GtkChild] public unowned Adw.ButtonRow shuffle_all_tracks;
|
2024-10-06 11:21:53 +00:00
|
|
|
|
2024-10-11 06:57:01 +00:00
|
|
|
[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 int64 play_position_ms { get; set; default = 0; }
|
|
|
|
public int64 play_duration_ms { get; set; default = 1; }
|
|
|
|
|
|
|
|
public double volume { get; set; default = 1.0; }
|
|
|
|
|
2024-10-06 11:21:53 +00:00
|
|
|
public Window (Gtk.Application app) {
|
|
|
|
Object (application: app);
|
|
|
|
}
|
2024-10-10 09:53:52 +00:00
|
|
|
|
|
|
|
construct {
|
2024-10-11 06:57:01 +00:00
|
|
|
this.notify["play-position-ms"].connect ((s, p) => {
|
|
|
|
int seconds = (int)(this.play_position_ms/1000);
|
|
|
|
this.play_position_label.label = "%02d:%02d".printf(seconds/60, seconds%60);
|
|
|
|
});
|
|
|
|
this.notify["play-duration-ms"].connect ((s, p) => {
|
|
|
|
int seconds = (int)(this.play_duration_ms/1000);
|
|
|
|
this.play_duration.label = "%02d:%02d".printf(seconds/60, seconds%60);
|
|
|
|
});
|
|
|
|
|
2024-10-10 09:53:52 +00:00
|
|
|
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));
|
|
|
|
}
|
2024-10-11 06:57:01 +00:00
|
|
|
|
|
|
|
public void show_mute () {
|
|
|
|
this.mute.icon_name = "audio-volume-muted";
|
|
|
|
}
|
|
|
|
|
|
|
|
public void show_unmute () {
|
|
|
|
this.mute.icon_name = "audio-volume-high";
|
|
|
|
}
|
2024-10-06 11:21:53 +00:00
|
|
|
}
|