2024-12-05 12:20:37 -07:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
|
|
|
|
|
|
use cosmic::{
|
2024-12-05 13:41:58 -07:00
|
|
|
theme,
|
|
|
|
|
widget::menu::{self, key_bind::KeyBind, ItemHeight, ItemWidth, MenuBar},
|
2024-12-05 12:20:37 -07:00
|
|
|
Element,
|
|
|
|
|
};
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
|
|
use crate::{fl, Action, Config, Message};
|
|
|
|
|
|
|
|
|
|
pub fn menu_bar<'a>(config: &Config, key_binds: &HashMap<KeyBind, Action>) -> Element<'a, Message> {
|
|
|
|
|
let mut recent_items = Vec::new();
|
|
|
|
|
|
2024-12-05 13:41:58 -07:00
|
|
|
MenuBar::new(vec![menu::Tree::with_children(
|
|
|
|
|
menu::root(fl!("file")),
|
|
|
|
|
menu::items(
|
2024-12-05 12:20:37 -07:00
|
|
|
key_binds,
|
|
|
|
|
vec![
|
2024-12-05 13:41:58 -07:00
|
|
|
menu::Item::Button(fl!("open-media"), Action::FileOpen),
|
|
|
|
|
menu::Item::Folder(fl!("open-recent-media"), recent_items),
|
|
|
|
|
menu::Item::Button(fl!("close-file"), Action::FileClose),
|
|
|
|
|
menu::Item::Divider,
|
|
|
|
|
menu::Item::Button(fl!("quit"), Action::WindowClose),
|
2024-12-05 12:20:37 -07:00
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)])
|
|
|
|
|
.item_height(ItemHeight::Dynamic(40))
|
|
|
|
|
.item_width(ItemWidth::Uniform(240))
|
2024-12-05 13:41:58 -07:00
|
|
|
.spacing(theme::active().cosmic().spacing.space_xxxs.into())
|
2024-12-05 12:20:37 -07:00
|
|
|
.into()
|
|
|
|
|
}
|