implement main menu as trait

This commit is contained in:
yggverse 2025-01-27 09:57:57 +02:00
parent 099bba0173
commit 0f89b526f7
2 changed files with 7 additions and 10 deletions

View File

@ -8,7 +8,7 @@ use tab::Tab;
use super::{BrowserAction, Profile, WindowAction}; use super::{BrowserAction, Profile, WindowAction};
use adw::{TabBar, TabView}; use adw::{TabBar, TabView};
use gtk::{prelude::BoxExt, Box, Orientation}; use gtk::{prelude::BoxExt, Box, MenuButton, Orientation};
use std::rc::Rc; use std::rc::Rc;
pub trait Bar { pub trait Bar {
@ -34,7 +34,7 @@ impl Bar for Box {
.build(); .build();
g_box.append(&TabBar::tab(window_action, view)); g_box.append(&TabBar::tab(window_action, view));
g_box.append(&Menu::build((browser_action, window_action), profile).menu_button); g_box.append(&MenuButton::menu((browser_action, window_action), profile));
g_box.append(&Control::new().window_controls); g_box.append(&Control::new().window_controls);
g_box g_box
} }

View File

@ -11,16 +11,16 @@ use std::rc::Rc;
// Config options // Config options
const LABEL_MAX_LENGTH: usize = 28; const LABEL_MAX_LENGTH: usize = 28;
pub struct Menu { pub trait Menu {
pub menu_button: MenuButton, fn menu(action: (&Rc<BrowserAction>, &Rc<WindowAction>), profile: &Rc<Profile>) -> Self;
} }
#[rustfmt::skip] // @TODO template builder? #[rustfmt::skip] // @TODO template builder?
impl Menu { impl Menu for MenuButton {
// Constructors // Constructors
/// Build new `Self` /// Build new `Self`
pub fn build( fn menu(
(browser_action, window_action): (&Rc<BrowserAction>, &Rc<WindowAction>), (browser_action, window_action): (&Rc<BrowserAction>, &Rc<WindowAction>),
profile: &Rc<Profile>, profile: &Rc<Profile>,
) -> Self { ) -> Self {
@ -252,10 +252,7 @@ impl Menu {
} }
}); });
// Result menu_button
Self {
menu_button
}
} }
} }