Initial implementation of the Tiling applet
This commit is contained in:
parent
fcd1cfff5e
commit
3353dc95ac
11 changed files with 509 additions and 49 deletions
202
Cargo.lock
generated
202
Cargo.lock
generated
|
|
@ -688,8 +688,8 @@ dependencies = [
|
|||
"freedesktop-icons",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"i18n-embed",
|
||||
"i18n-embed-fl",
|
||||
"i18n-embed 0.13.9",
|
||||
"i18n-embed-fl 0.6.7",
|
||||
"itertools 0.11.0",
|
||||
"libcosmic",
|
||||
"log",
|
||||
|
|
@ -698,8 +698,8 @@ dependencies = [
|
|||
"pretty_env_logger 0.5.0",
|
||||
"rand",
|
||||
"ron",
|
||||
"rust-embed",
|
||||
"rust-embed-utils",
|
||||
"rust-embed 6.8.1",
|
||||
"rust-embed-utils 7.8.1",
|
||||
"serde",
|
||||
"shlex",
|
||||
"tokio",
|
||||
|
|
@ -712,16 +712,16 @@ name = "cosmic-applet-audio"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cosmic-time",
|
||||
"i18n-embed",
|
||||
"i18n-embed-fl",
|
||||
"i18n-embed 0.13.9",
|
||||
"i18n-embed-fl 0.6.7",
|
||||
"icon-loader",
|
||||
"libcosmic",
|
||||
"libpulse-binding",
|
||||
"libpulse-glib-binding",
|
||||
"log",
|
||||
"pretty_env_logger 0.4.0",
|
||||
"rust-embed",
|
||||
"rust-embed-utils",
|
||||
"rust-embed 6.8.1",
|
||||
"rust-embed-utils 7.8.1",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
|
|
@ -731,13 +731,13 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"cosmic-time",
|
||||
"futures",
|
||||
"i18n-embed",
|
||||
"i18n-embed-fl",
|
||||
"i18n-embed 0.13.9",
|
||||
"i18n-embed-fl 0.6.7",
|
||||
"libcosmic",
|
||||
"log",
|
||||
"once_cell",
|
||||
"pretty_env_logger 0.5.0",
|
||||
"rust-embed",
|
||||
"rust-embed 6.8.1",
|
||||
"tokio",
|
||||
"zbus",
|
||||
]
|
||||
|
|
@ -750,15 +750,15 @@ dependencies = [
|
|||
"bluer",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"i18n-embed",
|
||||
"i18n-embed-fl",
|
||||
"i18n-embed 0.13.9",
|
||||
"i18n-embed-fl 0.6.7",
|
||||
"itertools 0.10.5",
|
||||
"libcosmic",
|
||||
"log",
|
||||
"once_cell",
|
||||
"pretty_env_logger 0.5.0",
|
||||
"rand",
|
||||
"rust-embed",
|
||||
"rust-embed 6.8.1",
|
||||
"slotmap",
|
||||
"tokio",
|
||||
]
|
||||
|
|
@ -767,11 +767,11 @@ dependencies = [
|
|||
name = "cosmic-applet-graphics"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"i18n-embed",
|
||||
"i18n-embed-fl",
|
||||
"i18n-embed 0.13.9",
|
||||
"i18n-embed-fl 0.6.7",
|
||||
"libcosmic",
|
||||
"once_cell",
|
||||
"rust-embed",
|
||||
"rust-embed 6.8.1",
|
||||
"tracing",
|
||||
"zbus",
|
||||
]
|
||||
|
|
@ -785,14 +785,14 @@ dependencies = [
|
|||
"cosmic-time",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"i18n-embed",
|
||||
"i18n-embed-fl",
|
||||
"i18n-embed 0.13.9",
|
||||
"i18n-embed-fl 0.6.7",
|
||||
"itertools 0.10.5",
|
||||
"libcosmic",
|
||||
"log",
|
||||
"pretty_env_logger 0.5.0",
|
||||
"rust-embed",
|
||||
"rust-embed-utils",
|
||||
"rust-embed 6.8.1",
|
||||
"rust-embed-utils 7.8.1",
|
||||
"slotmap",
|
||||
"tokio",
|
||||
"zbus",
|
||||
|
|
@ -807,13 +807,13 @@ dependencies = [
|
|||
"cosmic-notifications-config",
|
||||
"cosmic-notifications-util",
|
||||
"cosmic-time",
|
||||
"i18n-embed",
|
||||
"i18n-embed-fl",
|
||||
"i18n-embed 0.13.9",
|
||||
"i18n-embed-fl 0.6.7",
|
||||
"libcosmic",
|
||||
"nix 0.26.2",
|
||||
"ron",
|
||||
"rust-embed",
|
||||
"rust-embed-utils",
|
||||
"rust-embed 6.8.1",
|
||||
"rust-embed-utils 7.8.1",
|
||||
"sendfd",
|
||||
"tokio",
|
||||
"tracing",
|
||||
|
|
@ -826,8 +826,8 @@ dependencies = [
|
|||
name = "cosmic-applet-power"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"i18n-embed",
|
||||
"i18n-embed-fl",
|
||||
"i18n-embed 0.13.9",
|
||||
"i18n-embed-fl 0.6.7",
|
||||
"icon-loader",
|
||||
"libcosmic",
|
||||
"libpulse-binding",
|
||||
|
|
@ -835,8 +835,8 @@ dependencies = [
|
|||
"logind-zbus",
|
||||
"nix 0.26.2",
|
||||
"once_cell",
|
||||
"rust-embed",
|
||||
"rust-embed-utils",
|
||||
"rust-embed 6.8.1",
|
||||
"rust-embed-utils 7.8.1",
|
||||
"tokio",
|
||||
"zbus",
|
||||
]
|
||||
|
|
@ -852,6 +852,18 @@ dependencies = [
|
|||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cosmic-applet-tiling"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"i18n-embed 0.14.0",
|
||||
"i18n-embed-fl 0.7.0",
|
||||
"libcosmic",
|
||||
"once_cell",
|
||||
"rust-embed 8.0.0",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cosmic-applet-time"
|
||||
version = "0.1.0"
|
||||
|
|
@ -870,14 +882,14 @@ dependencies = [
|
|||
"cosmic-client-toolkit",
|
||||
"cosmic-protocols",
|
||||
"futures",
|
||||
"i18n-embed",
|
||||
"i18n-embed-fl",
|
||||
"i18n-embed 0.13.9",
|
||||
"i18n-embed-fl 0.6.7",
|
||||
"libcosmic",
|
||||
"log",
|
||||
"nix 0.26.2",
|
||||
"once_cell",
|
||||
"pretty_env_logger 0.5.0",
|
||||
"rust-embed",
|
||||
"rust-embed 6.8.1",
|
||||
"xdg",
|
||||
]
|
||||
|
||||
|
|
@ -2210,15 +2222,15 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
|||
|
||||
[[package]]
|
||||
name = "i18n-config"
|
||||
version = "0.4.4"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b987084cadad6e2f2b1e6ea62c44123591a3c044793a1beabf71a8356ea768d5"
|
||||
checksum = "0c9ce3c48cbc21fd5b22b9331f32b5b51f6ad85d969b99e793427332e76e7640"
|
||||
dependencies = [
|
||||
"log",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"thiserror",
|
||||
"toml 0.7.6",
|
||||
"toml 0.8.0",
|
||||
"unic-langid",
|
||||
]
|
||||
|
||||
|
|
@ -2238,7 +2250,29 @@ dependencies = [
|
|||
"locale_config",
|
||||
"log",
|
||||
"parking_lot 0.12.1",
|
||||
"rust-embed",
|
||||
"rust-embed 6.8.1",
|
||||
"thiserror",
|
||||
"unic-langid",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "i18n-embed"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26261c73a1670a3f632a8765bb6b22c62fc391f3ddc805b87fd00cd6158e4456"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"fluent",
|
||||
"fluent-langneg",
|
||||
"fluent-syntax",
|
||||
"i18n-embed-impl",
|
||||
"intl-memoizer",
|
||||
"lazy_static",
|
||||
"locale_config",
|
||||
"log",
|
||||
"parking_lot 0.12.1",
|
||||
"rust-embed 8.0.0",
|
||||
"thiserror",
|
||||
"unic-langid",
|
||||
"walkdir",
|
||||
|
|
@ -2255,7 +2289,28 @@ dependencies = [
|
|||
"fluent",
|
||||
"fluent-syntax",
|
||||
"i18n-config",
|
||||
"i18n-embed",
|
||||
"i18n-embed 0.13.9",
|
||||
"lazy_static",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn 2.0.29",
|
||||
"unic-langid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "i18n-embed-fl"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fc1f8715195dffc4caddcf1cf3128da15fe5d8a137606ea8856c9300047d5a2"
|
||||
dependencies = [
|
||||
"dashmap",
|
||||
"find-crate",
|
||||
"fluent",
|
||||
"fluent-syntax",
|
||||
"i18n-config",
|
||||
"i18n-embed 0.14.0",
|
||||
"lazy_static",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
|
|
@ -3586,7 +3641,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"toml_edit",
|
||||
"toml_edit 0.19.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3867,8 +3922,19 @@ version = "6.8.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a36224c3276f8c4ebc8c20f158eca7ca4359c8db89991c4925132aaaf6702661"
|
||||
dependencies = [
|
||||
"rust-embed-impl",
|
||||
"rust-embed-utils",
|
||||
"rust-embed-impl 6.8.1",
|
||||
"rust-embed-utils 7.8.1",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-embed"
|
||||
version = "8.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1e7d90385b59f0a6bf3d3b757f3ca4ece2048265d70db20a2016043d4509a40"
|
||||
dependencies = [
|
||||
"rust-embed-impl 8.0.0",
|
||||
"rust-embed-utils 8.0.0",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
|
|
@ -3880,7 +3946,20 @@ checksum = "49b94b81e5b2c284684141a2fb9e2a31be90638caf040bf9afbc5a0416afe1ac"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rust-embed-utils",
|
||||
"rust-embed-utils 7.8.1",
|
||||
"syn 2.0.29",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-embed-impl"
|
||||
version = "8.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c3d8c6fd84090ae348e63a84336b112b5c3918b3bf0493a581f7bd8ee623c29"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rust-embed-utils 8.0.0",
|
||||
"syn 2.0.29",
|
||||
"walkdir",
|
||||
]
|
||||
|
|
@ -3895,6 +3974,16 @@ dependencies = [
|
|||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-embed-utils"
|
||||
version = "8.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "873feff8cb7bf86fdf0a71bb21c95159f4e4a37dd7a4bd1855a940909b583ada"
|
||||
dependencies = [
|
||||
"sha2",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-ini"
|
||||
version = "0.18.0"
|
||||
|
|
@ -4649,7 +4738,19 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit",
|
||||
"toml_edit 0.19.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c226a7bba6d859b63c92c4b4fe69c5b6b72d0cb897dbc8e6012298e6154cb56e"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit 0.20.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4674,6 +4775,19 @@ dependencies = [
|
|||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ff63e60a958cefbb518ae1fd6566af80d9d4be430a33f3723dfc47d1d411d95"
|
||||
dependencies = [
|
||||
"indexmap 2.0.0",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.37"
|
||||
|
|
@ -4988,9 +5102,9 @@ checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
|
|||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.3.3"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698"
|
||||
checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi-util",
|
||||
|
|
|
|||
18
Cargo.toml
18
Cargo.toml
|
|
@ -10,18 +10,28 @@ members = [
|
|||
"cosmic-applet-notifications",
|
||||
"cosmic-applet-power",
|
||||
"cosmic-applet-status-area",
|
||||
"cosmic-applet-tiling",
|
||||
"cosmic-applet-time",
|
||||
"cosmic-applet-workspaces",
|
||||
"cosmic-panel-button",
|
||||
]
|
||||
|
||||
resolver="2"
|
||||
resolver = "2"
|
||||
|
||||
[workspace.dependencies]
|
||||
cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "e39748e" }
|
||||
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = ["client"], rev = "e39748e" }
|
||||
cosmic-time = { git = "https://github.com/pop-os/cosmic-time", default-features = false, features = ["libcosmic", "once_cell"] }
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = ["applet", "tokio", "wayland"] }
|
||||
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = [
|
||||
"client",
|
||||
], rev = "e39748e" }
|
||||
cosmic-time = { git = "https://github.com/pop-os/cosmic-time", default-features = false, features = [
|
||||
"libcosmic",
|
||||
"once_cell",
|
||||
] }
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = [
|
||||
"applet",
|
||||
"tokio",
|
||||
"wayland",
|
||||
] }
|
||||
|
||||
[profile.release]
|
||||
lto = "thin"
|
||||
|
|
|
|||
15
cosmic-applet-tiling/Cargo.toml
Normal file
15
cosmic-applet-tiling/Cargo.toml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[package]
|
||||
name = "cosmic-applet-tiling"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
libcosmic.workspace = true
|
||||
once_cell = "1"
|
||||
i18n-embed = { version = "0.14.0", features = ["fluent-system", "desktop-requester"] }
|
||||
i18n-embed-fl = "0.7.0"
|
||||
rust-embed = "8.0.0"
|
||||
tracing = "0.1"
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
[Desktop Entry]
|
||||
Name=Cosmic Applet Tiling
|
||||
Comment=Applet for Cosmic Panel
|
||||
Type=Application
|
||||
Exec=cosmic-applet-tiling
|
||||
Terminal=false
|
||||
Categories=Cosmic;Iced;
|
||||
Keywords=Cosmic;Iced;
|
||||
# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
|
||||
Icon=com.system76.CosmicAppletTiling
|
||||
StartupNotify=true
|
||||
NoDisplay=true
|
||||
X-CosmicApplet=true
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="applet-graphics-mode">
|
||||
<rect id="Rectangle 47" x="4" y="4" width="8" height="8" fill="#232323"/>
|
||||
<g id="Rectangle 48">
|
||||
<path d="M4 0.75C4 0.75 4 0 5 0C6 0 6 0.75 6 0.75V3H4V0.75Z" fill="#232323"/>
|
||||
</g>
|
||||
<g id="Rectangle 54">
|
||||
<path d="M0.75 6C0.75 6 0 6 0 5C0 4 0.75 4 0.75 4H3V6H0.75Z" fill="#232323"/>
|
||||
</g>
|
||||
<g id="Rectangle 57">
|
||||
<path d="M15.25 6C15.25 6 16 6 16 5C16 4 15.25 4 15.25 4H13V6H15.25Z" fill="#232323"/>
|
||||
</g>
|
||||
<g id="Rectangle 51">
|
||||
<path d="M4 15.25C4 15.25 4 16 5 16C6 16 6 15.25 6 15.25V13H4V15.25Z" fill="#232323"/>
|
||||
</g>
|
||||
<g id="Rectangle 49">
|
||||
<path d="M7 0.75C7 0.75 7 0 8 0C9 0 9 0.75 9 0.75V3H7V0.75Z" fill="#232323"/>
|
||||
</g>
|
||||
<g id="Rectangle 55">
|
||||
<path d="M0.75 9C0.75 9 0 9 0 8C0 7 0.75 7 0.75 7H3V9H0.75Z" fill="#232323"/>
|
||||
</g>
|
||||
<g id="Rectangle 58">
|
||||
<path d="M15.25 9C15.25 9 16 9 16 8C16 7 15.25 7 15.25 7H13V9H15.25Z" fill="#232323"/>
|
||||
</g>
|
||||
<g id="Rectangle 52">
|
||||
<path d="M7 15.25C7 15.25 7 16 8 16C9 16 9 15.25 9 15.25V13H7V15.25Z" fill="#232323"/>
|
||||
</g>
|
||||
<g id="Rectangle 50">
|
||||
<path d="M10 0.75C10 0.75 10 0 11 0C12 0 12 0.75 12 0.75V3H10V0.75Z" fill="#232323"/>
|
||||
</g>
|
||||
<g id="Rectangle 56">
|
||||
<path d="M0.75 12C0.75 12 0 12 0 11C0 10 0.75 10 0.75 10H3V12H0.75Z" fill="#232323"/>
|
||||
</g>
|
||||
<g id="Rectangle 59">
|
||||
<path d="M15.25 12C15.25 12 16 12 16 11C16 10 15.25 10 15.25 10H13V12H15.25Z" fill="#232323"/>
|
||||
</g>
|
||||
<g id="Rectangle 53">
|
||||
<path d="M10 15.25C10 15.25 10 16 11 16C12 16 12 15.25 12 15.25V13H10V15.25Z" fill="#232323"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
4
cosmic-applet-tiling/i18n.toml
Normal file
4
cosmic-applet-tiling/i18n.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
fallback_language = "en"
|
||||
|
||||
[fluent]
|
||||
assets_dir = "i18n"
|
||||
16
cosmic-applet-tiling/i18n/en/cosmic_applet_tiling.ftl
Normal file
16
cosmic-applet-tiling/i18n/en/cosmic_applet_tiling.ftl
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
tile-windows = Tile Windows
|
||||
floating-window-exceptions = Floating Window Exceptions
|
||||
shortcuts = Shortcuts
|
||||
launcher = Launcher
|
||||
navigate-windows = Navigate Windows
|
||||
toggle-tiling = Toggle Tiling
|
||||
view-all = View All
|
||||
show-window-titles = Show Window Titles
|
||||
show-active-hint = Show Active Hint
|
||||
active-border-radius = Active Border Radius
|
||||
active-hint-color = Active Hint Color
|
||||
gaps = Gaps
|
||||
|
||||
// Commands
|
||||
super = Super
|
||||
arrow-keys = Arrow keys
|
||||
47
cosmic-applet-tiling/src/localize.rs
Normal file
47
cosmic-applet-tiling/src/localize.rs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// SPDX-License-Identifier: MPL-2.0-only
|
||||
|
||||
use i18n_embed::{
|
||||
fluent::{fluent_language_loader, FluentLanguageLoader},
|
||||
DefaultLocalizer, LanguageLoader, Localizer,
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
use rust_embed::RustEmbed;
|
||||
|
||||
#[derive(RustEmbed)]
|
||||
#[folder = "i18n/"]
|
||||
struct Localizations;
|
||||
|
||||
pub static LANGUAGE_LOADER: Lazy<FluentLanguageLoader> = Lazy::new(|| {
|
||||
let loader: FluentLanguageLoader = fluent_language_loader!();
|
||||
|
||||
loader
|
||||
.load_fallback_language(&Localizations)
|
||||
.expect("Error while loading fallback language");
|
||||
|
||||
loader
|
||||
});
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! fl {
|
||||
($message_id:literal) => {{
|
||||
i18n_embed_fl::fl!($crate::localize::LANGUAGE_LOADER, $message_id)
|
||||
}};
|
||||
|
||||
($message_id:literal, $($args:expr),*) => {{
|
||||
i18n_embed_fl::fl!($crate::localize::LANGUAGE_LOADER, $message_id, $($args), *)
|
||||
}};
|
||||
}
|
||||
|
||||
// Get the `Localizer` to be used for localizing this library.
|
||||
pub fn localizer() -> Box<dyn Localizer> {
|
||||
Box::from(DefaultLocalizer::new(&*LANGUAGE_LOADER, &Localizations))
|
||||
}
|
||||
|
||||
pub fn localize() {
|
||||
let localizer = localizer();
|
||||
let requested_languages = i18n_embed::DesktopLanguageRequester::requested_languages();
|
||||
|
||||
if let Err(error) = localizer.select(&requested_languages) {
|
||||
eprintln!("Error while loading language for App List {}", error);
|
||||
}
|
||||
}
|
||||
10
cosmic-applet-tiling/src/main.rs
Normal file
10
cosmic-applet-tiling/src/main.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
use crate::window::Window;
|
||||
|
||||
mod localize;
|
||||
mod window;
|
||||
|
||||
fn main() -> cosmic::iced::Result {
|
||||
localize::localize();
|
||||
|
||||
cosmic::app::applet::run::<Window>(true, ())
|
||||
}
|
||||
189
cosmic-applet-tiling/src/window.rs
Normal file
189
cosmic-applet-tiling/src/window.rs
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
use crate::fl;
|
||||
use cosmic::app::Core;
|
||||
use cosmic::cosmic_theme::palette::rgb::Rgb;
|
||||
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
|
||||
use cosmic::iced::window::Id;
|
||||
use cosmic::iced::{Command, Limits};
|
||||
use cosmic::iced_runtime::core::window;
|
||||
use cosmic::iced_style::application;
|
||||
use cosmic::theme::{Button, Svg};
|
||||
use cosmic::widget::{button, list_column, settings, spin_button, text, toggler};
|
||||
use cosmic::{Element, Theme};
|
||||
|
||||
const ID: &str = "com.system76.CosmicAppletTiling";
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Window {
|
||||
core: Core,
|
||||
popup: Option<Id>,
|
||||
id_ctr: u128,
|
||||
tile_windows: bool,
|
||||
show_window_titles: bool,
|
||||
show_active_hint: bool,
|
||||
active_border_radius: spin_button::Model<i32>,
|
||||
active_hint_color: Rgb,
|
||||
gaps: spin_button::Model<i32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Message {
|
||||
TogglePopup,
|
||||
PopupClosed(Id),
|
||||
ToggleTileWindows(bool),
|
||||
ToggleShowWindowTitles(bool),
|
||||
ToggleShowActiveHint(bool),
|
||||
HandleActiveBorderRadius(spin_button::Message),
|
||||
SetActiveHintColor(Rgb),
|
||||
HandleGaps(spin_button::Message),
|
||||
}
|
||||
|
||||
impl cosmic::Application for Window {
|
||||
type Executor = cosmic::SingleThreadExecutor;
|
||||
type Flags = ();
|
||||
type Message = Message;
|
||||
const APP_ID: &'static str = ID;
|
||||
|
||||
fn core(&self) -> &Core {
|
||||
&self.core
|
||||
}
|
||||
|
||||
fn core_mut(&mut self) -> &mut Core {
|
||||
&mut self.core
|
||||
}
|
||||
|
||||
fn init(
|
||||
core: Core,
|
||||
_flags: Self::Flags,
|
||||
) -> (Self, Command<cosmic::app::Message<Self::Message>>) {
|
||||
let window = Window {
|
||||
core,
|
||||
active_border_radius: spin_button::Model::default().max(99).min(0).step(1),
|
||||
gaps: spin_button::Model::default().max(99).min(0).step(1),
|
||||
..Default::default()
|
||||
};
|
||||
(window, Command::none())
|
||||
}
|
||||
|
||||
fn on_close_requested(&self, id: window::Id) -> Option<Message> {
|
||||
Some(Message::PopupClosed(id))
|
||||
}
|
||||
|
||||
fn update(&mut self, message: Self::Message) -> Command<cosmic::app::Message<Self::Message>> {
|
||||
match message {
|
||||
Message::TogglePopup => {
|
||||
return if let Some(p) = self.popup.take() {
|
||||
destroy_popup(p)
|
||||
} else {
|
||||
self.id_ctr += 1;
|
||||
let new_id = Id(self.id_ctr);
|
||||
self.popup.replace(new_id);
|
||||
let mut popup_settings =
|
||||
self.core
|
||||
.applet_helper
|
||||
.get_popup_settings(Id(0), new_id, None, None, None);
|
||||
popup_settings.positioner.size_limits = Limits::NONE
|
||||
.max_width(372.0)
|
||||
.min_width(300.0)
|
||||
.min_height(200.0)
|
||||
.max_height(1080.0);
|
||||
get_popup(popup_settings)
|
||||
}
|
||||
}
|
||||
Message::PopupClosed(id) => {
|
||||
if self.popup.as_ref() == Some(&id) {
|
||||
self.popup = None;
|
||||
}
|
||||
}
|
||||
Message::ToggleTileWindows(toggled) => self.tile_windows = toggled,
|
||||
Message::ToggleShowWindowTitles(toggled) => self.show_window_titles = toggled,
|
||||
Message::ToggleShowActiveHint(toggled) => self.show_active_hint = toggled,
|
||||
Message::HandleActiveBorderRadius(msg) => match msg {
|
||||
spin_button::Message::Increment => self
|
||||
.active_border_radius
|
||||
.update(spin_button::Message::Increment),
|
||||
spin_button::Message::Decrement => self
|
||||
.active_border_radius
|
||||
.update(spin_button::Message::Decrement),
|
||||
},
|
||||
Message::SetActiveHintColor(_) => {}
|
||||
Message::HandleGaps(msg) => match msg {
|
||||
spin_button::Message::Increment => {
|
||||
self.gaps.update(spin_button::Message::Increment)
|
||||
}
|
||||
spin_button::Message::Decrement => {
|
||||
self.gaps.update(spin_button::Message::Decrement)
|
||||
}
|
||||
},
|
||||
}
|
||||
Command::none()
|
||||
}
|
||||
|
||||
fn view(&self) -> Element<Self::Message> {
|
||||
self.core
|
||||
.applet_helper
|
||||
.icon_button(ID)
|
||||
.on_press(Message::TogglePopup)
|
||||
.style(Button::Text)
|
||||
.into()
|
||||
}
|
||||
|
||||
fn view_window(&self, _id: Id) -> Element<Self::Message> {
|
||||
let content_list = list_column()
|
||||
.add(settings::item(
|
||||
fl!("tile-windows"),
|
||||
toggler(None, self.tile_windows, |value| {
|
||||
Message::ToggleTileWindows(value)
|
||||
}),
|
||||
))
|
||||
.add(settings::item(
|
||||
fl!("floating-window-exceptions"),
|
||||
button(Button::Card).icon(Svg::Symbolic, "arrow-right", 16),
|
||||
))
|
||||
.add(
|
||||
settings::view_section(fl!("shortcuts"))
|
||||
.add(settings::item(
|
||||
fl!("launcher"),
|
||||
text(format!("{} + /", fl!("super"))),
|
||||
))
|
||||
.add(settings::item(
|
||||
fl!("navigate-windows"),
|
||||
text(format!("{} + {}", fl!("super"), fl!("arrow-keys"))),
|
||||
))
|
||||
.add(settings::item(
|
||||
fl!("toggle-tiling"),
|
||||
text(format!("{} + Y", fl!("super"))),
|
||||
))
|
||||
.add(settings::item(fl!("view-all"), text(""))),
|
||||
)
|
||||
.add(settings::item(
|
||||
fl!("show-window-titles"),
|
||||
toggler(None, self.show_window_titles, |value| {
|
||||
Message::ToggleShowWindowTitles(value)
|
||||
}),
|
||||
))
|
||||
.add(settings::item(
|
||||
fl!("show-active-hint"),
|
||||
toggler(None, self.show_active_hint, |value| {
|
||||
Message::ToggleShowActiveHint(value)
|
||||
}),
|
||||
))
|
||||
.add(settings::item(
|
||||
fl!("active-border-radius"),
|
||||
spin_button(
|
||||
self.active_border_radius.value.to_string(),
|
||||
Message::HandleActiveBorderRadius,
|
||||
),
|
||||
))
|
||||
.add(settings::item(fl!("active-hint-color"), text("TODO")))
|
||||
.add(settings::item(
|
||||
fl!("gaps"),
|
||||
spin_button(self.gaps.value.to_string(), Message::HandleGaps),
|
||||
));
|
||||
|
||||
self.core.applet_helper.popup_container(content_list).into()
|
||||
}
|
||||
|
||||
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
|
||||
Some(cosmic::app::applet::style())
|
||||
}
|
||||
}
|
||||
3
justfile
3
justfile
|
|
@ -45,6 +45,7 @@ _install_notifications: (_install 'com.system76.CosmicAppletNotifications' 'cosm
|
|||
_install_power: (_install 'com.system76.CosmicAppletPower' 'cosmic-applet-power')
|
||||
_install_workspace: (_install 'com.system76.CosmicAppletWorkspaces' 'cosmic-applet-workspaces')
|
||||
_install_time: (_install 'com.system76.CosmicAppletTime' 'cosmic-applet-time')
|
||||
_install_tiling: (_install 'com.system76.CosmicAppletTiling' 'cosmic-applet-tiling')
|
||||
_install_status_area: (_install 'com.system76.CosmicAppletStatusArea' 'cosmic-applet-status-area')
|
||||
|
||||
# TODO: Turn this into one configurable applet?
|
||||
|
|
@ -54,7 +55,7 @@ _install_app_button: (_install_button 'com.system76.CosmicPanelAppButton' 'cosmi
|
|||
_install_workspaces_button: (_install_button 'com.system76.CosmicPanelWorkspacesButton' 'cosmic-panel-workspaces-button')
|
||||
|
||||
# Installs files into the system
|
||||
install: _install_app_list _install_audio _install_battery _install_bluetooth _install_graphics _install_network _install_notifications _install_power _install_workspace _install_time _install_panel_button _install_app_button _install_workspaces_button _install_status_area
|
||||
install: _install_app_list _install_audio _install_battery _install_bluetooth _install_graphics _install_network _install_notifications _install_power _install_workspace _install_time _install_tiling _install_panel_button _install_app_button _install_workspaces_button _install_status_area
|
||||
|
||||
# Extracts vendored dependencies if vendor=1
|
||||
_extract_vendor:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue