From b5b29b2e2ba349c07d450c914c019a1eb8720e9e Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Thu, 17 Oct 2024 12:29:37 +0300 Subject: [PATCH] Fix as many new clippy lints as possible Signed-off-by: Manos Pitsidianakis --- src/api/registry.rs | 2 +- src/api/types.rs | 2 +- src/app.rs | 4 +-- src/app/settings.rs | 19 ++++++---- src/app/settings/types.rs | 2 +- src/app/undo.rs | 4 +-- src/editor.rs | 26 +++++++------- src/editor/settings.rs | 10 +++--- src/editor/shortcuts.rs | 50 +++++++++++++------------- src/editor/state.rs | 4 +-- src/editor/tools.rs | 44 +++++++---------------- src/editor/tools/bezier.rs | 12 +++---- src/editor/tools/image.rs | 14 ++++---- src/editor/tools/panning.rs | 12 +++---- src/editor/tools/shapes.rs | 4 +-- src/editor/tools/tool_impl.rs | 14 +++----- src/git.rs | 2 +- src/git/tab.rs | 8 ++--- src/glyphs.rs | 6 ++-- src/glyphs/contours.rs | 4 +-- src/glyphs/guidelines.rs | 26 +++++++------- src/glyphs/metadata.rs | 21 +++++------ src/lib.rs | 15 ++++---- src/project.rs | 6 ++-- src/ufo.rs | 10 +++--- src/ufo/export.rs | 8 +++-- src/ufo/import.rs | 24 +++++++++---- src/ufo/objects.rs | 48 ++++++++++++------------- src/unicode/names/unicode.py | 12 +++---- src/utils/curves.rs | 6 ++-- src/utils/property_window.rs | 6 ++-- src/utils/property_window/types.rs | 8 ++--- src/views/canvas.rs | 14 ++++---- src/views/canvas/layers.rs | 6 ++-- src/views/canvas/settings.rs | 56 +++++++++++++++--------------- src/views/canvas/transformation.rs | 48 ++++++++++++------------- src/views/collection.rs | 22 ++++++------ src/views/overlay/child.rs | 8 ++--- src/window/workspace.rs | 14 ++++---- 39 files changed, 298 insertions(+), 303 deletions(-) diff --git a/src/api/registry.rs b/src/api/registry.rs index a7b85ac..e973247 100644 --- a/src/api/registry.rs +++ b/src/api/registry.rs @@ -455,7 +455,7 @@ pub struct ObjectRegistry { } impl ObjectRegistry { - const QUARK_KEY: &str = "api-uuid"; + const QUARK_KEY: &'static str = "api-uuid"; pub fn add(&mut self, obj: &glib::Object) -> Uuid { Self::opt_id(obj).unwrap_or_else(|| { diff --git a/src/api/types.rs b/src/api/types.rs index 56aff96..f6fb03c 100644 --- a/src/api/types.rs +++ b/src/api/types.rs @@ -514,7 +514,7 @@ macro_rules! generate_py_class { } _pyo3::ffi::PyType_Slot { slot: _pyo3::ffi::Py_tp_repr, - pfunc: trampoline as _pyo3::ffi::reprfunc as _, + pfunc: trampoline as _pyo3::ffi::reprfunc as *mut std::ffi::c_void, } }], }; diff --git a/src/app.rs b/src/app.rs index 5724b6b..b57e641 100644 --- a/src/app.rs +++ b/src/app.rs @@ -106,8 +106,8 @@ impl std::ops::Deref for Application { } impl Application { - pub const UI_FONT: &str = "ui-font"; - pub const THEME: &str = "theme"; + pub const UI_FONT: &'static str = "ui-font"; + pub const THEME: &'static str = "theme"; #[allow(clippy::new_without_default)] pub fn new() -> Self { diff --git a/src/app/settings.rs b/src/app/settings.rs index 164bc59..08ad8bc 100644 --- a/src/app/settings.rs +++ b/src/app/settings.rs @@ -199,6 +199,7 @@ impl SettingsInner { .read(true) .write(true) .create(false) + .truncate(false) .open(path) .is_ok() { @@ -208,6 +209,7 @@ impl SettingsInner { .read(true) .write(true) .create(true) + .truncate(false) .open(path)?; Ok(()) } @@ -247,6 +249,7 @@ impl SettingsInner { .read(true) .write(true) .create(true) + .truncate(false) .open(&path)?; let mut toml = String::new(); @@ -357,7 +360,9 @@ impl SettingsInner { .flatten() .filter(|wref| wref.upgrade().as_ref() != Some(obj)) { - let Some(obj) = e.upgrade() else { continue; }; + let Some(obj) = e.upgrade() else { + continue; + }; let document = self.document.borrow(); macro_rules! set_if_neq { ($ty:ty, $val:expr) => {{ @@ -604,12 +609,12 @@ impl Default for Settings { } impl Settings { - pub const HANDLE_SIZE: &str = "handle-size"; - pub const LINE_WIDTH: &str = "line-width"; - pub const GUIDELINE_WIDTH: &str = "guideline-width"; - pub const WARP_CURSOR: &str = "warp-cursor"; - pub const MARK_COLOR: &str = "mark-color"; - pub const SHOW_PRERELEASE_WARNING: &str = "show-prerelease-warning"; + pub const HANDLE_SIZE: &'static str = "handle-size"; + pub const LINE_WIDTH: &'static str = "line-width"; + pub const GUIDELINE_WIDTH: &'static str = "guideline-width"; + pub const WARP_CURSOR: &'static str = "warp-cursor"; + pub const MARK_COLOR: &'static str = "mark-color"; + pub const SHOW_PRERELEASE_WARNING: &'static str = "show-prerelease-warning"; pub fn new() -> Self { glib::Object::new::(&[]).unwrap() diff --git a/src/app/settings/types.rs b/src/app/settings/types.rs index 9976072..bf355c5 100644 --- a/src/app/settings/types.rs +++ b/src/app/settings/types.rs @@ -96,7 +96,7 @@ impl EnumValue<'_> for Theme { } impl Theme { - pub const PAPERWHITE_CSS: &[u8] = include_bytes!("../../themes/paperwhite/gtk.css"); + pub const PAPERWHITE_CSS: &'static [u8] = include_bytes!("../../themes/paperwhite/gtk.css"); } #[test] diff --git a/src/app/undo.rs b/src/app/undo.rs index 161b409..3ab20f3 100644 --- a/src/app/undo.rs +++ b/src/app/undo.rs @@ -136,8 +136,8 @@ impl Default for UndoDatabase { } impl UndoDatabase { - pub const CAN_UNDO: &str = "can-undo"; - pub const CAN_REDO: &str = "can-redo"; + pub const CAN_UNDO: &'static str = "can-undo"; + pub const CAN_REDO: &'static str = "can-redo"; pub fn new() -> Self { let ret: Self = glib::Object::new::(&[]).unwrap(); diff --git a/src/editor.rs b/src/editor.rs index 27902bd..fff2837 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -229,9 +229,9 @@ impl ObjectImpl for EditorInner { ), def_param!(f64 Editor::UNITS_PER_EM, 1.0, ufo::constants::UNITS_PER_EM), def_param!(f64 Editor::X_HEIGHT, 1.0, ufo::constants::X_HEIGHT), - def_param!(f64 Editor::ASCENDER, std::f64::MIN, ufo::constants::ASCENDER), - def_param!(f64 Editor::DESCENDER, std::f64::MIN, ufo::constants::DESCENDER), - def_param!(f64 Editor::CAP_HEIGHT, std::f64::MIN, ufo::constants::CAP_HEIGHT), + def_param!(f64 Editor::ASCENDER, f64::MIN, ufo::constants::ASCENDER), + def_param!(f64 Editor::DESCENDER, f64::MIN, ufo::constants::DESCENDER), + def_param!(f64 Editor::CAP_HEIGHT, f64::MIN, ufo::constants::CAP_HEIGHT), glib::ParamSpecBoolean::new( Editor::LOCK_GUIDELINES, Editor::LOCK_GUIDELINES, @@ -358,12 +358,12 @@ impl ObjectImpl for EditorInner { Editor::ACTIVE_TOOL => { let state = self.state.get().unwrap().borrow(); let active_tool = state.active_tool; - state.tools.get(&active_tool).map(Clone::clone).to_value() + state.tools.get(&active_tool).cloned().to_value() } Editor::PANNING_TOOL => { let state = self.state.get().unwrap().borrow(); let panning_tool = state.panning_tool; - state.tools.get(&panning_tool).map(Clone::clone).to_value() + state.tools.get(&panning_tool).cloned().to_value() } Editor::MENUBAR => Some(self.menubar.clone()).to_value(), Editor::LOCK => self.lock.get().1.bits().to_value(), @@ -548,11 +548,11 @@ impl_deref!(Editor, EditorInner); impl_friendly_name!(Editor); impl Editor { - pub const CLOSEABLE: &str = Workspace::CLOSEABLE; - pub const TITLE: &str = Workspace::TITLE; - pub const IS_MENU_VISIBLE: &str = Workspace::IS_MENU_VISIBLE; - pub const MENUBAR: &str = Workspace::MENUBAR; - pub const PREVIEW: &str = "preview"; + pub const CLOSEABLE: &'static str = Workspace::CLOSEABLE; + pub const TITLE: &'static str = Workspace::TITLE; + pub const IS_MENU_VISIBLE: &'static str = Workspace::IS_MENU_VISIBLE; + pub const MENUBAR: &'static str = Workspace::MENUBAR; + pub const PREVIEW: &'static str = "preview"; inherit_property!( FontInfo, ASCENDER, @@ -561,9 +561,9 @@ impl Editor { UNITS_PER_EM, X_HEIGHT ); - pub const MODIFYING_IN_PROCESS: &str = "modifying-in-process"; - pub const ACTIVE_TOOL: &str = "active-tool"; - pub const PANNING_TOOL: &str = "panning-tool"; + pub const MODIFYING_IN_PROCESS: &'static str = "modifying-in-process"; + pub const ACTIVE_TOOL: &'static str = "active-tool"; + pub const PANNING_TOOL: &'static str = "panning-tool"; inherit_property!( EditorSettings, SHOW_MINIMAP, diff --git a/src/editor/settings.rs b/src/editor/settings.rs index 2de5d25..7e90194 100644 --- a/src/editor/settings.rs +++ b/src/editor/settings.rs @@ -149,11 +149,11 @@ impl Default for EditorSettings { } impl EditorSettings { - pub const SHOW_MINIMAP: &str = "show-minimap"; - pub const LOCK_GUIDELINES: &str = "lock-guidelines"; - pub const SHOW_GLYPH_GUIDELINES: &str = "show-glyph-guidelines"; - pub const SHOW_PROJECT_GUIDELINES: &str = "show-project-guidelines"; - pub const SHOW_METRICS_GUIDELINES: &str = "show-metrics-guidelines"; + pub const SHOW_MINIMAP: &'static str = "show-minimap"; + pub const LOCK_GUIDELINES: &'static str = "lock-guidelines"; + pub const SHOW_GLYPH_GUIDELINES: &'static str = "show-glyph-guidelines"; + pub const SHOW_PROJECT_GUIDELINES: &'static str = "show-project-guidelines"; + pub const SHOW_METRICS_GUIDELINES: &'static str = "show-metrics-guidelines"; pub fn new() -> Self { glib::Object::new::(&[]).unwrap() diff --git a/src/editor/shortcuts.rs b/src/editor/shortcuts.rs index f371e1a..51127fa 100644 --- a/src/editor/shortcuts.rs +++ b/src/editor/shortcuts.rs @@ -24,31 +24,31 @@ use super::*; use gtk::gdk::keys::constants as keys; impl Editor { - pub const LOCK: &str = "lock"; - pub const SNAP: &str = "snap"; - pub const PRECISION: &str = "precision"; - pub const PREVIEW_ACTION: &str = Self::PREVIEW; - pub const ZOOM_IN_ACTION: &str = "zoom.in"; - pub const ZOOM_OUT_ACTION: &str = "zoom.out"; - pub const LOCK_ACTION: &str = Self::LOCK; - pub const LOCK_X_ACTION: &str = "lock.x"; - pub const LOCK_Y_ACTION: &str = "lock.y"; - pub const LOCK_LOCAL_ACTION: &str = "lock.local"; - pub const LOCK_CONTROLS_ACTION: &str = "lock.controls"; - pub const PRECISION_ACTION: &str = Self::PRECISION; - pub const SNAP_ACTION: &str = Self::SNAP; - pub const SNAP_CLEAR_ACTION: &str = "snap.clear"; - pub const SNAP_ANGLE_ACTION: &str = "snap.angle"; - pub const SNAP_GRID_ACTION: &str = "snap.grid"; - pub const SNAP_GUIDELINES_ACTION: &str = "snap.guidelines"; - pub const SNAP_METRICS_ACTION: &str = "snap.metrics"; - pub const MOVE_UP_ACTION: &str = "move.up"; - pub const MOVE_DOWN_ACTION: &str = "move.down"; - pub const MOVE_RIGHT_ACTION: &str = "move.right"; - pub const MOVE_LEFT_ACTION: &str = "move.left"; - pub const SELECT_ALL_ACTION: &str = "select.all"; - pub const SELECT_NONE_ACTION: &str = "select.none"; - pub const SELECT_INVERT_ACTION: &str = "select.invert"; + pub const LOCK: &'static str = "lock"; + pub const SNAP: &'static str = "snap"; + pub const PRECISION: &'static str = "precision"; + pub const PREVIEW_ACTION: &'static str = Self::PREVIEW; + pub const ZOOM_IN_ACTION: &'static str = "zoom.in"; + pub const ZOOM_OUT_ACTION: &'static str = "zoom.out"; + pub const LOCK_ACTION: &'static str = Self::LOCK; + pub const LOCK_X_ACTION: &'static str = "lock.x"; + pub const LOCK_Y_ACTION: &'static str = "lock.y"; + pub const LOCK_LOCAL_ACTION: &'static str = "lock.local"; + pub const LOCK_CONTROLS_ACTION: &'static str = "lock.controls"; + pub const PRECISION_ACTION: &'static str = Self::PRECISION; + pub const SNAP_ACTION: &'static str = Self::SNAP; + pub const SNAP_CLEAR_ACTION: &'static str = "snap.clear"; + pub const SNAP_ANGLE_ACTION: &'static str = "snap.angle"; + pub const SNAP_GRID_ACTION: &'static str = "snap.grid"; + pub const SNAP_GUIDELINES_ACTION: &'static str = "snap.guidelines"; + pub const SNAP_METRICS_ACTION: &'static str = "snap.metrics"; + pub const MOVE_UP_ACTION: &'static str = "move.up"; + pub const MOVE_DOWN_ACTION: &'static str = "move.down"; + pub const MOVE_RIGHT_ACTION: &'static str = "move.right"; + pub const MOVE_LEFT_ACTION: &'static str = "move.left"; + pub const SELECT_ALL_ACTION: &'static str = "select.all"; + pub const SELECT_NONE_ACTION: &'static str = "select.none"; + pub const SELECT_INVERT_ACTION: &'static str = "select.invert"; } impl EditorInner { diff --git a/src/editor/state.rs b/src/editor/state.rs index c5915f2..82e0b8f 100644 --- a/src/editor/state.rs +++ b/src/editor/state.rs @@ -248,7 +248,7 @@ impl State { clone!(@strong idxs, @weak self.kd_tree as kd_tree, @weak self.glyph as glyph, @weak viewport => move || { let mut kd_tree = kd_tree.borrow_mut(); let glyph = glyph.borrow(); - for contour_index in idxs.iter().map(|i| i.contour_index).collect::>() { + for contour_index in idxs.iter().map(|i| i.contour_index) { let contour = &glyph.contours[contour_index]; for (idx, new_pos) in contour.transform_points(contour_index, &idxs, m) { kd_tree.add(idx, new_pos); @@ -262,7 +262,7 @@ impl State { let m = if let Ok(m) = m.try_invert() {m} else {return;}; let mut kd_tree = kd_tree.borrow_mut(); let glyph = glyph.borrow(); - for contour_index in idxs.iter().map(|i| i.contour_index).collect::>() { + for contour_index in idxs.iter().map(|i| i.contour_index) { let contour = &glyph.contours[contour_index]; for (idx, new_pos) in contour.transform_points(contour_index, &idxs, m) { /* update kd_tree */ diff --git a/src/editor/tools.rs b/src/editor/tools.rs index ee3f7bc..c3c7e6d 100644 --- a/src/editor/tools.rs +++ b/src/editor/tools.rs @@ -30,7 +30,6 @@ mod tool_impl; mod zoom; pub use self::image::*; pub use bezier::*; -pub use bspline::*; pub use panning::*; pub use shapes::*; pub use tool_impl::*; @@ -48,15 +47,9 @@ impl Tool { let active_tools = state .tools .get(&state.active_tool) - .map(Clone::clone) + .cloned() .into_iter() - .chain( - state - .tools - .get(&state.panning_tool) - .map(Clone::clone) - .into_iter(), - ); + .chain(state.tools.get(&state.panning_tool).cloned()); drop(state); for t in active_tools { if t.on_button_press_event(obj.clone(), viewport, event) == Inhibit(true) { @@ -75,15 +68,9 @@ impl Tool { let active_tools = state .tools .get(&state.active_tool) - .map(Clone::clone) + .cloned() .into_iter() - .chain( - state - .tools - .get(&state.panning_tool) - .map(Clone::clone) - .into_iter(), - ); + .chain(state.tools.get(&state.panning_tool).cloned()); drop(state); for t in active_tools { if t.on_button_release_event(obj.clone(), viewport, event) == Inhibit(true) { @@ -99,13 +86,14 @@ impl Tool { event: >k::gdk::EventScroll, ) -> Inhibit { let state = obj.state().borrow(); - let (panning_tool, active_tool) = (state.panning_tool, state.active_tool); + let panning_tool = state.panning_tool; + let active_tool = state.active_tool; let active_tools = state .tools .get(&active_tool) - .map(Clone::clone) + .cloned() .into_iter() - .chain(state.tools.get(&panning_tool).map(Clone::clone).into_iter()) + .chain(state.tools.get(&panning_tool).cloned()) .chain(state.tools.clone().into_iter().filter_map(|(k, v)| { if [panning_tool, active_tool].contains(&k) { None @@ -131,15 +119,9 @@ impl Tool { let active_tools = state .tools .get(&state.active_tool) - .map(Clone::clone) + .cloned() .into_iter() - .chain( - state - .tools - .get(&state.panning_tool) - .map(Clone::clone) - .into_iter(), - ); + .chain(state.tools.get(&state.panning_tool).cloned()); drop(state); for t in active_tools { if t.on_motion_notify_event(obj.clone(), viewport, event) == Inhibit(true) { @@ -401,7 +383,7 @@ pub mod constraints { } impl Lock { - const ACTION_NAME: &str = Editor::LOCK_ACTION; + const ACTION_NAME: &'static str = Editor::LOCK_ACTION; pub fn as_str(&self) -> &'static str { match *self { @@ -438,7 +420,7 @@ pub mod constraints { } impl Precision { - const ACTION_NAME: &str = Editor::PRECISION_ACTION; + const ACTION_NAME: &'static str = Editor::PRECISION_ACTION; pub fn as_str(&self) -> &'static str { match *self { @@ -468,7 +450,7 @@ pub mod constraints { } impl Snap { - const ACTION_NAME: &str = Editor::SNAP_ACTION; + const ACTION_NAME: &'static str = Editor::SNAP_ACTION; pub fn as_str(&self) -> &'static str { match *self { diff --git a/src/editor/tools/bezier.rs b/src/editor/tools/bezier.rs index 57d4c0e..d7192c0 100644 --- a/src/editor/tools/bezier.rs +++ b/src/editor/tools/bezier.rs @@ -467,12 +467,8 @@ impl ToolImplImpl for BezierToolInner { self.transform_point(m, &view, state, state.curve_index, handle_point); } if !unlinked { - let linked_curve_point = state.contour.curves()[0] - .points() - .iter() - .nth(1) - .unwrap() - .clone(); + let linked_curve_point = + state.contour.curves()[0].points().get(1).unwrap().clone(); let new_mirrored_position = handle.mirror(state.first_point); let diff_vector = new_mirrored_position - linked_curve_point.position; let mut m = Matrix::identity(); @@ -567,7 +563,7 @@ impl BezierToolInner { mut state_opt: RefMut<'_, Option>, point: Point, ) { - if let Some(mut state) = state_opt.as_mut() { + if let Some(state) = state_opt.as_mut() { let add_to_kdtree = |state: &mut ContourState, curve_index: usize, curve_point: CurvePoint| { let editor_state = view.state().borrow(); @@ -738,7 +734,7 @@ impl Default for BezierTool { } impl BezierTool { - pub const ACTIVE: &str = "active"; + pub const ACTIVE: &'static str = "active"; pub fn new() -> Self { glib::Object::new(&[]).unwrap() diff --git a/src/editor/tools/image.rs b/src/editor/tools/image.rs index 8426a6b..fd519e0 100644 --- a/src/editor/tools/image.rs +++ b/src/editor/tools/image.rs @@ -72,8 +72,8 @@ impl ObjectImpl for ImageToolInner { ImageTool::ASCENDER, ImageTool::ASCENDER, ImageTool::ASCENDER, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, ufo::constants::ASCENDER, glib::ParamFlags::READWRITE, ), @@ -81,8 +81,8 @@ impl ObjectImpl for ImageToolInner { ImageTool::DESCENDER, ImageTool::DESCENDER, ImageTool::DESCENDER, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, ufo::constants::DESCENDER, glib::ParamFlags::READWRITE, ), @@ -193,9 +193,9 @@ glib::wrapper! { } impl ImageTool { - pub const ACTIVE: &str = "active"; - pub const ASCENDER: &str = FontInfo::ASCENDER; - pub const DESCENDER: &str = FontInfo::DESCENDER; + pub const ACTIVE: &'static str = "active"; + pub const ASCENDER: &'static str = FontInfo::ASCENDER; + pub const DESCENDER: &'static str = FontInfo::DESCENDER; pub fn new(glyph: Rc>, project: Project) -> Self { let ret: Self = glib::Object::new(&[]).unwrap(); diff --git a/src/editor/tools/panning.rs b/src/editor/tools/panning.rs index 89c261c..bbf817e 100644 --- a/src/editor/tools/panning.rs +++ b/src/editor/tools/panning.rs @@ -1165,11 +1165,11 @@ impl Default for PanningTool { } impl PanningTool { - pub const ACTIVE: &str = "active"; - pub const MOVE_ACTION: &str = "move.selection"; - pub const SCALE_ACTION: &str = "scale.selection"; - pub const ROTATE_ACTION: &str = "rotate.selection"; - pub const PAN_ACTION: &str = "pan"; + pub const ACTIVE: &'static str = "active"; + pub const MOVE_ACTION: &'static str = "move.selection"; + pub const SCALE_ACTION: &'static str = "scale.selection"; + pub const ROTATE_ACTION: &'static str = "rotate.selection"; + pub const PAN_ACTION: &'static str = "pan"; pub fn new() -> Self { glib::Object::new(&[]).unwrap() @@ -1520,7 +1520,7 @@ fn snap_to_closest_anchor( //todo } candidates.sort_by(|(_, a), (_, b)| a.total_cmp(b)); - candidates.get(0).map(|(p, _)| *p) + candidates.first().map(|(p, _)| *p) } fn change_continuity( diff --git a/src/editor/tools/shapes.rs b/src/editor/tools/shapes.rs index 8db98be..0a0295c 100644 --- a/src/editor/tools/shapes.rs +++ b/src/editor/tools/shapes.rs @@ -293,7 +293,7 @@ impl Default for QuadrilateralTool { } impl QuadrilateralTool { - pub const ACTIVE: &str = "active"; + pub const ACTIVE: &'static str = "active"; pub fn new() -> Self { glib::Object::new(&[]).unwrap() @@ -614,7 +614,7 @@ impl Default for EllipseTool { } impl EllipseTool { - pub const ACTIVE: &str = "active"; + pub const ACTIVE: &'static str = "active"; pub fn new() -> Self { glib::Object::new(&[]).unwrap() diff --git a/src/editor/tools/tool_impl.rs b/src/editor/tools/tool_impl.rs index 7db676a..096fd50 100644 --- a/src/editor/tools/tool_impl.rs +++ b/src/editor/tools/tool_impl.rs @@ -278,13 +278,7 @@ impl ToolImplInner { let t = self.instance().type_(); let active_tool = view.state().borrow().active_tool; if active_tool != t { - if let Some(previous_tool) = view - .state() - .borrow() - .tools - .get(&active_tool) - .map(Clone::clone) - { + if let Some(previous_tool) = view.state().borrow().tools.get(&active_tool).cloned() { previous_tool.on_deactivate(view); } @@ -359,9 +353,9 @@ glib::wrapper! { } impl ToolImpl { - pub const NAME: &str = "name"; - pub const DESCRIPTION: &str = "description"; - pub const ICON: &str = "icon"; + pub const NAME: &'static str = "name"; + pub const DESCRIPTION: &'static str = "description"; + pub const ICON: &'static str = "icon"; pub fn new() -> Self { glib::Object::new(&[]).unwrap() diff --git a/src/git.rs b/src/git.rs index 98b3b53..a02ced4 100644 --- a/src/git.rs +++ b/src/git.rs @@ -104,7 +104,7 @@ impl std::ops::Deref for Repository { } impl Repository { - pub const STATE: &str = "state"; + pub const STATE: &'static str = "state"; pub fn new(abs_path: &Path) -> Result, Box> { let ret: Self = glib::Object::new::(&[]).unwrap(); diff --git a/src/git/tab.rs b/src/git/tab.rs index 64ed54f..9e3d6e8 100644 --- a/src/git/tab.rs +++ b/src/git/tab.rs @@ -133,10 +133,10 @@ impl std::ops::Deref for GitSpace { } impl GitSpace { - pub const CLOSEABLE: &str = Workspace::CLOSEABLE; - pub const TITLE: &str = Workspace::TITLE; - pub const IS_MENU_VISIBLE: &str = Workspace::IS_MENU_VISIBLE; - pub const MENUBAR: &str = Workspace::MENUBAR; + pub const CLOSEABLE: &'static str = Workspace::CLOSEABLE; + pub const TITLE: &'static str = Workspace::TITLE; + pub const IS_MENU_VISIBLE: &'static str = Workspace::IS_MENU_VISIBLE; + pub const MENUBAR: &'static str = Workspace::MENUBAR; pub fn new(app: Application, project: Project, repository: Repository) -> Self { let ret: Self = glib::Object::new(&[]).unwrap(); diff --git a/src/glyphs.rs b/src/glyphs.rs index 4e14c4f..9b39248 100644 --- a/src/glyphs.rs +++ b/src/glyphs.rs @@ -362,7 +362,7 @@ impl Glyph { cr1.set_line_width(outline.size); cr1.set_source_color_alpha(outline.color); let mut pen_position: Option = None; - for (_ic, contour) in self.contours.iter().enumerate() { + for contour in self.contours.iter() { let curves = contour.curves(); if !contour.property::(Contour::OPEN) { if let Some(point) = curves.last().and_then(|b| b.points().last().cloned()) { @@ -373,7 +373,7 @@ impl Glyph { cr1.move_to(point.x, point.y); } - for (_jc, curv) in curves.iter().enumerate() { + for curv in curves.iter() { let degree = curv.degree(); let degree = if let Some(v) = degree { v @@ -442,7 +442,7 @@ impl Glyph { if let Some((degree, curv)) = highlight.and_then(|(contour_idx, curve_idx)| { self.contours .get(contour_idx) - .and_then(|contour| contour.curves().get(curve_idx).map(Clone::clone)) + .and_then(|contour| contour.curves().get(curve_idx).cloned()) .and_then(|curv| Some((curv.degree()?, curv))) }) { let curv_points = curv.points(); diff --git a/src/glyphs/contours.rs b/src/glyphs/contours.rs index e39eb02..923ddc0 100644 --- a/src/glyphs/contours.rs +++ b/src/glyphs/contours.rs @@ -41,8 +41,8 @@ impl std::ops::Deref for Contour { } impl Contour { - pub const OPEN: &str = "open"; - pub const BIGGEST_CURVE: &str = "biggest-curve"; + pub const OPEN: &'static str = "open"; + pub const BIGGEST_CURVE: &'static str = "biggest-curve"; pub fn new() -> Self { let ret: Self = glib::Object::new::(&[]).unwrap(); diff --git a/src/glyphs/guidelines.rs b/src/glyphs/guidelines.rs index 13775c0..4b22dee 100644 --- a/src/glyphs/guidelines.rs +++ b/src/glyphs/guidelines.rs @@ -77,8 +77,8 @@ impl ObjectImpl for GuidelineInner { Guideline::ANGLE, Guideline::ANGLE, Guideline::ANGLE, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, 0., ParamFlags::READWRITE | UI_EDITABLE, ), @@ -86,8 +86,8 @@ impl ObjectImpl for GuidelineInner { Guideline::X, Guideline::X, Guideline::X, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, 0.0, ParamFlags::READWRITE | UI_EDITABLE, ), @@ -95,8 +95,8 @@ impl ObjectImpl for GuidelineInner { Guideline::Y, Guideline::Y, Guideline::Y, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, 0.0, ParamFlags::READWRITE | UI_EDITABLE, ), @@ -363,13 +363,13 @@ impl From<&Guideline> for ufo::GuidelineInfo { } impl Guideline { - pub const NAME: &str = "name"; - pub const COLOR: &str = "color"; - pub const IDENTIFIER: &str = "identifier"; - pub const ANGLE: &str = "angle"; - pub const X: &str = "x"; - pub const Y: &str = "y"; - pub const MODIFIED: &str = "modified"; + pub const NAME: &'static str = "name"; + pub const COLOR: &'static str = "color"; + pub const IDENTIFIER: &'static str = "identifier"; + pub const ANGLE: &'static str = "angle"; + pub const X: &'static str = "x"; + pub const Y: &'static str = "y"; + pub const MODIFIED: &'static str = "modified"; pub fn new() -> Self { let ret: Self = glib::Object::new::(&[]).unwrap(); diff --git a/src/glyphs/metadata.rs b/src/glyphs/metadata.rs index 7c37f28..5506b44 100644 --- a/src/glyphs/metadata.rs +++ b/src/glyphs/metadata.rs @@ -92,7 +92,7 @@ impl ObjectImpl for GlyphMetadataInner { None, glib::ParamFlags::READWRITE | UI_EDITABLE, ), - def_param!(f64 GlyphMetadata::WIDTH, std::f64::MIN, 0.0), + def_param!(f64 GlyphMetadata::WIDTH, f64::MIN, 0.0), glib::ParamSpecObject::new( GlyphMetadata::LAYER, GlyphMetadata::LAYER, @@ -187,13 +187,13 @@ impl std::ops::Deref for GlyphMetadata { } impl GlyphMetadata { - pub const MODIFIED: &str = "modified"; - pub const MARK_COLOR: &str = "mark-color"; - pub const RELATIVE_PATH: &str = "relative-path"; - pub const FILENAME: &str = "filename"; - pub const NAME: &str = "name"; - pub const LAYER: &str = "layer"; - pub const WIDTH: &str = "width"; + pub const MODIFIED: &'static str = "modified"; + pub const MARK_COLOR: &'static str = "mark-color"; + pub const RELATIVE_PATH: &'static str = "relative-path"; + pub const FILENAME: &'static str = "filename"; + pub const NAME: &'static str = "name"; + pub const LAYER: &'static str = "layer"; + pub const WIDTH: &'static str = "width"; pub fn new() -> Self { let ret: Self = glib::Object::new::(&[]).unwrap(); @@ -254,7 +254,7 @@ impl CreatePropertyWindow for GlyphMetadata { if create { self.set_property(Self::FILENAME, "glyph_name.glif"); } - let mut w = PropertyWindow::builder(self.clone().upcast(), app) + let w = PropertyWindow::builder(self.clone().upcast(), app) .title(if create { "Add glyph".into() } else { @@ -276,7 +276,8 @@ impl CreatePropertyWindow for GlyphMetadata { filename.style_monospace(); name.bind_property("text", self, Self::FILENAME) .transform_to(|_, val| { - let Some(n) = val.get::>().ok()?.filter(|n| !n.is_empty()) else { + let Some(n) = val.get::>().ok()?.filter(|n| !n.is_empty()) + else { return Some("glyph_name.glif".to_value()); }; Some(format!("{n}.glif").to_value()) diff --git a/src/lib.rs b/src/lib.rs index d968bde..1a5cd70 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,7 +35,7 @@ clippy::assertions_on_result_states, /* pedantic */ clippy::cast_lossless, - clippy::cast_possible_wrap, + // clippy::cast_possible_wrap, [ref:TODO] re-enable clippy::ptr_as_ptr, clippy::bool_to_int_with_if, clippy::borrow_as_ptr, @@ -54,6 +54,9 @@ clippy::fallible_impl_from, // [ref:TODO] clippy::option_if_let_else, // [ref:TODO] clippy::cognitive_complexity, // [ref:TODO] + clippy::while_float, // [ref:TODO] + clippy::redundant_guards, // [ref:TODO] + clippy::bad_bit_mask, // [ref:TODO] )] #[macro_use] @@ -163,7 +166,6 @@ pub mod prelude { }; pub use window::Workspace; - pub use glib::prelude::*; pub use glib::subclass::Signal; pub use glib::{ ParamFlags, ParamSpec, ParamSpecBoolean, ParamSpecBoxed, ParamSpecDouble, ParamSpecObject, @@ -275,7 +277,7 @@ pub mod prelude { $name, $name, 0, - std::i64::MAX, + i64::MAX, $default, ParamFlags::READWRITE | UI_EDITABLE, ) @@ -289,7 +291,7 @@ pub mod prelude { $name, $name, 0, - std::u64::MAX, + u64::MAX, $default, ParamFlags::READWRITE | UI_EDITABLE, ) @@ -303,7 +305,7 @@ pub mod prelude { $name, $name, $min, - std::f64::MAX, + f64::MAX, $default, ParamFlags::READWRITE | UI_EDITABLE, ) @@ -316,7 +318,7 @@ pub mod prelude { macro_rules! inherit_property { ($t:ty, $($prop:ident),+$(,)?) => { $( - pub const $prop: &str = <$t>::$prop; + pub const $prop: &'static str = <$t>::$prop; )* } } @@ -338,5 +340,4 @@ pub mod prelude { }}; } } - pub use macros::*; } diff --git a/src/project.rs b/src/project.rs index a23fa78..988dac7 100644 --- a/src/project.rs +++ b/src/project.rs @@ -163,9 +163,9 @@ impl std::ops::Deref for Project { } impl Project { - pub const MODIFIED: &str = "modified"; - pub const NAME: &str = "name"; - pub const FILENAME_STEM: &str = "filename-stem"; + pub const MODIFIED: &'static str = "modified"; + pub const NAME: &'static str = "name"; + pub const FILENAME_STEM: &'static str = "filename-stem"; pub fn new() -> Self { let ret: Self = glib::Object::new::(&[]).unwrap(); diff --git a/src/ufo.rs b/src/ufo.rs index a79600e..6333ece 100644 --- a/src/ufo.rs +++ b/src/ufo.rs @@ -680,11 +680,11 @@ where } impl LayerContents { - const ERROR_NO_LAYERS: &str = "UFOv3 spec requires the presence of at least one layer, the default layer with name `public.default` and directory name `glyphs`."; - const ERROR_DEFAULT_DIR_NOT_GLYPHS: &str = "UFOv3 spec requires the default layer (i.e. the first one) to have its directory name equal to `glyphs`."; - const ERROR_HAS_DUPLICATE_LAYER_NAMES: &str = + const ERROR_NO_LAYERS: &'static str = "UFOv3 spec requires the presence of at least one layer, the default layer with name `public.default` and directory name `glyphs`."; + const ERROR_DEFAULT_DIR_NOT_GLYPHS: &'static str = "UFOv3 spec requires the default layer (i.e. the first one) to have its directory name equal to `glyphs`."; + const ERROR_HAS_DUPLICATE_LAYER_NAMES: &'static str = "UFOv3 spec requires that layer names are unique."; - const ERROR_HAS_DUPLICATE_LAYER_DIR_NAMES: &str = + const ERROR_HAS_DUPLICATE_LAYER_DIR_NAMES: &'static str = "Input contains duplicate layer directory values."; #[inline(always)] @@ -797,7 +797,7 @@ impl LayerContents { path.push(dir_name); if !path.exists() { if create { - std::fs::create_dir(&path)?; + std::fs::create_dir(path.as_path())?; } else { return Err( Self::new_dir_doesnt_exist_err(layer_name, dir_name, path).into() diff --git a/src/ufo/export.rs b/src/ufo/export.rs index 540a9d6..2aa2743 100644 --- a/src/ufo/export.rs +++ b/src/ufo/export.rs @@ -151,8 +151,12 @@ pub mod ufo_compile { return_if_not_ok_or_accept!(filechooser.run()); - let Some(f) = filechooser.filename() else { return; }; - let Some(output_dir) = f.to_str() else { return; }; + let Some(f) = filechooser.filename() else { + return; + }; + let Some(output_dir) = f.to_str() else { + return; + }; let (output_path, format) = if let Some(path) = filechooser.filename() { let filter = |p: &PathBuf| !p.is_dir(); match filechooser.filter().as_ref() { diff --git a/src/ufo/import.rs b/src/ufo/import.rs index e455531..42fd265 100644 --- a/src/ufo/import.rs +++ b/src/ufo/import.rs @@ -177,8 +177,12 @@ pub mod glyphsapp { return_if_not_ok_or_accept!(dialog.run()); dialog.hide(); - let Some(f) = dialog.filename() else { return; }; - let Some(path) = f.to_str() else { return; }; + let Some(f) = dialog.filename() else { + return; + }; + let Some(path) = f.to_str() else { + return; + }; match import(Glyphs2UFOOptions::new(path.into()).output_dir(None)) { Ok(instances) => { if instances.len() == 1 { @@ -336,8 +340,12 @@ pub mod ufo2 { ); return_if_not_ok_or_accept!(dialog.run()); dialog.hide(); - let Some(f) = dialog.filename() else { return; }; - let Some(input_dir) = f.to_str() else { return; }; + let Some(f) = dialog.filename() else { + return; + }; + let Some(input_dir) = f.to_str() else { + return; + }; drop(dialog); let dialog2 = gtk::FileChooserNative::new( Some("Select UFOv3 output path"), @@ -350,8 +358,12 @@ pub mod ufo2 { return_if_not_ok_or_accept!(dialog2.run()); dialog2.hide(); - let Some(f) = dialog2.filename() else { return; }; - let Some(output_dir) = f.to_str() else { return; }; + let Some(f) = dialog2.filename() else { + return; + }; + let Some(output_dir) = f.to_str() else { + return; + }; drop(dialog2); match import(UFO2ToUFO3Options::new(input_dir.into(), output_dir.into())) { Ok(instance) => { diff --git a/src/ufo/objects.rs b/src/ufo/objects.rs index e1369b9..6ce00bf 100644 --- a/src/ufo/objects.rs +++ b/src/ufo/objects.rs @@ -122,10 +122,10 @@ impl ObjectImpl for FontInfoInner { def_param!(u64 FontInfo::VERSION_MINOR, constants::VERSION_MINOR), def_param!(f64 FontInfo::UNITS_PER_EM, 1.0, constants::UNITS_PER_EM), def_param!(f64 FontInfo::X_HEIGHT, 1.0, constants::X_HEIGHT), - def_param!(f64 FontInfo::ASCENDER, std::f64::MIN, constants::ASCENDER), - def_param!(f64 FontInfo::DESCENDER, std::f64::MIN, constants::DESCENDER), - def_param!(f64 FontInfo::CAP_HEIGHT, std::f64::MIN, constants::CAP_HEIGHT), - def_param!(f64 FontInfo::ITALIC_ANGLE, std::f64::MIN, constants::ITALIC_ANGLE), + def_param!(f64 FontInfo::ASCENDER, f64::MIN, constants::ASCENDER), + def_param!(f64 FontInfo::DESCENDER, f64::MIN, constants::DESCENDER), + def_param!(f64 FontInfo::CAP_HEIGHT, f64::MIN, constants::CAP_HEIGHT), + def_param!(f64 FontInfo::ITALIC_ANGLE, f64::MIN, constants::ITALIC_ANGLE), ] }); PROPERTIES.as_ref() @@ -251,23 +251,23 @@ impl_deref!(FontInfo, FontInfoInner); impl_property_window!(FontInfo, { "Font Metadata" }); impl FontInfo { - pub const MODIFIED: &str = "modified"; - pub const FAMILY_NAME: &str = "family-name"; - pub const STYLE_NAME: &str = "style-name"; - pub const STYLE_MAP_FAMILY_NAME: &str = "style-map-family-name"; - pub const STYLE_MAP_STYLE_NAME: &str = "style-map-style-name"; - pub const YEAR: &str = "year"; - pub const COPYRIGHT: &str = "copyright"; - pub const TRADEMARK: &str = "trademark"; - pub const UNITS_PER_EM: &str = "units-per-em"; - pub const DESCENDER: &str = "descender"; - pub const X_HEIGHT: &str = "x-height"; - pub const CAP_HEIGHT: &str = "cap-height"; - pub const ASCENDER: &str = "ascender"; - pub const ITALIC_ANGLE: &str = "italic-angle"; - pub const NOTE: &str = "note"; - pub const VERSION_MAJOR: &str = "version-major"; - pub const VERSION_MINOR: &str = "version-minor"; + pub const MODIFIED: &'static str = "modified"; + pub const FAMILY_NAME: &'static str = "family-name"; + pub const STYLE_NAME: &'static str = "style-name"; + pub const STYLE_MAP_FAMILY_NAME: &'static str = "style-map-family-name"; + pub const STYLE_MAP_STYLE_NAME: &'static str = "style-map-style-name"; + pub const YEAR: &'static str = "year"; + pub const COPYRIGHT: &'static str = "copyright"; + pub const TRADEMARK: &'static str = "trademark"; + pub const UNITS_PER_EM: &'static str = "units-per-em"; + pub const DESCENDER: &'static str = "descender"; + pub const X_HEIGHT: &'static str = "x-height"; + pub const CAP_HEIGHT: &'static str = "cap-height"; + pub const ASCENDER: &'static str = "ascender"; + pub const ITALIC_ANGLE: &'static str = "italic-angle"; + pub const NOTE: &'static str = "note"; + pub const VERSION_MAJOR: &'static str = "version-major"; + pub const VERSION_MINOR: &'static str = "version-minor"; pub fn new() -> Self { let ret: Self = glib::Object::new::(&[]).unwrap(); @@ -475,9 +475,9 @@ mod layer { } impl Layer { - pub const MODIFIED: &str = "modified"; - pub const NAME: &str = "name"; - pub const DIR_NAME: &str = "dir-name"; + pub const MODIFIED: &'static str = "modified"; + pub const NAME: &'static str = "name"; + pub const DIR_NAME: &'static str = "dir-name"; pub fn new() -> Self { let ret: Self = glib::Object::new::(&[]).unwrap(); diff --git a/src/unicode/names/unicode.py b/src/unicode/names/unicode.py index 049df31..080ab40 100644 --- a/src/unicode/names/unicode.py +++ b/src/unicode/names/unicode.py @@ -178,7 +178,7 @@ def create_intervals(list): in_group = False group_start = 0 result = [] - for (idx, val) in enumerate(list): + for idx, val in enumerate(list): if not in_group: group_start = val in_group = True @@ -265,7 +265,7 @@ def write_enumeration_char_names(rf, encoded_groups): pub const ENUMERATION_CHAR_NAMES: &'static [(u32, u32, &'static [u16], &'static [u32])] = &[ """ ) - for (first, last, group_buffer, pos_buffer) in encoded_groups: + for first, last, group_buffer, pos_buffer in encoded_groups: rf.write("\t(%d, %d, &%s, &%s),\n" % (first, last, group_buffer, pos_buffer)) rf.write( """]; @@ -281,7 +281,7 @@ def write_special_groups(rf, special_groups): pub enum SpecialGroup { """ ) - for (_, _, groupname) in special_groups: + for _, _, groupname in special_groups: group_variant = groupname.replace(" ", "") rf.write("\t%s,\n" % group_variant) rf.write( @@ -293,7 +293,7 @@ def write_special_groups(rf, special_groups): pub const SPECIAL_GROUPS: &'static [(u32, u32, SpecialGroup)] = &[ """ ) - for (idx, (first, last, groupname)) in enumerate(special_groups): + for idx, (first, last, groupname) in enumerate(special_groups): if idx % 2 == 0: rf.write("\t") group_variant = groupname.replace(" ", "") @@ -331,7 +331,7 @@ def write_word_table(rf, word_table): pub const ENUMERATION_WORD_TABLE: &'static [&'static str] = &[ """ ) - for (idx, word) in enumerate(word_table): + for idx, word in enumerate(word_table): if idx % 8 == 0: rf.write("\t") rf.write('"%s", ' % word) @@ -384,7 +384,7 @@ def write_special_symbols(rf, word_index): match v { """ ) - for (first, last) in special_intervals: + for first, last in special_intervals: rf.write("\t\t%d..=%d => true,\n" % (first, last)) rf.write( """\t\t_ => false, diff --git a/src/utils/curves.rs b/src/utils/curves.rs index 6cb9365..7608eae 100644 --- a/src/utils/curves.rs +++ b/src/utils/curves.rs @@ -221,9 +221,9 @@ impl Default for Bezier { } impl Bezier { - pub const SMOOTH: &str = "smooth"; - pub const CONTINUITY_IN: &str = "continuity-in"; - pub const CONTINUITY_OUT: &str = "continuity-out"; + pub const SMOOTH: &'static str = "smooth"; + pub const CONTINUITY_IN: &'static str = "continuity-in"; + pub const CONTINUITY_OUT: &'static str = "continuity-out"; pub fn new(points: Vec) -> Self { let ret: Self = glib::Object::new::(&[]).unwrap(); diff --git a/src/utils/property_window.rs b/src/utils/property_window.rs index 588aa3d..14ec512 100644 --- a/src/utils/property_window.rs +++ b/src/utils/property_window.rs @@ -172,13 +172,13 @@ glib::wrapper! { } impl PropertyWindow { - const IS_DIRTY: &str = "is-dirty"; + const IS_DIRTY: &'static str = "is-dirty"; pub fn builder(obj: glib::Object, app: &crate::prelude::Application) -> PropertyWindowBuilder { PropertyWindowBuilder::new(obj, app) } - pub fn widgets(&mut self) -> FieldRef<'_, IndexMap> { + pub fn widgets(&self) -> FieldRef<'_, IndexMap> { self.imp().widgets.borrow().into() } @@ -191,7 +191,7 @@ impl PropertyWindow { } fn object_to_property_grid( - &mut self, + &self, obj: glib::Object, friendly_name: Option>, create: bool, diff --git a/src/utils/property_window/types.rs b/src/utils/property_window/types.rs index b425f61..7791eb0 100644 --- a/src/utils/property_window/types.rs +++ b/src/utils/property_window/types.rs @@ -146,7 +146,7 @@ mod builder { .min_content_height(600) .min_content_width(500) .build(); - let mut ret: PropertyWindow = glib::Object::new(&[]).unwrap(); + let ret: PropertyWindow = glib::Object::new(&[]).unwrap(); ret.imp().app.set(self.app.clone()).unwrap(); ret.object_to_property_grid( self.obj.clone(), @@ -837,7 +837,7 @@ mod widgets { } else { entry.connect_changed(clone!(@weak obj, @strong project, @strong property => move |entry| { let active_id = entry.active_id(); - obj.set_property(property.name(), active_id.and_then(|n| project.all_layers.borrow().iter().find(|l| l.name.borrow().as_str() == n).map(Layer::clone))); + obj.set_property(property.name(), active_id.and_then(|n| project.all_layers.borrow().iter().find(|l| l.name.borrow().as_str() == n).cloned())); })); } let mut active_id: Cow<'static, str> = if let Some(l) = val { @@ -876,8 +876,8 @@ mod widgets { obj.bind_property(property.name(), &l, "label") .transform_to(|_, val| { let Some(l): Option = val.get::>().ok()? else { - return Some(String::new().to_value()); - }; + return Some(String::new().to_value()); + }; Some(format!("Directory: {}/", l.dir_name.borrow()).to_value()) }) .flags(glib::BindingFlags::SYNC_CREATE) diff --git a/src/views/canvas.rs b/src/views/canvas.rs index d4fc3fc..81db10e 100644 --- a/src/views/canvas.rs +++ b/src/views/canvas.rs @@ -223,8 +223,8 @@ impl ObjectImpl for CanvasInner { Canvas::VIEW_HEIGHT, Canvas::VIEW_HEIGHT, Canvas::VIEW_HEIGHT, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, 1000.0, ParamFlags::READWRITE, ), @@ -232,8 +232,8 @@ impl ObjectImpl for CanvasInner { Canvas::VIEW_WIDTH, Canvas::VIEW_WIDTH, Canvas::VIEW_WIDTH, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, 1000.0, ParamFlags::READWRITE, ), @@ -241,8 +241,8 @@ impl ObjectImpl for CanvasInner { Canvas::CONTENT_WIDTH, Canvas::CONTENT_WIDTH, Canvas::CONTENT_WIDTH, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, 0.0, ParamFlags::READWRITE, ), @@ -251,7 +251,7 @@ impl ObjectImpl for CanvasInner { Canvas::RULER_BREADTH_PIXELS, Canvas::RULER_BREADTH_PIXELS, 0.0, - std::f64::MAX, + f64::MAX, 0.0, ParamFlags::READABLE, ), diff --git a/src/views/canvas/layers.rs b/src/views/canvas/layers.rs index 54db0ef..9603eb2 100644 --- a/src/views/canvas/layers.rs +++ b/src/views/canvas/layers.rs @@ -122,9 +122,9 @@ impl std::ops::Deref for Layer { } impl Layer { - pub const ACTIVE: &str = "active"; - pub const HIDDEN: &str = "hidden"; - pub const NAME: &str = "name"; + pub const ACTIVE: &'static str = "active"; + pub const HIDDEN: &'static str = "hidden"; + pub const NAME: &'static str = "name"; pub fn new() -> Self { let ret: Self = glib::Object::new(&[]).expect("Failed to create Layer"); diff --git a/src/views/canvas/settings.rs b/src/views/canvas/settings.rs index 0c64bfc..15a518b 100644 --- a/src/views/canvas/settings.rs +++ b/src/views/canvas/settings.rs @@ -465,34 +465,34 @@ impl Default for CanvasSettings { } impl CanvasSettings { - pub const HANDLE_SIZE: &str = "handle-size"; - pub const LINE_WIDTH: &str = "line-width"; - pub const INNER_FILL: &str = "inner-fill"; - pub const VIEW_HEIGHT: &str = "view-height"; - pub const VIEW_WIDTH: &str = "view-width"; - pub const SHOW_GRID: &str = "show-grid"; - pub const SHOW_GUIDELINES: &str = "show-guidelines"; - pub const SHOW_HANDLES: &str = "show-handles"; - pub const SHOW_DIRECTION: &str = "show-direction"; - pub const HANDLE_OPTIONS: &str = "handle-options"; - pub const SMOOTH_CORNER_OPTIONS: &str = "smooth-corner-options"; - pub const CORNER_OPTIONS: &str = "corner-options"; - pub const DIRECTION_OPTIONS: &str = "direction-options"; - pub const HANDLE_CONNECTION_OPTIONS: &str = "handle-connection-options"; - pub const OUTLINE_OPTIONS: &str = "outline-options"; - pub const SHOW_TOTAL_AREA: &str = "show-total-area"; - pub const SHOW_RULERS: &str = "show-rules"; - pub const TRANSFORMATION: &str = "transformation"; - pub const WARP_CURSOR: &str = "warp-cursor"; - pub const MOUSE: &str = "mouse"; - pub const BG_COLOR: &str = "bg-color"; - pub const GLYPH_INNER_FILL_COLOR: &str = "glyph-inner-fill-color"; - pub const GLYPH_BBOX_BG_COLOR: &str = "glyph-bbox-bg-color"; - pub const RULER_BREADTH_PIXELS: &str = "ruler-breadth-pixels"; - pub const RULER_FG_COLOR: &str = "ruler-fg-color"; - pub const RULER_BG_COLOR: &str = "ruler-bg-color"; - pub const RULER_INDICATOR_COLOR: &str = "ruler-indicator-color"; - pub const CONTENT_WIDTH: &str = "content-width"; + pub const HANDLE_SIZE: &'static str = "handle-size"; + pub const LINE_WIDTH: &'static str = "line-width"; + pub const INNER_FILL: &'static str = "inner-fill"; + pub const VIEW_HEIGHT: &'static str = "view-height"; + pub const VIEW_WIDTH: &'static str = "view-width"; + pub const SHOW_GRID: &'static str = "show-grid"; + pub const SHOW_GUIDELINES: &'static str = "show-guidelines"; + pub const SHOW_HANDLES: &'static str = "show-handles"; + pub const SHOW_DIRECTION: &'static str = "show-direction"; + pub const HANDLE_OPTIONS: &'static str = "handle-options"; + pub const SMOOTH_CORNER_OPTIONS: &'static str = "smooth-corner-options"; + pub const CORNER_OPTIONS: &'static str = "corner-options"; + pub const DIRECTION_OPTIONS: &'static str = "direction-options"; + pub const HANDLE_CONNECTION_OPTIONS: &'static str = "handle-connection-options"; + pub const OUTLINE_OPTIONS: &'static str = "outline-options"; + pub const SHOW_TOTAL_AREA: &'static str = "show-total-area"; + pub const SHOW_RULERS: &'static str = "show-rules"; + pub const TRANSFORMATION: &'static str = "transformation"; + pub const WARP_CURSOR: &'static str = "warp-cursor"; + pub const MOUSE: &'static str = "mouse"; + pub const BG_COLOR: &'static str = "bg-color"; + pub const GLYPH_INNER_FILL_COLOR: &'static str = "glyph-inner-fill-color"; + pub const GLYPH_BBOX_BG_COLOR: &'static str = "glyph-bbox-bg-color"; + pub const RULER_BREADTH_PIXELS: &'static str = "ruler-breadth-pixels"; + pub const RULER_FG_COLOR: &'static str = "ruler-fg-color"; + pub const RULER_BG_COLOR: &'static str = "ruler-bg-color"; + pub const RULER_INDICATOR_COLOR: &'static str = "ruler-indicator-color"; + pub const CONTENT_WIDTH: &'static str = "content-width"; pub fn new() -> Self { glib::Object::new::(&[]).unwrap() diff --git a/src/views/canvas/transformation.rs b/src/views/canvas/transformation.rs index 28b040c..8e819c4 100644 --- a/src/views/canvas/transformation.rs +++ b/src/views/canvas/transformation.rs @@ -90,8 +90,8 @@ impl ObjectImpl for TransformationInner { Transformation::CAMERA_X, Transformation::CAMERA_X, Transformation::CAMERA_X, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, TransformationInner::INIT_CAMERA_X_VAL, ParamFlags::READWRITE, ), @@ -99,8 +99,8 @@ impl ObjectImpl for TransformationInner { Transformation::CAMERA_Y, Transformation::CAMERA_Y, Transformation::CAMERA_Y, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, TransformationInner::INIT_CAMERA_Y_VAL, ParamFlags::READWRITE, ), @@ -108,8 +108,8 @@ impl ObjectImpl for TransformationInner { Transformation::PIXELS_PER_UNIT, Transformation::PIXELS_PER_UNIT, Transformation::PIXELS_PER_UNIT, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, TransformationInner::INIT_PIXELS_PER_UNIT_VAL, ParamFlags::READABLE, ), @@ -117,8 +117,8 @@ impl ObjectImpl for TransformationInner { Transformation::UNITS_PER_EM, Transformation::UNITS_PER_EM, Transformation::UNITS_PER_EM, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, TransformationInner::INIT_UNITS_PER_EM_VAL, ParamFlags::READWRITE, ), @@ -126,8 +126,8 @@ impl ObjectImpl for TransformationInner { Transformation::VIEW_HEIGHT, Transformation::VIEW_HEIGHT, Transformation::VIEW_HEIGHT, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, TransformationInner::INIT_VIEW_HEIGHT_VAL, ParamFlags::READWRITE, ), @@ -135,8 +135,8 @@ impl ObjectImpl for TransformationInner { Transformation::VIEW_WIDTH, Transformation::VIEW_WIDTH, Transformation::VIEW_WIDTH, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, TransformationInner::INIT_VIEW_WIDTH_VAL, ParamFlags::READWRITE, ), @@ -158,8 +158,8 @@ impl ObjectImpl for TransformationInner { Transformation::CONTENT_WIDTH, Transformation::CONTENT_WIDTH, Transformation::CONTENT_WIDTH, - std::f64::MIN, - std::f64::MAX, + f64::MIN, + f64::MAX, 0.0, ParamFlags::READWRITE, ), @@ -270,16 +270,16 @@ impl std::ops::Deref for Transformation { } impl Transformation { - pub const CENTERED: &str = "centered"; - pub const FIT_VIEW: &str = "fit-view"; - pub const VIEW_HEIGHT: &str = super::Canvas::VIEW_HEIGHT; - pub const VIEW_WIDTH: &str = super::Canvas::VIEW_WIDTH; - pub const CONTENT_WIDTH: &str = super::Canvas::CONTENT_WIDTH; - pub const SCALE: &str = "scale"; - pub const CAMERA_X: &str = "camera-x"; - pub const CAMERA_Y: &str = "camera-y"; - pub const PIXELS_PER_UNIT: &str = "pixels-per-unit"; - pub const UNITS_PER_EM: &str = FontInfo::UNITS_PER_EM; + pub const CENTERED: &'static str = "centered"; + pub const FIT_VIEW: &'static str = "fit-view"; + pub const VIEW_HEIGHT: &'static str = super::Canvas::VIEW_HEIGHT; + pub const VIEW_WIDTH: &'static str = super::Canvas::VIEW_WIDTH; + pub const CONTENT_WIDTH: &'static str = super::Canvas::CONTENT_WIDTH; + pub const SCALE: &'static str = "scale"; + pub const CAMERA_X: &'static str = "camera-x"; + pub const CAMERA_Y: &'static str = "camera-y"; + pub const PIXELS_PER_UNIT: &'static str = "pixels-per-unit"; + pub const UNITS_PER_EM: &'static str = FontInfo::UNITS_PER_EM; pub fn new() -> Self { let ret: Self = glib::Object::new(&[]).expect("Failed to create Transformation"); diff --git a/src/views/collection.rs b/src/views/collection.rs index 032fcb0..83b4b65 100644 --- a/src/views/collection.rs +++ b/src/views/collection.rs @@ -518,7 +518,7 @@ impl ObjectImpl for CollectionInner { Collection::ZOOM_FACTOR, Collection::ZOOM_FACTOR, 0.0, - std::f64::MAX, + f64::MAX, 1.0, ParamFlags::READWRITE, ), @@ -588,10 +588,10 @@ glib::wrapper! { } impl Collection { - pub const TITLE: &str = Workspace::TITLE; - pub const CLOSEABLE: &str = Workspace::CLOSEABLE; - pub const ZOOM_FACTOR: &str = "zoom-factor"; - pub const NEW_GLYPH: &str = "new-glyph"; + pub const TITLE: &'static str = Workspace::TITLE; + pub const CLOSEABLE: &'static str = Workspace::CLOSEABLE; + pub const ZOOM_FACTOR: &'static str = "zoom-factor"; + pub const NEW_GLYPH: &'static str = "new-glyph"; pub fn new(app: Application, project: Project) -> Self { let ret: Self = glib::Object::new(&[]).expect("Failed to create Main Window"); @@ -1015,7 +1015,7 @@ impl ObjectImpl for GlyphBoxInner { GlyphBox::ZOOM_FACTOR, GlyphBox::ZOOM_FACTOR, 0.0, - std::f64::MAX, + f64::MAX, 1.0, ParamFlags::READWRITE, ), @@ -1078,11 +1078,11 @@ impl BinImpl for GlyphBoxInner {} impl EventBoxImpl for GlyphBoxInner {} impl GlyphBox { - pub const SHOW_DETAILS: &str = "show-details"; - pub const ZOOM_FACTOR: &str = Collection::ZOOM_FACTOR; - pub const FOCUSED: &str = "focused"; - pub const MODIFIED: &str = GlyphMetadata::MODIFIED; - pub const MARK_COLOR: &str = GlyphMetadata::MARK_COLOR; + pub const SHOW_DETAILS: &'static str = "show-details"; + pub const ZOOM_FACTOR: &'static str = Collection::ZOOM_FACTOR; + pub const FOCUSED: &'static str = "focused"; + pub const MODIFIED: &'static str = GlyphMetadata::MODIFIED; + pub const MARK_COLOR: &'static str = GlyphMetadata::MARK_COLOR; fn emit_open_glyph_edit(&self) { self.imp() diff --git a/src/views/overlay/child.rs b/src/views/overlay/child.rs index 26e709a..13a2d8a 100644 --- a/src/views/overlay/child.rs +++ b/src/views/overlay/child.rs @@ -146,10 +146,10 @@ glib::wrapper! { } impl Child { - pub const WIDGET: &str = "widget"; - pub const MOVABLE: &str = "movable"; - pub const EXPANDABLE: &str = "expandable"; - pub const EXPANDED: &str = "expanded"; + pub const WIDGET: &'static str = "widget"; + pub const MOVABLE: &'static str = "movable"; + pub const EXPANDABLE: &'static str = "expandable"; + pub const EXPANDED: &'static str = "expanded"; pub fn new>(child: P) -> Self { Self::new_inner(child.upcast()) diff --git a/src/window/workspace.rs b/src/window/workspace.rs index 2193b69..4313f64 100644 --- a/src/window/workspace.rs +++ b/src/window/workspace.rs @@ -195,13 +195,13 @@ glib::wrapper! { } impl Workspace { - pub const REORDERABLE: &str = "reorderable"; - pub const CLOSEABLE: &str = "closeable"; - pub const TITLE: &str = "title"; - pub const IS_MENU_VISIBLE: &str = "is-menu-visible"; - pub const MENUBAR: &str = "menubar"; - pub const CHILD: &str = "child"; - pub const MENUMODEL: &str = "menu-model"; + pub const REORDERABLE: &'static str = "reorderable"; + pub const CLOSEABLE: &'static str = "closeable"; + pub const TITLE: &'static str = "title"; + pub const IS_MENU_VISIBLE: &'static str = "is-menu-visible"; + pub const MENUBAR: &'static str = "menubar"; + pub const CHILD: &'static str = "child"; + pub const MENUMODEL: &'static str = "menu-model"; pub fn new(child: >k::Widget) -> Self { let ret: Self = glib::Object::new(&[]).expect("Failed to create Workspace");