make setup a dialog

This commit is contained in:
me 2024-10-12 19:06:15 +00:00
parent 648f202177
commit 1f42452571
4 changed files with 21 additions and 25 deletions

View file

@ -1,15 +1,15 @@
using Gtk 4.0; using Gtk 4.0;
using Adw 1; using Adw 1;
template $WaveletSetup: Adw.NavigationPage { template $WaveletSetup: Adw.PreferencesDialog {
title: _("Setup"); title: _("Setup");
Adw.ToolbarView { Adw.ToolbarView {
[top] [top]
Adw.HeaderBar {} Adw.HeaderBar {}
Adw.Clamp { Adw.PreferencesPage {
child: Adw.PreferencesGroup { Adw.PreferencesGroup {
title: _("Authentication"); title: _("Authentication");
[header-suffix] [header-suffix]
@ -59,7 +59,7 @@ template $WaveletSetup: Adw.NavigationPage {
activated => $on_authn_validate_activated (); activated => $on_authn_validate_activated ();
} }
}; }
} }
} }
} }

View file

@ -22,7 +22,7 @@
public extern void randomness (int N, void *P); public extern void randomness (int N, void *P);
[GtkTemplate (ui = "/eu/callcc/Wavelet/setup.ui")] [GtkTemplate (ui = "/eu/callcc/Wavelet/setup.ui")]
public class Wavelet.Setup : Adw.NavigationPage { public class Wavelet.Setup : Adw.PreferencesDialog {
public string status { get; private set; default = _("Not connected"); } public string status { get; private set; default = _("Not connected"); }
public bool authn_can_edit { get; private set; default = true; } public bool authn_can_edit { get; private set; default = true; }

View file

@ -19,7 +19,13 @@ template $WaveletWindow: Adw.ApplicationWindow {
Adw.ToolbarView { Adw.ToolbarView {
[top] [top]
Adw.HeaderBar {} Adw.HeaderBar {
[end]
Button {
icon-name: "applications-system";
clicked => $show_setup_dialog ();
}
}
content: Box { content: Box {
orientation: vertical; orientation: vertical;
@ -31,13 +37,6 @@ template $WaveletWindow: Adw.ApplicationWindow {
row-activated => $on_sidebar_row_activated(); row-activated => $on_sidebar_row_activated();
ListBoxRow sidebar_setup {
Label {
xalign: 0;
label: _("Setup");
}
}
ListBoxRow sidebar_play_queue { ListBoxRow sidebar_play_queue {
Label { Label {
xalign: 0; xalign: 0;
@ -78,13 +77,6 @@ paintable: bind template.playing_cover_art;
[content] [content]
Stack stack { Stack stack {
StackPage {
name: "setup";
title: _("Setup");
child: $WaveletSetup setup {};
}
StackPage { StackPage {
name: "play_queue"; name: "play_queue";
title: _("Play queue"); title: _("Play queue");

View file

@ -21,14 +21,14 @@
[GtkTemplate (ui = "/eu/callcc/Wavelet/window.ui")] [GtkTemplate (ui = "/eu/callcc/Wavelet/window.ui")]
class Wavelet.Window : Adw.ApplicationWindow { class Wavelet.Window : Adw.ApplicationWindow {
[GtkChild] private unowned Gtk.ListBox sidebar; [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.ListBoxRow sidebar_play_queue;
[GtkChild] private unowned Gtk.Stack stack; [GtkChild] private unowned Gtk.Stack stack;
[GtkChild] public unowned Wavelet.Setup setup;
[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;
private Wavelet.Setup setup;
public bool playing { get; private set; default = false; } public bool playing { get; private set; default = false; }
[GtkChild] private unowned Gtk.Scale play_position; [GtkChild] private unowned Gtk.Scale play_position;
@ -81,6 +81,8 @@ class Wavelet.Window : Adw.ApplicationWindow {
() => {}, () => {},
() => { error ("could not acquire dbus name"); }); () => { error ("could not acquire dbus name"); });
this.setup = new Wavelet.Setup ();
this.setup.connected.connect ((api) => { this.setup.connected.connect ((api) => {
public_api = api; public_api = api;
@ -160,9 +162,7 @@ class Wavelet.Window : Adw.ApplicationWindow {
} }
[GtkCallback] private void on_sidebar_row_activated (Gtk.ListBoxRow row) { [GtkCallback] private void on_sidebar_row_activated (Gtk.ListBoxRow row) {
if (row == this.sidebar_setup) { if (row == this.sidebar_play_queue) {
this.stack.set_visible_child_name("setup");
} else if (row == this.sidebar_play_queue) {
this.stack.set_visible_child_name("play_queue"); this.stack.set_visible_child_name("play_queue");
} }
} }
@ -216,4 +216,8 @@ class Wavelet.Window : Adw.ApplicationWindow {
[GtkCallback] private void on_skip_backward_clicked () { [GtkCallback] private void on_skip_backward_clicked () {
this.play_queue.skip_backward (); this.play_queue.skip_backward ();
} }
[GtkCallback] private void show_setup_dialog () {
this.setup.present (this);
}
} }