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