From 3f5b4f9dfa27f3db9f28f5e178e6fc2272fb228d Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 30 Sep 2024 17:53:08 +0300 Subject: [PATCH] activate history buttons --- .../main/tab/page/navigation/history/back.rs | 31 +++++++++++++++---- .../tab/page/navigation/history/forward.rs | 30 ++++++++++++++---- 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/src/browser/main/tab/page/navigation/history/back.rs b/src/browser/main/tab/page/navigation/history/back.rs index 7be81d18..aeb6d426 100644 --- a/src/browser/main/tab/page/navigation/history/back.rs +++ b/src/browser/main/tab/page/navigation/history/back.rs @@ -1,19 +1,38 @@ -use gtk::{gio::SimpleAction, Button}; +use gtk::{ + gio::SimpleAction, + prelude::{ActionExt, ButtonExt}, + Button, +}; use std::sync::Arc; pub struct Back { + action_tab_page_navigation_history_back: Arc, widget: Button, } impl Back { // Construct pub fn new(action_tab_page_navigation_history_back: Arc) -> Self { + // Init widget + let widget = Button::builder() + .icon_name("go-previous-symbolic") + .tooltip_text("Back") + .sensitive(false) + .build(); + + // Init events + widget.connect_clicked({ + let action_tab_page_navigation_history_back = + action_tab_page_navigation_history_back.clone(); + move |_| { + action_tab_page_navigation_history_back.activate(None); + } + }); + + // Return activated struct Self { - widget: Button::builder() - .icon_name("go-previous-symbolic") - .tooltip_text("Back") - .sensitive(false) - .build(), + action_tab_page_navigation_history_back, + widget, } } diff --git a/src/browser/main/tab/page/navigation/history/forward.rs b/src/browser/main/tab/page/navigation/history/forward.rs index ce156ef9..65c212f8 100644 --- a/src/browser/main/tab/page/navigation/history/forward.rs +++ b/src/browser/main/tab/page/navigation/history/forward.rs @@ -1,19 +1,37 @@ -use gtk::{gio::SimpleAction, Button}; +use gtk::{ + prelude::{ActionExt, ButtonExt}, + {gio::SimpleAction, Button}, +}; use std::sync::Arc; pub struct Forward { + action_tab_page_navigation_history_forward: Arc, widget: Button, } impl Forward { // Construct pub fn new(action_tab_page_navigation_history_forward: Arc) -> Self { + // Init widget + let widget = Button::builder() + .icon_name("go-next-symbolic") + .tooltip_text("Forward") + .sensitive(false) + .build(); + + // Init events + widget.connect_clicked({ + let action_tab_page_navigation_history_forward = + action_tab_page_navigation_history_forward.clone(); + move |_| { + action_tab_page_navigation_history_forward.activate(None); + } + }); + + // Return activated struct Self { - widget: Button::builder() - .icon_name("go-next-symbolic") - .tooltip_text("Forward") - .sensitive(false) - .build(), + action_tab_page_navigation_history_forward, + widget, } }