remove extra levels

This commit is contained in:
yggverse 2025-01-23 15:03:30 +02:00
parent bd766a2154
commit 176d24da4f
5 changed files with 43 additions and 95 deletions

View File

@ -36,7 +36,7 @@ impl History {
let forward = Rc::new(Forward::build(action));
// Init widget
let widget = Rc::new(Widget::build(&back.widget.button, &forward.widget.button));
let widget = Rc::new(Widget::build(&back.button, &forward.button));
// Init memory
let memory = RefCell::new(Vec::new());

View File

@ -1,13 +1,13 @@
mod widget;
use widget::Widget;
use super::WindowAction;
use gtk::{
prelude::{ButtonExt, WidgetExt},
Button,
};
use std::rc::Rc;
pub struct Back {
action: Rc<WindowAction>,
pub widget: Rc<Widget>,
pub button: Button,
}
impl Back {
@ -15,19 +15,30 @@ impl Back {
/// Build new `Self`
pub fn build(action: &Rc<WindowAction>) -> Self {
// Init gobject
let button = Button::builder()
.icon_name("go-previous-symbolic")
.tooltip_text("Back")
.sensitive(false)
.build();
// Init events
button.connect_clicked({
let action = action.clone();
move |_| action.history_back.activate()
});
// Return activated `Self`
Self {
action: action.clone(),
widget: Rc::new(Widget::build(action)),
button,
}
}
// Actions
pub fn update(&self, status: bool) {
// Update actions
self.action.history_back.simple_action.set_enabled(status);
// Update child components
self.widget.update(status);
self.button.set_sensitive(status);
}
}

View File

@ -1,38 +0,0 @@
use super::WindowAction;
use gtk::{
prelude::{ButtonExt, WidgetExt},
Button,
};
use std::rc::Rc;
pub struct Widget {
pub button: Button,
}
impl Widget {
// Constructors
/// Build new `Self`
pub fn build(action: &Rc<WindowAction>) -> Self {
// Init gobject
let button = Button::builder()
.icon_name("go-previous-symbolic")
.tooltip_text("Back")
.sensitive(false)
.build();
// Init events
button.connect_clicked({
let action = action.clone();
move |_| action.history_back.activate()
});
// Return activated `Self`
Self { button }
}
// Actions
pub fn update(&self, is_sensitive: bool) {
self.button.set_sensitive(is_sensitive);
}
}

View File

@ -1,13 +1,14 @@
mod widget;
use widget::Widget;
use gtk::{
prelude::{ButtonExt, WidgetExt},
Button,
};
use super::WindowAction;
use std::rc::Rc;
pub struct Forward {
action: Rc<WindowAction>,
pub widget: Rc<Widget>,
pub button: Button,
}
impl Forward {
@ -15,21 +16,33 @@ impl Forward {
/// Build new `Self`
pub fn build(action: &Rc<WindowAction>) -> Self {
// Init gobject
let button = Button::builder()
.icon_name("go-next-symbolic")
.tooltip_text("Forward")
.sensitive(false)
.build();
// Init events
button.connect_clicked({
let action = action.clone();
move |_| action.history_forward.activate()
});
// Return activated `Self`
Self {
action: action.clone(),
widget: Rc::new(Widget::build(action)),
button,
}
}
// Actions
pub fn update(&self, status: bool) {
// Update actions
self.action
.history_forward
.simple_action
.set_enabled(status);
// Update child components
self.widget.update(status);
self.button.set_sensitive(status);
}
}

View File

@ -1,38 +0,0 @@
use super::WindowAction;
use gtk::{
prelude::{ButtonExt, WidgetExt},
Button,
};
use std::rc::Rc;
pub struct Widget {
pub button: Button,
}
impl Widget {
// Constructors
/// Build new `Self`
pub fn build(action: &Rc<WindowAction>) -> Self {
// Init gobject
let button = Button::builder()
.icon_name("go-next-symbolic")
.tooltip_text("Forward")
.sensitive(false)
.build();
// Init events
button.connect_clicked({
let action = action.clone();
move |_| action.history_forward.activate()
});
// Return activated `Self`
Self { button }
}
// Actions
pub fn update(&self, is_sensitive: bool) {
self.button.set_sensitive(is_sensitive);
}
}