Commit e1a7dfda authored by René Rössler's avatar René Rössler 😍
Browse files

obay all the clippy lints

parent 48369a28
Pipeline #104472257 passed with stage
in 12 minutes and 21 seconds
......@@ -85,7 +85,7 @@ fn create_window(renderer: Arc<RwLock<Renderer>>, application: &Application) {
ignore_signals.clone(),
dirty.clone(),
);
preview_to_live::init(&builder, renderer.clone(), update_ui.clone(), dirty.clone());
preview_to_live::init(&builder, renderer.clone(), update_ui.clone(), dirty);
render_groups::init(
&builder,
renderer.clone(),
......
......@@ -4,8 +4,9 @@ use glib::Sender;
use gtk::prelude::*;
use gtk::*;
use std::{
cmp::Ordering::*,
sync::{
atomic::{AtomicBool, Ordering},
atomic::{AtomicBool, Ordering::Relaxed},
Arc, Mutex, RwLock,
},
time::Duration,
......@@ -41,7 +42,7 @@ pub fn init(
palettes.connect_cursor_changed(
clone!(renderer, update_ui, ignore_signals, dirty => move |palettes| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -56,7 +57,7 @@ pub fn init(
if config.preview_palette != preview_palette {
config.preview_palette = preview_palette;
dirty.palettes.store(true, Ordering::Relaxed);
dirty.palettes.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}
}
......@@ -66,7 +67,7 @@ pub fn init(
let move_new_index = Arc::new(Mutex::new(None));
palettes_model.connect_row_inserted(
clone!(ignore_signals, move_new_index => move |_model, path, _iter| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -77,22 +78,22 @@ pub fn init(
palettes_model.connect_row_deleted(
clone!(ignore_signals, move_new_index, renderer, dirty, update_ui => move |_model, path| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
if let Some(mut new_index) = move_new_index.lock().unwrap().take() {
let mut old_index = *path.get_indices().first().unwrap() as usize;
if new_index > old_index {
new_index -= 1;
} else if old_index > new_index {
old_index -= 1;
}
match old_index.cmp(&new_index) {
Greater => old_index -= 1,
Less => new_index -= 1,
Equal => {},
};
let renderer = renderer.read().unwrap();
let mut config = renderer.config.write().unwrap();
config.palettes.swap(old_index, new_index);
dirty.palettes.store(true, Ordering::Relaxed);
dirty.palettes.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}
}),
......@@ -100,7 +101,7 @@ pub fn init(
palettes_text.connect_edited(
clone!(renderer, update_ui, ignore_signals, dirty => move |_palettes_text, path, new_name| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -110,14 +111,14 @@ pub fn init(
let mut config = renderer.config.write().unwrap();
config.palettes[index as usize].name = new_name.into();
dirty.palettes.store(true, Ordering::Relaxed);
dirty.palettes.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}),
);
palettes_live.connect_toggled(
clone!(renderer, update_ui, ignore_signals, dirty => move |_palettes, path| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -126,14 +127,14 @@ pub fn init(
let mut config = renderer.config.write().unwrap();
config.live_palette = index as usize;
dirty.palettes.store(true, Ordering::Relaxed);
dirty.palettes.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}),
);
palettes_new.connect_clicked(
clone!(renderer, update_ui, ignore_signals, dirty => move |_| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -144,14 +145,14 @@ pub fn init(
colors: vec![],
});
dirty.palettes.store(true, Ordering::Relaxed);
dirty.palettes.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}),
);
palettes_clone.connect_clicked(
clone!(renderer, update_ui, ignore_signals, dirty => move |_| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -163,14 +164,14 @@ pub fn init(
config.palettes.push(palette);
}
dirty.palettes.store(true, Ordering::Relaxed);
dirty.palettes.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}),
);
palettes_remove.connect_clicked(
clone!(renderer, update_ui, ignore_signals, dirty => move |_| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -184,14 +185,14 @@ pub fn init(
}
}
dirty.palettes.store(true, Ordering::Relaxed);
dirty.palettes.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}),
);
palettes_cycle_on.connect_property_active_notify(
clone!(renderer, update_ui, ignore_signals => move |palettes_cycle_on| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -206,7 +207,7 @@ pub fn init(
palettes_cycle_random.connect_property_active_notify(
clone!(renderer, update_ui, ignore_signals => move |palettes_cycle_random| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -221,7 +222,7 @@ pub fn init(
palettes_cycle_duration.connect_value_changed(
clone!(renderer, ignore_signals => move |palettes_cycle_duration| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -251,7 +252,7 @@ pub fn update_ui(builder: &Builder, renderer: &Renderer, dirty: Arc<Dirty>) {
let config = renderer.config.read().unwrap();
let is_dirty = dirty.palettes.load(Ordering::Relaxed)
let is_dirty = dirty.palettes.load(Relaxed)
|| palettes_model
.get_iter(&TreePath::new_from_indicesv(&[config.live_palette as i32]))
.map(|iter| {
......@@ -262,7 +263,7 @@ pub fn update_ui(builder: &Builder, renderer: &Renderer, dirty: Arc<Dirty>) {
})
.unwrap_or(false);
if is_dirty {
dirty.palettes.store(false, Ordering::Relaxed);
dirty.palettes.store(false, Relaxed);
palettes_model.clear();
config
.palettes
......
......@@ -6,8 +6,9 @@ use gtk::{
ToggleButton, TreePath, TreeView,
};
use std::{
cmp::Ordering::*,
sync::{
atomic::{AtomicBool, Ordering},
atomic::{AtomicBool, Ordering::Relaxed},
Arc, Mutex, RwLock,
},
time::Duration,
......@@ -43,7 +44,7 @@ pub fn init(
presets.connect_cursor_changed(
clone!(renderer, update_ui, ignore_signals, dirty => move |presets| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -58,7 +59,7 @@ pub fn init(
if config.preview_preset != preview_preset {
config.preview_preset = preview_preset;
dirty.presets.store(true, Ordering::Relaxed);
dirty.presets.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}
}
......@@ -68,7 +69,7 @@ pub fn init(
let move_new_index = Arc::new(Mutex::new(None));
presets_model.connect_row_inserted(
clone!(ignore_signals, move_new_index => move |_model, path, _iter| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -79,22 +80,22 @@ pub fn init(
presets_model.connect_row_deleted(
clone!(ignore_signals, move_new_index, renderer, dirty, update_ui => move |_model, path| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
if let Some(mut new_index) = move_new_index.lock().unwrap().take() {
let mut old_index = *path.get_indices().first().unwrap() as usize;
if new_index > old_index {
new_index -= 1;
} else if old_index > new_index {
old_index -= 1;
}
match old_index.cmp(&new_index) {
Greater => old_index -= 1,
Less => new_index -= 1,
Equal => {},
};
let renderer = renderer.read().unwrap();
let mut config = renderer.config.write().unwrap();
config.presets.swap(old_index, new_index);
dirty.presets.store(true, Ordering::Relaxed);
dirty.presets.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}
}),
......@@ -102,7 +103,7 @@ pub fn init(
presets_text.connect_edited(
clone!(renderer, update_ui, ignore_signals, dirty => move |_presets_text, path, new_name| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -111,14 +112,14 @@ pub fn init(
let mut config = renderer.config.write().unwrap();
config.presets[index as usize].name = new_name.into();
dirty.presets.store(true, Ordering::Relaxed);
dirty.presets.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}),
);
presets_live.connect_toggled(
clone!(renderer, update_ui, ignore_signals, dirty => move |_presets, path| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -127,14 +128,14 @@ pub fn init(
let mut config = renderer.config.write().unwrap();
config.live_preset = index as usize;
dirty.presets.store(true, Ordering::Relaxed);
dirty.presets.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}),
);
presets_new.connect_clicked(
clone!(renderer, update_ui, ignore_signals, dirty => move |_| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -147,14 +148,14 @@ pub fn init(
},
});
dirty.presets.store(true, Ordering::Relaxed);
dirty.presets.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}),
);
presets_clone.connect_clicked(
clone!(renderer, update_ui, ignore_signals, dirty => move |_| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -166,14 +167,14 @@ pub fn init(
config.presets.push(preset);
}
dirty.presets.store(true, Ordering::Relaxed);
dirty.presets.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}),
);
presets_remove.connect_clicked(
clone!(renderer, update_ui, ignore_signals, dirty => move |_| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -186,14 +187,14 @@ pub fn init(
config.preview_preset -= 1;
}
}
dirty.presets.store(true, Ordering::Relaxed);
dirty.presets.store(true, Relaxed);
let _ = update_ui.send(UpdateUiConfig::default());
}),
);
presets_cycle_on.connect_property_active_notify(
clone!(renderer, update_ui, ignore_signals => move |presets_cycle_on| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -208,7 +209,7 @@ pub fn init(
presets_cycle_random.connect_property_active_notify(
clone!(renderer, update_ui, ignore_signals => move |presets_cycle_random| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -223,7 +224,7 @@ pub fn init(
presets_cycle_duration.connect_value_changed(
clone!(renderer, ignore_signals => move |presets_cycle_duration| {
if ignore_signals.load(Ordering::Relaxed) {
if ignore_signals.load(Relaxed) {
return;
}
......@@ -253,7 +254,7 @@ pub fn update_ui(builder: &Builder, renderer: &Renderer, dirty: Arc<Dirty>) {
let config = renderer.config.read().unwrap();
let is_dirty = dirty.presets.load(Ordering::Relaxed)
let is_dirty = dirty.presets.load(Relaxed)
|| presets_model
.get_iter(&TreePath::new_from_indicesv(&[config.live_preset as i32]))
.map(|iter| {
......@@ -264,7 +265,7 @@ pub fn update_ui(builder: &Builder, renderer: &Renderer, dirty: Arc<Dirty>) {
})
.unwrap_or(false);
if is_dirty {
dirty.presets.store(false, Ordering::Relaxed);
dirty.presets.store(false, Relaxed);
presets_model.clear();
config
.presets
......
......@@ -20,7 +20,6 @@ pub fn init(builder: &Builder, renderer: Arc<RwLock<Renderer>>) {
gled::path()
.map(
|path| format!("{}.gled", path.file_stem().unwrap().to_str().unwrap())
.to_owned()
)
.unwrap_or_else(|| "No Project".to_owned()),
if gled::has_unsaved_changes() { "*" } else { "" },
......@@ -31,7 +30,7 @@ pub fn init(builder: &Builder, renderer: Arc<RwLock<Renderer>>) {
.file_path
.as_ref()
.map(|path| {
format!("{}.svg", path.file_stem().unwrap().to_str().unwrap()).to_owned()
format!("{}.svg", path.file_stem().unwrap().to_str().unwrap())
})
.unwrap_or_else(|| "No SVG File".to_owned())
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment