Skip to content

Commit

Permalink
Running linter on gactions, mod and template files.
Browse files Browse the repository at this point in the history
  • Loading branch information
toadkarter committed Oct 8, 2023
1 parent 4591ae2 commit 0d8cb99
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
10 changes: 6 additions & 4 deletions src/application/gactions.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use adw::ColorScheme;
use serde::{Deserialize, Serialize};
use super::{selection::Selectable, *};
use crate::application::user_settings::UserSettingsKey::ThemeKey;
use crate::application::user_settings::UserSettingsValue::ThemeValue;
use super::{selection::Selectable, *};
use crate::{export::ModuleFile, fatal::*, project::Project, simulator::Simulator, FileExtension};
use adw::ColorScheme;
use serde::{Deserialize, Serialize};

#[derive(Default, Clone, Copy, Serialize, Deserialize)]
pub enum Theme {
Expand Down Expand Up @@ -375,7 +375,9 @@ impl Application {
user_settings.set_setting(ThemeKey, ThemeValue(new));
match user_settings.save_config() {
Ok(()) => {}
Err(_save_config_err) => { println!("Could not save to config") }
Err(_save_config_err) => {
println!("Could not save to config")
}
}

action.set_state(&new.to_variant());
Expand Down
18 changes: 9 additions & 9 deletions src/application/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ pub mod clipboard;
pub mod editor;
pub mod gactions;
pub mod selection;
pub mod user_settings;
pub mod template;
pub mod user_settings;

use crate::application::gactions::Theme;
use crate::application::user_settings::UserSettingsKey::ThemeKey;
use crate::application::user_settings::UserSettingsValue::ThemeValue;
use crate::{application::clipboard::Clipboard, config, ui::dialogs};
use action::*;
use adw::traits::MessageDialogExt;
use gtk::{gio, glib, prelude::*, subclass::prelude::*};
use selection::SelectionField;
use crate::application::gactions::Theme;
use crate::application::user_settings::UserSettingsKey::ThemeKey;
use crate::application::user_settings::UserSettingsValue::ThemeValue;
use std::cell::RefCell;

glib::wrapper! {
Expand Down Expand Up @@ -158,11 +158,11 @@ impl Application {
let action = gio::SimpleAction::from(gaction);

if gaction.name() == "change-theme" {
let theme_variant =
match self.imp().user_settings().borrow().get_setting(ThemeKey) {
Some(ThemeValue(custom_theme)) => { custom_theme.to_variant() }
None => { Theme::SystemPreference.to_variant() }
};
let theme_variant = match self.imp().user_settings().borrow().get_setting(ThemeKey)
{
Some(ThemeValue(custom_theme)) => custom_theme.to_variant(),
None => Theme::SystemPreference.to_variant(),
};

action.set_state(&theme_variant);
}
Expand Down
16 changes: 9 additions & 7 deletions src/application/template.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use adw::ColorScheme;
use crate::application::gactions;
use crate::application::user_settings::UserSettings;
use crate::application::user_settings::UserSettingsKey::ThemeKey;
use crate::application::user_settings::UserSettingsValue::ThemeValue;
use crate::{
fatal::*,
project::*,
renderer::Theme,
simulator::*,
ui::{circuit_view::CircuitView, dialogs, main_window::MainWindow},
};
use crate::application::gactions;
use crate::application::user_settings::UserSettings;
use crate::application::user_settings::UserSettingsKey::ThemeKey;
use crate::application::user_settings::UserSettingsValue::ThemeValue;
use adw::subclass::prelude::*;
use adw::ColorScheme;
use gtk::{gdk, gio, glib, prelude::*};
use std::cell::RefCell;

Expand Down Expand Up @@ -61,7 +61,7 @@ impl ApplicationTemplate {
let user_settings = self.user_settings.borrow_mut();
let theme: gactions::Theme = match user_settings.get_setting(ThemeKey) {
Some(ThemeValue(custom_theme)) => *custom_theme,
_ => gactions::Theme::SystemPreference
_ => gactions::Theme::SystemPreference,
};

let color_scheme = Into::<ColorScheme>::into(theme);
Expand Down Expand Up @@ -182,7 +182,9 @@ impl ApplicationTemplate {
self.action_stack.borrow().is_dirty()
}

pub fn user_settings(&self) -> &RefCell<UserSettings> { &self.user_settings }
pub fn user_settings(&self) -> &RefCell<UserSettings> {
&self.user_settings
}

pub fn generate_clipboard(&self) -> Clipboard {
if let Some(selected) = self.with_current_plot(|plot| !matches!(plot.selection(), Selection::None)) && selected {
Expand Down

0 comments on commit 0d8cb99

Please sign in to comment.