2024-09-20 18:02:10 +03:00
|
|
|
mod subject;
|
|
|
|
mod tray;
|
2024-09-18 20:33:29 +03:00
|
|
|
|
2024-09-23 18:51:48 +03:00
|
|
|
use subject::Subject;
|
|
|
|
use tray::Tray;
|
2024-09-23 13:50:59 +03:00
|
|
|
|
2024-09-28 01:29:05 +03:00
|
|
|
use gtk::{gio::SimpleAction, glib::GString, HeaderBar};
|
2024-09-24 23:08:40 +03:00
|
|
|
|
2024-09-28 03:10:07 +03:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
2024-09-22 12:38:13 +03:00
|
|
|
pub struct Header {
|
2024-09-23 18:51:48 +03:00
|
|
|
widget: HeaderBar,
|
2024-09-25 22:19:48 +03:00
|
|
|
subject: Subject,
|
2024-09-22 12:38:13 +03:00
|
|
|
}
|
|
|
|
|
2024-09-22 18:36:49 +03:00
|
|
|
impl Header {
|
2024-09-23 13:50:59 +03:00
|
|
|
// Construct
|
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>,
|
2024-09-30 15:02:22 +03:00
|
|
|
action_tab_page_navigation_base: Arc<SimpleAction>,
|
|
|
|
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
|
|
|
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
2024-09-30 14:49:37 +03:00
|
|
|
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
2024-09-28 03:10:07 +03:00
|
|
|
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 01:53:16 +03:00
|
|
|
let tray = Tray::new(
|
|
|
|
action_debug,
|
|
|
|
action_quit,
|
|
|
|
action_tab_append,
|
|
|
|
action_tab_close,
|
|
|
|
action_tab_close_all,
|
2024-09-30 15:02:22 +03:00
|
|
|
action_tab_page_navigation_base,
|
|
|
|
action_tab_page_navigation_history_back,
|
|
|
|
action_tab_page_navigation_history_forward,
|
2024-09-30 14:49:37 +03:00
|
|
|
action_tab_page_navigation_reload,
|
2024-09-28 01:53:16 +03:00
|
|
|
action_tab_pin,
|
|
|
|
);
|
2024-09-28 01:29:05 +03:00
|
|
|
|
2024-09-23 18:51:48 +03:00
|
|
|
let subject = Subject::new();
|
|
|
|
|
2024-09-28 01:29:05 +03:00
|
|
|
// Init widget
|
2024-09-23 18:51:48 +03:00
|
|
|
let widget = HeaderBar::builder().build();
|
|
|
|
widget.pack_start(tray.widget());
|
|
|
|
widget.set_title_widget(Some(subject.widget()));
|
|
|
|
|
2024-09-28 01:29:05 +03:00
|
|
|
// Return new struct
|
2024-09-26 00:59:44 +03:00
|
|
|
Self { widget, subject }
|
2024-09-25 22:19:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Actions
|
2024-09-27 16:23:59 +03:00
|
|
|
pub fn update(&self, title: Option<GString>, description: Option<GString>) {
|
2024-09-25 22:19:48 +03:00
|
|
|
self.subject.update(title, description);
|
2024-09-22 18:36:49 +03:00
|
|
|
}
|
2024-09-19 11:29:03 +03:00
|
|
|
|
2024-09-22 18:36:49 +03:00
|
|
|
// Getters
|
2024-09-23 18:51:48 +03:00
|
|
|
pub fn widget(&self) -> &HeaderBar {
|
2024-09-22 18:36:49 +03:00
|
|
|
&self.widget
|
|
|
|
}
|
2024-09-20 18:02:10 +03:00
|
|
|
}
|