Init Animations: animate toggler widgets (#96)

This commit is contained in:
Brock 2023-06-07 13:43:49 -06:00 committed by GitHub
parent 8119b29aca
commit 3ec06bef80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 251 additions and 153 deletions

167
Cargo.lock generated
View file

@ -75,9 +75,9 @@ dependencies = [
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "1.0.1" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@ -493,10 +493,11 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
[[package]] [[package]]
name = "calloop" name = "calloop"
version = "0.10.5" version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a59225be45a478d772ce015d9743e49e92798ece9e34eda9a6aa2a6a7f40192" checksum = "52e0d00eb1ea24371a97d2da6201c6747a633dc6dc1988ef503403b4c59504a8"
dependencies = [ dependencies = [
"bitflags 1.3.2",
"log", "log",
"nix 0.25.1", "nix 0.25.1",
"slotmap", "slotmap",
@ -512,9 +513,9 @@ checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
[[package]] [[package]]
name = "cfg-expr" name = "cfg-expr"
version = "0.15.1" version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8790cf1286da485c72cf5fc7aeba308438800036ec67d89425924c4807268c9" checksum = "e70d3ad08698a0568b0562f22710fe6bfc1f4a61a367c77d0398c562eadd453a"
dependencies = [ dependencies = [
"smallvec", "smallvec",
"target-lexicon", "target-lexicon",
@ -703,6 +704,7 @@ name = "cosmic-applet-audio"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cosmic-applet", "cosmic-applet",
"cosmic-time",
"i18n-embed", "i18n-embed",
"i18n-embed-fl", "i18n-embed-fl",
"icon-loader", "icon-loader",
@ -710,7 +712,6 @@ dependencies = [
"libpulse-binding", "libpulse-binding",
"libpulse-glib-binding", "libpulse-glib-binding",
"log", "log",
"once_cell",
"pretty_env_logger 0.4.0", "pretty_env_logger 0.4.0",
"rust-embed", "rust-embed",
"rust-embed-utils", "rust-embed-utils",
@ -722,6 +723,7 @@ name = "cosmic-applet-battery"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cosmic-applet", "cosmic-applet",
"cosmic-time",
"futures", "futures",
"i18n-embed", "i18n-embed",
"i18n-embed-fl", "i18n-embed-fl",
@ -776,6 +778,7 @@ dependencies = [
"anyhow", "anyhow",
"cosmic-applet", "cosmic-applet",
"cosmic-dbus-networkmanager", "cosmic-dbus-networkmanager",
"cosmic-time",
"futures", "futures",
"futures-util", "futures-util",
"i18n-embed", "i18n-embed",
@ -783,7 +786,6 @@ dependencies = [
"itertools", "itertools",
"libcosmic", "libcosmic",
"log", "log",
"once_cell",
"pretty_env_logger 0.5.0", "pretty_env_logger 0.5.0",
"rust-embed", "rust-embed",
"rust-embed-utils", "rust-embed-utils",
@ -797,6 +799,7 @@ name = "cosmic-applet-notifications"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cosmic-applet", "cosmic-applet",
"cosmic-time",
"icon-loader", "icon-loader",
"libcosmic", "libcosmic",
"nix 0.24.3", "nix 0.24.3",
@ -869,7 +872,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/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"atomicwrites", "atomicwrites",
"cosmic-config-derive", "cosmic-config-derive",
@ -883,7 +886,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/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"quote", "quote",
"syn 1.0.109", "syn 1.0.109",
@ -914,7 +917,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-panel-config" name = "cosmic-panel-config"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/cosmic-panel?rev=11cfff0#11cfff080cf22fc2073fe42feca82afc88eef16e" source = "git+https://github.com/pop-os/cosmic-panel?rev=6cef482#6cef482fac0670b77646cbbd57227307abe3c52b"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cosmic-config", "cosmic-config",
@ -960,7 +963,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/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cosmic-config", "cosmic-config",
@ -972,6 +975,15 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "cosmic-time"
version = "0.2.0"
source = "git+https://github.com/pop-os/cosmic-time?rev=e6ff6d5#e6ff6d5f8992a5d7071b3211baf19a74df73f5c0"
dependencies = [
"libcosmic",
"once_cell",
]
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.7" version = "0.2.7"
@ -1176,7 +1188,7 @@ dependencies = [
"hashbrown 0.12.3", "hashbrown 0.12.3",
"lock_api", "lock_api",
"once_cell", "once_cell",
"parking_lot_core 0.9.7", "parking_lot_core 0.9.8",
] ]
[[package]] [[package]]
@ -1354,11 +1366,11 @@ dependencies = [
[[package]] [[package]]
name = "dlib" name = "dlib"
version = "0.5.0" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac1b7517328c04c2aa68422fc60a41b92208182142ed04a25879c26c8f878794" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
dependencies = [ dependencies = [
"libloading 0.7.4", "libloading 0.8.0",
] ]
[[package]] [[package]]
@ -1517,15 +1529,15 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
[[package]] [[package]]
name = "exr" name = "exr"
version = "1.6.3" version = "1.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdd2162b720141a91a054640662d3edce3d50a944a50ffca5313cd951abb35b4" checksum = "279d3efcc55e19917fff7ab3ddd6c14afb6a90881a0078465196fe2f99d08c56"
dependencies = [ dependencies = [
"bit_field", "bit_field",
"flume", "flume",
"half", "half",
"lebe", "lebe",
"miniz_oxide 0.6.2", "miniz_oxide 0.7.1",
"rayon-core", "rayon-core",
"smallvec", "smallvec",
"zune-inflate", "zune-inflate",
@ -1691,9 +1703,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]] [[package]]
name = "form_urlencoded" name = "form_urlencoded"
version = "1.1.0" version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652"
dependencies = [ dependencies = [
"percent-encoding", "percent-encoding",
] ]
@ -1870,9 +1882,9 @@ dependencies = [
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.9" version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"js-sys", "js-sys",
@ -1925,9 +1937,9 @@ checksum = "518faa5064866338b013ff9b2350dc318e14cc4fcd6cb8206d7e7c9886c98815"
[[package]] [[package]]
name = "glib" name = "glib"
version = "0.17.9" version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7f1de7cbde31ea4f0a919453a2dcece5d54d5b70e08f8ad254dc4840f5f09b6" checksum = "d3fad45ba8d4d2cea612b432717e834f48031cd8853c8aaf43b2c79fec8d144b"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"futures-channel", "futures-channel",
@ -1947,9 +1959,9 @@ dependencies = [
[[package]] [[package]]
name = "glib-macros" name = "glib-macros"
version = "0.17.9" version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a7206c5c03851ef126ea1444990e81fdd6765fb799d5bc694e4897ca01bb97f" checksum = "eca5c79337338391f1ab8058d6698125034ce8ef31b72a442437fa6c8580de26"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"heck", "heck",
@ -1962,9 +1974,9 @@ dependencies = [
[[package]] [[package]]
name = "glib-sys" name = "glib-sys"
version = "0.17.4" version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f00ad0a1bf548e61adfff15d83430941d9e1bb620e334f779edd1c745680a5" checksum = "d80aa6ea7bba0baac79222204aa786a6293078c210abe69ef1336911d4bdc4f0"
dependencies = [ dependencies = [
"libc", "libc",
"system-deps", "system-deps",
@ -1972,9 +1984,9 @@ dependencies = [
[[package]] [[package]]
name = "glow" name = "glow"
version = "0.12.1" version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e007a07a24de5ecae94160f141029e9a347282cfe25d1d58d85d845cf3130f1" checksum = "807edf58b70c0b5b2181dd39fe1839dbdb3ba02645630dc5f753e23da307f762"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"slotmap", "slotmap",
@ -1995,9 +2007,9 @@ dependencies = [
[[package]] [[package]]
name = "gobject-sys" name = "gobject-sys"
version = "0.17.4" version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15e75b0000a64632b2d8ca3cf856af9308e3a970844f6e9659bd197f026793d0" checksum = "cd34c3317740a6358ec04572c1bcfd3ac0b5b6529275fae255b237b314bb8062"
dependencies = [ dependencies = [
"glib-sys", "glib-sys",
"libc", "libc",
@ -2246,9 +2258,9 @@ dependencies = [
[[package]] [[package]]
name = "iana-time-zone" name = "iana-time-zone"
version = "0.1.56" version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"core-foundation-sys", "core-foundation-sys",
@ -2270,7 +2282,7 @@ dependencies = [
[[package]] [[package]]
name = "iced" name = "iced"
version = "0.9.0" version = "0.9.0"
source = "git+https://github.com/pop-os/libcosmic/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"iced_accessibility", "iced_accessibility",
"iced_core", "iced_core",
@ -2285,7 +2297,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_accessibility" name = "iced_accessibility"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"accesskit", "accesskit",
"accesskit_unix", "accesskit_unix",
@ -2294,7 +2306,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_core" name = "iced_core"
version = "0.9.0" version = "0.9.0"
source = "git+https://github.com/pop-os/libcosmic/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"iced_accessibility", "iced_accessibility",
@ -2309,7 +2321,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_futures" name = "iced_futures"
version = "0.6.0" version = "0.6.0"
source = "git+https://github.com/pop-os/libcosmic/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"futures", "futures",
"iced_core", "iced_core",
@ -2322,7 +2334,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_graphics" name = "iced_graphics"
version = "0.8.0" version = "0.8.0"
source = "git+https://github.com/pop-os/libcosmic/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"bytemuck", "bytemuck",
@ -2339,7 +2351,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_renderer" name = "iced_renderer"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"iced_graphics", "iced_graphics",
"iced_tiny_skia", "iced_tiny_skia",
@ -2351,7 +2363,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_runtime" name = "iced_runtime"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"iced_accessibility", "iced_accessibility",
"iced_core", "iced_core",
@ -2363,7 +2375,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_sctk" name = "iced_sctk"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"enum-repr", "enum-repr",
"float-cmp", "float-cmp",
@ -2384,7 +2396,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_style" name = "iced_style"
version = "0.8.0" version = "0.8.0"
source = "git+https://github.com/pop-os/libcosmic/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"iced_core", "iced_core",
"once_cell", "once_cell",
@ -2394,7 +2406,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_tiny_skia" name = "iced_tiny_skia"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"cosmic-text", "cosmic-text",
@ -2412,7 +2424,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_wgpu" name = "iced_wgpu"
version = "0.10.0" version = "0.10.0"
source = "git+https://github.com/pop-os/libcosmic/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"bytemuck", "bytemuck",
@ -2434,7 +2446,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_widget" name = "iced_widget"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"iced_renderer", "iced_renderer",
"iced_runtime", "iced_runtime",
@ -2465,9 +2477,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]] [[package]]
name = "idna" name = "idna"
version = "0.3.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c"
dependencies = [ dependencies = [
"unicode-bidi", "unicode-bidi",
"unicode-normalization", "unicode-normalization",
@ -2675,14 +2687,14 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.144" version = "0.2.146"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b"
[[package]] [[package]]
name = "libcosmic" name = "libcosmic"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/?rev=31f7e97#31f7e97d5bf4860be5afd406209eed733f736f04" source = "git+https://github.com/pop-os/libcosmic/?rev=5765053#5765053ad70d7b0fded56fe9e9c73649509a03ae"
dependencies = [ dependencies = [
"apply", "apply",
"cosmic-config", "cosmic-config",
@ -2692,6 +2704,8 @@ dependencies = [
"freedesktop-icons", "freedesktop-icons",
"iced", "iced",
"iced_core", "iced_core",
"iced_futures",
"iced_renderer",
"iced_runtime", "iced_runtime",
"iced_sctk", "iced_sctk",
"iced_style", "iced_style",
@ -2815,9 +2829,9 @@ dependencies = [
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.9" version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"scopeguard", "scopeguard",
@ -3196,18 +3210,18 @@ dependencies = [
[[package]] [[package]]
name = "object" name = "object"
version = "0.30.3" version = "0.30.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.17.2" version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]] [[package]]
name = "option-ext" name = "option-ext"
@ -3331,7 +3345,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [ dependencies = [
"lock_api", "lock_api",
"parking_lot_core 0.9.7", "parking_lot_core 0.9.8",
] ]
[[package]] [[package]]
@ -3350,22 +3364,22 @@ dependencies = [
[[package]] [[package]]
name = "parking_lot_core" name = "parking_lot_core"
version = "0.9.7" version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"redox_syscall 0.2.16", "redox_syscall 0.3.5",
"smallvec", "smallvec",
"windows-sys 0.45.0", "windows-targets 0.48.0",
] ]
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.2.0" version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
[[package]] [[package]]
name = "phf" name = "phf"
@ -3710,9 +3724,9 @@ dependencies = [
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.8.3" version = "1.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
@ -4338,15 +4352,16 @@ checksum = "af547b166dd1ea4b472165569fc456cfb6818116f854690b0ff205e636523dab"
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "3.5.0" version = "3.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6"
dependencies = [ dependencies = [
"autocfg",
"cfg-if", "cfg-if",
"fastrand", "fastrand",
"redox_syscall 0.3.5", "redox_syscall 0.3.5",
"rustix 0.37.19", "rustix 0.37.19",
"windows-sys 0.45.0", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -4725,9 +4740,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]] [[package]]
name = "url" name = "url"
version = "2.3.1" version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb"
dependencies = [ dependencies = [
"form_urlencoded", "form_urlencoded",
"idna", "idna",
@ -5171,9 +5186,9 @@ dependencies = [
[[package]] [[package]]
name = "wgpu-hal" name = "wgpu-hal"
version = "0.16.0" version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41af2ea7d87bd41ad0a37146252d5f7c26490209f47f544b2ee3b3ff34c7732e" checksum = "74851c2c8e5d97652e74c241d41b0656b31c924a45dcdecde83975717362cfa4"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"arrayvec", "arrayvec",
@ -5527,9 +5542,9 @@ dependencies = [
[[package]] [[package]]
name = "xml-rs" name = "xml-rs"
version = "0.8.13" version = "0.8.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d8f380ae16a37b30e6a2cf67040608071384b1450c189e61bea3ff57cde922d" checksum = "52839dc911083a8ef63efa4d039d1f58b5e409f923e44c80828f206f66e5541c"
[[package]] [[package]]
name = "xmlparser" name = "xmlparser"

View file

@ -15,6 +15,8 @@ members = [
"cosmic-panel-button", "cosmic-panel-button",
] ]
resolver="2"
[profile.release] [profile.release]
lto = "thin" lto = "thin"
# lto = "fat" # lto = "fat"

View file

@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
cosmic = { package = "libcosmic", git = "https://github.com/pop-os/libcosmic/", rev = "31f7e97", default-features = false, features = ["wayland", "tokio"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "5765053", default-features = false, features = ["tokio", "wayland"] }
ron = { version = "0.8" } ron = { version = "0.8" }
serde = { version = "1.0" } serde = { version = "1.0" }
cosmic-panel-config = {git = "https://github.com/pop-os/cosmic-panel", rev = "11cfff0" } cosmic-panel-config = { git = "https://github.com/pop-os/cosmic-panel", rev = "6cef482" }

View file

@ -1,16 +1,15 @@
use cosmic::{ use cosmic::{
iced::{self, window, Limits}, iced::{
alignment::{Horizontal, Vertical},
wayland::InitialSurface,
widget::{self, Container},
window, Limits, Color, Element, Length, Rectangle, Settings,
},
iced_style, iced_widget, sctk, iced_style, iced_widget, sctk,
theme::Button, theme::Button,
Renderer, Renderer,
}; };
use cosmic_panel_config::{CosmicPanelBackground, PanelAnchor, PanelSize}; use cosmic_panel_config::{CosmicPanelBackground, PanelAnchor, PanelSize};
use iced::{
alignment::{Horizontal, Vertical},
wayland::InitialSurface,
widget::{self, Container},
Color, Element, Length, Rectangle, Settings,
};
use iced_style::{button::StyleSheet, container::Appearance}; use iced_style::{button::StyleSheet, container::Appearance};
use iced_widget::runtime::command::platform_specific::wayland::{ use iced_widget::runtime::command::platform_specific::wayland::{
popup::{SctkPopupSettings, SctkPositioner}, popup::{SctkPopupSettings, SctkPositioner},

View file

@ -7,7 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "f0cfe09" } cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "f0cfe09" }
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = ["client"], rev = "f0cfe09" } cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = ["client"], rev = "f0cfe09" }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "31f7e97", default-features = false, features = ["wayland", "tokio"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "5765053", default-features = false, features = ["wayland", "tokio"] }
cosmic-applet = { path = "../applet" } cosmic-applet = { path = "../applet" }
# libcosmic = { path = "../../libcosmic", default-features = false, features = ["wayland", "tokio"] } # libcosmic = { path = "../../libcosmic", default-features = false, features = ["wayland", "tokio"] }
ron = "0.8" ron = "0.8"

View file

@ -10,7 +10,8 @@ icon-loader = { version = "0.3.6", features = ["gtk"] }
libpulse-binding = "2.26.0" libpulse-binding = "2.26.0"
libpulse-glib-binding = "2.25.0" libpulse-glib-binding = "2.25.0"
tokio = { version = "1.20.1", features=["full"] } tokio = { version = "1.20.1", features=["full"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "31f7e97", default-features = false, features = ["tokio", "wayland"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "5765053", default-features = false, features = ["tokio", "wayland"] }
cosmic-time = { git = "https://github.com/pop-os/cosmic-time", rev = "e6ff6d5", default-features = false, features = ["libcosmic", "once_cell"] }
cosmic-applet = { path = "../applet" } cosmic-applet = { path = "../applet" }
log = "0.4.14" log = "0.4.14"
pretty_env_logger = "0.4.0" pretty_env_logger = "0.4.0"
@ -19,5 +20,4 @@ i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester
i18n-embed-fl = "0.6" i18n-embed-fl = "0.6"
rust-embed = "6.6" rust-embed = "6.6"
rust-embed-utils = "7.5.0" rust-embed-utils = "7.5.0"
once_cell = "1.17.1"

View file

@ -4,7 +4,7 @@ use i18n_embed::{
fluent::{fluent_language_loader, FluentLanguageLoader}, fluent::{fluent_language_loader, FluentLanguageLoader},
DefaultLocalizer, LanguageLoader, Localizer, DefaultLocalizer, LanguageLoader, Localizer,
}; };
use once_cell::sync::Lazy; use cosmic_time::once_cell::sync::Lazy;
use rust_embed::RustEmbed; use rust_embed::RustEmbed;
#[derive(RustEmbed)] #[derive(RustEmbed)]

View file

@ -11,11 +11,15 @@ use cosmic_applet::{applet_button_theme, CosmicAppletHelper};
use cosmic::iced::{ use cosmic::iced::{
self, self,
widget::{column, row, slider, text, toggler}, widget::{column, row, slider, text},
window, Alignment, Application, Command, Length, Subscription, window, Alignment, Application, Command, Length, Subscription,
}; };
use cosmic::iced_style::application::{self, Appearance}; use cosmic::iced_style::application::{self, Appearance};
use cosmic::{Element, Theme}; use cosmic::{Element, Theme};
use cosmic_time::{
once_cell::sync::Lazy,
anim, chain, id, Timeline, Instant,
};
use iced::wayland::popup::{destroy_popup, get_popup}; use iced::wayland::popup::{destroy_popup, get_popup};
use iced::widget::container; use iced::widget::container;
@ -36,6 +40,8 @@ pub fn main() -> cosmic::iced::Result {
Audio::run(helper.window_settings()) Audio::run(helper.window_settings())
} }
static SHOW_MEDIA_CONTROLS: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
#[derive(Default)] #[derive(Default)]
struct Audio { struct Audio {
is_open: IsOpen, is_open: IsOpen,
@ -50,6 +56,7 @@ struct Audio {
popup: Option<window::Id>, popup: Option<window::Id>,
show_media_controls_in_top_panel: bool, show_media_controls_in_top_panel: bool,
id_ctr: u128, id_ctr: u128,
timeline: Timeline,
} }
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
@ -70,7 +77,8 @@ enum Message {
Pulse(pulse::Event), Pulse(pulse::Event),
Ignore, Ignore,
TogglePopup, TogglePopup,
ToggleMediaControlsInTopPanel(bool), ToggleMediaControlsInTopPanel(chain::Toggler, bool),
Frame(Instant),
} }
impl Application for Audio { impl Application for Audio {
@ -115,6 +123,9 @@ impl Application for Audio {
fn update(&mut self, message: Message) -> Command<Message> { fn update(&mut self, message: Message) -> Command<Message> {
match message { match message {
Message::Frame(now) => {
self.timeline.now(now)
},
Message::TogglePopup => { Message::TogglePopup => {
if let Some(p) = self.popup.take() { if let Some(p) = self.popup.take() {
return destroy_popup(p); return destroy_popup(p);
@ -261,7 +272,8 @@ impl Application for Audio {
pulse::Event::Disconnected => self.pulse_state.disconnected(), pulse::Event::Disconnected => self.pulse_state.disconnected(),
}, },
Message::Ignore => {} Message::Ignore => {}
Message::ToggleMediaControlsInTopPanel(enabled) => { Message::ToggleMediaControlsInTopPanel(chain, enabled) => {
self.timeline.set_chain(chain).start();
self.show_media_controls_in_top_panel = enabled; self.show_media_controls_in_top_panel = enabled;
} }
}; };
@ -270,7 +282,9 @@ impl Application for Audio {
} }
fn subscription(&self) -> Subscription<Message> { fn subscription(&self) -> Subscription<Message> {
pulse::connect().map(Message::Pulse) Subscription::batch(vec![pulse::connect().map(Message::Pulse),
self.timeline.as_subscription().map(Message::Frame),
])
} }
fn view(&self, id: window::Id) -> Element<Message> { fn view(&self, id: window::Id) -> Element<Message> {
@ -375,12 +389,13 @@ impl Application for Audio {
.padding([12, 24]) .padding([12, 24])
.width(Length::Fill), .width(Length::Fill),
container( container(
toggler( anim!( // toggler
Some(fl!("show-media-controls")), SHOW_MEDIA_CONTROLS,
self.show_media_controls_in_top_panel, &self.timeline,
Message::ToggleMediaControlsInTopPanel, Some(fl!("show-media-controls")),
) self.show_media_controls_in_top_panel,
.text_size(14) Message::ToggleMediaControlsInTopPanel,
).text_size(14)
) )
.padding([0, 24]), .padding([0, 24]),
container(divider::horizontal::light()) container(divider::horizontal::light())

View file

@ -5,7 +5,8 @@ edition = "2021"
[dependencies] [dependencies]
once_cell = "1.16.0" once_cell = "1.16.0"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "31f7e97", default-features = false, features = ["tokio", "wayland"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "5765053", default-features = false, features = ["tokio", "wayland"] }
cosmic-time = { git = "https://github.com/pop-os/cosmic-time", rev = "e6ff6d5", default-features = false, features = ["libcosmic", "once_cell"] }
cosmic-applet = { path = "../applet" } cosmic-applet = { path = "../applet" }
futures = "0.3" futures = "0.3"
zbus = { version = "3.13", default-features = false, features = ["tokio"] } zbus = { version = "3.13", default-features = false, features = ["tokio"] }

View file

@ -20,9 +20,14 @@ use cosmic::iced::{
use cosmic::iced_runtime::core::layout::Limits; use cosmic::iced_runtime::core::layout::Limits;
use cosmic::iced_style::application::{self, Appearance}; use cosmic::iced_style::application::{self, Appearance};
use cosmic::theme::Svg; use cosmic::theme::Svg;
use cosmic::widget::{button, divider, icon, toggler}; use cosmic::widget::{button, divider, icon};
use cosmic::{Element, Theme}; use cosmic::{Element, Theme};
use cosmic_applet::{applet_button_theme, CosmicAppletHelper}; use cosmic_applet::{applet_button_theme, CosmicAppletHelper};
use cosmic_time::{
once_cell::sync::Lazy,
anim, chain, id, Timeline, Instant,
};
use log::error; use log::error;
use std::time::Duration; use std::time::Duration;
use tokio::sync::mpsc::UnboundedSender; use tokio::sync::mpsc::UnboundedSender;
@ -48,6 +53,8 @@ pub fn run() -> cosmic::iced::Result {
CosmicBatteryApplet::run(helper.window_settings()) CosmicBatteryApplet::run(helper.window_settings())
} }
static MAX_CHARGE: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
#[derive(Clone, Default)] #[derive(Clone, Default)]
struct CosmicBatteryApplet { struct CosmicBatteryApplet {
icon_name: String, icon_name: String,
@ -64,6 +71,7 @@ struct CosmicBatteryApplet {
applet_helper: CosmicAppletHelper, applet_helper: CosmicAppletHelper,
power_profile: Power, power_profile: Power,
power_profile_sender: Option<UnboundedSender<PowerProfileRequest>>, power_profile_sender: Option<UnboundedSender<PowerProfileRequest>>,
timeline: Timeline,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -76,7 +84,7 @@ enum Message {
}, },
SetKbdBrightness(i32), SetKbdBrightness(i32),
SetScreenBrightness(i32), SetScreenBrightness(i32),
SetChargingLimit(bool), SetChargingLimit(chain::Toggler, bool),
UpdateKbdBrightness(f64), UpdateKbdBrightness(f64),
UpdateScreenBrightness(f64), UpdateScreenBrightness(f64),
OpenBatterySettings, OpenBatterySettings,
@ -87,6 +95,7 @@ enum Message {
InitProfile(UnboundedSender<PowerProfileRequest>, Power), InitProfile(UnboundedSender<PowerProfileRequest>, Power),
Profile(Power), Profile(Power),
SelectProfile(Power), SelectProfile(Power),
Frame(Instant),
} }
impl Application for CosmicBatteryApplet { impl Application for CosmicBatteryApplet {
@ -111,6 +120,7 @@ impl Application for CosmicBatteryApplet {
fn update(&mut self, message: Message) -> Command<Message> { fn update(&mut self, message: Message) -> Command<Message> {
match message { match message {
Message::Frame(now) => self.timeline.now(now),
Message::SetKbdBrightness(brightness) => { Message::SetKbdBrightness(brightness) => {
self.kbd_brightness = (brightness as f64 / 100.0).clamp(0., 1.); self.kbd_brightness = (brightness as f64 / 100.0).clamp(0., 1.);
if let Some(tx) = &self.kbd_sender { if let Some(tx) = &self.kbd_sender {
@ -123,8 +133,9 @@ impl Application for CosmicBatteryApplet {
let _ = tx.send(ScreenBacklightRequest::Set(self.screen_brightness)); let _ = tx.send(ScreenBacklightRequest::Set(self.screen_brightness));
} }
} }
Message::SetChargingLimit(enable_charging_limit) => { Message::SetChargingLimit(chain, enable) => {
self.charging_limit = enable_charging_limit; self.timeline.set_chain(chain).start();
self.charging_limit = enable;
} }
Message::OpenBatterySettings => { Message::OpenBatterySettings => {
// TODO Ashley // TODO Ashley
@ -309,9 +320,13 @@ impl Application for CosmicBatteryApplet {
.width(Length::Fill) .width(Length::Fill)
.padding([0, 12]), .padding([0, 12]),
container( container(
toggler(fl!("max-charge"), self.charging_limit, |_| { anim!( //toggler
Message::SetChargingLimit(!self.charging_limit) MAX_CHARGE,
}) &self.timeline,
fl!("max-charge"),
self.charging_limit,
Message::SetChargingLimit,
)
.text_size(14) .text_size(14)
.width(Length::Fill) .width(Length::Fill)
) )
@ -396,6 +411,7 @@ impl Application for CosmicBatteryApplet {
(_, PowerProfileUpdate::Init(tx, p)) => Message::InitProfile(p, tx), (_, PowerProfileUpdate::Init(tx, p)) => Message::InitProfile(p, tx),
(_, PowerProfileUpdate::Error(e)) => Message::Errored(e), // TODO: handle error (_, PowerProfileUpdate::Error(e)) => Message::Errored(e), // TODO: handle error
}), }),
self.timeline.as_subscription().map(Message::Frame),
]) ])
} }

View file

@ -8,7 +8,7 @@ license = "GPL-3.0-or-later"
once_cell = "1.16.0" once_cell = "1.16.0"
bluer = { version = "0.15", features = ["bluetoothd", "id"] } bluer = { version = "0.15", features = ["bluetoothd", "id"] }
futures-util = "0.3.21" futures-util = "0.3.21"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "31f7e97", default-features = false, features = ["wayland", "tokio"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "5765053", default-features = false, features = ["wayland", "tokio"] }
cosmic-applet = { path = "../applet" } cosmic-applet = { path = "../applet" }
futures = "0.3" futures = "0.3"
log = "0.4" log = "0.4"

View file

@ -7,7 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
zbus = "3.13" zbus = "3.13"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "31f7e97", default-features = false, features = ["tokio", "wayland"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "5765053", default-features = false, features = ["tokio", "wayland"] }
cosmic-applet = { path = "../applet" } cosmic-applet = { path = "../applet" }
once_cell = "1" once_cell = "1"
# Application i18n # Application i18n

View file

@ -5,11 +5,11 @@ edition = "2021"
license = "GPL-3.0-or-later" license = "GPL-3.0-or-later"
[dependencies] [dependencies]
once_cell = "1.16.0"
cosmic-dbus-networkmanager = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "main" } cosmic-dbus-networkmanager = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "main" }
# cosmic-dbus-networkmanager = { path = "../../../dbus-settings-bindings/networkmanager" } # cosmic-dbus-networkmanager = { path = "../../../dbus-settings-bindings/networkmanager" }
futures-util = "0.3.21" futures-util = "0.3.21"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "31f7e97", default-features = false, features = ["wayland", "tokio"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "5765053", default-features = false, features = ["tokio", "wayland"] }
cosmic-time = { git = "https://github.com/pop-os/cosmic-time", rev = "e6ff6d5", default-features = false, features = ["libcosmic", "once_cell"] }
cosmic-applet = { path = "../applet" } cosmic-applet = { path = "../applet" }
futures = "0.3" futures = "0.3"
zbus = { version = "3.13", default-features = false } zbus = { version = "3.13", default-features = false }

View file

@ -13,11 +13,13 @@ use cosmic::{
}, },
iced_style::{application, button::StyleSheet}, iced_style::{application, button::StyleSheet},
theme::{Button, Svg}, theme::{Button, Svg},
widget::{button, divider, icon, toggler}, widget::{button, divider, icon},
Element, Theme, Element, Theme,
}; };
use cosmic_applet::CosmicAppletHelper; use cosmic_applet::CosmicAppletHelper;
use cosmic_dbus_networkmanager::interface::enums::{ActiveConnectionState, DeviceState}; use cosmic_dbus_networkmanager::interface::enums::{ActiveConnectionState, DeviceState};
use cosmic_time::{anim, chain, id, once_cell::sync::Lazy, Instant, Timeline};
use futures::channel::mpsc::UnboundedSender; use futures::channel::mpsc::UnboundedSender;
use zbus::Connection; use zbus::Connection;
@ -76,6 +78,9 @@ impl Into<AccessPoint> for NewConnectionState {
} }
} }
static WIFI: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
static AIRPLANE_MODE: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
#[derive(Default)] #[derive(Default)]
struct CosmicNetworkApplet { struct CosmicNetworkApplet {
icon_name: String, icon_name: String,
@ -89,6 +94,7 @@ struct CosmicNetworkApplet {
show_visible_networks: bool, show_visible_networks: bool,
new_connection: Option<NewConnectionState>, new_connection: Option<NewConnectionState>,
conn: Option<Connection>, conn: Option<Connection>,
timeline: Timeline,
} }
impl CosmicNetworkApplet { impl CosmicNetworkApplet {
@ -112,6 +118,29 @@ impl CosmicNetworkApplet {
}) })
.to_string() .to_string()
} }
fn update_togglers(&mut self, state: &NetworkManagerState) {
let timeline = &mut self.timeline;
if state.wifi_enabled != self.nm_state.wifi_enabled {
let chain = if state.wifi_enabled {
chain::Toggler::on(WIFI.clone(), 1.)
} else {
chain::Toggler::off(WIFI.clone(), 1.)
};
timeline.set_chain(chain);
};
if state.airplane_mode != self.nm_state.airplane_mode {
let chain = if state.airplane_mode {
chain::Toggler::on(AIRPLANE_MODE.clone(), 1.)
} else {
chain::Toggler::off(AIRPLANE_MODE.clone(), 1.)
};
timeline.set_chain(chain);
};
timeline.start();
}
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -122,13 +151,14 @@ pub(crate) enum Message {
ToggleAirplaneMode(bool), ToggleAirplaneMode(bool),
ToggleWiFi(bool), ToggleWiFi(bool),
ToggleVisibleNetworks, ToggleVisibleNetworks,
Errored(String),
Ignore, Ignore,
NetworkManagerEvent(NetworkManagerEvent), NetworkManagerEvent(NetworkManagerEvent),
SelectWirelessAccessPoint(AccessPoint), SelectWirelessAccessPoint(AccessPoint),
CancelNewConnection, CancelNewConnection,
Password(String), Password(String),
SubmitPassword, SubmitPassword,
Frame(Instant),
// Errored(String),
} }
impl Application for CosmicNetworkApplet { impl Application for CosmicNetworkApplet {
@ -153,6 +183,7 @@ impl Application for CosmicNetworkApplet {
fn update(&mut self, message: Message) -> Command<Message> { fn update(&mut self, message: Message) -> Command<Message> {
match message { match message {
Message::Frame(now) => self.timeline.now(now),
Message::TogglePopup => { Message::TogglePopup => {
if let Some(p) = self.popup.take() { if let Some(p) = self.popup.take() {
self.show_visible_networks = false; self.show_visible_networks = false;
@ -179,20 +210,14 @@ impl Application for CosmicNetworkApplet {
return get_popup(popup_settings); return get_popup(popup_settings);
} }
} }
Message::Errored(_) => todo!(), // Message::Errored(_) => todo!(),
Message::Ignore => {} Message::Ignore => {}
Message::ToggleAirplaneMode(enabled) => { Message::ToggleAirplaneMode(enabled) => {
self.nm_state.airplane_mode = enabled;
if let Some(tx) = self.nm_sender.as_mut() { if let Some(tx) = self.nm_sender.as_mut() {
let _ = tx.unbounded_send(NetworkManagerRequest::SetAirplaneMode(enabled)); let _ = tx.unbounded_send(NetworkManagerRequest::SetAirplaneMode(enabled));
} }
} }
Message::ToggleWiFi(enabled) => { Message::ToggleWiFi(enabled) => {
if !enabled {
self.nm_state.clear();
}
self.nm_state.wifi_enabled = enabled;
if let Some(tx) = self.nm_sender.as_mut() { if let Some(tx) = self.nm_sender.as_mut() {
let _ = tx.unbounded_send(NetworkManagerRequest::SetWiFi(enabled)); let _ = tx.unbounded_send(NetworkManagerRequest::SetWiFi(enabled));
} }
@ -204,6 +229,7 @@ impl Application for CosmicNetworkApplet {
state, state,
} => { } => {
self.nm_sender.replace(sender); self.nm_sender.replace(sender);
self.update_togglers(&state);
self.nm_state = state; self.nm_state = state;
self.update_icon_name(); self.update_icon_name();
self.conn = Some(conn); self.conn = Some(conn);
@ -236,7 +262,9 @@ impl Application for CosmicNetworkApplet {
self.new_connection.take(); self.new_connection.take();
} }
} }
_ => {} _ => {
self.update_togglers(&state);
}
} }
} else { } else {
match req { match req {
@ -500,18 +528,28 @@ impl Application for CosmicNetworkApplet {
let mut content = column![ let mut content = column![
vpn_ethernet_col, vpn_ethernet_col,
container( container(
toggler(fl!("airplane-mode"), self.nm_state.airplane_mode, |m| { anim!(
Message::ToggleAirplaneMode(m) //toggler
}) AIRPLANE_MODE,
&self.timeline,
fl!("airplane-mode"),
self.nm_state.airplane_mode,
|_chain, enable| { Message::ToggleAirplaneMode(enable) },
)
.text_size(14) .text_size(14)
.width(Length::Fill) .width(Length::Fill)
) )
.padding([0, 12]), .padding([0, 12]),
divider::horizontal::light(), divider::horizontal::light(),
container( container(
toggler(fl!("wifi"), self.nm_state.wifi_enabled, |m| { anim!(
Message::ToggleWiFi(m) //toggler
}) WIFI,
&self.timeline,
fl!("wifi"),
self.nm_state.wifi_enabled,
|_chain, enable| { Message::ToggleWiFi(enable) },
)
.text_size(14) .text_size(14)
.width(Length::Fill) .width(Length::Fill)
) )
@ -683,9 +721,11 @@ impl Application for CosmicNetworkApplet {
fn subscription(&self) -> Subscription<Message> { fn subscription(&self) -> Subscription<Message> {
let network_sub = let network_sub =
network_manager_subscription(0).map(|e| Message::NetworkManagerEvent(e.1)); network_manager_subscription(0).map(|e| Message::NetworkManagerEvent(e.1));
let timeline = self.timeline.as_subscription().map(Message::Frame);
if let Some(conn) = self.conn.as_ref() { if let Some(conn) = self.conn.as_ref() {
Subscription::batch(vec![ Subscription::batch(vec![
timeline,
network_sub, network_sub,
active_conns_subscription(0, conn.clone()) active_conns_subscription(0, conn.clone())
.map(|e| Message::NetworkManagerEvent(e.1)), .map(|e| Message::NetworkManagerEvent(e.1)),
@ -694,7 +734,7 @@ impl Application for CosmicNetworkApplet {
.map(|e| Message::NetworkManagerEvent(e.1)), .map(|e| Message::NetworkManagerEvent(e.1)),
]) ])
} else { } else {
network_sub Subscription::batch(vec![timeline, network_sub])
} }
} }

View file

@ -1,10 +1,10 @@
// SPDX-License-Identifier: MPL-2.0-only // SPDX-License-Identifier: MPL-2.0-only
use cosmic_time::once_cell::sync::Lazy;
use i18n_embed::{ use i18n_embed::{
fluent::{fluent_language_loader, FluentLanguageLoader}, fluent::{fluent_language_loader, FluentLanguageLoader},
DefaultLocalizer, LanguageLoader, Localizer, DefaultLocalizer, LanguageLoader, Localizer,
}; };
use once_cell::sync::Lazy;
use rust_embed::RustEmbed; use rust_embed::RustEmbed;
#[derive(RustEmbed)] #[derive(RustEmbed)]

View file

@ -1,11 +1,11 @@
use super::{NetworkManagerEvent, NetworkManagerState}; use super::{NetworkManagerEvent, NetworkManagerState};
use cosmic::iced::{self, subscription}; use cosmic::iced::{self, subscription};
use cosmic_dbus_networkmanager::nm::NetworkManager; use cosmic_dbus_networkmanager::nm::NetworkManager;
use futures::StreamExt;
use log::error; use log::error;
use std::fmt::Debug; use std::fmt::Debug;
use std::hash::Hash; use std::hash::Hash;
use zbus::Connection; use zbus::Connection;
use futures::StreamExt;
pub fn devices_subscription<I: 'static + Hash + Copy + Send + Sync + Debug>( pub fn devices_subscription<I: 'static + Hash + Copy + Send + Sync + Debug>(
id: I, id: I,
@ -50,10 +50,7 @@ async fn start_listening<I: Copy + Debug>(
let new_state = NetworkManagerState::new(&conn).await.unwrap_or_default(); let new_state = NetworkManagerState::new(&conn).await.unwrap_or_default();
( (
Some(( Some((id, NetworkManagerEvent::WirelessAccessPoints(new_state))),
id,
NetworkManagerEvent::WirelessAccessPoints(new_state),
)),
State::Continue(conn), State::Continue(conn),
) )
} }

View file

@ -15,7 +15,7 @@ use cosmic_dbus_networkmanager::{
}; };
use futures::{ use futures::{
channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender}, channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender},
FutureExt, StreamExt, StreamExt,
}; };
use tokio::{process::Command, time::timeout}; use tokio::{process::Command, time::timeout};
use zbus::{ use zbus::{
@ -141,7 +141,7 @@ async fn start_listening<I: Copy + Debug>(
Some(NetworkManagerRequest::SetWiFi(enabled)) => { Some(NetworkManagerRequest::SetWiFi(enabled)) => {
let success = network_manager.set_wireless_enabled(enabled).await.is_ok(); let success = network_manager.set_wireless_enabled(enabled).await.is_ok();
let response = NetworkManagerEvent::RequestResponse { let response = NetworkManagerEvent::RequestResponse {
req: NetworkManagerRequest::SetAirplaneMode(enabled), req: NetworkManagerRequest::SetWiFi(enabled),
success, success,
state: NetworkManagerState::new(&conn).await.unwrap_or_default(), state: NetworkManagerState::new(&conn).await.unwrap_or_default(),
}; };
@ -624,6 +624,7 @@ impl NetworkManagerState {
Ok(_self) Ok(_self)
} }
#[allow(dead_code)]
pub fn clear(&mut self) { pub fn clear(&mut self) {
self.active_conns = Vec::new(); self.active_conns = Vec::new();
self.known_access_points = Vec::new(); self.known_access_points = Vec::new();

View file

@ -6,6 +6,7 @@ license = "GPL-3.0-or-later"
[dependencies] [dependencies]
icon-loader = { version = "0.3.6", features = ["gtk"] } icon-loader = { version = "0.3.6", features = ["gtk"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "31f7e97", default-features = false, features = ["tokio", "wayland"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "5765053", default-features = false, features = ["tokio", "wayland"] }
cosmic-time = { git = "https://github.com/pop-os/cosmic-time", rev = "e6ff6d5", default-features = false, features = ["libcosmic", "once_cell"] }
cosmic-applet = { path = "../applet" } cosmic-applet = { path = "../applet" }
nix = "0.24.1" nix = "0.24.1"

View file

@ -9,9 +9,10 @@ use cosmic::iced_style::application::{self, Appearance};
use cosmic::iced_widget::Button; use cosmic::iced_widget::Button;
use cosmic::theme::Svg; use cosmic::theme::Svg;
use cosmic::widget::{divider, icon, toggler}; use cosmic::widget::{divider, icon};
use cosmic::Renderer; use cosmic::Renderer;
use cosmic::{Element, Theme}; use cosmic::{Element, Theme};
use cosmic_time::{anim, chain, id, once_cell::sync::Lazy, Instant, Timeline};
use std::process; use std::process;
@ -20,6 +21,8 @@ pub fn main() -> cosmic::iced::Result {
Notifications::run(helper.window_settings()) Notifications::run(helper.window_settings())
} }
static DO_NOT_DISTURB: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
#[derive(Default)] #[derive(Default)]
struct Notifications { struct Notifications {
applet_helper: CosmicAppletHelper, applet_helper: CosmicAppletHelper,
@ -29,14 +32,16 @@ struct Notifications {
id_ctr: u128, id_ctr: u128,
do_not_disturb: bool, do_not_disturb: bool,
notifications: Vec<Vec<String>>, notifications: Vec<Vec<String>>,
timeline: Timeline,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
enum Message { enum Message {
TogglePopup, TogglePopup,
DoNotDisturb(bool), DoNotDisturb(chain::Toggler, bool),
Settings, Settings,
Ignore, Ignore,
Frame(Instant),
} }
impl Application for Notifications { impl Application for Notifications {
@ -75,11 +80,15 @@ impl Application for Notifications {
} }
fn subscription(&self) -> Subscription<Message> { fn subscription(&self) -> Subscription<Message> {
Subscription::none() self.timeline.as_subscription().map(Message::Frame)
} }
fn update(&mut self, message: Message) -> Command<Message> { fn update(&mut self, message: Message) -> Command<Message> {
match message { match message {
Message::Frame(now) => {
self.timeline.now(now);
Command::none()
}
Message::TogglePopup => { Message::TogglePopup => {
if let Some(p) = self.popup.take() { if let Some(p) = self.popup.take() {
destroy_popup(p) destroy_popup(p)
@ -98,7 +107,8 @@ impl Application for Notifications {
get_popup(popup_settings) get_popup(popup_settings)
} }
} }
Message::DoNotDisturb(b) => { Message::DoNotDisturb(chain, b) => {
self.timeline.set_chain(chain).start();
self.do_not_disturb = b; self.do_not_disturb = b;
Command::none() Command::none()
} }
@ -117,14 +127,15 @@ impl Application for Notifications {
.on_press(Message::TogglePopup) .on_press(Message::TogglePopup)
.into() .into()
} else { } else {
let do_not_disturb = let do_not_disturb = row![anim!(
row![ DO_NOT_DISTURB,
toggler(String::from("Do Not Disturb"), self.do_not_disturb, |b| { &self.timeline,
Message::DoNotDisturb(b) String::from("Do Not Disturb"),
}) self.do_not_disturb,
.width(Length::Fill) Message::DoNotDisturb
] )
.padding([0, 24]); .width(Length::Fill)]
.padding([0, 24]);
let settings = let settings =
row_button(vec!["Notification Settings...".into()]).on_press(Message::Settings); row_button(vec!["Notification Settings...".into()]).on_press(Message::Settings);

View file

@ -9,7 +9,7 @@ icon-loader = { version = "0.3.6", features = ["gtk"] }
libpulse-binding = "2.26.0" libpulse-binding = "2.26.0"
libpulse-glib-binding = "2.25.0" libpulse-glib-binding = "2.25.0"
tokio = { version = "1.20.1", features=["full"] } tokio = { version = "1.20.1", features=["full"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "31f7e97", default-features = false, features = ["tokio", "wayland"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "5765053", default-features = false, features = ["tokio", "wayland"] }
cosmic-applet = { path = "../applet" } cosmic-applet = { path = "../applet" }
nix = "0.26.2" nix = "0.26.2"
zbus = "3.13" zbus = "3.13"

View file

@ -6,7 +6,7 @@ license = "GPL-3.0-or-later"
[dependencies] [dependencies]
icon-loader = { version = "0.3.6", features = ["gtk"] } icon-loader = { version = "0.3.6", features = ["gtk"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "31f7e97", default-features = false, features = ["tokio", "wayland"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "5765053", default-features = false, features = ["tokio", "wayland"] }
cosmic-applet = { path = "../applet" } cosmic-applet = { path = "../applet" }
nix = "0.24.1" nix = "0.24.1"
chrono = { version = "0.4.23", features = ["clock"] } chrono = { version = "0.4.23", features = ["clock"] }

View file

@ -5,7 +5,7 @@ authors = ["Ashley Wulber <ashley@system76.com>"]
edition = "2021" edition = "2021"
[dependencies] [dependencies]
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "31f7e97", default-features = false, features = ["tokio", "wayland"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "5765053", default-features = false, features = ["tokio", "wayland"] }
cosmic-applet = { path = "../applet" } cosmic-applet = { path = "../applet" }
cosmic-client-toolkit = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, rev = "f0cfe09" } cosmic-client-toolkit = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, rev = "f0cfe09" }
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = ["client"], rev = "f0cfe09" } cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = ["client"], rev = "f0cfe09" }

View file

@ -6,5 +6,5 @@ license = "GPL-3.0-or-later"
[dependencies] [dependencies]
freedesktop-desktop-entry = "0.5.0" freedesktop-desktop-entry = "0.5.0"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "31f7e97", default-features = false, features = ["tokio", "wayland"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "5765053", default-features = false, features = ["tokio", "wayland"] }
cosmic-applet = { path = "../applet" } cosmic-applet = { path = "../applet" }