Format
This commit is contained in:
parent
7598130650
commit
4f8d22c120
2 changed files with 147 additions and 139 deletions
283
src/menu.rs
283
src/menu.rs
|
|
@ -529,143 +529,152 @@ pub fn menu_bar<'a>(
|
|||
.item_width(ItemWidth::Uniform(360))
|
||||
.spacing(theme::active().cosmic().spacing.space_xxxs.into())
|
||||
.into_element(
|
||||
core,
|
||||
key_binds,
|
||||
MENU_ID.clone(),
|
||||
Message::Surface,
|
||||
vec![
|
||||
(
|
||||
fl!("file"),
|
||||
vec![
|
||||
menu::Item::Button(fl!("new-tab"), None, Action::TabNew),
|
||||
menu::Item::Button(fl!("new-window"), None, Action::WindowNew),
|
||||
menu::Item::Button(fl!("new-folder"), None, Action::NewFolder),
|
||||
menu::Item::Button(fl!("new-file"), None, Action::NewFile),
|
||||
menu_button_optional(
|
||||
fl!("open"),
|
||||
Action::Open,
|
||||
(selected > 0 && selected_dir == 0) || (selected_dir == 1 && selected == 1),
|
||||
),
|
||||
menu_button_optional(fl!("menu-open-with"), Action::OpenWith, selected == 1),
|
||||
menu::Item::Divider,
|
||||
menu_button_optional(fl!("rename"), Action::Rename, selected > 0),
|
||||
menu::Item::Divider,
|
||||
menu_button_optional(fl!("add-to-sidebar"), Action::AddToSidebar, selected > 0),
|
||||
menu::Item::Divider,
|
||||
menu_button_optional(
|
||||
if in_trash {
|
||||
fl!("delete-permanently")
|
||||
} else {
|
||||
fl!("move-to-trash")
|
||||
},
|
||||
Action::Delete,
|
||||
selected > 0,
|
||||
),
|
||||
menu::Item::Divider,
|
||||
menu::Item::Button(fl!("close-tab"), None, Action::TabClose),
|
||||
menu::Item::Button(fl!("quit"), None, Action::WindowClose),
|
||||
],
|
||||
),
|
||||
(
|
||||
(fl!("edit")),
|
||||
vec![
|
||||
menu_button_optional(fl!("cut"), Action::Cut, selected > 0),
|
||||
menu_button_optional(fl!("copy"), Action::Copy, selected > 0),
|
||||
menu_button_optional(fl!("paste"), Action::Paste, selected > 0),
|
||||
menu::Item::Button(fl!("select-all"), None, Action::SelectAll),
|
||||
menu::Item::Divider,
|
||||
menu::Item::Button(fl!("history"), None, Action::EditHistory),
|
||||
],
|
||||
),
|
||||
(
|
||||
(fl!("view")),
|
||||
vec![
|
||||
menu::Item::Button(fl!("zoom-in"), None, Action::ZoomIn),
|
||||
menu::Item::Button(fl!("default-size"), None, Action::ZoomDefault),
|
||||
menu::Item::Button(fl!("zoom-out"), None, Action::ZoomOut),
|
||||
menu::Item::Divider,
|
||||
menu::Item::CheckBox(
|
||||
fl!("grid-view"),
|
||||
None,
|
||||
tab_opt.map_or(false, |tab| matches!(tab.config.view, tab::View::Grid)),
|
||||
Action::TabViewGrid,
|
||||
),
|
||||
menu::Item::CheckBox(
|
||||
fl!("list-view"),
|
||||
None,
|
||||
tab_opt.map_or(false, |tab| matches!(tab.config.view, tab::View::List)),
|
||||
Action::TabViewList,
|
||||
),
|
||||
menu::Item::Divider,
|
||||
menu::Item::CheckBox(
|
||||
fl!("show-hidden-files"),
|
||||
None,
|
||||
tab_opt.map_or(false, |tab| tab.config.show_hidden),
|
||||
Action::ToggleShowHidden,
|
||||
),
|
||||
menu::Item::CheckBox(
|
||||
fl!("list-directories-first"),
|
||||
None,
|
||||
tab_opt.map_or(false, |tab| tab.config.folders_first),
|
||||
Action::ToggleFoldersFirst,
|
||||
),
|
||||
menu::Item::CheckBox(
|
||||
fl!("show-details"),
|
||||
None,
|
||||
config.show_details,
|
||||
Action::Preview,
|
||||
),
|
||||
menu::Item::Divider,
|
||||
menu_button_optional(
|
||||
fl!("gallery-preview"),
|
||||
Action::Gallery,
|
||||
selected_gallery > 0,
|
||||
),
|
||||
menu::Item::Divider,
|
||||
menu::Item::Button(fl!("menu-settings"), None, Action::Settings),
|
||||
menu::Item::Divider,
|
||||
menu::Item::Button(fl!("menu-about"), None, Action::About),
|
||||
],
|
||||
),
|
||||
(
|
||||
(fl!("sort")),
|
||||
vec![
|
||||
sort_item(fl!("sort-a-z"), tab::HeadingOptions::Name, true),
|
||||
sort_item(fl!("sort-z-a"), tab::HeadingOptions::Name, false),
|
||||
sort_item(
|
||||
fl!("sort-newest-first"),
|
||||
if in_trash {
|
||||
tab::HeadingOptions::TrashedOn
|
||||
} else {
|
||||
tab::HeadingOptions::Modified
|
||||
},
|
||||
false,
|
||||
),
|
||||
sort_item(
|
||||
fl!("sort-oldest-first"),
|
||||
if in_trash {
|
||||
tab::HeadingOptions::TrashedOn
|
||||
} else {
|
||||
tab::HeadingOptions::Modified
|
||||
},
|
||||
true,
|
||||
),
|
||||
sort_item(
|
||||
fl!("sort-smallest-to-largest"),
|
||||
tab::HeadingOptions::Size,
|
||||
true,
|
||||
),
|
||||
sort_item(
|
||||
fl!("sort-largest-to-smallest"),
|
||||
tab::HeadingOptions::Size,
|
||||
false,
|
||||
),
|
||||
//TODO: sort by type
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
}
|
||||
core,
|
||||
key_binds,
|
||||
MENU_ID.clone(),
|
||||
Message::Surface,
|
||||
vec![
|
||||
(
|
||||
fl!("file"),
|
||||
vec![
|
||||
menu::Item::Button(fl!("new-tab"), None, Action::TabNew),
|
||||
menu::Item::Button(fl!("new-window"), None, Action::WindowNew),
|
||||
menu::Item::Button(fl!("new-folder"), None, Action::NewFolder),
|
||||
menu::Item::Button(fl!("new-file"), None, Action::NewFile),
|
||||
menu_button_optional(
|
||||
fl!("open"),
|
||||
Action::Open,
|
||||
(selected > 0 && selected_dir == 0)
|
||||
|| (selected_dir == 1 && selected == 1),
|
||||
),
|
||||
menu_button_optional(
|
||||
fl!("menu-open-with"),
|
||||
Action::OpenWith,
|
||||
selected == 1,
|
||||
),
|
||||
menu::Item::Divider,
|
||||
menu_button_optional(fl!("rename"), Action::Rename, selected > 0),
|
||||
menu::Item::Divider,
|
||||
menu_button_optional(
|
||||
fl!("add-to-sidebar"),
|
||||
Action::AddToSidebar,
|
||||
selected > 0,
|
||||
),
|
||||
menu::Item::Divider,
|
||||
menu_button_optional(
|
||||
if in_trash {
|
||||
fl!("delete-permanently")
|
||||
} else {
|
||||
fl!("move-to-trash")
|
||||
},
|
||||
Action::Delete,
|
||||
selected > 0,
|
||||
),
|
||||
menu::Item::Divider,
|
||||
menu::Item::Button(fl!("close-tab"), None, Action::TabClose),
|
||||
menu::Item::Button(fl!("quit"), None, Action::WindowClose),
|
||||
],
|
||||
),
|
||||
(
|
||||
(fl!("edit")),
|
||||
vec![
|
||||
menu_button_optional(fl!("cut"), Action::Cut, selected > 0),
|
||||
menu_button_optional(fl!("copy"), Action::Copy, selected > 0),
|
||||
menu_button_optional(fl!("paste"), Action::Paste, selected > 0),
|
||||
menu::Item::Button(fl!("select-all"), None, Action::SelectAll),
|
||||
menu::Item::Divider,
|
||||
menu::Item::Button(fl!("history"), None, Action::EditHistory),
|
||||
],
|
||||
),
|
||||
(
|
||||
(fl!("view")),
|
||||
vec![
|
||||
menu::Item::Button(fl!("zoom-in"), None, Action::ZoomIn),
|
||||
menu::Item::Button(fl!("default-size"), None, Action::ZoomDefault),
|
||||
menu::Item::Button(fl!("zoom-out"), None, Action::ZoomOut),
|
||||
menu::Item::Divider,
|
||||
menu::Item::CheckBox(
|
||||
fl!("grid-view"),
|
||||
None,
|
||||
tab_opt.map_or(false, |tab| matches!(tab.config.view, tab::View::Grid)),
|
||||
Action::TabViewGrid,
|
||||
),
|
||||
menu::Item::CheckBox(
|
||||
fl!("list-view"),
|
||||
None,
|
||||
tab_opt.map_or(false, |tab| matches!(tab.config.view, tab::View::List)),
|
||||
Action::TabViewList,
|
||||
),
|
||||
menu::Item::Divider,
|
||||
menu::Item::CheckBox(
|
||||
fl!("show-hidden-files"),
|
||||
None,
|
||||
tab_opt.map_or(false, |tab| tab.config.show_hidden),
|
||||
Action::ToggleShowHidden,
|
||||
),
|
||||
menu::Item::CheckBox(
|
||||
fl!("list-directories-first"),
|
||||
None,
|
||||
tab_opt.map_or(false, |tab| tab.config.folders_first),
|
||||
Action::ToggleFoldersFirst,
|
||||
),
|
||||
menu::Item::CheckBox(
|
||||
fl!("show-details"),
|
||||
None,
|
||||
config.show_details,
|
||||
Action::Preview,
|
||||
),
|
||||
menu::Item::Divider,
|
||||
menu_button_optional(
|
||||
fl!("gallery-preview"),
|
||||
Action::Gallery,
|
||||
selected_gallery > 0,
|
||||
),
|
||||
menu::Item::Divider,
|
||||
menu::Item::Button(fl!("menu-settings"), None, Action::Settings),
|
||||
menu::Item::Divider,
|
||||
menu::Item::Button(fl!("menu-about"), None, Action::About),
|
||||
],
|
||||
),
|
||||
(
|
||||
(fl!("sort")),
|
||||
vec![
|
||||
sort_item(fl!("sort-a-z"), tab::HeadingOptions::Name, true),
|
||||
sort_item(fl!("sort-z-a"), tab::HeadingOptions::Name, false),
|
||||
sort_item(
|
||||
fl!("sort-newest-first"),
|
||||
if in_trash {
|
||||
tab::HeadingOptions::TrashedOn
|
||||
} else {
|
||||
tab::HeadingOptions::Modified
|
||||
},
|
||||
false,
|
||||
),
|
||||
sort_item(
|
||||
fl!("sort-oldest-first"),
|
||||
if in_trash {
|
||||
tab::HeadingOptions::TrashedOn
|
||||
} else {
|
||||
tab::HeadingOptions::Modified
|
||||
},
|
||||
true,
|
||||
),
|
||||
sort_item(
|
||||
fl!("sort-smallest-to-largest"),
|
||||
tab::HeadingOptions::Size,
|
||||
true,
|
||||
),
|
||||
sort_item(
|
||||
fl!("sort-largest-to-smallest"),
|
||||
tab::HeadingOptions::Size,
|
||||
false,
|
||||
),
|
||||
//TODO: sort by type
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
pub fn location_context_menu<'a>(ancestor_index: usize) -> Element<'a, tab::Message> {
|
||||
//TODO: only add some of these when in App mode
|
||||
|
|
|
|||
|
|
@ -334,8 +334,7 @@ impl MimeAppCache {
|
|||
.entry(mime.clone())
|
||||
.or_insert_with(|| Vec::with_capacity(1));
|
||||
if !apps.iter().any(|x| filename_eq(&x.path, filename)) {
|
||||
if let Some(app) =
|
||||
all_apps.find(|x| filename_eq(&x.path, filename))
|
||||
if let Some(app) = all_apps.find(|x| filename_eq(&x.path, filename))
|
||||
{
|
||||
apps.push(MimeApp::from(&app));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue