Skip to content

Commit

Permalink
implement main menu as trait
Browse files Browse the repository at this point in the history
  • Loading branch information
yggverse committed Jan 27, 2025
1 parent 099bba0 commit 0f89b52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/app/browser/window/header/bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
13 changes: 5 additions & 8 deletions src/app/browser/window/header/bar/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -252,10 +252,7 @@ impl Menu {
}
});

// Result
Self {
menu_button
}
menu_button
}
}

Expand Down

0 comments on commit 0f89b52

Please sign in to comment.