make setup a dialog

This commit is contained in:
Erica Z 2024-10-12 19:06:15 +00:00
parent 9ace252065
commit c9cc47df1f
4 changed files with 21 additions and 25 deletions

View file

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

View file

@ -22,7 +22,7 @@
public extern void randomness (int N, void *P);
[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 bool authn_can_edit { get; private set; default = true; }

View file

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

View file

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