From 6f9863d0e7b187a21903c6761b7ee5d978a54d67 Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 18 Sep 2024 20:33:29 +0300 Subject: [PATCH] init browser modules --- Cargo.toml | 2 +- src/app/browser.rs | 15 +++++++++++++++ src/app/browser/header.rs | 7 +++++++ src/app/browser/main.rs | 9 +++++++++ src/main.rs | 21 +++++++++------------ 5 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 src/app/browser.rs create mode 100644 src/app/browser/header.rs create mode 100644 src/app/browser/main.rs diff --git a/Cargo.toml b/Cargo.toml index a10edbf0..fbcf4c24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,4 +4,4 @@ version = "0.1.0" edition = "2021" [dependencies] -gtk4 = "0.9.1" +gtk4 = { version = "0.9.1", features = ["v4_6"] } diff --git a/src/app/browser.rs b/src/app/browser.rs new file mode 100644 index 00000000..f0e538ee --- /dev/null +++ b/src/app/browser.rs @@ -0,0 +1,15 @@ +#[path = "browser/header.rs"] mod header; +#[path = "browser/main.rs"] mod main; + +use gtk4 as gtk; +use gtk::{Application, ApplicationWindow}; + +pub fn new(app: &Application) -> ApplicationWindow +{ + return ApplicationWindow::builder().application(app) + .default_width(640) + .default_height(480) + //.titlebar(&header::new()) + .child(&main::new()) + .build(); +} \ No newline at end of file diff --git a/src/app/browser/header.rs b/src/app/browser/header.rs new file mode 100644 index 00000000..22d74342 --- /dev/null +++ b/src/app/browser/header.rs @@ -0,0 +1,7 @@ +use gtk4 as gtk; +use gtk::HeaderBar; + +pub fn new() -> HeaderBar +{ + return HeaderBar::builder().build(); +} \ No newline at end of file diff --git a/src/app/browser/main.rs b/src/app/browser/main.rs new file mode 100644 index 00000000..c62a9ad1 --- /dev/null +++ b/src/app/browser/main.rs @@ -0,0 +1,9 @@ +use gtk4 as gtk; +use gtk::Box; + +pub fn new() -> Box +{ + return Box::builder().orientation( + gtk::Orientation::Vertical + ).build(); +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 87fce67f..52698245 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,24 +1,21 @@ +#[path = "app/browser.rs"] mod browser; + use gtk4 as gtk; use gtk::prelude::*; -use gtk::{glib, Application, ApplicationWindow}; +use gtk::{glib, Application}; fn main() -> glib::ExitCode { - let app = Application::builder() - .application_id("io.github.yggverse.Yoda.app") - .build(); + let app = Application::builder().application_id( + "io.github.yggverse.Yoda.app" + ).build(); app.connect_activate( |app| { - let window = ApplicationWindow::builder() - .application(app) - .default_width(640) - .default_height(480) - .title("Yoda") - .build(); - - window.present(); + browser::new( + app + ).present(); } );