mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
remove extra levels
This commit is contained in:
parent
bd766a2154
commit
176d24da4f
5 changed files with 43 additions and 95 deletions
|
|
@ -36,7 +36,7 @@ impl History {
|
||||||
let forward = Rc::new(Forward::build(action));
|
let forward = Rc::new(Forward::build(action));
|
||||||
|
|
||||||
// Init widget
|
// 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
|
// Init memory
|
||||||
let memory = RefCell::new(Vec::new());
|
let memory = RefCell::new(Vec::new());
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
mod widget;
|
|
||||||
|
|
||||||
use widget::Widget;
|
|
||||||
|
|
||||||
use super::WindowAction;
|
use super::WindowAction;
|
||||||
|
use gtk::{
|
||||||
|
prelude::{ButtonExt, WidgetExt},
|
||||||
|
Button,
|
||||||
|
};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Back {
|
pub struct Back {
|
||||||
action: Rc<WindowAction>,
|
action: Rc<WindowAction>,
|
||||||
pub widget: Rc<Widget>,
|
pub button: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Back {
|
impl Back {
|
||||||
|
|
@ -15,19 +15,30 @@ impl Back {
|
||||||
|
|
||||||
/// Build new `Self`
|
/// Build new `Self`
|
||||||
pub fn build(action: &Rc<WindowAction>) -> 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 {
|
Self {
|
||||||
action: action.clone(),
|
action: action.clone(),
|
||||||
widget: Rc::new(Widget::build(action)),
|
button,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
pub fn update(&self, status: bool) {
|
pub fn update(&self, status: bool) {
|
||||||
// Update actions
|
|
||||||
self.action.history_back.simple_action.set_enabled(status);
|
self.action.history_back.simple_action.set_enabled(status);
|
||||||
|
self.button.set_sensitive(status);
|
||||||
// Update child components
|
|
||||||
self.widget.update(status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
mod widget;
|
use gtk::{
|
||||||
|
prelude::{ButtonExt, WidgetExt},
|
||||||
use widget::Widget;
|
Button,
|
||||||
|
};
|
||||||
|
|
||||||
use super::WindowAction;
|
use super::WindowAction;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Forward {
|
pub struct Forward {
|
||||||
action: Rc<WindowAction>,
|
action: Rc<WindowAction>,
|
||||||
pub widget: Rc<Widget>,
|
pub button: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Forward {
|
impl Forward {
|
||||||
|
|
@ -15,21 +16,33 @@ impl Forward {
|
||||||
|
|
||||||
/// Build new `Self`
|
/// Build new `Self`
|
||||||
pub fn build(action: &Rc<WindowAction>) -> 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 {
|
Self {
|
||||||
action: action.clone(),
|
action: action.clone(),
|
||||||
widget: Rc::new(Widget::build(action)),
|
button,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn update(&self, status: bool) {
|
pub fn update(&self, status: bool) {
|
||||||
// Update actions
|
|
||||||
self.action
|
self.action
|
||||||
.history_forward
|
.history_forward
|
||||||
.simple_action
|
.simple_action
|
||||||
.set_enabled(status);
|
.set_enabled(status);
|
||||||
|
|
||||||
// Update child components
|
self.button.set_sensitive(status);
|
||||||
self.widget.update(status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue