mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-10 18:34:14 +00:00
define struct, implement action
This commit is contained in:
parent
c0ebe95eb8
commit
ecd686976c
@ -5,14 +5,18 @@ use gtk::prelude::BoxExt;
|
|||||||
use gtk::Box;
|
use gtk::Box;
|
||||||
|
|
||||||
pub fn new() -> Box {
|
pub fn new() -> Box {
|
||||||
|
// Init components
|
||||||
|
let tab = tab::new();
|
||||||
|
|
||||||
|
// Init widget
|
||||||
let tray = Box::builder()
|
let tray = Box::builder()
|
||||||
.orientation(gtk::Orientation::Horizontal)
|
.orientation(gtk::Orientation::Horizontal)
|
||||||
.spacing(8)
|
.spacing(8)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Compose childs
|
// Compose childs
|
||||||
tray.append(&menu::new());
|
tray.append(&menu::new()); // @TODO
|
||||||
tray.append(&tab::new());
|
tray.append(tab.widget.as_ref());
|
||||||
|
|
||||||
tray
|
tray // @TODO struct
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,27 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use gtk::prelude::{ButtonExt, WidgetExt};
|
||||||
use gtk::Button;
|
use gtk::Button;
|
||||||
|
|
||||||
pub fn new() -> Button {
|
pub struct Tab {
|
||||||
let tab = Button::builder()
|
pub widget: Arc<gtk::Button>,
|
||||||
.icon_name("tab-new-symbolic")
|
}
|
||||||
.tooltip_text("New tab")
|
|
||||||
.build();
|
pub fn new() -> Tab {
|
||||||
|
// Init widget
|
||||||
return tab;
|
let widget = Arc::new(
|
||||||
|
Button::builder()
|
||||||
|
.icon_name("tab-new-symbolic")
|
||||||
|
.tooltip_text("New tab")
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Init events
|
||||||
|
widget.connect_clicked(|this| {
|
||||||
|
this.activate_action("win.tab_append", None)
|
||||||
|
.expect("The action does not exist");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Result
|
||||||
|
Tab { widget }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user