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 adw::{TabBar, TabView};
use gtk::{prelude::BoxExt, Box, Orientation};
use gtk::{prelude::BoxExt, Box, MenuButton, Orientation};
use std::rc::Rc;
pub trait Bar {
@ -34,7 +34,7 @@ impl Bar for Box {
.build();
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
}

View File

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