chore: update for navbar popup
This commit is contained in:
parent
0e761ba811
commit
e00725a450
1 changed files with 99 additions and 88 deletions
29
src/app.rs
29
src/app.rs
|
|
@ -2525,9 +2525,17 @@ impl Application for App {
|
|||
.on_middle_press(|entity| {
|
||||
cosmic::Action::App(Message::NavMenuAction(NavMenuAction::OpenInNewTab(entity)))
|
||||
})
|
||||
.context_menu(self.nav_context_menu(self.nav_bar_context_id))
|
||||
.close_icon(icon::from_name("media-eject-symbolic").size(16).icon())
|
||||
.into_container();
|
||||
.context_menu(self.nav_context_menu())
|
||||
.close_icon(icon::from_name("media-eject-symbolic").size(16).icon());
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
{
|
||||
nav = nav
|
||||
.window_id_maybe(self.core().main_window_id())
|
||||
.on_surface_action(|m| cosmic::Action::Cosmic(cosmic::app::Action::Surface(m)))
|
||||
}
|
||||
|
||||
let mut nav = nav.into_container();
|
||||
|
||||
if !self.core.is_condensed() {
|
||||
nav = nav.max_width(280);
|
||||
|
|
@ -2538,14 +2546,12 @@ impl Application for App {
|
|||
))
|
||||
}
|
||||
|
||||
fn nav_context_menu(
|
||||
&self,
|
||||
entity: widget::nav_bar::Id,
|
||||
) -> Option<Vec<widget::menu::Tree<cosmic::Action<Self::Message>>>> {
|
||||
fn nav_context_menu(&self) -> Option<Vec<widget::menu::Tree<cosmic::Action<Self::Message>>>> {
|
||||
let items = self.nav_model.iter().map(|entity| {
|
||||
let favorite_index_opt = self.nav_model.data::<FavoriteIndex>(entity);
|
||||
let location_opt = self.nav_model.data::<Location>(entity);
|
||||
|
||||
let mut items = Vec::with_capacity(7);
|
||||
let mut items: Vec<widget::menu::Item<NavMenuAction, String>> = Vec::with_capacity(7);
|
||||
|
||||
if location_opt
|
||||
.and_then(Location::path_opt)
|
||||
|
|
@ -2627,8 +2633,13 @@ impl Application for App {
|
|||
NavMenuAction::EmptyTrash,
|
||||
));
|
||||
}
|
||||
items
|
||||
});
|
||||
|
||||
Some(cosmic::widget::menu::items(&HashMap::new(), items))
|
||||
Some(cosmic::widget::menu::nav_context(
|
||||
&HashMap::new(),
|
||||
items.collect(),
|
||||
))
|
||||
}
|
||||
|
||||
fn nav_model(&self) -> Option<&segmented_button::SingleSelectModel> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue