diff options
author | Guillaume Desmottes <guillaume.desmottes@onestream.live> | 2023-02-02 15:13:56 +0300 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@onestream.live> | 2023-02-13 20:04:53 +0300 |
commit | 77e99e92fb8554c7d4b0273e8c20a63202bf8053 (patch) | |
tree | 12de08167092ca15fd206cd6fa8c8f1c51a7ddd9 | |
parent | 51d61af8634fbd189a16eb84ea308024a8a08d51 (diff) |
spotifyaudiosrc: use Settings Default to define default props
Makes it easier to change one property's default value.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1074>
-rw-r--r-- | audio/spotify/src/spotifyaudiosrc/imp.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/audio/spotify/src/spotifyaudiosrc/imp.rs b/audio/spotify/src/spotifyaudiosrc/imp.rs index 99931387..f15ada69 100644 --- a/audio/spotify/src/spotifyaudiosrc/imp.rs +++ b/audio/spotify/src/spotifyaudiosrc/imp.rs @@ -99,43 +99,45 @@ impl ObjectSubclass for SpotifyAudioSrc { impl ObjectImpl for SpotifyAudioSrc { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { + let default = Settings::default(); + vec![glib::ParamSpecString::builder("username") .nick("Username") .blurb("Spotify device username from https://www.spotify.com/us/account/set-device-password/") - .default_value(Some("")) + .default_value(Some(default.username.as_str())) .mutable_ready() .build(), glib::ParamSpecString::builder("password") .nick("Password") .blurb("Spotify device password from https://www.spotify.com/us/account/set-device-password/") - .default_value(Some("")) + .default_value(Some(default.password.as_str())) .mutable_ready() .build(), glib::ParamSpecString::builder("cache-credentials") .nick("Credentials cache") .blurb("Directory where to cache Spotify credentials") - .default_value(Some("")) + .default_value(Some(default.cache_credentials.as_str())) .mutable_ready() .build(), glib::ParamSpecString::builder("cache-files") .nick("Files cache") .blurb("Directory where to cache downloaded files from Spotify") - .default_value(Some("")) + .default_value(Some(default.cache_files.as_str())) .mutable_ready() .build(), glib::ParamSpecUInt64::builder("cache-max-size") .nick("Cache max size") .blurb("The max allowed size of the cache, in bytes, or 0 to disable the cache limit") - .default_value(0) + .default_value(default.cache_max_size) .mutable_ready() .build(), glib::ParamSpecString::builder("track") .nick("Spotify URI") .blurb("Spotify track URI, in the form 'spotify:track:$SPOTIFY_ID'") - .default_value(Some("")) + .default_value(Some(default.track.as_str())) .mutable_ready() .build(), - glib::ParamSpecEnum::builder::<Bitrate>("bitrate") + glib::ParamSpecEnum::builder_with_default::<Bitrate>("bitrate", default.bitrate) .nick("Spotify bitrate") .blurb("Spotify audio bitrate in kbit/s") .mutable_ready() |