From dd194d99426b59344290355580aeebbd4da90e57 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 12 May 2020 18:04:48 +0200 Subject: Add basic code for web-view GUI implementation Signed-off-by: Matthias Beyer --- Cargo.toml | 2 ++ assets/index.html | 5 +++++ src/main.rs | 19 ++++++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 assets/index.html diff --git a/Cargo.toml b/Cargo.toml index 617263a..2186eca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,3 +37,5 @@ tokio = { version = "0.2", features = ["full"] } add_getters_setters = "1.1" xdg = "2" structopt = "0.3" +web-view = "0.6" +handlebars = "3" diff --git a/assets/index.html b/assets/index.html new file mode 100644 index 0000000..7e38f36 --- /dev/null +++ b/assets/index.html @@ -0,0 +1,5 @@ + + +

HelloWorld

+ + diff --git a/src/main.rs b/src/main.rs index 6ec2e89..8de1e6a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,8 @@ extern crate hyper; extern crate env_logger; extern crate itertools; extern crate xdg; +extern crate handlebars; +extern crate web_view; #[macro_use] extern crate failure; #[macro_use] extern crate is_match; @@ -43,6 +45,7 @@ use futures::future::TryFutureExt; use serde_json::to_string_pretty as serde_json_to_string_pretty; use serde_json::from_str as serde_json_from_str; use failure::Fallible as Result; +use failure::Error; use failure::err_msg; use crate::app::App; @@ -97,8 +100,18 @@ async fn main() -> Result<()> { } }.await?; - drop(config); - - Ok(()) + let html_content = include_str!("../assets/index.html"); + + web_view::builder() + .title("My Project") + .content(web_view::Content::Html(html_content)) + .resizable(true) + .debug(true) + .user_data(()) + .invoke_handler(|_webview, _arg| Ok(())) + .build() + .map_err(Error::from)? + .run() + .map_err(Error::from) } -- cgit v1.2.3