summaryrefslogtreecommitdiffstats
path: root/ozone-ui/src
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2025-01-29 03:27:31 -0600
committerLibravatar bigfoot547 <[email protected]>2025-01-29 03:27:31 -0600
commit00675738a4012580c6db10d9e1115732559bdaf3 (patch)
treeb07774fe20140f48f3c27241051cf4ddd61a2577 /ozone-ui/src
parentwip: auth (diff)
do device code auth
Diffstat (limited to 'ozone-ui/src')
-rw-r--r--ozone-ui/src/main.rs47
1 files changed, 40 insertions, 7 deletions
diff --git a/ozone-ui/src/main.rs b/ozone-ui/src/main.rs
index 0d578a1..43a9c42 100644
--- a/ozone-ui/src/main.rs
+++ b/ozone-ui/src/main.rs
@@ -1,8 +1,13 @@
use std::borrow::Cow;
+use std::error::Error;
use reqwest::Url;
use slint::run_event_loop;
+use winit::application::ApplicationHandler;
+use winit::event::WindowEvent;
+use winit::event_loop::{ActiveEventLoop, ControlFlow, EventLoop};
+use winit::window::{Window, WindowAttributes, WindowId};
use wry::http::{Response, StatusCode};
-use wry::{WebViewBuilder, WebViewBuilderExtWindows};
+use wry::WebViewBuilder;
slint::slint! {
export component HelloWorld inherits Window {
@@ -10,12 +15,39 @@ slint::slint! {
}
}
-fn main() {
+struct Application {
+ window: Option<Window>
+}
+
+impl ApplicationHandler for Application {
+ fn resumed(&mut self, event_loop: &ActiveEventLoop) {
+ let win = event_loop.create_window(WindowAttributes::default()).unwrap();
+
+
+ win.set_visible(true);
+ self.window = Some(win);
+ }
+
+ fn window_event(&mut self, event_loop: &ActiveEventLoop, window_id: WindowId, event: WindowEvent) {
+ match event {
+ WindowEvent::CloseRequested => {
+ event_loop.exit();
+ }
+ WindowEvent::RedrawRequested => {
+ if let Some(ref window) = self.window {
+ window.request_redraw();
+ }
+ }
+ _ => { }
+ }
+ }
+}
+
+fn main() -> Result<(), Box<dyn Error>> {
simple_logger::SimpleLogger::new().env().init().unwrap();
+ gtk::init()?;
let hw = HelloWorld::new().unwrap();
- hw.show().unwrap();
-
let wv = WebViewBuilder::new()
.with_url("https://login.live.com/oauth20_authorize.srf?client_id=00000000402b5328&redirect_uri=ms-xal-00000000402b5328://auth&response_type=token&display=touch&scope=service::user.auth.xboxlive.com::MBI_SSL%20offline_access&prompt=select_account")
.with_navigation_handler(|url| {
@@ -35,7 +67,8 @@ fn main() {
}
true
- }).build(&hw.window().window_handle()).unwrap();
-
- run_event_loop().unwrap();
+ }).build_as_child(&hw.window().window_handle()).unwrap();
+ wv.set_visible(true).unwrap();
+ hw.run().unwrap();
+ Ok(())
}