From c9cc47df1f0ba6a42dcea0a212f27eff4404e198 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Sat, 12 Oct 2024 19:06:15 +0000 Subject: [PATCH] make setup a dialog --- src/setup.blp | 8 ++++---- src/setup.vala | 2 +- src/window.blp | 22 +++++++--------------- src/window.vala | 14 +++++++++----- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/setup.blp b/src/setup.blp index 8aca20b..f886e69 100644 --- a/src/setup.blp +++ b/src/setup.blp @@ -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 (); } - }; + } } } } diff --git a/src/setup.vala b/src/setup.vala index 8f1c665..1a2c06b 100644 --- a/src/setup.vala +++ b/src/setup.vala @@ -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; } diff --git a/src/window.blp b/src/window.blp index 25793a8..856a409 100644 --- a/src/window.blp +++ b/src/window.blp @@ -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"); diff --git a/src/window.vala b/src/window.vala index d78b6a5..3069adc 100644 --- a/src/window.vala +++ b/src/window.vala @@ -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); + } }