From 9342bd0e57126909776b95b0761ad5bef3b416f6 Mon Sep 17 00:00:00 2001 From: pml68 Date: Sun, 16 Feb 2025 13:49:34 +0100 Subject: refactor: random stuff --- Cargo.toml | 5 +++-- src/error.rs | 6 ++++++ src/main.rs | 10 +++++----- src/types/project.rs | 36 ++++++++++++++++++------------------ 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 54e5ed4..41478af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,13 @@ [package] name = "iced_builder" -description = "GUI builder for iced, built with iced." +description = "UI builder for iced, built with iced." version = "0.1.0" edition = "2021" authors = ["pml68 "] repository = "https://github.com/pml68/iced-builder" license = "GPL-3.0-or-later" -keywords = ["gui", "iced"] +categories = ["gui"] +keywords = ["gui", "ui", "graphics", "interface", "widgets"] [dependencies] iced = { version = "0.13.1", features = [ "image","svg","advanced","tokio"] } diff --git a/src/error.rs b/src/error.rs index f4011bd..09e6e86 100644 --- a/src/error.rs +++ b/src/error.rs @@ -53,3 +53,9 @@ impl From for Error { Self::Other(value) } } + +impl From for String { + fn from(value: Error) -> Self { + value.to_string() + } +} diff --git a/src/main.rs b/src/main.rs index 6301682..5f25a28 100644 --- a/src/main.rs +++ b/src/main.rs @@ -164,7 +164,7 @@ impl App { self.editor_content = text_editor::Content::with_text(&code); } - Err(error) => error_dialog(error.to_string()), + Err(error) => error_dialog(error), } } Message::DropNewElement(name, point, _) => { @@ -188,7 +188,7 @@ impl App { Ok(Some(ref element)) => { self.project.element_tree = Some(element.clone()); } - Err(error) => error_dialog(error.to_string()), + Err(error) => error_dialog(error), _ => {} } @@ -218,7 +218,7 @@ impl App { action, ); if let Err(error) = result { - error_dialog(error.to_string()); + error_dialog(error); } self.is_dirty = true; @@ -278,7 +278,7 @@ impl App { self.project_path = Some(path); return Task::done(Message::RefreshEditorContent); } - Err(error) => error_dialog(error.to_string()), + Err(error) => error_dialog(error), } } Message::SaveFile => { @@ -311,7 +311,7 @@ impl App { self.project_path = Some(path); self.is_dirty = false; } - Err(error) => error_dialog(error.to_string()), + Err(error) => error_dialog(error), } } } diff --git a/src/types/project.rs b/src/types/project.rs index 27c576b..18247ae 100644 --- a/src/types/project.rs +++ b/src/types/project.rs @@ -122,30 +122,30 @@ impl Project { let app_code = format!( r#"// Automatically generated by iced Builder - use iced::{{widget::{{{imports}}},Element}}; - {theme_imports} +use iced::{{widget::{{{imports}}},Element}}; +{theme_imports} - fn main() -> iced::Result {{ - iced::application("{}", State::update, State::view).theme(State::theme).run() - }} +fn main() -> iced::Result {{ + iced::application("{}", State::update, State::view).theme(State::theme).run() +}} - #[derive(Default)] - struct State; +#[derive(Default)] +struct State; - #[derive(Debug, Clone)] - enum Message {{}} +#[derive(Debug, Clone)] +enum Message {{}} - impl State {{ - fn update(&mut self, _message: Message) {{}} +impl State {{ + fn update(&mut self, _message: Message) {{}} - fn theme(&self) -> iced::Theme {{ - iced::Theme::{} - }} + fn theme(&self) -> iced::Theme {{ + iced::Theme::{} + }} - fn view(&self) -> Element {{ - {view}.into() - }} - }}"#, + fn view(&self) -> Element {{ + {view}.into() + }} +}}"#, match self.title { Some(ref t) => t, None => "New app", -- cgit v1.2.3