From e44eafa47b138328cb1bd82f7c56a014770a8b1d Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 20 Nov 2023 12:26:05 -0500 Subject: [PATCH] refactor: use single instance --- Cargo.lock | 532 ++++++++++++++++++++----------- Cargo.toml | 6 +- src/app.rs | 207 +++++++----- src/app_group.rs | 8 +- src/subscriptions/mod.rs | 1 - src/subscriptions/toggle_dbus.rs | 84 ----- src/widgets/application.rs | 7 +- src/widgets/group.rs | 2 +- 8 files changed, 485 insertions(+), 362 deletions(-) delete mode 100644 src/subscriptions/toggle_dbus.rs diff --git a/Cargo.lock b/Cargo.lock index 00237b0..a18a8d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,6 +104,54 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" + +[[package]] +name = "anstyle-parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +dependencies = [ + "anstyle", + "windows-sys", +] + [[package]] name = "anyhow" version = "1.0.75" @@ -143,6 +191,12 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "as-raw-xcb-connection" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d5f312b0a56c5cdf967c0aeb67f6289603354951683bc97ddc595ab974ba9aa" + [[package]] name = "ash" version = "0.37.3+1.3.251" @@ -209,15 +263,15 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.6.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" +checksum = "fc5ea910c42e5ab19012bab31f53cb4d63d54c3a27730f9a833a88efcf4bb52d" dependencies = [ - "async-lock 2.8.0", + "async-lock 3.1.1", "async-task", "concurrent-queue", "fastrand 2.0.1", - "futures-lite 1.13.0", + "futures-lite 2.0.1", "slab", ] @@ -259,18 +313,18 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997" dependencies = [ - "async-lock 3.1.0", + "async-lock 3.1.1", "cfg-if", "concurrent-queue", "futures-io", "futures-lite 2.0.1", "parking", "polling 3.3.0", - "rustix 0.38.21", + "rustix 0.38.25", "slab", "tracing", "waker-fn", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -284,9 +338,9 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb2ab2aa8a746e221ab826c73f48bc6ba41be6763f0855cb249eb6d154cf1d7" +checksum = "655b9c7fe787d3b25cc0f804a1a8401790f0c5bc395beb5a64dc77d8de079105" dependencies = [ "event-listener 3.1.0", "event-listener-strategy", @@ -306,8 +360,8 @@ dependencies = [ "cfg-if", "event-listener 3.1.0", "futures-lite 1.13.0", - "rustix 0.38.21", - "windows-sys 0.48.0", + "rustix 0.38.25", + "windows-sys", ] [[package]] @@ -333,10 +387,10 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix 0.38.21", + "rustix 0.38.25", "signal-hook-registry", "slab", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -365,12 +419,11 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "atomicwrites" version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4d45f362125ed144544e57b0ec6de8fd6a296d41a6252fc4a20c0cf12e9ed3a" +source = "git+https://github.com/jackpot51/rust-atomicwrites#043ab4859d53ffd3d55334685303d8df39c9f768" dependencies = [ - "rustix 0.38.21", + "rustix 0.38.25", "tempfile", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -485,7 +538,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ "async-channel 2.1.0", - "async-lock 3.1.0", + "async-lock 3.1.1", "async-task", "fastrand 2.0.1", "futures-io", @@ -541,7 +594,7 @@ dependencies = [ "bitflags 2.4.1", "log", "polling 3.3.0", - "rustix 0.38.21", + "rustix 0.38.25", "slab", "thiserror", ] @@ -553,16 +606,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" dependencies = [ "calloop", - "rustix 0.38.21", + "rustix 0.38.25", "wayland-backend 0.3.2", "wayland-client 0.31.1", ] [[package]] name = "cc" -version = "1.0.84" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f8e7c90afad890484a21653d08b6e209ae34770fb5ee298f9c699fcc1e5c856" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "libc", ] @@ -579,18 +632,58 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +[[package]] +name = "clap" +version = "4.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "clap_lex" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" + [[package]] name = "cocoa" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" +checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c" dependencies = [ "bitflags 1.3.2", "block", "cocoa-foundation", "core-foundation", "core-graphics", - "foreign-types", + "foreign-types 0.5.0", "libc", "objc", ] @@ -625,6 +718,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "com-rs" version = "0.2.1" @@ -658,14 +757,14 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "core-graphics" -version = "0.22.3" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" +checksum = "970a29baf4110c26fedbc7f82107d42c23f7e88e404c4577ed73fe99ff85a212" dependencies = [ "bitflags 1.3.2", "core-foundation", "core-graphics-types", - "foreign-types", + "foreign-types 0.5.0", "libc", ] @@ -685,6 +784,7 @@ name = "cosmic-app-library" version = "0.1.0" dependencies = [ "anyhow", + "clap", "current_locale", "freedesktop-desktop-entry", "freedesktop-icons", @@ -709,10 +809,19 @@ dependencies = [ "zbus", ] +[[package]] +name = "cosmic-client-toolkit" +version = "0.1.0" +source = "git+https://github.com/pop-os/cosmic-protocols?rev=5faec87#5faec87be0a1fd1d72e99431ac8e6647ff1dfd41" +dependencies = [ + "cosmic-protocols", + "smithay-client-toolkit 0.18.0", + "wayland-client 0.31.1", +] + [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -726,12 +835,24 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "quote", "syn 1.0.109", ] +[[package]] +name = "cosmic-protocols" +version = "0.1.0" +source = "git+https://github.com/pop-os/cosmic-protocols?rev=5faec87#5faec87be0a1fd1d72e99431ac8e6647ff1dfd41" +dependencies = [ + "bitflags 2.4.1", + "wayland-backend 0.3.2", + "wayland-client 0.31.1", + "wayland-protocols 0.31.0", + "wayland-scanner 0.31.0", + "wayland-server", +] + [[package]] name = "cosmic-text" version = "0.9.0" @@ -755,7 +876,6 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "almost", "cosmic-config", @@ -859,6 +979,16 @@ dependencies = [ "serde", ] +[[package]] +name = "ctor" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583" +dependencies = [ + "quote", + "syn 2.0.39", +] + [[package]] name = "current_locale" version = "0.1.1" @@ -1022,7 +1152,7 @@ dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -1057,6 +1187,41 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +[[package]] +name = "drm" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb1b703ffbc7ebd216eba7900008049a56ace55580ecb2ee7fa801e8d8be87" +dependencies = [ + "bitflags 2.4.1", + "bytemuck", + "drm-ffi", + "drm-fourcc", + "nix 0.27.1", +] + +[[package]] +name = "drm-ffi" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba7d1c19c4b6270e89d59fb27dc6d02a317c658a8a54e54781e1db9b5947595d" +dependencies = [ + "drm-sys", + "nix 0.27.1", +] + +[[package]] +name = "drm-fourcc" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aafbcdb8afc29c1a7ee5fbe53b5d62f4565b35a042a662ca9fecd0b54dae6f4" + +[[package]] +name = "drm-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a4f1c0468062a56cd5705f1e3b5409eb286d5596a2028ec8e947595d7e715ae" + [[package]] name = "either" version = "1.9.0" @@ -1116,19 +1281,19 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" +checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "etagere" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf22f748754352918e082e0039335ee92454a5d62bcaf69b5e8daf5907d9644" +checksum = "306960881d6c46bd0dd6b7f07442a441418c08d0d3e63d8d080b0f64c6343e4e" dependencies = [ "euclid", "svg_fmt", @@ -1225,7 +1390,7 @@ dependencies = [ "cfg-if", "libc", "redox_syscall 0.3.5", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -1354,7 +1519,28 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" dependencies = [ - "foreign-types-shared", + "foreign-types-shared 0.1.1", +] + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared 0.3.1", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", ] [[package]] @@ -1363,6 +1549,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + [[package]] name = "form_urlencoded" version = "1.2.0" @@ -1487,7 +1679,11 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" dependencies = [ + "fastrand 2.0.1", "futures-core", + "futures-io", + "memchr", + "parking", "pin-project-lite", ] @@ -1544,9 +1740,9 @@ dependencies = [ [[package]] name = "gethostname" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +checksum = "bb65d4ba3173c56a500b555b532f72c42e8d1fe64962b518897f8959fae2c177" dependencies = [ "libc", "winapi", @@ -1852,7 +2048,6 @@ dependencies = [ [[package]] name = "iced" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "iced_accessibility", "iced_core", @@ -1867,7 +2062,6 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "accesskit", "accesskit_unix", @@ -1876,13 +2070,13 @@ dependencies = [ [[package]] name = "iced_core" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "bitflags 1.3.2", "iced_accessibility", "instant", "log", "palette", + "serde", "smithay-client-toolkit 0.18.0", "thiserror", "twox-hash", @@ -1891,7 +2085,6 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.7.0" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "futures", "iced_core", @@ -1904,7 +2097,6 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -1922,7 +2114,6 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -1935,7 +2126,6 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.1.1" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "iced_accessibility", "iced_core", @@ -1947,7 +2137,6 @@ dependencies = [ [[package]] name = "iced_sctk" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "enum-repr", "float-cmp", @@ -1971,7 +2160,6 @@ dependencies = [ [[package]] name = "iced_style" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "iced_core", "once_cell", @@ -1981,7 +2169,6 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "bytemuck", "cosmic-text", @@ -1999,7 +2186,6 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.11.1" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2021,7 +2207,6 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.1.3" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "iced_renderer", "iced_runtime", @@ -2150,9 +2335,15 @@ checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.48.0", + "windows-sys", ] +[[package]] +name = "io-lifetimes" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bffb4def18c48926ccac55c1223e02865ce1a821751a95920448662696e7472c" + [[package]] name = "is-terminal" version = "0.4.9" @@ -2160,8 +2351,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.21", - "windows-sys 0.48.0", + "rustix 0.38.25", + "windows-sys", ] [[package]] @@ -2270,10 +2461,10 @@ checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic/#405aaf134d00a6aef223aef3799b3904b1050b0c" dependencies = [ "apply", "ashpd", + "cosmic-client-toolkit", "cosmic-config", "cosmic-theme", "css-color", @@ -2291,14 +2482,16 @@ dependencies = [ "iced_widget", "lazy_static", "palette", + "ron", + "serde", "slotmap", - "smithay-client-toolkit 0.17.0", "taffy", "thiserror", "tokio", "tracing", "unicode-segmentation", "url", + "zbus", ] [[package]] @@ -2318,7 +2511,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" dependencies = [ "cfg-if", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -2400,9 +2593,9 @@ dependencies = [ [[package]] name = "lyon_algorithms" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00a0349cd8f0270781bb93a824b63df6178e3b4a27794e7be3ce3763f5a44d6e" +checksum = "a3bca95f9a4955b3e4a821fbbcd5edfbd9be2a9a50bb5758173e5358bfb4c623" dependencies = [ "lyon_path", "num-traits", @@ -2473,15 +2666,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memmap2" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f49388d20533534cd19360ad3d6a7dadc885944aa802ba3995040c5ec11288c6" -dependencies = [ - "libc", -] - [[package]] name = "memmap2" version = "0.8.0" @@ -2536,7 +2720,7 @@ dependencies = [ "bitflags 1.3.2", "block", "core-graphics-types", - "foreign-types", + "foreign-types 0.3.2", "log", "objc", ] @@ -2566,7 +2750,7 @@ dependencies = [ "libc", "log", "wasi", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -2618,28 +2802,26 @@ dependencies = [ [[package]] name = "nix" -version = "0.25.1" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" dependencies = [ - "autocfg", "bitflags 1.3.2", "cfg-if", "libc", - "memoffset 0.6.5", + "memoffset 0.7.1", + "pin-utils", ] [[package]] name = "nix" -version = "0.26.4" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "cfg-if", "libc", - "memoffset 0.7.1", - "pin-utils", ] [[package]] @@ -2668,7 +2850,7 @@ dependencies = [ "log", "mio", "walkdir", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -3069,7 +3251,7 @@ dependencies = [ "libc", "log", "pin-project-lite", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -3081,9 +3263,9 @@ dependencies = [ "cfg-if", "concurrent-queue", "pin-project-lite", - "rustix 0.38.21", + "rustix 0.38.25", "tracing", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -3445,23 +3627,23 @@ checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ "bitflags 1.3.2", "errno", - "io-lifetimes", + "io-lifetimes 1.0.11", "libc", "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "rustix" -version = "0.38.21" +version = "0.38.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" dependencies = [ "bitflags 2.4.1", "errno", "libc", "linux-raw-sys 0.4.11", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -3673,33 +3855,6 @@ dependencies = [ "wayland-protocols 0.29.5", ] -[[package]] -name = "smithay-client-toolkit" -version = "0.17.0" -source = "git+https://github.com/smithay/client-toolkit?rev=dc8c4a0#dc8c4a035128208af65141fe12142a1dbc4a32bb" -dependencies = [ - "bitflags 2.4.1", - "bytemuck", - "calloop", - "calloop-wayland-source", - "cursor-icon", - "dlib", - "log", - "memmap2 0.7.1", - "nix 0.26.4", - "pkg-config", - "thiserror", - "wayland-backend 0.3.2", - "wayland-client 0.31.1", - "wayland-csd-frame", - "wayland-cursor 0.31.0", - "wayland-protocols 0.31.0", - "wayland-protocols-wlr", - "wayland-scanner 0.31.0", - "xkbcommon 0.5.1", - "xkeysym", -] - [[package]] name = "smithay-client-toolkit" version = "0.18.0" @@ -3714,7 +3869,7 @@ dependencies = [ "log", "memmap2 0.9.0", "pkg-config", - "rustix 0.38.21", + "rustix 0.38.25", "thiserror", "wayland-backend 0.3.2", "wayland-client 0.31.1", @@ -3723,7 +3878,7 @@ dependencies = [ "wayland-protocols 0.31.0", "wayland-protocols-wlr", "wayland-scanner 0.31.0", - "xkbcommon 0.7.0", + "xkbcommon", "xkeysym", ] @@ -3754,33 +3909,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "softbuffer" -version = "0.2.0" -source = "git+https://github.com/pop-os/softbuffer?tag=cosmic-2.0-old#ece901a9f60dc89ca740dc3bd11f3c909e801723" +version = "0.3.3" +source = "git+https://github.com/pop-os/softbuffer?tag=v0.3-cosmic#6f0371ccece51d124c6c5d37082189df0dc5f9ba" dependencies = [ + "as-raw-xcb-connection", "bytemuck", "cfg_aliases", "cocoa", "core-graphics", - "fastrand 1.9.0", - "foreign-types", + "drm", + "fastrand 2.0.1", + "foreign-types 0.5.0", + "js-sys", "log", - "nix 0.26.4", + "memmap2 0.9.0", "objc", "raw-window-handle", - "redox_syscall 0.3.5", - "thiserror", + "redox_syscall 0.4.1", + "rustix 0.38.25", + "tiny-xlib", "wasm-bindgen", - "wayland-backend 0.1.2", - "wayland-client 0.30.2", - "wayland-sys 0.30.1", + "wayland-backend 0.3.2", + "wayland-client 0.31.1", + "wayland-sys 0.31.1", "web-sys", - "windows-sys 0.42.0", - "x11-dl", + "windows-sys", "x11rb", ] @@ -3907,15 +4065,15 @@ dependencies = [ "cfg-if", "fastrand 2.0.1", "redox_syscall 0.4.1", - "rustix 0.38.21", - "windows-sys 0.48.0", + "rustix 0.38.25", + "windows-sys", ] [[package]] name = "termcolor" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" dependencies = [ "winapi-util", ] @@ -3977,11 +4135,23 @@ dependencies = [ "strict-num", ] +[[package]] +name = "tiny-xlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4098d49269baa034a8d1eae9bd63e9fa532148d772121dace3bcd6a6c98eb6d" +dependencies = [ + "as-raw-xcb-connection", + "ctor", + "libloading 0.8.1", + "tracing", +] + [[package]] name = "tinystr" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0e245e80bdc9b4e5356fc45a72184abbc3861992603f515270e9340f5a219" +checksum = "83c02bf3c538ab32ba913408224323915f4ef9a6d61c0e85d493f355921c0ece" dependencies = [ "displaydoc", ] @@ -4016,7 +4186,7 @@ dependencies = [ "signal-hook-registry", "socket2 0.5.5", "tracing", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -4319,6 +4489,12 @@ dependencies = [ "tiny-skia-path", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "version_check" version = "0.9.4" @@ -4436,7 +4612,7 @@ checksum = "41b48e27457e8da3b2260ac60d0a94512f5cba36448679f3747c0865b7893ed8" dependencies = [ "cc", "downcast-rs", - "io-lifetimes", + "io-lifetimes 1.0.11", "nix 0.26.4", "scoped-tls", "smallvec", @@ -4576,6 +4752,7 @@ dependencies = [ "wayland-backend 0.3.2", "wayland-client 0.31.1", "wayland-scanner 0.31.0", + "wayland-server", ] [[package]] @@ -4624,6 +4801,20 @@ dependencies = [ "quote", ] +[[package]] +name = "wayland-server" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f3f0c52a445936ca1184c98f1a69cf4ad9c9130788884531ef04428468cb1ce" +dependencies = [ + "bitflags 2.4.1", + "downcast-rs", + "io-lifetimes 2.0.2", + "nix 0.26.4", + "wayland-backend 0.3.2", + "wayland-scanner 0.31.0", +] + [[package]] name = "wayland-sys" version = "0.29.5" @@ -4642,7 +4833,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96b2a02ac608e07132978689a6f9bf4214949c85998c247abadd4f4129b1aa06" dependencies = [ "dlib", - "lazy_static", "log", "pkg-config", ] @@ -4655,6 +4845,7 @@ checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af" dependencies = [ "dlib", "log", + "once_cell", "pkg-config", ] @@ -4735,7 +4926,7 @@ dependencies = [ "block", "core-graphics-types", "d3d12", - "foreign-types", + "foreign-types 0.3.2", "glow", "gpu-alloc", "gpu-allocator", @@ -4829,21 +5020,6 @@ dependencies = [ "windows-targets 0.42.2", ] -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -4976,27 +5152,17 @@ dependencies = [ "memchr", ] -[[package]] -name = "x11-dl" -version = "2.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" -dependencies = [ - "libc", - "once_cell", - "pkg-config", -] - [[package]] name = "x11rb" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf3c79412dd91bae7a7366b8ad1565a85e35dd049affc3a6a2c549e97419617" +checksum = "b1641b26d4dec61337c35a1b1aaf9e3cba8f46f0b43636c609ab0291a648040a" dependencies = [ + "as-raw-xcb-connection", "gethostname", "libc", "libloading 0.7.4", - "nix 0.25.1", + "nix 0.26.4", "once_cell", "winapi", "winapi-wsapoll", @@ -5005,11 +5171,11 @@ dependencies = [ [[package]] name = "x11rb-protocol" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0b1513b141123073ce54d5bb1d33f801f17508fbd61e02060b1214e96d39c56" +checksum = "82d6c3f9a0fb6701fab8f6cea9b0c0bd5d6876f1f89f7fada07e558077c344bc" dependencies = [ - "nix 0.25.1", + "nix 0.26.4", ] [[package]] @@ -5037,16 +5203,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "xkbcommon" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52db25b599e92bf6e3904134618728eeb7b49a5a4f38f107f92399bb9c496b88" -dependencies = [ - "libc", - "memmap2 0.7.1", -] - [[package]] name = "xkbcommon" version = "0.7.0" @@ -5166,18 +5322,18 @@ checksum = "dd15f8e0dbb966fd9245e7498c7e9e5055d9e5c8b676b95bd67091cd11a1e697" [[package]] name = "zerocopy" -version = "0.7.25" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.25" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 433e5ee..e32f724 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ authors = ["Ashley Wulber "] edition = "2021" [dependencies] -libcosmic = { git = "https://github.com/pop-os/libcosmic/", default-features = false, features = ["wayland", "tokio"] } -# libcosmic = { path = "../libcosmic", default-features = false, features = ["wayland", "tokio"] } +# libcosmic = { git = "https://github.com/pop-os/libcosmic/", default-features = false, features = ["wayland", "tokio"] } +libcosmic = { path = "../libcosmic", default-features = false, features = ["wayland", "tokio", "single-instance"] } tokio = { version = "1.17.0", features = ["sync", "rt", "process"] } pretty_env_logger = "0.5" log = "0.4" @@ -30,6 +30,6 @@ freedesktop-icons = "0.2.4" current_locale = "0.1.1" url = "2.4" nix = "0.26" - +clap = { version = "4.4.8", features = ["derive"] } [profile.release] lto = "thin" diff --git a/src/app.rs b/src/app.rs index be92036..e783964 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,9 +1,11 @@ use std::fmt::Debug; +use std::str::FromStr; use std::sync::Arc; -use cosmic::app::{Command, Core, Settings}; -use cosmic::cosmic_config::{Config, ConfigSet, CosmicConfigEntry}; +use clap::{Parser, Subcommand}; +use cosmic::app::{Command, Core, CosmicFlags, DbusActivationDetails, Settings}; +use cosmic::cosmic_config::{Config, CosmicConfigEntry}; use cosmic::cosmic_theme::Spacing; use cosmic::iced::id::Id; use cosmic::iced::subscription::events_with; @@ -31,17 +33,17 @@ use cosmic::theme::{self, Button, TextInput}; use cosmic::widget::button::StyleSheet as ButtonStyleSheet; use cosmic::widget::icon::{from_name, from_path}; use cosmic::widget::{button, icon, search_input, text_input, tooltip, Column}; -use cosmic::{iced, sctk, Element, Theme}; +use cosmic::{cctk::sctk, iced, Element, Theme}; use iced::wayland::actions::layer_surface::IcedMargin; - use itertools::Itertools; use log::error; use once_cell::sync::Lazy; +use ron::error::SpannedError; +use serde::{Deserialize, Serialize}; use crate::app_group::{AppLibraryConfig, DesktopEntryData}; use crate::fl; use crate::subscriptions::desktop_files::desktop_files; -use crate::subscriptions::toggle_dbus::dbus_toggle; use crate::widgets::application::ApplicationButton; use crate::widgets::group::GroupButton; @@ -67,8 +69,53 @@ const DELETE_GROUP_WINDOW_ID: SurfaceId = SurfaceId(3); pub(crate) const DND_ICON_ID: SurfaceId = SurfaceId(4); pub(crate) const MENU_ID: SurfaceId = SurfaceId(5); +#[derive(Parser, Debug, Serialize, Deserialize, Clone)] +#[command(author, version, about, long_about = None)] +#[command(propagate_version = true)] +pub struct Args { + #[command(subcommand)] + subcommand: Option, +} + +#[derive(Subcommand, Debug, Serialize, Deserialize, Clone)] +pub enum LauncherCommands { + /// Open the launcher + Open, + /// Close the launcher + Close, +} + +impl FromStr for LauncherCommands { + type Err = SpannedError; + + fn from_str(s: &str) -> Result { + ron::de::from_str(s) + } +} + +impl ToString for LauncherCommands { + fn to_string(&self) -> String { + ron::ser::to_string(self).unwrap() + } +} + +impl CosmicFlags for Args { + type SubCommand = LauncherCommands; + type Args = Vec; + + fn action(&self) -> Option<&LauncherCommands> { + self.subcommand.as_ref() + } +} + +impl From>> for Message { + fn from(msg: DbusActivationDetails>) -> Self { + Message::DbusActivation(msg) + } +} + pub fn run() -> cosmic::iced::Result { - cosmic::app::run::( + cosmic::app::run_single_instance::( Settings::default() .antialiasing(true) .client_decorations(true) @@ -78,9 +125,8 @@ pub fn run() -> cosmic::iced::Result { .scale_factor(1.0) .no_main_window(true) .exit_on_close(false), - (), - )?; - Ok(()) + Args::parse(), + ) } #[derive(Default)] @@ -106,7 +152,6 @@ struct CosmicAppLibrary { enum Message { InputChanged(String), Layer(LayerEvent), - Toggle, Hide, Clear, ActivateApp(usize), @@ -133,8 +178,9 @@ enum Message { StartDndOffer(usize), FinishDndOffer(usize, DesktopEntryData), LeaveDndOffer, - Ignore, ScrollYOffset(f32), + DbusActivation(DbusActivationDetails>), + Ignore, } #[derive(Clone)] @@ -159,12 +205,30 @@ impl CosmicAppLibrary { .filtered(self.cur_group, self.locale.as_deref(), &self.search_value); self.entry_path_input.sort_by(|a, b| a.name.cmp(&b.name)); } + + pub fn hide(&mut self) -> Command { + self.active_surface = false; + self.new_group = None; + self.search_value.clear(); + self.edit_name = None; + self.cur_group = 0; + self.group_to_delete = None; + self.load_apps(); + iced::Command::batch(vec![ + text_input::focus(SEARCH_ID.clone()), + destroy_layer_surface(NEW_GROUP_WINDOW_ID), + destroy_layer_surface(DELETE_GROUP_WINDOW_ID), + destroy_layer_surface(WINDOW_ID), + cancel_dnd(), + iced::Command::perform(async {}, |_| cosmic::app::Message::App(Message::Clear)), + ]) + } } impl cosmic::Application for CosmicAppLibrary { type Message = Message; type Executor = executor::Default; - type Flags = (); + type Flags = Args; const APP_ID: &'static str = "com.system76.CosmicAppLibrary"; fn core(&self) -> &Core { @@ -202,18 +266,7 @@ impl cosmic::Application for CosmicAppLibrary { return commands::popup::destroy_popup(MENU_ID); } if self.active_surface { - self.active_surface = false; - self.edit_name = None; - self.new_group = None; - return iced::Command::batch(vec![ - destroy_layer_surface(NEW_GROUP_WINDOW_ID), - destroy_layer_surface(DELETE_GROUP_WINDOW_ID), - destroy_layer_surface(WINDOW_ID), - cancel_dnd(), - iced::Command::perform(async {}, |_| { - cosmic::app::Message::App(Message::Clear) - }), - ]); + return self.hide(); } } Message::Clear => { @@ -244,7 +297,7 @@ impl cosmic::Application for CosmicAppLibrary { }; for arg in exec { // TODO handle "%" args here if necessary? - if !arg.starts_with("%") { + if !arg.starts_with('%') { cmd.arg(arg); } } @@ -264,44 +317,9 @@ impl cosmic::Application for CosmicAppLibrary { self.scroll_offset = 0.0; self.load_apps(); } - Message::Toggle => { - if self.active_surface { - self.active_surface = false; - self.new_group = None; - return Command::batch(vec![ - destroy_layer_surface(NEW_GROUP_WINDOW_ID), - destroy_layer_surface(DELETE_GROUP_WINDOW_ID), - destroy_layer_surface(WINDOW_ID), - ]); - } else { - let mut cmds = Vec::new(); - self.edit_name = None; - self.search_value = "".to_string(); - self.active_surface = true; - self.scroll_offset = 0.0; - self.cur_group = 0; - cmds.push(text_input::focus(SEARCH_ID.clone())); - cmds.push(get_layer_surface(SctkLayerSurfaceSettings { - id: WINDOW_ID, - keyboard_interactivity: KeyboardInteractivity::Exclusive, - anchor: Anchor::TOP, - namespace: "app-library".into(), - size: None, - margin: IcedMargin { - top: 16, - right: 0, - bottom: 0, - left: 0, - }, - ..Default::default() - })); - return Command::batch(cmds); - } - } Message::LoadApps => { self.load_apps(); } - Message::Ignore => {} Message::Delete(group) => { self.group_to_delete = Some(group); return get_layer_surface(SctkLayerSurfaceSettings { @@ -363,9 +381,9 @@ impl cosmic::Application for CosmicAppLibrary { return destroy_layer_surface(NEW_GROUP_WINDOW_ID); } Message::OpenContextMenu(rect, i) => { - if let Some(i) = self.menu.take() { - if i == i { - return commands::popup::destroy_popup(MENU_ID.clone()); + if let Some(cur_i) = self.menu.take() { + if i == cur_i { + return commands::popup::destroy_popup(MENU_ID); } } else { self.menu = Some(i); @@ -394,7 +412,7 @@ impl cosmic::Application for CosmicAppLibrary { } Message::CloseContextMenu => { self.menu = None; - return commands::popup::destroy_popup(MENU_ID.clone()); + return commands::popup::destroy_popup(MENU_ID); } Message::SelectAction(action) => { if let Some(info) = self.menu.take().and_then(|i| self.entry_path_input.get(i)) { @@ -412,20 +430,20 @@ impl cosmic::Application for CosmicAppLibrary { let mut exec = shlex::Shlex::new(&exec); let mut cmd = match exec.next() { - Some(cmd) if !cmd.contains("=") => { + Some(cmd) if !cmd.contains('=') => { tokio::process::Command::new(cmd) } _ => return Command::none(), }; for arg in exec { // TODO handle "%" args here if necessary? - if !arg.starts_with("%") { + if !arg.starts_with('%') { cmd.arg(arg); } } let _ = cmd.spawn(); return iced::Command::batch(vec![ - commands::popup::destroy_popup(MENU_ID.clone()), + commands::popup::destroy_popup(MENU_ID), iced::Command::perform(async {}, |_| { cosmic::app::Message::App(Message::Hide) }), @@ -435,7 +453,6 @@ impl cosmic::Application for CosmicAppLibrary { } } Message::StartDrag(i) => { - // self.dnd_icon = self.entry_path_input.get(i).map(|e| e.icon.clone()); self.dnd_icon = Some(i); } Message::FinishDrag(copy) => { @@ -445,7 +462,7 @@ impl cosmic::Application for CosmicAppLibrary { .take() .and_then(|i| self.entry_path_input.get(i)) { - let _ = self.config.remove_entry(self.cur_group, &info.id); + self.config.remove_entry(self.cur_group, &info.id); if let Some(helper) = self.helper.as_ref() { if let Err(err) = self.config.write_entry(helper) { error!("{:?}", err); @@ -502,6 +519,49 @@ impl cosmic::Application for CosmicAppLibrary { self.group_to_delete = None; return destroy_layer_surface(DELETE_GROUP_WINDOW_ID); } + Message::DbusActivation(details) => match details { + DbusActivationDetails::ActivateAction { + action: LauncherCommands::Open, + args: _, + } + | DbusActivationDetails::Activate + if !self.active_surface => + { + self.edit_name = None; + self.search_value = "".to_string(); + self.active_surface = true; + self.scroll_offset = 0.0; + self.cur_group = 0; + return Command::batch(vec![ + text_input::focus(SEARCH_ID.clone()), + get_layer_surface(SctkLayerSurfaceSettings { + id: WINDOW_ID, + keyboard_interactivity: KeyboardInteractivity::Exclusive, + anchor: Anchor::TOP, + namespace: "app-library".into(), + size: None, + margin: IcedMargin { + top: 16, + right: 0, + bottom: 0, + left: 0, + }, + ..Default::default() + }), + ]); + } + DbusActivationDetails::ActivateAction { + action: LauncherCommands::Close, + args: _, + } + | DbusActivationDetails::Activate + if self.active_surface => + { + return self.hide(); + } + _ => {} + }, + Message::Ignore => {} } Command::none() } @@ -516,7 +576,6 @@ impl cosmic::Application for CosmicAppLibrary { if id == DND_ICON_ID { let Some(icon_path) = self .dnd_icon - .clone() .and_then(|i| self.entry_path_input.get(i).map(|e| e.icon.clone())) else { return container(horizontal_space(Length::Fixed(1.0))) @@ -1047,19 +1106,15 @@ impl cosmic::Application for CosmicAppLibrary { fn subscription(&self) -> Subscription { Subscription::batch( vec![ - dbus_toggle(0).map(|_| Message::Toggle), desktop_files(0).map(|_| Message::LoadApps), events_with(|e, _status| match e { cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland( wayland::Event::Layer(e, ..), )) => Some(Message::Layer(e)), cosmic::iced::Event::Keyboard(cosmic::iced::keyboard::Event::KeyReleased { - key_code, + key_code: KeyCode::Escape, modifiers: _mods, - }) => match key_code { - KeyCode::Escape => Some(Message::Hide), - _ => None, - }, + }) => Some(Message::Hide), _ => None, }), ] diff --git a/src/app_group.rs b/src/app_group.rs index 89a09ff..ebe0c3e 100644 --- a/src/app_group.rs +++ b/src/app_group.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use std::vec; use cosmic::cosmic_config::cosmic_config_derive::CosmicConfigEntry; -use cosmic::cosmic_config::{self, Config, ConfigGet, ConfigSet, CosmicConfigEntry}; +use cosmic::cosmic_config::{self, CosmicConfigEntry}; use freedesktop_desktop_entry::DesktopEntry; use itertools::Itertools; use once_cell::sync::Lazy; @@ -58,7 +58,7 @@ impl AppGroup { std::fs::read_to_string(&path).ok().and_then(|input| { DesktopEntry::decode(&path, &input).ok().and_then(|de| { let name = de - .name(locale.as_ref().map(|x| &**x)) + .name(locale.as_deref()) .unwrap_or(Cow::Borrowed(de.appid)) .to_string(); let Some(exec) = de.exec() else { @@ -105,7 +105,7 @@ impl AppGroup { .actions() .map(|actions| { actions - .split(";") + .split(';') .filter_map(|action| { let name = de .action_entry_localized(action, "Name", locale); @@ -210,7 +210,7 @@ impl TryFrom for DesktopEntryData { .actions() .map(|actions| { actions - .split(";") + .split(';') .filter_map(|action| { let name = de.action_entry_localized(action, "name", None); let exec = de.action_entry(action, "exec"); diff --git a/src/subscriptions/mod.rs b/src/subscriptions/mod.rs index 2dae1ae..1824a93 100644 --- a/src/subscriptions/mod.rs +++ b/src/subscriptions/mod.rs @@ -1,2 +1 @@ pub mod desktop_files; -pub mod toggle_dbus; diff --git a/src/subscriptions/toggle_dbus.rs b/src/subscriptions/toggle_dbus.rs deleted file mode 100644 index 4d7c4cd..0000000 --- a/src/subscriptions/toggle_dbus.rs +++ /dev/null @@ -1,84 +0,0 @@ -use cosmic::iced::subscription; -use futures::{ - channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender}, - StreamExt, -}; -use log::error; -use std::{fmt::Debug, hash::Hash}; -use zbus::{dbus_interface, Connection, ConnectionBuilder}; - -pub fn dbus_toggle( - id: I, -) -> cosmic::iced::Subscription<(I, DbusEvent)> { - subscription::unfold(id, State::Ready, move |mut state| async move { - loop { - let (event, new_state) = start_listening(id, state).await; - state = new_state; - if let Some(event) = event { - return (event, state); - } - } - }) -} - -#[derive(Debug)] -pub enum State { - Ready, - Waiting(Connection, UnboundedReceiver), - Finished, -} - -async fn start_listening(id: I, state: State) -> (Option<(I, DbusEvent)>, State) { - match state { - State::Ready => { - let (tx, rx) = unbounded(); - if let Some(conn) = ConnectionBuilder::session() - .ok() - .and_then(|conn| conn.name("com.system76.CosmicAppLibrary").ok()) - .and_then(|conn| { - conn.serve_at( - "/com/system76/CosmicAppLibrary", - CosmicAppLibraryServer { tx }, - ) - .ok() - }) - .map(|conn| conn.build()) - { - match conn.await { - Ok(conn) => { - return (None, State::Waiting(conn, rx)); - } - Err(e) => { - error!("{e:?}"); - } - } - } - return (None, State::Finished); - } - State::Waiting(conn, mut rx) => { - if let Some(DbusEvent::Toggle) = rx.next().await { - (Some((id, DbusEvent::Toggle)), State::Waiting(conn, rx)) - } else { - (None, State::Finished) - } - } - State::Finished => cosmic::iced::futures::future::pending().await, - } -} - -#[derive(Debug, Clone, Copy)] -pub enum DbusEvent { - Toggle, -} - -#[derive(Debug)] -pub(crate) struct CosmicAppLibraryServer { - pub(crate) tx: UnboundedSender, -} - -#[dbus_interface(name = "com.system76.CosmicAppLibrary")] -impl CosmicAppLibraryServer { - async fn toggle(&self) { - self.tx.unbounded_send(DbusEvent::Toggle).unwrap(); - } -} diff --git a/src/widgets/application.rs b/src/widgets/application.rs index 598e151..88d0138 100644 --- a/src/widgets/application.rs +++ b/src/widgets/application.rs @@ -3,12 +3,12 @@ use std::mem; use std::path::PathBuf; +use cosmic::cctk::sctk::reexports::client::protocol::wl_data_device_manager::DndAction; use cosmic::cosmic_theme::Spacing; use cosmic::iced::wayland::actions::data_device::{DataFromMimeType, DndIcon}; use cosmic::iced_core::alignment::Horizontal; use cosmic::iced_core::event::{wayland, PlatformSpecific}; use cosmic::iced_runtime::command::platform_specific; -use cosmic::sctk::reexports::client::protocol::wl_data_device_manager::DndAction; use cosmic::iced_core::{ event, layout, mouse, overlay, renderer, touch, Alignment, Clipboard, Element, Event, Length, @@ -18,10 +18,7 @@ use cosmic::iced_core::{ use cosmic::iced_core::widget::{operation::OperationOutputWrapper, tree, Operation, Tree}; use cosmic::widget::icon::from_path; use cosmic::{ - iced::{ - self, - widget::{column, text}, - }, + iced::widget::{column, text}, theme, widget::{button, icon}, }; diff --git a/src/widgets/group.rs b/src/widgets/group.rs index ff67047..f984a1e 100644 --- a/src/widgets/group.rs +++ b/src/widgets/group.rs @@ -4,12 +4,12 @@ use std::mem; use std::str::FromStr; +use cosmic::cctk::sctk::reexports::client::protocol::wl_data_device_manager::DndAction; use cosmic::cosmic_theme::Spacing; use cosmic::iced_core::alignment::Horizontal; use cosmic::iced_core::event::{wayland, PlatformSpecific}; use cosmic::iced_runtime::command::platform_specific; use cosmic::iced_widget::graphics::image::image_rs::EncodableLayout; -use cosmic::sctk::reexports::client::protocol::wl_data_device_manager::DndAction; use cosmic::iced_core::{ event, layout, mouse, overlay, renderer, Alignment, Clipboard, Element, Event, Length, Padding,