2024-09-20 18:02:10 +03:00
|
|
|
mod menu;
|
|
|
|
mod tab;
|
2024-09-23 18:51:48 +03:00
|
|
|
|
|
|
|
use menu::Menu;
|
|
|
|
use tab::Tab;
|
2024-09-19 11:29:03 +03:00
|
|
|
|
2024-09-28 03:10:07 +03:00
|
|
|
use gtk::{
|
|
|
|
gio::SimpleAction,
|
|
|
|
prelude::BoxExt,
|
|
|
|
{Box, Orientation},
|
|
|
|
};
|
|
|
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
2024-09-22 20:58:23 +03:00
|
|
|
pub struct Tray {
|
2024-09-23 18:51:48 +03:00
|
|
|
widget: Box,
|
2024-09-22 20:58:23 +03:00
|
|
|
}
|
2024-09-19 11:29:03 +03:00
|
|
|
|
2024-09-22 20:58:23 +03:00
|
|
|
impl Tray {
|
2024-09-28 01:53:16 +03:00
|
|
|
pub fn new(
|
2024-09-28 03:10:07 +03:00
|
|
|
action_debug: Arc<SimpleAction>,
|
|
|
|
action_quit: Arc<SimpleAction>,
|
|
|
|
action_tab_append: Arc<SimpleAction>,
|
|
|
|
action_tab_close: Arc<SimpleAction>,
|
|
|
|
action_tab_close_all: Arc<SimpleAction>,
|
|
|
|
action_tab_page_reload: Arc<SimpleAction>,
|
|
|
|
action_tab_pin: Arc<SimpleAction>,
|
2024-09-28 01:53:16 +03:00
|
|
|
) -> Self {
|
2024-09-28 01:29:05 +03:00
|
|
|
// Init components
|
2024-09-28 03:10:07 +03:00
|
|
|
let tab = Tab::new(action_tab_append.clone());
|
|
|
|
|
2024-09-28 01:53:16 +03:00
|
|
|
let menu = Menu::new(
|
|
|
|
action_debug,
|
|
|
|
action_quit,
|
|
|
|
action_tab_append,
|
|
|
|
action_tab_close,
|
|
|
|
action_tab_close_all,
|
|
|
|
action_tab_page_reload,
|
|
|
|
action_tab_pin,
|
|
|
|
);
|
2024-09-28 02:06:04 +03:00
|
|
|
|
2024-09-28 01:29:05 +03:00
|
|
|
// Init widget
|
2024-09-23 18:51:48 +03:00
|
|
|
let widget = Box::builder()
|
|
|
|
.orientation(Orientation::Horizontal)
|
|
|
|
.spacing(8)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
widget.append(menu.widget());
|
|
|
|
widget.append(tab.widget());
|
|
|
|
|
2024-09-28 01:29:05 +03:00
|
|
|
// Return new struct
|
2024-09-23 18:51:48 +03:00
|
|
|
Self { widget }
|
2024-09-22 20:58:23 +03:00
|
|
|
}
|
2024-09-19 11:29:03 +03:00
|
|
|
|
2024-09-22 20:58:23 +03:00
|
|
|
// Getters
|
2024-09-23 18:51:48 +03:00
|
|
|
pub fn widget(&self) -> &Box {
|
2024-09-22 20:58:23 +03:00
|
|
|
&self.widget
|
|
|
|
}
|
2024-09-20 18:02:10 +03:00
|
|
|
}
|