From a21a63e4b8ef9567b305a995e3d96f2a7d02620d Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Sun, 23 Mar 2025 10:25:28 +0100 Subject: [PATCH] preferences: Add settings for library URL --- data/de.johrpan.Musicus.gschema.xml.in | 8 ++++++++ data/ui/preferences_dialog.blp | 18 ++++++++++++++++++ src/preferences_dialog.rs | 21 +++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/data/de.johrpan.Musicus.gschema.xml.in b/data/de.johrpan.Musicus.gschema.xml.in index 29c2805..27f4f52 100644 --- a/data/de.johrpan.Musicus.gschema.xml.in +++ b/data/de.johrpan.Musicus.gschema.xml.in @@ -52,5 +52,13 @@ '{"title":"A long time ago","description":"Works that you haven\'t listened to for a long time.","design":"Purple","prefer_recently_added":0.0,"prefer_least_recently_played":1.0,"avoid_repeated_composers":60,"avoid_repeated_instruments":60,"play_full_recordings":true}' Default settings for program 3 + + false + Use a custom URL for library downloads + + + 'https://musicus.johrpan.de/musicus_library_latest.zip' + Custom URL for library downloads + diff --git a/data/ui/preferences_dialog.blp b/data/ui/preferences_dialog.blp index 16f3dc9..6bfe78a 100644 --- a/data/ui/preferences_dialog.blp +++ b/data/ui/preferences_dialog.blp @@ -62,4 +62,22 @@ template $MusicusPreferencesDialog: Adw.PreferencesDialog { } } } + + Adw.PreferencesPage { + title: _("Library"); + + Adw.PreferencesGroup { + title: _("Library download"); + + Adw.SwitchRow use_custom_url_row { + title: _("Use custom download URL"); + active: false; + } + + Adw.EntryRow custom_url_row { + title: _("Download URL"); + show-apply-button: true; + } + } + } } diff --git a/src/preferences_dialog.rs b/src/preferences_dialog.rs index aa40743..be07780 100644 --- a/src/preferences_dialog.rs +++ b/src/preferences_dialog.rs @@ -19,6 +19,10 @@ mod imp { pub avoid_repeated_instruments_adjustment: TemplateChild, #[template_child] pub play_full_recordings_row: TemplateChild, + #[template_child] + pub use_custom_url_row: TemplateChild, + #[template_child] + pub custom_url_row: TemplateChild, } #[glib::object_subclass] @@ -83,6 +87,23 @@ mod imp { "active", ) .build(); + + settings + .bind( + "use-custom-library-url", + &*self.use_custom_url_row, + "active", + ) + .build(); + + settings + .bind("custom-library-url", &*self.custom_url_row, "text") + .build(); + + self.use_custom_url_row + .bind_property("active", &*self.custom_url_row, "sensitive") + .sync_create() + .build(); } }