From 0759f1484303ab65a7095c0204c54b899242066c Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 19 Sep 2024 10:37:16 +0300 Subject: [PATCH] init navbar components --- src/app/browser/main/tab/page.rs | 17 ++++++- src/app/browser/main/tab/page/content.rs | 9 ++++ src/app/browser/main/tab/page/navigation.rs | 50 +++++++++++++++++++ .../browser/main/tab/page/navigation/base.rs | 22 ++++++++ .../main/tab/page/navigation/bookmark.rs | 22 ++++++++ .../main/tab/page/navigation/history.rs | 34 +++++++++++++ .../main/tab/page/navigation/history/back.rs | 22 ++++++++ .../tab/page/navigation/history/forward.rs | 22 ++++++++ .../main/tab/page/navigation/reload.rs | 22 ++++++++ .../main/tab/page/navigation/request.rs | 22 ++++++++ 10 files changed, 240 insertions(+), 2 deletions(-) create mode 100644 src/app/browser/main/tab/page/content.rs create mode 100644 src/app/browser/main/tab/page/navigation.rs create mode 100644 src/app/browser/main/tab/page/navigation/base.rs create mode 100644 src/app/browser/main/tab/page/navigation/bookmark.rs create mode 100644 src/app/browser/main/tab/page/navigation/history.rs create mode 100644 src/app/browser/main/tab/page/navigation/history/back.rs create mode 100644 src/app/browser/main/tab/page/navigation/history/forward.rs create mode 100644 src/app/browser/main/tab/page/navigation/reload.rs create mode 100644 src/app/browser/main/tab/page/navigation/request.rs diff --git a/src/app/browser/main/tab/page.rs b/src/app/browser/main/tab/page.rs index 306b3750..3c4ab363 100644 --- a/src/app/browser/main/tab/page.rs +++ b/src/app/browser/main/tab/page.rs @@ -1,9 +1,22 @@ +#[path = "page/navigation.rs"] mod navigation; +#[path = "page/content.rs"] mod content; + use gtk::Box; -// use gtk::prelude::BoxExt; @TODO append +use gtk::prelude::BoxExt; pub fn new() -> Box { - return Box::builder().orientation( + let page = Box::builder().orientation( gtk::Orientation::Vertical ).build(); + + page.append( + &navigation::new() + ); + + page.append( + &content::new() + ); + + return page; } \ No newline at end of file diff --git a/src/app/browser/main/tab/page/content.rs b/src/app/browser/main/tab/page/content.rs new file mode 100644 index 00000000..306b3750 --- /dev/null +++ b/src/app/browser/main/tab/page/content.rs @@ -0,0 +1,9 @@ +use gtk::Box; +// use gtk::prelude::BoxExt; @TODO append + +pub fn new() -> Box +{ + return Box::builder().orientation( + gtk::Orientation::Vertical + ).build(); +} \ No newline at end of file diff --git a/src/app/browser/main/tab/page/navigation.rs b/src/app/browser/main/tab/page/navigation.rs new file mode 100644 index 00000000..d27a8071 --- /dev/null +++ b/src/app/browser/main/tab/page/navigation.rs @@ -0,0 +1,50 @@ +#[path = "navigation/base.rs"] mod base; +#[path = "navigation/history.rs"] mod history; +#[path = "navigation/reload.rs"] mod reload; +#[path = "navigation/request.rs"] mod request; +#[path = "navigation/bookmark.rs"] mod bookmark; + +use gtk::Box; +use gtk::prelude::BoxExt; + +pub fn new() -> Box +{ + let navigation = Box::builder() + + // Tuneup + .orientation( + gtk::Orientation::Horizontal + ) + + .spacing(8) + + .margin_top(8) + .margin_start(8) + .margin_end(8) + .margin_bottom(8) + + .build(); + + // Compose childs + navigation.append( + &base::new() + ); + + navigation.append( + &history::new() + ); + + navigation.append( + &reload::new() + ); + + navigation.append( + &request::new() + ); + + navigation.append( + &bookmark::new() + ); + + return navigation; +} \ No newline at end of file diff --git a/src/app/browser/main/tab/page/navigation/base.rs b/src/app/browser/main/tab/page/navigation/base.rs new file mode 100644 index 00000000..dcf9099f --- /dev/null +++ b/src/app/browser/main/tab/page/navigation/base.rs @@ -0,0 +1,22 @@ +use gtk::Button; + +pub fn new() -> Button +{ + let button = Button::builder() + + .icon_name( + "go-home-symbolic" + ) + + .tooltip_text( + "Base" + ) + + .sensitive( + false + ) + + .build(); + + return button; +} \ No newline at end of file diff --git a/src/app/browser/main/tab/page/navigation/bookmark.rs b/src/app/browser/main/tab/page/navigation/bookmark.rs new file mode 100644 index 00000000..0704adeb --- /dev/null +++ b/src/app/browser/main/tab/page/navigation/bookmark.rs @@ -0,0 +1,22 @@ +use gtk::Button; + +pub fn new() -> Button +{ + let button = Button::builder() + + .icon_name( + "starred-symbolic" + ) + + .tooltip_text( + "Toggle bookmark" + ) + + .sensitive( + false + ) + + .build(); + + return button; +} \ No newline at end of file diff --git a/src/app/browser/main/tab/page/navigation/history.rs b/src/app/browser/main/tab/page/navigation/history.rs new file mode 100644 index 00000000..6835921a --- /dev/null +++ b/src/app/browser/main/tab/page/navigation/history.rs @@ -0,0 +1,34 @@ +#[path = "history/back.rs"] mod back; +#[path = "history/forward.rs"] mod forward; + +use gtk::Box; +use gtk::prelude::BoxExt; + +pub fn new() -> Box +{ + let history = Box::builder() + + // Tuneup + .orientation( + gtk::Orientation::Horizontal + ) + + .css_classes( + [ + "linked" // merge childs + ] + ) + + .build(); + + // Compose childs + history.append( + &back::new() + ); + + history.append( + &forward::new() + ); + + return history; +} \ No newline at end of file diff --git a/src/app/browser/main/tab/page/navigation/history/back.rs b/src/app/browser/main/tab/page/navigation/history/back.rs new file mode 100644 index 00000000..b63494d9 --- /dev/null +++ b/src/app/browser/main/tab/page/navigation/history/back.rs @@ -0,0 +1,22 @@ +use gtk::Button; + +pub fn new() -> Button +{ + let button = Button::builder() + + .icon_name( + "go-previous-symbolic" + ) + + .tooltip_text( + "Back" + ) + + .sensitive( + false + ) + + .build(); + + return button; +} \ No newline at end of file diff --git a/src/app/browser/main/tab/page/navigation/history/forward.rs b/src/app/browser/main/tab/page/navigation/history/forward.rs new file mode 100644 index 00000000..95c58ede --- /dev/null +++ b/src/app/browser/main/tab/page/navigation/history/forward.rs @@ -0,0 +1,22 @@ +use gtk::Button; + +pub fn new() -> Button +{ + let button = Button::builder() + + .icon_name( + "go-next-symbolic" + ) + + .tooltip_text( + "Forward" + ) + + .sensitive( + false + ) + + .build(); + + return button; +} \ No newline at end of file diff --git a/src/app/browser/main/tab/page/navigation/reload.rs b/src/app/browser/main/tab/page/navigation/reload.rs new file mode 100644 index 00000000..5f4e3c4a --- /dev/null +++ b/src/app/browser/main/tab/page/navigation/reload.rs @@ -0,0 +1,22 @@ +use gtk::Button; + +pub fn new() -> Button +{ + let button = Button::builder() + + .icon_name( + "view-refresh-symbolic" + ) + + .tooltip_text( + "Reload" + ) + + .sensitive( + false + ) + + .build(); + + return button; +} \ No newline at end of file diff --git a/src/app/browser/main/tab/page/navigation/request.rs b/src/app/browser/main/tab/page/navigation/request.rs new file mode 100644 index 00000000..7b17ba90 --- /dev/null +++ b/src/app/browser/main/tab/page/navigation/request.rs @@ -0,0 +1,22 @@ +use gtk::Entry; + +pub fn new() -> Entry +{ + let entry = Entry::builder() + + .placeholder_text( + "URL or search term..." + ) + + .hexpand( + true + ) + + .progress_pulse_step( + 0.1 + ) + + .build(); + + return entry; +} \ No newline at end of file