Skip to content

Commit 5ce5597

Browse files
committed
code cleanup, prepare for 0.12.0
1 parent bb54b5d commit 5ce5597

12 files changed

Lines changed: 64 additions & 159 deletions

File tree

data/src/config/general.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ pub struct GeneralConfig {
1414
pub non_gui_quiet_output: bool,
1515
pub non_gui_use_cwd: bool,
1616
pub hide_gif: bool,
17-
pub idle_gif: Option<PathBuf>,
18-
pub ripping_gif: Option<PathBuf>,
19-
pub complete_gif: Option<PathBuf>,
2017
pub suppress_warnings: bool,
2118
pub show_errors_in_text_editor: bool,
2219
pub sample_name_params: SampleNameParams,
@@ -29,9 +26,6 @@ impl Default for GeneralConfig {
2926
non_gui_quiet_output: false,
3027
non_gui_use_cwd: false,
3128
hide_gif: false,
32-
idle_gif: None,
33-
ripping_gif: None,
34-
complete_gif: None,
3529
suppress_warnings: false,
3630
theme: Themes::default(),
3731
sample_name_params: SampleNameParams::default(),

data/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
//! Data components of XMODITS
2-
//!
3-
4-
#![allow(dead_code)]
5-
#![allow(unused_imports)]
62
73
pub mod config;
84
pub mod theme;

data/src/theme.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
pub mod themes;
22

33
use iced::Color;
4-
use serde::{Deserialize, Serialize};
54
pub use themes::Themes;
65

76
pub struct Theme {

data/src/theme/themes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use iced::{color, Color};
1+
use iced::color;
22
use serde::{Deserialize, Serialize};
33

44
use super::Palette;

src/logger.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
pub mod crash_handler;
21
pub mod bad_modules;
2+
pub mod crash_handler;
33

4-
pub use crash_handler::set_panic_hook;
54
pub use bad_modules::log_file_on_panic;
5+
pub use crash_handler::set_panic_hook;
66

77
use anyhow::Result;
88
use rand::Rng;
@@ -59,15 +59,8 @@ where
5959
/// This allows logs to be displayed when launched from the terminal.
6060
pub fn reattach_windows_terminal() {
6161
#[cfg(windows)]
62-
unsafe {
63-
use std::sync::Once;
62+
{
6463
use windows_sys::Win32::System::Console::{AttachConsole, ATTACH_PARENT_PROCESS};
65-
66-
// Probably overkill to wrap in ONCE
67-
static ONCE: Once = Once::new();
68-
69-
ONCE.call_once(|| {
70-
let _ = AttachConsole(ATTACH_PARENT_PROCESS);
71-
});
64+
let _ = unsafe { AttachConsole(ATTACH_PARENT_PROCESS) };
7265
}
7366
}

src/logger/bad_modules.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ type Subscriber = Box<dyn Fn(PathBuf) + Send + Sync + 'static>;
1111

1212
#[derive(Default)]
1313
pub(crate) struct BadModules {
14-
modules: RwLock<Vec<PathBuf>>,
1514
subscribers: RwLock<Vec<Subscriber>>,
1615
}
1716

@@ -29,8 +28,6 @@ impl BadModules {
2928
.read()
3029
.iter()
3130
.for_each(|notify| notify(path.clone()));
32-
33-
self.modules.write().push(path);
3431
}
3532
}
3633

src/screen/config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
pub mod name_preview;
44
pub mod sample_naming;
55
pub mod sample_ripping;
6-
// pub mod custom_filters;

src/screen/config/name_preview.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,8 @@
11
//! Preview how ripped samples will be named
22
3-
use std::path::PathBuf;
4-
53
use data::config::{SampleNameConfig, SampleNameParams, SampleRippingConfig};
64
use xmodits_lib::interface::{name::Context, Sample};
75

8-
use crate::widget::Element;
9-
10-
#[derive(Debug, Clone)]
11-
pub enum Message {
12-
ModuleName(String),
13-
FileName(Option<String>),
14-
Source(PathBuf),
15-
RawIndex(u16),
16-
SeqIndex(u16),
17-
}
18-
19-
pub fn update(name_params: &mut SampleNameParams, message: Message) {
20-
tracing::info!("{:?}", &message);
21-
22-
match message {
23-
Message::ModuleName(module_name) => name_params.module_name = module_name,
24-
Message::FileName(file_name) => name_params.sample_filename = file_name,
25-
Message::Source(source) => name_params.module_source = source,
26-
Message::RawIndex(raw_index) => name_params.raw_index = raw_index,
27-
Message::SeqIndex(seq_index) => name_params.seq_index = seq_index,
28-
}
29-
}
30-
31-
pub fn view<'a>() -> Element<'a, Message> {
32-
todo!()
33-
}
34-
356
pub fn preview_name<'a>(
367
params: &SampleNameParams,
378
naming: &'a SampleNameConfig,

src/screen/settings.rs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
use data::config::{self};
22
use iced::widget::{checkbox, column, pick_list, row};
33
use iced::Command;
4-
use std::path::PathBuf;
54

6-
use crate::screen::config::name_preview;
7-
use crate::utils::folder_dialog;
85
use crate::widget::helpers::control;
96
use crate::widget::Element;
107

118
#[derive(Debug, Clone)]
129
pub enum Message {
1310
NonGuiQuietOutput(bool),
1411
NonGuiUseCwd(bool),
15-
SetLogFolder(Option<PathBuf>),
16-
SetLogFolderDialog,
1712
ShowAnimatedGIF(bool),
1813
SuppressWarnings(bool),
1914
ShowErrorsInTextEditor(bool),
20-
SetGif {
21-
kind: GIFKind,
22-
path: Option<PathBuf>,
23-
},
2415
SetTheme(data::theme::Themes),
25-
NamePreview(name_preview::Message),
26-
ImportTheme,
27-
ExportTheme,
2816
}
2917

3018
/*
@@ -58,7 +46,6 @@ pub fn view(general: &config::GeneralConfig) -> Element<Message> {
5846

5947
column![control("Application Settings", settings)]
6048
.push(themes(general))
61-
// .push(animated_gif(general))
6249
.push_maybe(non_gui(general))
6350
.spacing(8)
6451
.into()
@@ -71,7 +58,6 @@ pub fn themes(general: &config::GeneralConfig) -> Element<Message> {
7158
Some(general.theme),
7259
Message::SetTheme
7360
),
74-
// button("Load").on_press(Message::ImportTheme),
7561
]
7662
.spacing(8)
7763
.align_items(iced::Alignment::Center);
@@ -103,50 +89,15 @@ pub enum GIFKind {
10389
Complete,
10490
}
10591

106-
// pub fn animated_gif(general: &config::GeneralConfig) -> Element<Message> {
107-
// let settings = column![checkbox(
108-
// "Hide Animated GIFs",
109-
// general.hide_gif,
110-
// Message::ShowAnimatedGIF
111-
// ),
112-
// ]
113-
114-
// // .push(button(
115-
// // general
116-
// // .logging_path
117-
// // .as_deref()
118-
// // .map(filename)
119-
// // .unwrap_or_default(),
120-
// // ))
121-
// .spacing(8);
122-
// control("Animated GIFs", settings).into()
123-
// }
124-
12592
pub fn update(cfg: &mut config::GeneralConfig, message: Message) -> Command<Message> {
12693
tracing::info!("{:?}", &message);
12794

12895
match message {
12996
Message::NonGuiQuietOutput(quiet_output) => cfg.non_gui_quiet_output = quiet_output,
13097
Message::NonGuiUseCwd(use_cwd) => cfg.non_gui_use_cwd = use_cwd,
131-
Message::SetLogFolder(log_path) => {
132-
if let Some(log_path) = log_path {
133-
cfg.logging_path = Some(log_path)
134-
}
135-
}
136-
Message::SetLogFolderDialog => {
137-
return Command::perform(folder_dialog(), Message::SetLogFolder)
138-
}
13998
Message::ShowAnimatedGIF(toggle) => cfg.hide_gif = toggle,
14099
Message::SuppressWarnings(toggle) => cfg.suppress_warnings = toggle,
141-
Message::SetGif { kind, path } => match kind {
142-
GIFKind::Idle => cfg.idle_gif = path,
143-
GIFKind::Ripping => cfg.ripping_gif = path,
144-
GIFKind::Complete => cfg.complete_gif = path,
145-
},
146100
Message::SetTheme(theme) => cfg.theme = theme,
147-
Message::NamePreview(msg) => name_preview::update(&mut cfg.sample_name_params, msg),
148-
Message::ImportTheme => (),
149-
Message::ExportTheme => (),
150101
Message::ShowErrorsInTextEditor(show) => cfg.show_errors_in_text_editor = show,
151102
}
152103

src/screen/tracker_info.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::utils::filename;
99
use crate::widget::helpers::{centered_container, control_filled, text_adv};
1010
use crate::widget::Element;
1111

12-
use iced::widget::{button, column, text, Space};
12+
use iced::widget::{column, text, Space};
1313
use iced::Alignment;
1414
use xmodits_lib::common::info::Info;
1515

@@ -67,7 +67,7 @@ impl TrackerInfo {
6767
} => {
6868
#[cfg(feature = "audio")]
6969
let view_samples_button = Some(
70-
button("View Samples")
70+
iced::widget::button("View Samples")
7171
.on_press(Message::PreviewSamples(path.to_owned()))
7272
.padding(5),
7373
);

0 commit comments

Comments
 (0)