summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-12-02 19:57:16 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-12-08 18:43:34 +0100
commit36dc8675f5757c81d3b78da19d6f7bb4f34a555c (patch)
tree5bd5a417fce1ab40198f72663ffb6ecaec8047a0 /src
parent969de98ddad7311fbcd74f93910444af8fdb7882 (diff)
Implement hello-world gui with iced
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r--src/cli.rs7
-rw-r--r--src/gui/mod.rs32
-rw-r--r--src/main.rs17
3 files changed, 50 insertions, 6 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 8e912e0..3f74128 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -9,7 +9,6 @@ pub fn app<'a>() -> App<'a> {
.version(crate_version!())
.about("Distributed social network")
-
.subcommand(App::new("profile")
.author(crate_authors!())
.version(crate_version!())
@@ -51,4 +50,10 @@ pub fn app<'a>() -> App<'a> {
)
)
)
+
+ .subcommand(App::new("gui")
+ .author(crate_authors!())
+ .version(crate_version!())
+ .about("Start the distrox gui")
+ )
}
diff --git a/src/gui/mod.rs b/src/gui/mod.rs
new file mode 100644
index 0000000..a7cc4ff
--- /dev/null
+++ b/src/gui/mod.rs
@@ -0,0 +1,32 @@
+use anyhow::Result;
+use iced::Application;
+
+#[derive(Debug)]
+struct DistroxGui;
+
+impl Application for DistroxGui {
+ type Executor = iced::executor::Default; // tokio
+ type Message = ();
+ type Flags = ();
+
+ fn new(_flags: ()) -> (Self, iced::Command<Self::Message>) {
+ (DistroxGui, iced::Command::none())
+ }
+
+ fn title(&self) -> String {
+ String::from("distrox")
+ }
+
+ fn update(&mut self, _message: Self::Message, _clipboard: &mut iced::Clipboard) -> iced::Command<Self::Message> {
+ iced::Command::none()
+ }
+
+ fn view(&mut self) -> iced::Element<Self::Message> {
+ iced::Text::new("Hello, world!").into()
+ }
+
+}
+
+pub fn run() -> Result<()> {
+ DistroxGui::run(iced::Settings::default()).map_err(anyhow::Error::from)
+}
diff --git a/src/main.rs b/src/main.rs
index 257847c..3caf1ae 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,17 +8,24 @@ pub mod consts;
pub mod ipfs_client;
pub mod profile;
pub mod types;
+mod gui;
-#[tokio::main]
-async fn main() -> Result<()> {
+fn main() -> Result<()> {
let _ = env_logger::try_init()?;
let matches = crate::cli::app().get_matches();
match matches.subcommand() {
Some(("profile", matches)) => crate::commands::profile(matches).await,
- _ => unimplemented!()
- }
-
+ Some(("gui", _)) => crate::gui::run(),
+ Some((other, _)) => {
+ log::error!("No subcommand {} implemented", other);
+ Ok(())
+ },
+ _ => {
+ log::error!("Don't know what to do");
+ Ok(())
+ },
+ }
}