preferences: Add settings for library URL

This commit is contained in:
Elias Projahn 2025-03-23 10:25:28 +01:00
parent d12e6a02a4
commit a21a63e4b8
3 changed files with 47 additions and 0 deletions

View file

@ -52,5 +52,13 @@
<default l10n="messages">'{"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>
<summary>Default settings for program 3</summary>
</key>
<key name="use-custom-library-url" type="b">
<default>false</default>
<summary>Use a custom URL for library downloads</summary>
</key>
<key name="custom-library-url" type="s">
<default>'https://musicus.johrpan.de/musicus_library_latest.zip'</default>
<summary>Custom URL for library downloads</summary>
</key>
</schema>
</schemalist>

View file

@ -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;
}
}
}
}

View file

@ -19,6 +19,10 @@ mod imp {
pub avoid_repeated_instruments_adjustment: TemplateChild<gtk::Adjustment>,
#[template_child]
pub play_full_recordings_row: TemplateChild<adw::SwitchRow>,
#[template_child]
pub use_custom_url_row: TemplateChild<adw::SwitchRow>,
#[template_child]
pub custom_url_row: TemplateChild<adw::EntryRow>,
}
#[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();
}
}