enshort action namespace

This commit is contained in:
yggverse 2024-11-14 14:33:29 +02:00
parent 03d97da6c7
commit ec95ae2580
7 changed files with 24 additions and 30 deletions

View File

@ -1,6 +1,6 @@
use gtk::{prelude::ButtonExt, Button};
use crate::app::browser::window::action::Action as WindowAction;
use crate::app::browser::window::Action;
use std::rc::Rc;
const ICON_YES: &str = "starred-symbolic";
@ -13,7 +13,7 @@ pub struct Widget {
impl Widget {
// Constructors
pub fn new(action: Rc<WindowAction>) -> Self {
pub fn new(action: Rc<Action>) -> Self {
// Init gobject
let gobject = Button::builder()
.icon_name(ICON_NON)

View File

@ -2,21 +2,21 @@ mod widget;
use widget::Widget;
use crate::app::browser::window::action::Action as WindowAction;
use crate::app::browser::window::Action;
use std::rc::Rc;
pub struct Back {
window_action: Rc<WindowAction>,
action: Rc<Action>,
widget: Rc<Widget>,
}
impl Back {
// Constructors
pub fn new(window_action: Rc<WindowAction>) -> Self {
pub fn new(action: Rc<Action>) -> Self {
Self {
window_action: window_action.clone(),
widget: Rc::new(Widget::new(window_action)),
action: action.clone(),
widget: Rc::new(Widget::new(action)),
}
}
@ -24,10 +24,7 @@ impl Back {
pub fn update(&self, status: bool) {
// Update actions
self.window_action
.history_back()
.gobject()
.set_enabled(status);
self.action.history_back().gobject().set_enabled(status);
// Update child components
self.widget.update(status);

View File

@ -1,4 +1,4 @@
use crate::app::browser::window::action::Action as WindowAction;
use crate::app::browser::window::Action;
use gtk::{
prelude::{ButtonExt, WidgetExt},
Button,
@ -11,7 +11,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new(window_action: Rc<WindowAction>) -> Self {
pub fn new(action: Rc<Action>) -> Self {
// Init gobject
let gobject = Button::builder()
.icon_name("go-previous-symbolic")
@ -20,7 +20,7 @@ impl Widget {
.build();
// Init events
gobject.connect_clicked(move |_| window_action.history_back().activate());
gobject.connect_clicked(move |_| action.history_back().activate());
// Return activated `Self`
Self { gobject }

View File

@ -2,30 +2,27 @@ mod widget;
use widget::Widget;
use crate::app::browser::window::action::Action as WindowAction;
use crate::app::browser::window::Action;
use std::rc::Rc;
pub struct Forward {
window_action: Rc<WindowAction>,
action: Rc<Action>,
widget: Rc<Widget>,
}
impl Forward {
// Construct
pub fn new(window_action: Rc<WindowAction>) -> Self {
pub fn new(action: Rc<Action>) -> Self {
Self {
window_action: window_action.clone(),
widget: Rc::new(Widget::new(window_action)),
action: action.clone(),
widget: Rc::new(Widget::new(action)),
}
}
// Actions
pub fn update(&self, status: bool) {
// Update actions
self.window_action
.history_forward()
.gobject()
.set_enabled(status);
self.action.history_forward().gobject().set_enabled(status);
// Update child components
self.widget.update(status);

View File

@ -1,4 +1,4 @@
use crate::app::browser::window::action::Action as WindowAction;
use crate::app::browser::window::Action;
use gtk::{
prelude::{ButtonExt, WidgetExt},
Button,
@ -11,7 +11,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new(window_action: Rc<WindowAction>) -> Self {
pub fn new(action: Rc<Action>) -> Self {
// Init gobject
let gobject = Button::builder()
.icon_name("go-next-symbolic")
@ -20,7 +20,7 @@ impl Widget {
.build();
// Init events
gobject.connect_clicked(move |_| window_action.history_forward().activate());
gobject.connect_clicked(move |_| action.history_forward().activate());
// Return activated `Self`
Self { gobject }

View File

@ -1,4 +1,4 @@
use crate::app::browser::window::action::Action as WindowAction;
use crate::app::browser::window::Action;
use gtk::{
prelude::{ButtonExt, WidgetExt},
Button,
@ -11,7 +11,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new(action: Rc<WindowAction>) -> Self {
pub fn new(action: Rc<Action>) -> Self {
// Init gobject
let gobject = Button::builder()
.icon_name("go-home-symbolic")

View File

@ -1,4 +1,4 @@
use crate::app::browser::window::action::Action as WindowAction;
use crate::app::browser::window::Action;
use gtk::{
prelude::{ButtonExt, WidgetExt},
Button,
@ -11,7 +11,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new(action: Rc<WindowAction>) -> Self {
pub fn new(action: Rc<Action>) -> Self {
// Init gobject
let gobject = Button::builder()
.icon_name("view-refresh-symbolic")