diff options
| author | pml68 <contact@pml68.dev> | 2025-02-16 13:49:34 +0100 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-02-16 13:49:34 +0100 |
| commit | 9342bd0e57126909776b95b0761ad5bef3b416f6 (patch) | |
| tree | 2fba1bfc5ff691c0c601a4caa28468bfa558359c | |
| parent | chore: update dependencies (diff) | |
| download | iced-builder-9342bd0e57126909776b95b0761ad5bef3b416f6.tar.gz | |
refactor: random stuff
Diffstat (limited to '')
| -rw-r--r-- | Cargo.toml | 5 | ||||
| -rw-r--r-- | src/error.rs | 6 | ||||
| -rw-r--r-- | src/main.rs | 10 | ||||
| -rw-r--r-- | src/types/project.rs | 36 |
4 files changed, 32 insertions, 25 deletions
@@ -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 <contact@pml68.dev>"] 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<String> for Error { Self::Other(value) } } + +impl From<Error> 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<Message> {{ - {view}.into() - }} - }}"#, + fn view(&self) -> Element<Message> {{ + {view}.into() + }} +}}"#, match self.title { Some(ref t) => t, None => "New app", |
