Browse Source

integrate simple action object

master
yggverse 2 months ago
parent
commit
ff2073d302
  1. 3
      src/browser/header/tray.rs
  2. 21
      src/browser/header/tray/tab.rs

3
src/browser/header/tray.rs

@ -31,7 +31,8 @@ impl Tray {
action_tab_page_reload, action_tab_page_reload,
action_tab_pin, action_tab_pin,
); );
let tab = Tab::new();
let tab = Tab::new(action_tab_append);
// Init widget // Init widget
let widget = Box::builder() let widget = Box::builder()

21
src/browser/header/tray/tab.rs

@ -1,4 +1,4 @@
use gtk::Button; use gtk::{gio::SimpleAction, prelude::ActionExt, prelude::ButtonExt, Button};
pub struct Tab { pub struct Tab {
pub widget: Button, pub widget: Button,
@ -6,14 +6,23 @@ pub struct Tab {
impl Tab { impl Tab {
// Construct // Construct
pub fn new() -> Self { pub fn new(action_tab_append: &SimpleAction) -> Self {
Self { // Init widget
widget: Button::builder() let widget = Button::builder()
.action_name("win.tab_append")
.icon_name("tab-new-symbolic") .icon_name("tab-new-symbolic")
.tooltip_text("New tab") .tooltip_text("New tab")
.build(), .build();
// Init events
widget.connect_clicked({
let action_tab_append = action_tab_append.clone();
move |_| {
action_tab_append.activate(None);
} }
});
// Return activated struct
Self { widget }
} }
// Getters // Getters

Loading…
Cancel
Save