Skip to content

Commit

Permalink
Support latest libcosmic
Browse files Browse the repository at this point in the history
  • Loading branch information
jpttrssn committed Nov 26, 2024
1 parent 06150f7 commit 62d26c6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 23 deletions.
16 changes: 13 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1547,37 +1547,44 @@ impl Application for App {
{
items.push(cosmic::widget::menu::Item::Button(
fl!("open"),
None,
NavMenuAction::Open(entity),
));
items.push(cosmic::widget::menu::Item::Button(
fl!("open-with"),
None,
NavMenuAction::OpenWith(entity),
));
} else {
items.push(cosmic::widget::menu::Item::Button(
fl!("open-in-new-tab"),
None,
NavMenuAction::OpenInNewTab(entity),
));
items.push(cosmic::widget::menu::Item::Button(
fl!("open-in-new-window"),
None,
NavMenuAction::OpenInNewWindow(entity),
));
}
items.push(cosmic::widget::menu::Item::Divider);
items.push(cosmic::widget::menu::Item::Button(
fl!("show-details"),
None,
NavMenuAction::Preview(entity),
));
items.push(cosmic::widget::menu::Item::Divider);
if favorite_index_opt.is_some() {
items.push(cosmic::widget::menu::Item::Button(
fl!("remove-from-sidebar"),
None,
NavMenuAction::RemoveFromSidebar(entity),
));
}
if matches!(location_opt, Some(Location::Trash)) {
items.push(cosmic::widget::menu::Item::Button(
fl!("empty-trash"),
None,
NavMenuAction::EmptyTrash,
));
}
Expand Down Expand Up @@ -2858,7 +2865,7 @@ impl Application for App {
let mut paths = Vec::with_capacity(recently_trashed.len());
let icon_sizes = self.config.tab.icon_sizes;

return cosmic::command::future(async move {
return cosmic::task::future(async move {
match tokio::task::spawn_blocking(move || Location::Trash.scan(icon_sizes))
.await
{
Expand Down Expand Up @@ -3713,8 +3720,11 @@ impl Application for App {
widget::row::with_children(vec![
widget::icon(app.icon.clone()).size(32).into(),
if app.is_default {
widget::text::body(fl!("default-app", name = app.name.as_str()))
.into()
widget::text::body(fl!(
"default-app",
name = Some(app.name.as_str())
))
.into()
} else {
widget::text::body(app.name.to_string()).into()
},
Expand Down
55 changes: 35 additions & 20 deletions src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ fn menu_button_optional(
enabled: bool,
) -> menu::Item<Action, String> {
if enabled {
menu::Item::Button(label, action)
menu::Item::Button(label, None, action)
} else {
menu::Item::ButtonDisabled(label, action)
menu::Item::ButtonDisabled(label, None, action)
}
}

Expand Down Expand Up @@ -351,6 +351,7 @@ pub fn dialog_menu<'a>(
let sort_item = |label, sort, dir| {
menu::Item::CheckBox(
label,
None,
sort_name == sort && sort_direction == dir,
Action::SetSort(sort, dir),
)
Expand Down Expand Up @@ -382,11 +383,13 @@ pub fn dialog_menu<'a>(
vec![
menu::Item::CheckBox(
fl!("grid-view"),
None,
matches!(tab.config.view, tab::View::Grid),
Action::TabViewGrid,
),
menu::Item::CheckBox(
fl!("list-view"),
None,
matches!(tab.config.view, tab::View::List),
Action::TabViewList,
),
Expand Down Expand Up @@ -447,21 +450,23 @@ pub fn dialog_menu<'a>(
menu::items(
key_binds,
vec![
menu::Item::Button(fl!("zoom-in"), Action::ZoomIn),
menu::Item::Button(fl!("default-size"), Action::ZoomDefault),
menu::Item::Button(fl!("zoom-out"), Action::ZoomOut),
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!("show-hidden-files"),
None,
tab.config.show_hidden,
Action::ToggleShowHidden,
),
menu::Item::CheckBox(
fl!("list-directories-first"),
None,
tab.config.folders_first,
Action::ToggleFoldersFirst,
),
menu::Item::CheckBox(fl!("show-details"), show_details, Action::Preview),
menu::Item::CheckBox(fl!("show-details"), None, show_details, Action::Preview),
menu::Item::Divider,
menu_button_optional(
fl!("gallery-preview"),
Expand All @@ -487,6 +492,7 @@ pub fn menu_bar<'a>(
let sort_item = |label, sort, dir| {
menu::Item::CheckBox(
label,
None,
sort_options.map_or(false, |(sort_name, sort_direction, _)| {
sort_name == sort && sort_direction == dir
}),
Expand Down Expand Up @@ -518,10 +524,10 @@ pub fn menu_bar<'a>(
menu::items(
key_binds,
vec![
menu::Item::Button(fl!("new-tab"), Action::TabNew),
menu::Item::Button(fl!("new-window"), Action::WindowNew),
menu::Item::Button(fl!("new-folder"), Action::NewFolder),
menu::Item::Button(fl!("new-file"), Action::NewFile),
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,
Expand All @@ -535,8 +541,8 @@ pub fn menu_bar<'a>(
menu::Item::Divider,
menu_button_optional(fl!("move-to-trash"), Action::MoveToTrash, selected > 0),
menu::Item::Divider,
menu::Item::Button(fl!("close-tab"), Action::TabClose),
menu::Item::Button(fl!("quit"), Action::WindowClose),
menu::Item::Button(fl!("close-tab"), None, Action::TabClose),
menu::Item::Button(fl!("quit"), None, Action::WindowClose),
],
),
),
Expand All @@ -548,9 +554,9 @@ pub fn menu_bar<'a>(
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"), Action::SelectAll),
menu::Item::Button(fl!("select-all"), None, Action::SelectAll),
menu::Item::Divider,
menu::Item::Button(fl!("history"), Action::EditHistory),
menu::Item::Button(fl!("history"), None, Action::EditHistory),
],
),
),
Expand All @@ -559,42 +565,51 @@ pub fn menu_bar<'a>(
menu::items(
key_binds,
vec![
menu::Item::Button(fl!("zoom-in"), Action::ZoomIn),
menu::Item::Button(fl!("default-size"), Action::ZoomDefault),
menu::Item::Button(fl!("zoom-out"), Action::ZoomOut),
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"), config.show_details, Action::Preview),
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"), Action::Settings),
menu::Item::Button(fl!("menu-settings"), None, Action::Settings),
menu::Item::Divider,
menu::Item::Button(fl!("menu-about"), Action::About),
menu::Item::Button(fl!("menu-about"), None, Action::About),
],
),
),
Expand Down

0 comments on commit 62d26c6

Please sign in to comment.