summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-05-12 18:04:48 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-05-12 18:07:04 +0200
commitdd194d99426b59344290355580aeebbd4da90e57 (patch)
tree182a648a97a65bcc32b35c851f5c48ae8e166a2d
parentf475a18746c337440d59592af484e857237f9064 (diff)
Add basic code for web-view GUI implementation
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--Cargo.toml2
-rw-r--r--assets/index.html5
-rw-r--r--src/main.rs19
3 files changed, 23 insertions, 3 deletions
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 @@
+<html>
+ <body>
+ <h1>HelloWorld</h1>
+ </body>
+</html>
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)
}