improv(menu): update menu declaration.
- Updated libcosmic - Updated menu declaration.
This commit is contained in:
parent
2e63774882
commit
57e41766b9
5 changed files with 99 additions and 144 deletions
75
Cargo.lock
generated
75
Cargo.lock
generated
|
|
@ -848,8 +848,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clipboard_macos"
|
name = "clipboard_macos"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-mime-types#c3e9e794b94a2e79419517145424dc2035a572da"
|
||||||
checksum = "145a7f9e9b89453bc0a5e32d166456405d389cea5b578f57f1274b1397588a95"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"objc",
|
"objc",
|
||||||
"objc-foundation",
|
"objc-foundation",
|
||||||
|
|
@ -859,17 +858,16 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clipboard_wayland"
|
name = "clipboard_wayland"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-mime-types#c3e9e794b94a2e79419517145424dc2035a572da"
|
||||||
checksum = "003f886bc4e2987729d10c1db3424e7f80809f3fc22dbc16c685738887cb37b8"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"mime 0.1.0",
|
||||||
"smithay-clipboard",
|
"smithay-clipboard",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clipboard_x11"
|
name = "clipboard_x11"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-mime-types#c3e9e794b94a2e79419517145424dc2035a572da"
|
||||||
checksum = "4274ea815e013e0f9f04a2633423e14194e408a0576c943ce3d14ca56c50031c"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"x11rb",
|
"x11rb",
|
||||||
|
|
@ -1040,7 +1038,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-config"
|
name = "cosmic-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomicwrites",
|
"atomicwrites",
|
||||||
"cosmic-config-derive",
|
"cosmic-config-derive",
|
||||||
|
|
@ -1057,7 +1055,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-config-derive"
|
name = "cosmic-config-derive"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
|
|
@ -1101,7 +1099,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-text"
|
name = "cosmic-text"
|
||||||
version = "0.11.2"
|
version = "0.11.2"
|
||||||
source = "git+https://github.com/pop-os/cosmic-text.git#a53a0b3a8c085143470a9d26ac2c2911cc479033"
|
source = "git+https://github.com/pop-os/cosmic-text.git#18c3d2acec5e7f64a670c6643ee3ab220bc92a89"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.4.2",
|
||||||
"fontdb",
|
"fontdb",
|
||||||
|
|
@ -1123,7 +1121,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-theme"
|
name = "cosmic-theme"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"almost",
|
"almost",
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
|
|
@ -1866,9 +1864,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "freedesktop-desktop-entry"
|
name = "freedesktop-desktop-entry"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "45157175a725e81f3f594382430b6b78af5f8f72db9bd51b94f0785f80fc6d29"
|
checksum = "287f89b1a3d88dd04d2b65dfec39f3c381efbcded7b736456039c4ee49d54b17"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs 3.0.2",
|
"dirs 3.0.2",
|
||||||
"gettext-rs",
|
"gettext-rs",
|
||||||
|
|
@ -2470,7 +2468,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced"
|
name = "iced"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2480,12 +2478,13 @@ dependencies = [
|
||||||
"iced_winit",
|
"iced_winit",
|
||||||
"image",
|
"image",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
"window_clipboard",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_accessibility"
|
name = "iced_accessibility"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"accesskit_winit",
|
"accesskit_winit",
|
||||||
|
|
@ -2494,7 +2493,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_core"
|
name = "iced_core"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"log",
|
"log",
|
||||||
|
|
@ -2505,13 +2504,14 @@ dependencies = [
|
||||||
"smol_str",
|
"smol_str",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"web-time",
|
"web-time",
|
||||||
|
"window_clipboard",
|
||||||
"xxhash-rust",
|
"xxhash-rust",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_futures"
|
name = "iced_futures"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2524,7 +2524,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_graphics"
|
name = "iced_graphics"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2548,7 +2548,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_renderer"
|
name = "iced_renderer"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_tiny_skia",
|
"iced_tiny_skia",
|
||||||
|
|
@ -2560,17 +2560,18 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_runtime"
|
name = "iced_runtime"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"iced_futures",
|
"iced_futures",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
"window_clipboard",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_style"
|
name = "iced_style"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
@ -2580,7 +2581,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_tiny_skia"
|
name = "iced_tiny_skia"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"cosmic-text",
|
"cosmic-text",
|
||||||
|
|
@ -2597,7 +2598,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_wgpu"
|
name = "iced_wgpu"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2616,7 +2617,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_widget"
|
name = "iced_widget"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_renderer",
|
"iced_renderer",
|
||||||
"iced_runtime",
|
"iced_runtime",
|
||||||
|
|
@ -2630,7 +2631,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_winit"
|
name = "iced_winit"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_runtime",
|
"iced_runtime",
|
||||||
|
|
@ -2955,10 +2956,11 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libcosmic"
|
name = "libcosmic"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
|
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"apply",
|
"apply",
|
||||||
"ashpd 0.7.0",
|
"ashpd 0.7.0",
|
||||||
|
"chrono",
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
"cosmic-theme",
|
"cosmic-theme",
|
||||||
"css-color",
|
"css-color",
|
||||||
|
|
@ -2977,7 +2979,7 @@ dependencies = [
|
||||||
"iced_widget",
|
"iced_widget",
|
||||||
"iced_winit",
|
"iced_winit",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"mime",
|
"mime 0.3.17",
|
||||||
"nix 0.27.1",
|
"nix 0.27.1",
|
||||||
"palette",
|
"palette",
|
||||||
"rfd",
|
"rfd",
|
||||||
|
|
@ -3205,6 +3207,14 @@ dependencies = [
|
||||||
"paste",
|
"paste",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mime"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-mime-types#c3e9e794b94a2e79419517145424dc2035a572da"
|
||||||
|
dependencies = [
|
||||||
|
"smithay-clipboard",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mime"
|
name = "mime"
|
||||||
version = "0.3.17"
|
version = "0.3.17"
|
||||||
|
|
@ -3217,7 +3227,7 @@ version = "2.0.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
|
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mime",
|
"mime 0.3.17",
|
||||||
"unicase",
|
"unicase",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -4538,9 +4548,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smithay-clipboard"
|
name = "smithay-clipboard"
|
||||||
version = "0.7.1"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/pop-os/smithay-clipboard?tag=pop-mime-types#cc0101c1f9ccc937a413bd3af3c0f6217f27e935"
|
||||||
checksum = "c091e7354ea8059d6ad99eace06dd13ddeedbb0ac72d40a9a6e7ff790525882d"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"smithay-client-toolkit",
|
"smithay-client-toolkit",
|
||||||
|
|
@ -5664,13 +5673,13 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "window_clipboard"
|
name = "window_clipboard"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-mime-types#c3e9e794b94a2e79419517145424dc2035a572da"
|
||||||
checksum = "f6d692d46038c433f9daee7ad8757e002a4248c20b0a3fbc991d99521d3bcb6d"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clipboard-win",
|
"clipboard-win",
|
||||||
"clipboard_macos",
|
"clipboard_macos",
|
||||||
"clipboard_wayland",
|
"clipboard_wayland",
|
||||||
"clipboard_x11",
|
"clipboard_x11",
|
||||||
|
"mime 0.1.0",
|
||||||
"raw-window-handle 0.6.0",
|
"raw-window-handle 0.6.0",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
@ -6061,7 +6070,7 @@ checksum = "87bf7b69bb50588d70a36e467be29d3df3e8c32580276d62eded9738c1a797aa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs-next",
|
"dirs-next",
|
||||||
"glob",
|
"glob",
|
||||||
"mime",
|
"mime 0.3.17",
|
||||||
"nom 5.1.3",
|
"nom 5.1.3",
|
||||||
"unicase",
|
"unicase",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
12
src/app.rs
12
src/app.rs
|
|
@ -1,6 +1,8 @@
|
||||||
// Copyright 2023 System76 <info@system76.com>
|
// Copyright 2023 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
use cosmic::widget::menu::action::MenuAction;
|
||||||
|
use cosmic::widget::menu::key_bind::KeyBind;
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
app::{message, Command, Core},
|
app::{message, Command, Core},
|
||||||
cosmic_config, cosmic_theme, executor,
|
cosmic_config, cosmic_theme, executor,
|
||||||
|
|
@ -32,7 +34,7 @@ use std::{
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{AppTheme, Config, IconSizes, TabConfig, CONFIG_VERSION},
|
config::{AppTheme, Config, IconSizes, TabConfig, CONFIG_VERSION},
|
||||||
fl, home_dir,
|
fl, home_dir,
|
||||||
key_bind::{key_binds, KeyBind},
|
key_bind::key_binds,
|
||||||
menu, mime_app,
|
menu, mime_app,
|
||||||
operation::Operation,
|
operation::Operation,
|
||||||
spawn_detached::spawn_detached,
|
spawn_detached::spawn_detached,
|
||||||
|
|
@ -83,8 +85,10 @@ pub enum Action {
|
||||||
WindowNew,
|
WindowNew,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Action {
|
impl MenuAction for Action {
|
||||||
pub fn message(self, entity_opt: Option<Entity>) -> Message {
|
type Message = Message;
|
||||||
|
|
||||||
|
fn message(&self, entity_opt: Option<Entity>) -> Message {
|
||||||
match self {
|
match self {
|
||||||
Action::About => Message::ToggleContextPage(ContextPage::About),
|
Action::About => Message::ToggleContextPage(ContextPage::About),
|
||||||
Action::Copy => Message::Copy(entity_opt),
|
Action::Copy => Message::Copy(entity_opt),
|
||||||
|
|
@ -121,7 +125,7 @@ impl Action {
|
||||||
Message::TabMessage(entity_opt, tab::Message::View(tab::View::List))
|
Message::TabMessage(entity_opt, tab::Message::View(tab::View::List))
|
||||||
}
|
}
|
||||||
Action::ToggleShowHidden => Message::TabMessage(None, tab::Message::ToggleShowHidden),
|
Action::ToggleShowHidden => Message::TabMessage(None, tab::Message::ToggleShowHidden),
|
||||||
Action::ToggleSort(sort) => Message::TabMessage(None, tab::Message::ToggleSort(sort)),
|
Action::ToggleSort(sort) => Message::TabMessage(None, tab::Message::ToggleSort(*sort)),
|
||||||
Action::WindowClose => Message::WindowClose,
|
Action::WindowClose => Message::WindowClose,
|
||||||
Action::WindowNew => Message::WindowNew,
|
Action::WindowNew => Message::WindowNew,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,9 @@
|
||||||
use cosmic::{
|
use cosmic::widget::menu::key_bind::KeyBind;
|
||||||
iced::keyboard::{Key, Modifiers},
|
use cosmic::{iced::keyboard::Key, iced_core::keyboard::key::Named};
|
||||||
iced_core::keyboard::key::Named,
|
use std::collections::HashMap;
|
||||||
};
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::{collections::HashMap, fmt};
|
|
||||||
|
|
||||||
use crate::app::Action;
|
use crate::app::Action;
|
||||||
|
use cosmic::widget::menu::key_bind::Modifier;
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
|
||||||
pub enum Modifier {
|
|
||||||
Super,
|
|
||||||
Ctrl,
|
|
||||||
Alt,
|
|
||||||
Shift,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
|
||||||
pub struct KeyBind {
|
|
||||||
pub modifiers: Vec<Modifier>,
|
|
||||||
pub key: Key,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl KeyBind {
|
|
||||||
pub fn matches(&self, modifiers: Modifiers, key: &Key) -> bool {
|
|
||||||
key == &self.key
|
|
||||||
&& modifiers.logo() == self.modifiers.contains(&Modifier::Super)
|
|
||||||
&& modifiers.control() == self.modifiers.contains(&Modifier::Ctrl)
|
|
||||||
&& modifiers.alt() == self.modifiers.contains(&Modifier::Alt)
|
|
||||||
&& modifiers.shift() == self.modifiers.contains(&Modifier::Shift)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for KeyBind {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
for modifier in self.modifiers.iter() {
|
|
||||||
write!(f, "{:?} + ", modifier)?;
|
|
||||||
}
|
|
||||||
match &self.key {
|
|
||||||
Key::Character(c) => write!(f, "{}", c.to_uppercase()),
|
|
||||||
Key::Named(named) => write!(f, "{:?}", named),
|
|
||||||
other => write!(f, "{:?}", other),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: load from config
|
//TODO: load from config
|
||||||
pub fn key_binds() -> HashMap<KeyBind, Action> {
|
pub fn key_binds() -> HashMap<KeyBind, Action> {
|
||||||
|
|
|
||||||
104
src/menu.rs
104
src/menu.rs
|
|
@ -1,5 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
use cosmic::widget::menu::key_bind::KeyBind;
|
||||||
|
use cosmic::widget::menu::menu_tree::{menu_items, menu_root, MenuItem};
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
//TODO: export iced::widget::horizontal_rule in cosmic::widget
|
//TODO: export iced::widget::horizontal_rule in cosmic::widget
|
||||||
iced::{widget::horizontal_rule, Alignment, Background, Border, Length},
|
iced::{widget::horizontal_rule, Alignment, Background, Border, Length},
|
||||||
|
|
@ -16,7 +18,6 @@ use crate::{
|
||||||
app::{Action, Message},
|
app::{Action, Message},
|
||||||
config::TabConfig,
|
config::TabConfig,
|
||||||
fl,
|
fl,
|
||||||
key_bind::KeyBind,
|
|
||||||
tab::{self, HeadingOptions, Location, Tab},
|
tab::{self, HeadingOptions, Location, Tab},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -171,75 +172,56 @@ pub fn context_menu<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn menu_bar<'a>(key_binds: &HashMap<KeyBind, Action>) -> Element<'a, Message> {
|
pub fn menu_bar<'a>(key_binds: &HashMap<KeyBind, Action>) -> Element<'a, Message> {
|
||||||
//TODO: port to libcosmic
|
|
||||||
let menu_root = |label| {
|
|
||||||
widget::button(widget::text(label))
|
|
||||||
.padding([4, 12])
|
|
||||||
.style(theme::Button::MenuRoot)
|
|
||||||
};
|
|
||||||
|
|
||||||
let find_key = |action: &Action| -> String {
|
|
||||||
for (key_bind, key_action) in key_binds.iter() {
|
|
||||||
if action == key_action {
|
|
||||||
return key_bind.to_string();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String::new()
|
|
||||||
};
|
|
||||||
|
|
||||||
let menu_item = |label, action| {
|
|
||||||
let key = find_key(&action);
|
|
||||||
MenuTree::new(
|
|
||||||
menu_button!(
|
|
||||||
widget::text(label),
|
|
||||||
widget::horizontal_space(Length::Fill),
|
|
||||||
widget::text(key)
|
|
||||||
)
|
|
||||||
.on_press(action.message(None)),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
MenuBar::new(vec![
|
MenuBar::new(vec![
|
||||||
MenuTree::with_children(
|
MenuTree::with_children(
|
||||||
menu_root(fl!("file")),
|
menu_root(fl!("file")),
|
||||||
vec![
|
menu_items(
|
||||||
menu_item(fl!("new-tab"), Action::TabNew),
|
key_binds,
|
||||||
menu_item(fl!("new-window"), Action::WindowNew),
|
vec![
|
||||||
menu_item(fl!("new-file"), Action::NewFile),
|
MenuItem::Action(fl!("new-tab"), Action::TabNew),
|
||||||
menu_item(fl!("new-folder"), Action::NewFolder),
|
MenuItem::Action(fl!("new-window"), Action::WindowNew),
|
||||||
menu_item(fl!("open"), Action::Open),
|
MenuItem::Action(fl!("new-file"), Action::NewFile),
|
||||||
MenuTree::new(horizontal_rule(1)),
|
MenuItem::Action(fl!("new-folder"), Action::NewFolder),
|
||||||
menu_item(fl!("rename"), Action::Rename),
|
MenuItem::Action(fl!("open"), Action::Open),
|
||||||
//TOOD: add to sidebar, then divider
|
MenuItem::Separator,
|
||||||
MenuTree::new(horizontal_rule(1)),
|
MenuItem::Action(fl!("rename"), Action::Rename),
|
||||||
menu_item(fl!("move-to-trash"), Action::MoveToTrash),
|
//TOOD: add to sidebar, then divider
|
||||||
MenuTree::new(horizontal_rule(1)),
|
MenuItem::Separator,
|
||||||
menu_item(fl!("close-tab"), Action::TabClose),
|
MenuItem::Action(fl!("move-to-trash"), Action::MoveToTrash),
|
||||||
menu_item(fl!("quit"), Action::WindowClose),
|
MenuItem::Separator,
|
||||||
],
|
MenuItem::Action(fl!("close-tab"), Action::TabClose),
|
||||||
|
MenuItem::Action(fl!("quit"), Action::WindowClose),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
MenuTree::with_children(
|
MenuTree::with_children(
|
||||||
menu_root(fl!("edit")),
|
menu_root(fl!("edit")),
|
||||||
vec![
|
menu_items(
|
||||||
menu_item(fl!("cut"), Action::Cut),
|
key_binds,
|
||||||
menu_item(fl!("copy"), Action::Copy),
|
vec![
|
||||||
menu_item(fl!("paste"), Action::Paste),
|
MenuItem::Action(fl!("cut"), Action::Cut),
|
||||||
menu_item(fl!("select-all"), Action::SelectAll),
|
MenuItem::Action(fl!("copy"), Action::Copy),
|
||||||
MenuTree::new(horizontal_rule(1)),
|
MenuItem::Action(fl!("paste"), Action::Paste),
|
||||||
//TODO: edit history
|
MenuItem::Action(fl!("select-all"), Action::SelectAll),
|
||||||
menu_item(fl!("operations"), Action::Operations),
|
MenuItem::Separator,
|
||||||
],
|
//TODO: edit history
|
||||||
|
MenuItem::Action(fl!("operations"), Action::Operations),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
MenuTree::with_children(
|
MenuTree::with_children(
|
||||||
menu_root(fl!("view")),
|
menu_root(fl!("view")),
|
||||||
vec![
|
menu_items(
|
||||||
menu_item(fl!("grid-view"), Action::TabViewGrid),
|
key_binds,
|
||||||
menu_item(fl!("list-view"), Action::TabViewList),
|
vec![
|
||||||
MenuTree::new(horizontal_rule(1)),
|
MenuItem::Action(fl!("grid-view"), Action::TabViewGrid),
|
||||||
menu_item(fl!("menu-settings"), Action::Settings),
|
MenuItem::Action(fl!("list-view"), Action::TabViewList),
|
||||||
MenuTree::new(horizontal_rule(1)),
|
MenuItem::Separator,
|
||||||
menu_item(fl!("menu-about"), Action::About),
|
MenuItem::Action(fl!("menu-settings"), Action::Settings),
|
||||||
],
|
MenuItem::Separator,
|
||||||
|
MenuItem::Action(fl!("menu-about"), Action::About),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
.item_height(ItemHeight::Dynamic(40))
|
.item_height(ItemHeight::Dynamic(40))
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
use cosmic::widget::menu::key_bind::KeyBind;
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
cosmic_theme,
|
cosmic_theme,
|
||||||
iced::{
|
iced::{
|
||||||
|
|
@ -37,9 +38,7 @@ use crate::{
|
||||||
app::{self, Action},
|
app::{self, Action},
|
||||||
config::{IconSizes, TabConfig},
|
config::{IconSizes, TabConfig},
|
||||||
dialog::DialogKind,
|
dialog::DialogKind,
|
||||||
fl,
|
fl, menu,
|
||||||
key_bind::KeyBind,
|
|
||||||
menu,
|
|
||||||
mime_app::{mime_apps, MimeApp},
|
mime_app::{mime_apps, MimeApp},
|
||||||
mime_icon::{mime_for_path, mime_icon},
|
mime_icon::{mime_for_path, mime_icon},
|
||||||
mouse_area,
|
mouse_area,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue