settings: remove get prefix

Remove "get_" whenever possible
This commit is contained in:
Stéphane Cerveau 2022-02-21 17:48:14 +01:00 committed by Stéphane Cerveau
parent 435e7bfd0d
commit 16fee2a289
2 changed files with 7 additions and 7 deletions

View file

@ -30,7 +30,7 @@ pub struct Settings {
impl Settings {
fn settings_file_exist() {
let s = Settings::get_settings_file_path();
let s = Settings::settings_file_path();
if !s.exists() {
if let Some(parent_dir) = s.parent() {
@ -47,7 +47,7 @@ impl Settings {
}
}
fn get_settings_file_path() -> PathBuf {
fn settings_file_path() -> PathBuf {
let mut path = glib::user_config_dir();
path.push(config::APP_ID);
path.push("settings.toml");
@ -80,7 +80,7 @@ impl Settings {
Settings::save_settings(&settings);
}
pub fn get_favorites_list() -> Vec<String> {
pub fn favorites_list() -> Vec<String> {
let mut favorites = Vec::new();
let settings = Settings::load_settings();
for fav in settings.favorites {
@ -92,7 +92,7 @@ impl Settings {
// Save the provided settings to the settings path
pub fn save_settings(settings: &Settings) {
Settings::settings_file_exist();
let s = Settings::get_settings_file_path();
let s = Settings::settings_file_path();
if let Err(e) = serde_any::to_file(&s, settings) {
GPS_ERROR!("Error while trying to save file: {} {}", s.display(), e);
}
@ -100,7 +100,7 @@ impl Settings {
// Load the current settings
pub fn load_settings() -> Settings {
let s = Settings::get_settings_file_path();
let s = Settings::settings_file_path();
if s.exists() && s.is_file() {
match serde_any::from_file::<Settings, _>(&s) {
Ok(s) => s,

View file

@ -19,7 +19,7 @@ use gtk::{gio, glib};
pub fn reset_favorite_list(favorite_list: &TreeView) {
let model = ListStore::new(&[String::static_type()]);
favorite_list.set_model(Some(&model));
let favorites = Settings::get_favorites_list();
let favorites = Settings::favorites_list();
for favorite in favorites {
model.insert_with_values(None, &[(0, &favorite)]);
}
@ -88,7 +88,7 @@ pub fn setup_favorite_list(app: &GPSApp) {
}
pub fn add_to_favorite_list(app: &GPSApp, element_name: String) {
let mut favorites = Settings::get_favorites_list();
let mut favorites = Settings::favorites_list();
favorites.sort();
if !favorites.contains(&element_name) {
let favorite_list: TreeView = app