mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
Add setting for library path
This commit is contained in:
parent
af01dc1953
commit
5387a51def
2 changed files with 21 additions and 0 deletions
|
|
@ -13,5 +13,9 @@
|
|||
<default>false</default>
|
||||
<summary>Window maximized state</summary>
|
||||
</key>
|
||||
<key name="library-path" type="s">
|
||||
<default>''</default>
|
||||
<summary>Path to the music library</summary>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use crate::{
|
|||
};
|
||||
use adw::subclass::prelude::*;
|
||||
use gtk::{gio, glib, glib::clone, prelude::*};
|
||||
use std::path::Path;
|
||||
|
||||
mod imp {
|
||||
use super::*;
|
||||
|
|
@ -73,6 +74,12 @@ mod imp {
|
|||
|
||||
let obj = self.obj().to_owned();
|
||||
self.player.connect_raise(move |_| obj.present());
|
||||
|
||||
let settings = gio::Settings::new("de.johrpan.musicus");
|
||||
let library_path = settings.string("library-path").to_string();
|
||||
if !library_path.is_empty() {
|
||||
self.obj().load_library(&library_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -126,6 +133,16 @@ impl MusicusWindow {
|
|||
#[template_callback]
|
||||
fn set_library_folder(&self, folder: &gio::File) {
|
||||
let path = folder.path().unwrap();
|
||||
|
||||
let settings = gio::Settings::new("de.johrpan.musicus");
|
||||
settings
|
||||
.set_string("library-path", path.to_str().unwrap())
|
||||
.unwrap();
|
||||
|
||||
self.load_library(path);
|
||||
}
|
||||
|
||||
fn load_library(&self, path: impl AsRef<Path>) {
|
||||
let library = MusicusLibrary::new(path);
|
||||
self.imp()
|
||||
.navigation_view
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue