From 926633e4f26303f1bf11f56e97cca012e0ce6052 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 12 Jul 2023 15:02:52 -0700 Subject: [PATCH] chore: Update gtk-rs crates to 0.17 Fixes https://github.com/pop-os/keyboard-configurator/issues/180. Requires a fair number of changes, but behavior *should* be the same. --- Cargo.lock | 342 +++++++++++++++++++---------- Cargo.toml | 6 +- backend/Cargo.toml | 2 +- backend/build.rs | 8 +- backend/src/layout/meta.rs | 2 + backend/src/layout/mod.rs | 2 +- build.rs | 4 +- ffi/Cargo.toml | 2 +- layouts.py | 7 + src/backlight.rs | 62 ++---- src/configurator_app.rs | 29 +-- src/keyboard.rs | 43 ++-- src/keyboard_layer.rs | 96 ++++---- src/main.rs | 7 +- src/main_window.rs | 13 +- src/picker/mod.rs | 10 +- src/picker/picker_group_box.rs | 50 ++--- src/testing.rs | 24 +- widgets/Cargo.toml | 4 +- widgets/examples/keyboard_color.rs | 7 +- widgets/src/choose_color.rs | 2 +- widgets/src/color_circle.rs | 12 +- widgets/src/color_wheel.rs | 103 ++++----- widgets/src/keyboard_color.rs | 45 ++-- 24 files changed, 455 insertions(+), 427 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f369bfe2..da54735e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" dependencies = [ "memchr", ] @@ -37,9 +37,9 @@ dependencies = [ [[package]] name = "async-channel" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", "event-listener", @@ -101,9 +101,9 @@ checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" [[package]] name = "atk" -version = "0.15.1" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c3d816ce6f0e2909a96830d6911c2aff044370b1ef92d7f267b43bae5addedd" +checksum = "6ba16453d10c712284061a05f6510f75abeb92b56ba88dfeb48c74775020cc22" dependencies = [ "atk-sys", "bitflags", @@ -113,9 +113,9 @@ dependencies = [ [[package]] name = "atk-sys" -version = "0.15.1" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58aeb089fb698e06db8089971c7ee317ab9644bade33383f63631437b03aafb6" +checksum = "e3bf0a7ca572fbd5762fd8f8cd65a581e06767bc1234913fe1f43e370cff6e90" dependencies = [ "glib-sys", "gobject-sys", @@ -181,22 +181,23 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cairo-rs" -version = "0.15.12" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c76ee391b03d35510d9fa917357c7f1855bd9a6659c95a1b392e33f49b3369bc" +checksum = "ab3603c4028a5e368d09b51c8b624b9a46edcd7c3778284077a6125af73c9f0a" dependencies = [ "bitflags", "cairo-sys-rs", "glib", "libc", + "once_cell", "thiserror", ] [[package]] name = "cairo-sys-rs" -version = "0.15.1" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8" +checksum = "691d0c66b1fb4881be80a760cb8fe76ea97218312f9dfe2c9cc0f496ca279cb1" dependencies = [ "glib-sys", "libc", @@ -217,11 +218,12 @@ checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "cfg-expr" -version = "0.11.0" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0357a6402b295ca3a86bc148e84df46c02e41f41fef186bda662557ef6328aa" +checksum = "215c0072ecc28f92eeb0eea38ba63ddfcb65c2828c46311d646f1a3ff5f9841c" dependencies = [ "smallvec", + "target-lexicon", ] [[package]] @@ -292,7 +294,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.25", ] [[package]] @@ -335,6 +337,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.3.1" @@ -395,7 +403,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59a98bbaacea1c0eb6a0876280051b892eb73594fd90cf3b20e9c817029c57d2" dependencies = [ - "toml", + "toml 0.5.11", ] [[package]] @@ -514,7 +522,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.25", ] [[package]] @@ -555,9 +563,9 @@ dependencies = [ [[package]] name = "gdk" -version = "0.15.4" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6e05c1f572ab0e1f15be94217f0dc29088c248b14f792a5ff0af0d84bcda9e8" +checksum = "be1df5ea52cccd7e3a0897338b5564968274b52f5fd12601e0afa44f454c74d3" dependencies = [ "bitflags", "cairo-rs", @@ -571,22 +579,23 @@ dependencies = [ [[package]] name = "gdk-pixbuf" -version = "0.15.11" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad38dd9cc8b099cceecdf41375bb6d481b1b5a7cd5cd603e10a69a9383f8619a" +checksum = "695d6bc846438c5708b07007537b9274d883373dd30858ca881d7d71b5540717" dependencies = [ "bitflags", "gdk-pixbuf-sys", "gio", "glib", "libc", + "once_cell", ] [[package]] name = "gdk-pixbuf-sys" -version = "0.15.10" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "140b2f5378256527150350a8346dbdb08fadc13453a7a2d73aecd5fab3c402a7" +checksum = "9285ec3c113c66d7d0ab5676599176f1f42f4944ca1b581852215bf5694870cb" dependencies = [ "gio-sys", "glib-sys", @@ -597,9 +606,9 @@ dependencies = [ [[package]] name = "gdk-sys" -version = "0.15.1" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e7a08c1e8f06f4177fb7e51a777b8c1689f743a7bc11ea91d44d2226073a88" +checksum = "2152de9d38bc67a17b3fe49dc0823af5bf874df59ea088c5f28f31cf103de703" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -636,26 +645,29 @@ dependencies = [ [[package]] name = "gio" -version = "0.15.12" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68fdbc90312d462781a395f7a16d96a2b379bb6ef8cd6310a2df272771c4283b" +checksum = "a6973e92937cf98689b6a054a9e56c657ed4ff76de925e36fc331a15f0c5d30a" dependencies = [ "bitflags", "futures-channel", "futures-core", "futures-io", + "futures-util", "gio-sys", "glib", "libc", "once_cell", + "pin-project-lite", + "smallvec", "thiserror", ] [[package]] name = "gio-sys" -version = "0.15.10" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32157a475271e2c4a023382e9cab31c4584ee30a97da41d3c4e9fdd605abcf8d" +checksum = "0ccf87c30a12c469b6d958950f6a9c09f2be20b7773f7e70d20b867fdf2628c3" dependencies = [ "glib-sys", "gobject-sys", @@ -666,33 +678,42 @@ dependencies = [ [[package]] name = "glib" -version = "0.15.12" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edb0306fbad0ab5428b0ca674a23893db909a98582969c9b537be4ced78c505d" +checksum = "d3fad45ba8d4d2cea612b432717e834f48031cd8853c8aaf43b2c79fec8d144b" dependencies = [ "bitflags", "futures-channel", "futures-core", "futures-executor", "futures-task", + "futures-util", + "gio-sys", "glib-macros", "glib-sys", "gobject-sys", "libc", + "memchr", "once_cell", "smallvec", "thiserror", ] +[[package]] +name = "glib-build-tools" +version = "0.17.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a65d79efe318ef2cbbbb37032b125866fd82c34ea44c816132621bbc552e716" + [[package]] name = "glib-macros" -version = "0.15.13" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10c6ae9f6fa26f4fb2ac16b528d138d971ead56141de489f8111e259b9df3c4a" +checksum = "eca5c79337338391f1ab8058d6698125034ce8ef31b72a442437fa6c8580de26" dependencies = [ "anyhow", "heck", - "proc-macro-crate 1.2.1", + "proc-macro-crate 1.3.1", "proc-macro-error", "proc-macro2", "quote", @@ -701,9 +722,9 @@ dependencies = [ [[package]] name = "glib-sys" -version = "0.15.10" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef4b192f8e65e9cf76cbf4ea71fa8e3be4a0e18ffe3d68b8da6836974cc5bad4" +checksum = "d80aa6ea7bba0baac79222204aa786a6293078c210abe69ef1336911d4bdc4f0" dependencies = [ "libc", "system-deps", @@ -711,9 +732,9 @@ dependencies = [ [[package]] name = "gobject-sys" -version = "0.15.10" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a" +checksum = "cd34c3317740a6358ec04572c1bcfd3ac0b5b6529275fae255b237b314bb8062" dependencies = [ "glib-sys", "libc", @@ -722,9 +743,9 @@ dependencies = [ [[package]] name = "gtk" -version = "0.15.5" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e3004a2d5d6d8b5057d2b57b3712c9529b62e82c77f25c1fecde1fd5c23bd0" +checksum = "b6c4222ab92b08d4d0bab90ddb6185b4e575ceeea8b8cdf00b938d7b6661d966" dependencies = [ "atk", "bitflags", @@ -745,9 +766,9 @@ dependencies = [ [[package]] name = "gtk-sys" -version = "0.15.3" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5bc2f0587cba247f60246a0ca11fe25fb733eabc3de12d1965fc07efab87c84" +checksum = "4d8eb6a4b93e5a7e6980f7348d08c1cd93d31fae07cf97f20678c5ec41de3d7e" dependencies = [ "atk-sys", "cairo-sys-rs", @@ -763,18 +784,24 @@ dependencies = [ [[package]] name = "gtk3-macros" -version = "0.15.6" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "684c0456c086e8e7e9af73ec5b84e35938df394712054550e81558d21c44ab0d" +checksum = "3efb84d682c9a39c10bd9f24f5a4b9c15cc8c7edc45c19cb2ca2c4fc38b2d95e" dependencies = [ "anyhow", - "proc-macro-crate 1.2.1", + "proc-macro-crate 1.3.1", "proc-macro-error", "proc-macro2", "quote", "syn 1.0.109", ] +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "heck" version = "0.4.1" @@ -792,18 +819,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "hidapi" @@ -825,15 +843,15 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "i18n-config" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d9f93ceee6543011739bc81699b5e0cf1f23f3a80364649b6d80de8636bc8df" +checksum = "b987084cadad6e2f2b1e6ea62c44123591a3c044793a1beabf71a8356ea768d5" dependencies = [ "log", "serde", "serde_derive", "thiserror", - "toml", + "toml 0.7.6", "unic-langid", ] @@ -892,6 +910,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "instant" version = "0.1.12" @@ -926,16 +954,16 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi 0.3.2", "libc", "windows-sys", ] [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" [[package]] name = "lazy_static" @@ -1051,11 +1079,11 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi 0.3.2", "libc", ] @@ -1090,9 +1118,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.2" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "ordered-float" @@ -1130,11 +1158,12 @@ dependencies = [ [[package]] name = "pango" -version = "0.15.10" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e4045548659aee5313bde6c582b0d83a627b7904dd20dc2d9ef0895d414e4f" +checksum = "35be456fc620e61f62dff7ff70fbd54dcbaf0a4b920c0f16de1107c47d921d48" dependencies = [ "bitflags", + "gio", "glib", "libc", "once_cell", @@ -1143,9 +1172,9 @@ dependencies = [ [[package]] name = "pango-sys" -version = "0.15.10" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2a00081cde4661982ed91d80ef437c20eacaf6aa1a5962c0279ae194662c3aa" +checksum = "3da69f9f3850b0d8990d462f8c709561975e95f689c1cdf0fecdebde78b35195" dependencies = [ "glib-sys", "gobject-sys", @@ -1155,9 +1184,9 @@ dependencies = [ [[package]] name = "pangocairo" -version = "0.15.1" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7876a45c1f1d1a75a2601dc6d9ef2cb5a8be0e3d76f909d82450759929035366" +checksum = "86bf29cb1c2e73817944f66011fb12135e1c6d268e8e4c5cfc689101c25822cf" dependencies = [ "bitflags", "cairo-rs", @@ -1169,9 +1198,9 @@ dependencies = [ [[package]] name = "pangocairo-sys" -version = "0.15.1" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cf746594916c81d5f739af9335c5f55a1f4606d80b3e1d821f18cf95a29494" +checksum = "94dfd38d9bf8ff5f881be2107ba49fcb22090d247aa00133f8dadf96b122b97a" dependencies = [ "cairo-sys-rs", "glib-sys", @@ -1251,9 +1280,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" [[package]] name = "pin-utils" @@ -1295,18 +1324,17 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" dependencies = [ - "toml", + "toml 0.5.11", ] [[package]] name = "proc-macro-crate" -version = "1.2.1" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "thiserror", - "toml", + "toml_edit", ] [[package]] @@ -1335,18 +1363,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" +checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -1413,9 +1441,21 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.3" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310" dependencies = [ "aho-corasick", "memchr", @@ -1424,9 +1464,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.29" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "rust-embed" @@ -1478,9 +1518,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.20" +version = "0.37.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b96e891d04aa506a6d1f318d2771bcb1c7dfda84e126660ace067c9b474bb2c0" +checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ "bitflags", "errno", @@ -1492,9 +1532,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" [[package]] name = "same-file" @@ -1531,29 +1571,29 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.164" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.164" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.25", ] [[package]] name = "serde_json" -version = "1.0.99" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" +checksum = "b5062a995d481b2308b6064e9af76011f2921c35f97b0468811ed9f6cd91dfed" dependencies = [ "itoa", "ryu", @@ -1562,13 +1602,22 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" +checksum = "1d89a8107374290037607734c0b73a85db7ed80cae314b3c5791f192a496e731" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.25", +] + +[[package]] +name = "serde_spanned" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +dependencies = [ + "serde", ] [[package]] @@ -1607,9 +1656,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "socket2" @@ -1652,9 +1701,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.22" +version = "2.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616" +checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" dependencies = [ "proc-macro2", "quote", @@ -1663,14 +1712,14 @@ dependencies = [ [[package]] name = "system-deps" -version = "6.0.3" +version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2955b1fe31e1fa2fbd1976b71cc69a606d7d4da16f6de3333d0c92d51419aeff" +checksum = "30c2de8a4d8f4b823d634affc9cd2a74ec98c53a756f317e529a48046cbf71f3" dependencies = [ "cfg-expr", "heck", "pkg-config", - "toml", + "toml 0.7.6", "version-compare", ] @@ -1681,7 +1730,7 @@ dependencies = [ "cascade", "env_logger", "futures", - "gio", + "glib-build-tools", "gtk", "i18n-embed", "i18n-embed-fl", @@ -1755,6 +1804,12 @@ dependencies = [ "libc", ] +[[package]] +name = "target-lexicon" +version = "0.12.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8e77cb757a61f51b947ec4a7e3646efd825b73561db1c232a8ccb639e611a0" + [[package]] name = "termcolor" version = "1.2.0" @@ -1775,22 +1830,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.25", ] [[package]] @@ -1811,6 +1866,40 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c500344a19072298cd05a7224b3c0c629348b78692bf48466c5238656e315a78" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tools" version = "0.1.0" @@ -1845,9 +1934,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" [[package]] name = "unicode-width" @@ -1952,9 +2041,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -2007,6 +2096,15 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "winnow" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81a2094c43cc94775293eaa0e499fbc30048a6d824ac82c0351a8c0bf9112529" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.8.0" @@ -2071,7 +2169,7 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4ca5e22593eb4212382d60d26350065bf2a02c34b85bc850474a74b589a3de9" dependencies = [ - "proc-macro-crate 1.2.1", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", diff --git a/Cargo.toml b/Cargo.toml index 0d570e2e..3a11d832 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,10 @@ members = [ "tools", "ffi", "backend", "widgets" ] [dependencies] cascade = "1" futures = "0.3.13" -gtk = { version = "0.15.0", features = ["v3_22"] } +gtk = { version = "0.17.0" } libc = "0.2" once_cell = "1.4" -pangocairo = "0.15.0" +pangocairo = "0.17.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" log = "0.4.0" @@ -28,7 +28,7 @@ i18n-embed-fl = "0.5.0" rust-embed = { version = "5.9.0", features = ["debug-embed"] } [build-dependencies] -gio = "0.15.0" +glib-build-tools = "0.17.0" [target.'cfg(target_os = "windows")'.dependencies] winreg = "0.8" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index a6c10271..59fd9ede 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -10,7 +10,7 @@ async-process = "1.7.0" cascade = "1" futures = { version = "0.3.13", features = ["thread-pool"] } futures-timer = "3.0.2" -glib = { version = "0.15.0", optional = true } +glib = { version = "0.17.0", optional = true } hidapi = { version = "1.2", default-features = false, features = ["linux-shared-hidraw"] } libc = "0.2" once_cell = "1.4" diff --git a/backend/build.rs b/backend/build.rs index bc85fd03..4bd729e6 100644 --- a/backend/build.rs +++ b/backend/build.rs @@ -25,11 +25,15 @@ fn main() { .unwrap_or_else(|| { panic!("'keyboard:' not found in {}", path.display()); }); + let is_qmk = meta + .get("is_qmk") + .and_then(|v| v.as_bool()) + .unwrap_or(false); writeln!( outfile, - " (\"system76/{}\", \"{}\"),", - file_name, keyboard + " (\"system76/{}\", \"{}\", {}),", + file_name, keyboard, is_qmk ) .unwrap(); diff --git a/backend/src/layout/meta.rs b/backend/src/layout/meta.rs index c62bd6fc..d39819f8 100644 --- a/backend/src/layout/meta.rs +++ b/backend/src/layout/meta.rs @@ -30,4 +30,6 @@ pub struct Meta { #[serde(default = "num_layers_default")] pub num_layers: u8, pub pressed_color: Rgb, + #[serde(default)] + pub is_qmk: bool, } diff --git a/backend/src/layout/mod.rs b/backend/src/layout/mod.rs index 54e97d5e..bfa06943 100644 --- a/backend/src/layout/mod.rs +++ b/backend/src/layout/mod.rs @@ -44,7 +44,7 @@ pub struct Layout { } macro_rules! keyboards { - ($( ($board:expr, $keyboard:expr) ),* $(,)?) => { + ($( ($board:expr, $keyboard:expr, $is_qmk:expr) ),* $(,)?) => { fn layout_data(board: &str, use_legacy_scancodes: bool) -> Option<(&'static str, &'static str, &'static str, &'static str, &'static str, &'static str)> { match board { $( diff --git a/build.rs b/build.rs index a2ab71c7..39eb871f 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,6 @@ fn main() { - gio::compile_resources( - "data", + glib_build_tools::compile_resources( + &["data"], "data/com.system76.keyboardconfigurator.gresource.xml", "compiled.gresource", ); diff --git a/ffi/Cargo.toml b/ffi/Cargo.toml index 7b4a6e6b..453a18ed 100644 --- a/ffi/Cargo.toml +++ b/ffi/Cargo.toml @@ -9,5 +9,5 @@ name = "system76_keyboard_configurator" crate-type = [ "cdylib" ] [dependencies] -gtk = "0.15.0" +gtk = "0.17.0" system76-keyboard-configurator-widgets = { path = "../widgets" } diff --git a/layouts.py b/layouts.py index 37151ac9..b976cdc0 100755 --- a/layouts.py +++ b/layouts.py @@ -556,9 +556,14 @@ def generate_layout_dir(ecdir: str, board: str, is_qmk: bool, override: str) -> parser.add_argument("ecdir", help='For QMK boards that is the qmk_firmware (github.com/system76/qmk_firmware) directory itself, otherwise use the ec directory (github.com/system76/ec)') parser.add_argument("board", help='The name of the manufacturer and board name. Example: "system76/launch_2"') parser.add_argument("--qmk", action="store_true", help="Required if you plan on using a keyboard with QMK firmware.") +parser.add_argument("--qmk-legacy", action="store_true", help="Re-generate keymap json for old qmk version.") parser.add_argument("--override", help="Override the output directory. See layouts/keyboards/. Usage: '--override overrides/0.19.12/'", default='') args = parser.parse_args() +if args.qmk_legacy: + # Only keymap differs for legacy qmk, so don't generate anything related to individial boards + sys.exit(0) + if args.board == 'all': if args.qmk: boarddir = f'{args.ecdir}/keyboards/system76' @@ -570,3 +575,5 @@ def generate_layout_dir(ecdir: str, board: str, is_qmk: bool, override: str) -> generate_layout_dir(args.ecdir, f'system76/{i}', args.qmk, args.override) else: generate_layout_dir(args.ecdir, args.board, args.qmk, args.override) + + diff --git a/src/backlight.rs b/src/backlight.rs index 30225942..03610a37 100644 --- a/src/backlight.rs +++ b/src/backlight.rs @@ -41,7 +41,9 @@ impl ObjectSubclass for BacklightInner { } impl ObjectImpl for BacklightInner { - fn constructed(&self, obj: &Self::Type) { + fn constructed(&self) { + let obj = self.obj(); + self.do_not_set.set(true); let mode_combobox = cascade! { @@ -80,11 +82,11 @@ impl ObjectImpl for BacklightInner { let saturation_adjustment = cascade! { gtk::Adjustment::new(0., 0., 100., 1., 1., 0.); ..bind_property("value", &keyboard_color, "hs") - .transform_from(|_, value| { + .transform_from(|_, value: glib::Value| { let hs: &Hs = value.get().unwrap(); Some((hs.s * 100.).to_value()) }) - .transform_to(|_, value| { + .transform_to(|_, value: glib::Value| { let s: f64 = value.get().unwrap(); Some(Hs::new(0., s / 100.).to_value()) }) @@ -171,61 +173,41 @@ impl ObjectImpl for BacklightInner { self.saturation_row.set(saturation_row); } - fn dispose(&self, obj: &Self::Type) { - obj.led_save(); + fn dispose(&self) { + self.obj().led_save(); } fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy> = Lazy::new(|| { vec![ - glib::ParamSpecString::new( - "mode", - "mode", - "mode", - None, - glib::ParamFlags::READABLE, - ), - glib::ParamSpecBoxed::new( - "selected", - "selected", - "selected", - SelectedKeys::static_type(), - glib::ParamFlags::WRITABLE, - ), - glib::ParamSpecBoolean::new( - "is-per-key", - "is-per-key", - "is-per-key", - false, - glib::ParamFlags::READABLE, - ), + glib::ParamSpecString::builder("mode").read_only().build(), + glib::ParamSpecBoxed::builder::("selected") + .write_only() + .build(), + glib::ParamSpecBoolean::builder("is-per-key") + .read_only() + .build(), ] }); PROPERTIES.as_ref() } - fn set_property( - &self, - obj: &Self::Type, - _id: usize, - value: &glib::Value, - pspec: &glib::ParamSpec, - ) { + fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) { match pspec.name() { "selected" => { let selected: &SelectedKeys = value.get().unwrap(); - obj.inner().selected.replace(selected.clone()); - obj.update_per_key(); + self.selected.replace(selected.clone()); + self.obj().update_per_key(); } _ => unimplemented!(), } } - fn property(&self, obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { + fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { match pspec.name() { - "mode" => obj.mode().id.to_value(), - "is-per-key" => obj.mode().is_per_key().to_value(), + "mode" => self.obj().mode().id.to_value(), + "is-per-key" => self.obj().mode().is_per_key().to_value(), _ => unimplemented!(), } } @@ -245,7 +227,7 @@ impl Backlight { let max_brightness = board.max_brightness() as f64; let has_led_save = board.has_led_save(); - let obj: Self = glib::Object::new(&[]).unwrap(); + let obj: Self = glib::Object::new(); obj.inner().board.set(board.clone()); obj.inner().keyboard_color.set_board(Some(board)); obj.inner().brightness_scale.set_range(0.0, max_brightness); @@ -280,7 +262,7 @@ impl Backlight { } fn inner(&self) -> &BacklightInner { - BacklightInner::from_instance(self) + BacklightInner::from_obj(self) } fn board(&self) -> &Board { diff --git a/src/configurator_app.rs b/src/configurator_app.rs index 2c3ae76f..1849e2ba 100644 --- a/src/configurator_app.rs +++ b/src/configurator_app.rs @@ -21,10 +21,12 @@ impl ObjectSubclass for ConfiguratorAppInner { } impl ObjectImpl for ConfiguratorAppInner { - fn constructed(&self, app: &ConfiguratorApp) { + fn constructed(&self) { + let app = self.obj(); + app.set_application_id(Some("com.system76.keyboardconfigurator")); - self.parent_constructed(app); + self.parent_constructed(); app.add_main_option( "fake-keyboard", @@ -54,7 +56,7 @@ impl ObjectImpl for ConfiguratorAppInner { } impl ApplicationImpl for ConfiguratorAppInner { - fn handle_local_options(&self, _app: &ConfiguratorApp, opts: &glib::VariantDict) -> i32 { + fn handle_local_options(&self, opts: &glib::VariantDict) -> glib::ExitCode { fn lookup(opts: &glib::VariantDict, key: &str) -> Option { opts.lookup_value(key, None)?.get() } @@ -69,11 +71,11 @@ impl ApplicationImpl for ConfiguratorAppInner { self.debug_layers.set(opts.contains("debug-layers")); self.launch_test.set(opts.contains("launch-test")); - -1 + self.parent_handle_local_options(opts) } - fn startup(&self, app: &ConfiguratorApp) { - self.parent_startup(app); + fn startup(&self) { + self.parent_startup(); let about_action = cascade! { gio::SimpleAction::new("about", None); @@ -110,6 +112,7 @@ impl ApplicationImpl for ConfiguratorAppInner { }); }; + let app = self.obj(); app.add_action(&about_action); app.add_action(&flash_heavy_1); app.add_action(&flash_2); @@ -122,14 +125,14 @@ impl ApplicationImpl for ConfiguratorAppInner { } } - fn activate(&self, app: &ConfiguratorApp) { - self.parent_activate(app); + fn activate(&self) { + self.parent_activate(); - if let Some(window) = app.active_window() { + if let Some(window) = self.obj().active_window() { info!("Focusing current window"); window.present(); } else { - MainWindow::new(app); + MainWindow::new(&*self.obj()); } } } @@ -144,11 +147,11 @@ glib::wrapper! { impl ConfiguratorApp { fn new() -> Self { - glib::Object::new(&[]).unwrap() + glib::Object::new() } fn inner(&self) -> &ConfiguratorAppInner { - ConfiguratorAppInner::from_instance(self) + ConfiguratorAppInner::from_obj(self) } pub fn phony_board_names(&self) -> &[String] { @@ -225,7 +228,7 @@ fn windows_init() { } } -pub fn run() -> i32 { +pub fn run() -> glib::ExitCode { gtk::init().unwrap(); glib::set_prgname(Some("com.system76.keyboardconfigurator")); diff --git a/src/keyboard.rs b/src/keyboard.rs index de4410e6..a0ed0489 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -42,8 +42,10 @@ impl ObjectSubclass for KeyboardInner { } impl ObjectImpl for KeyboardInner { - fn constructed(&self, keyboard: &Keyboard) { - self.parent_constructed(keyboard); + fn constructed(&self) { + self.parent_constructed(); + + let keyboard = self.obj(); let layer_stack = cascade! { gtk::Stack::new(); @@ -85,7 +87,7 @@ impl ObjectImpl for KeyboardInner { }; cascade! { - keyboard; + &keyboard; ..set_orientation(gtk::Orientation::Vertical); ..set_spacing(32); ..add(&stack_switcher); @@ -136,35 +138,24 @@ impl ObjectImpl for KeyboardInner { fn properties() -> &'static [glib::ParamSpec] { use once_cell::sync::Lazy; - static PROPERTIES: Lazy> = Lazy::new(|| { - vec![glib::ParamSpecBoxed::new( - "selected", - "selected", - "selected", - SelectedKeys::static_type(), - glib::ParamFlags::READWRITE, - )] - }); + static PROPERTIES: Lazy> = + Lazy::new(|| vec![glib::ParamSpecBoxed::builder::("selected").build()]); PROPERTIES.as_ref() } - fn set_property( - &self, - keyboard: &Keyboard, - _id: usize, - value: &glib::Value, - pspec: &glib::ParamSpec, - ) { + fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) { match pspec.name() { - "selected" => keyboard.set_selected(value.get::<&SelectedKeys>().unwrap().clone()), + "selected" => self + .obj() + .set_selected(value.get::<&SelectedKeys>().unwrap().clone()), _ => unimplemented!(), } } - fn property(&self, keyboard: &Keyboard, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { + fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { match pspec.name() { - "selected" => keyboard.selected().to_value(), + "selected" => self.obj().selected().to_value(), _ => unimplemented!(), } } @@ -181,7 +172,7 @@ glib::wrapper! { impl Keyboard { pub fn new(board: Board, debug_layers: bool, launch_test: bool) -> Self { - let keyboard: Self = glib::Object::new(&[]).unwrap(); + let keyboard: Self = glib::Object::new(); keyboard .inner() @@ -258,7 +249,7 @@ impl Keyboard { } fn inner(&self) -> &KeyboardInner { - KeyboardInner::from_instance(self) + KeyboardInner::from_obj(self) } pub fn handle_backend_event(&self, event: BoardEvent) { @@ -417,7 +408,7 @@ impl Keyboard { let chooser = cascade! { gtk::FileChooserNative::new(Some(&fl!("layout-import")), None::<>k::Window>, gtk::FileChooserAction::Open, Some(&fl!("button-import")), Some(&fl!("button-cancel"))); - ..add_filter(&filter); + ..add_filter(filter); }; if chooser.run() == gtk::ResponseType::Accept { @@ -448,7 +439,7 @@ impl Keyboard { let chooser = cascade! { gtk::FileChooserNative::new(Some(&fl!("layout-export")), None::<>k::Window>, gtk::FileChooserAction::Save, Some("Export"), Some("Cancel")); - ..add_filter(&filter); + ..add_filter(filter); ..set_current_name(&format!("{}.json", fl!("untitled-layout"))); ..set_do_overwrite_confirmation(true); }; diff --git a/src/keyboard_layer.rs b/src/keyboard_layer.rs index 10d8cd5d..44ff1d43 100644 --- a/src/keyboard_layer.rs +++ b/src/keyboard_layer.rs @@ -35,60 +35,39 @@ impl ObjectSubclass for KeyboardLayerInner { } impl ObjectImpl for KeyboardLayerInner { - fn constructed(&self, widget: &KeyboardLayer) { - self.parent_constructed(widget); + fn constructed(&self) { + self.parent_constructed(); - widget.add_events(gdk::EventMask::BUTTON_PRESS_MASK); + self.obj().add_events(gdk::EventMask::BUTTON_PRESS_MASK); } fn properties() -> &'static [glib::ParamSpec] { use once_cell::sync::Lazy; static PROPERTIES: Lazy> = Lazy::new(|| { vec![ - glib::ParamSpecBoxed::new( - "selected", - "selected", - "selected", - SelectedKeys::static_type(), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoxed::new( - "testing-colors", - "testing-colors", - "testing-colors", - TestingColors::static_type(), - glib::ParamFlags::READWRITE, - ), + glib::ParamSpecBoxed::builder::("selected").build(), + glib::ParamSpecBoxed::builder::("testing-colors").build(), ] }); PROPERTIES.as_ref() } - fn set_property( - &self, - widget: &KeyboardLayer, - _id: usize, - value: &glib::Value, - pspec: &glib::ParamSpec, - ) { + fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) { match pspec.name() { - "selected" => widget.set_selected(value.get::<&SelectedKeys>().unwrap().clone()), + "selected" => self + .obj() + .set_selected(value.get::<&SelectedKeys>().unwrap().clone()), "testing-colors" => { self.testing_colors .replace(value.get::<&TestingColors>().unwrap().clone()); - widget.queue_draw(); + self.obj().queue_draw(); } _ => unimplemented!(), } } - fn property( - &self, - _widget: &KeyboardLayer, - _id: usize, - pspec: &glib::ParamSpec, - ) -> glib::Value { + fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { match pspec.name() { "selected" => self.selected.borrow().to_value(), "testing-colors" => self.testing_colors.borrow().to_value(), @@ -98,15 +77,15 @@ impl ObjectImpl for KeyboardLayerInner { } impl WidgetImpl for KeyboardLayerInner { - fn draw(&self, widget: &KeyboardLayer, cr: &cairo::Context) -> Inhibit { - self.parent_draw(widget, cr); + fn draw(&self, cr: &cairo::Context) -> Inhibit { + self.parent_draw(cr); let selected = Rgb::new(0xfb, 0xb8, 0x6c).to_floats(); let testing_colors = self.testing_colors.borrow(); - for (i, k) in widget.keys().iter().enumerate() { - let Rect { x, y, w, h } = widget.key_position(k); + for (i, k) in self.obj().keys().iter().enumerate() { + let Rect { x, y, w, h } = self.obj().key_position(k); let mut bg = if let Some(rgb) = testing_colors .0 @@ -149,16 +128,16 @@ impl WidgetImpl for KeyboardLayerInner { cr.set_source_rgba(bg.0, bg.1, bg.2, bg_alpha); cr.fill_preserve().unwrap(); - if self.selectable.get() && widget.selected().contains(&i) { + if self.selectable.get() && self.obj().selected().contains(&i) { cr.set_source_rgb(selected.0, selected.1, selected.2); cr.set_line_width(4.); cr.stroke().unwrap(); } // Draw label - let text = widget.page().get_label(k); + let text = self.obj().page().get_label(k); let layout = cascade! { - widget.create_pango_layout(Some(&text)); + self.obj().create_pango_layout(Some(&text)); ..set_width((w * pango::SCALE as f64) as i32); ..set_alignment(pango::Alignment::Center); }; @@ -172,22 +151,23 @@ impl WidgetImpl for KeyboardLayerInner { Inhibit(false) } - fn button_press_event(&self, widget: &KeyboardLayer, evt: &gdk::EventButton) -> Inhibit { - self.parent_button_press_event(widget, evt); + fn button_press_event(&self, evt: &gdk::EventButton) -> Inhibit { + self.parent_button_press_event(evt); if !self.selectable.get() { return Inhibit(false); } let pos = evt.position(); - let pressed = widget + let pressed = self + .obj() .keys() .iter() - .position(|k| widget.key_position(k).contains(pos.0, pos.1)); + .position(|k| self.obj().key_position(k).contains(pos.0, pos.1)); if let Some(pressed) = pressed { let shift = evt.state().contains(gdk::ModifierType::SHIFT_MASK); - let mut selected = widget.selected(); + let mut selected = self.obj().selected(); if shift { if selected.contains(&pressed) { selected.remove(&pressed); @@ -200,36 +180,36 @@ impl WidgetImpl for KeyboardLayerInner { selected.clear(); selected.insert(pressed); } - widget.set_selected(selected); + self.obj().set_selected(selected); } Inhibit(false) } - fn request_mode(&self, _widget: &Self::Type) -> gtk::SizeRequestMode { + fn request_mode(&self) -> gtk::SizeRequestMode { gtk::SizeRequestMode::HeightForWidth } - fn preferred_width(&self, widget: &Self::Type) -> (i32, i32) { - (widget.narrow_width(), widget.wide_width()) + fn preferred_width(&self) -> (i32, i32) { + (self.obj().narrow_width(), self.obj().wide_width()) } - fn preferred_height(&self, widget: &Self::Type) -> (i32, i32) { - let height = widget.narrow_height(); + fn preferred_height(&self) -> (i32, i32) { + let height = self.obj().narrow_height(); (height, height) } - fn preferred_height_for_width(&self, widget: &Self::Type, width: i32) -> (i32, i32) { - let height = if width < widget.wide_width() { - widget.narrow_height() + fn preferred_height_for_width(&self, width: i32) -> (i32, i32) { + let height = if width < self.obj().wide_width() { + self.obj().narrow_height() } else { - widget.wide_height() + self.obj().wide_height() }; (height, height) } - fn preferred_width_for_height(&self, widget: &Self::Type, _width: i32) -> (i32, i32) { - self.preferred_width(widget) + fn preferred_width_for_height(&self, _width: i32) -> (i32, i32) { + self.preferred_width() } } @@ -242,14 +222,14 @@ glib::wrapper! { impl KeyboardLayer { pub fn new(page: Page, board: Board) -> Self { - let obj = glib::Object::new::(&[]).unwrap(); + let obj = glib::Object::new::(); obj.inner().page.set(page); obj.inner().board.set(board); obj } fn inner(&self) -> &KeyboardLayerInner { - KeyboardLayerInner::from_instance(self) + KeyboardLayerInner::from_obj(self) } pub fn page(&self) -> Page { diff --git a/src/main.rs b/src/main.rs index 205cec00..930d1afa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,6 @@ extern crate log; use i18n_embed::DesktopLanguageRequester; use std::env; -use std::process; mod about_dialog; mod backlight; @@ -20,13 +19,15 @@ mod picker; mod shortcuts_window; mod testing; +use gtk::glib; + pub use self::configurator_app::run; use self::{ backlight::*, configurator_app::*, error_dialog::*, keyboard::*, keyboard_layer::*, main_window::*, page::*, picker::*, shortcuts_window::*, testing::*, }; -fn main() { +fn main() -> glib::ExitCode { translate(); env_logger::Builder::from_env( env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), @@ -42,7 +43,7 @@ fn main() { } } - process::exit(crate::run()); + crate::run() } fn translate() { diff --git a/src/main_window.rs b/src/main_window.rs index cf8531f6..1620a04c 100644 --- a/src/main_window.rs +++ b/src/main_window.rs @@ -60,9 +60,10 @@ impl ObjectSubclass for MainWindowInner { } impl ObjectImpl for MainWindowInner { - fn constructed(&self, window: &MainWindow) { - self.parent_constructed(window); + fn constructed(&self) { + self.parent_constructed(); + let window = self.obj(); let back_button = cascade! { gtk::Button::new(); ..add(>k::Image::from_icon_name(Some("go-previous-symbolic"), gtk::IconSize::Button)); @@ -216,8 +217,8 @@ impl ObjectImpl for MainWindowInner { } } impl WidgetImpl for MainWindowInner { - fn destroy(&self, window: &MainWindow) { - self.parent_destroy(window); + fn destroy(&self) { + self.parent_destroy(); info!("Window close"); } } @@ -234,7 +235,7 @@ glib::wrapper! { impl MainWindow { pub fn new(app: &ConfiguratorApp) -> Self { - let window: Self = glib::Object::new(&[]).unwrap(); + let window: Self = glib::Object::new(); let is_testing_mode = app.launch_test(); app.add_window(&window); @@ -290,7 +291,7 @@ impl MainWindow { } fn inner(&self) -> &MainWindowInner { - MainWindowInner::from_instance(self) + MainWindowInner::from_obj(self) } fn handle_backend_event_stream(&self, mut receiver: backend::Events, is_dummy: bool) { diff --git a/src/picker/mod.rs b/src/picker/mod.rs index 1017805d..7e9cf33b 100644 --- a/src/picker/mod.rs +++ b/src/picker/mod.rs @@ -44,8 +44,10 @@ impl ObjectSubclass for PickerInner { } impl ObjectImpl for PickerInner { - fn constructed(&self, picker: &Picker) { - self.parent_constructed(picker); + fn constructed(&self) { + self.parent_constructed(); + + let picker = self.obj(); let group_box = cascade! { PickerGroupBox::new(); @@ -77,11 +79,11 @@ glib::wrapper! { impl Picker { pub fn new() -> Self { - glib::Object::new(&[]).unwrap() + glib::Object::new() } fn inner(&self) -> &PickerInner { - PickerInner::from_instance(self) + PickerInner::from_obj(self) } fn keyboard(&self) -> Option { diff --git a/src/picker/picker_group_box.rs b/src/picker/picker_group_box.rs index aa39800d..90a85233 100644 --- a/src/picker/picker_group_box.rs +++ b/src/picker/picker_group_box.rs @@ -42,8 +42,8 @@ impl ObjectSubclass for PickerGroupBoxInner { } impl ObjectImpl for PickerGroupBoxInner { - fn constructed(&self, widget: &PickerGroupBox) { - self.parent_constructed(widget); + fn constructed(&self) { + self.parent_constructed(); let style_provider = cascade! { gtk::CssProvider::new(); @@ -73,14 +73,14 @@ impl ObjectImpl for PickerGroupBoxInner { for group in &groups { group.vbox.show(); - group.vbox.set_parent(widget); + group.vbox.set_parent(&*self.obj()); } self.keys.set(keys); self.groups.set(groups); cascade! { - widget; + self.obj(); ..connect_signals(); ..show_all(); }; @@ -88,23 +88,20 @@ impl ObjectImpl for PickerGroupBoxInner { fn signals() -> &'static [Signal] { static SIGNALS: Lazy> = Lazy::new(|| { - vec![Signal::builder( - "key-pressed", - &[String::static_type().into()], - glib::Type::UNIT.into(), - ) - .build()] + vec![Signal::builder("key-pressed") + .param_types([String::static_type()]) + .build()] }); SIGNALS.as_ref() } } impl WidgetImpl for PickerGroupBoxInner { - fn request_mode(&self, _widget: &Self::Type) -> gtk::SizeRequestMode { + fn request_mode(&self) -> gtk::SizeRequestMode { gtk::SizeRequestMode::HeightForWidth } - fn preferred_width(&self, _widget: &Self::Type) -> (i32, i32) { + fn preferred_width(&self) -> (i32, i32) { let minimum_width = self .groups .iter() @@ -121,8 +118,9 @@ impl WidgetImpl for PickerGroupBoxInner { (minimum_width, natural_width) } - fn preferred_height_for_width(&self, widget: &Self::Type, width: i32) -> (i32, i32) { - let rows = widget.rows_for_width(width); + fn preferred_height_for_width(&self, width: i32) -> (i32, i32) { + let obj = self.obj(); + let rows = obj.rows_for_width(width); let height = rows .iter() .map(|row| { @@ -137,9 +135,10 @@ impl WidgetImpl for PickerGroupBoxInner { (height, height) } - fn size_allocate(&self, obj: &Self::Type, allocation: >k::Allocation) { - self.parent_size_allocate(obj, allocation); + fn size_allocate(&self, allocation: >k::Allocation) { + self.parent_size_allocate(allocation); + let obj = self.obj(); let rows = obj.rows_for_width(allocation.width()); let total_width = rows @@ -171,7 +170,9 @@ impl WidgetImpl for PickerGroupBoxInner { } } - fn realize(&self, widget: &Self::Type) { + fn realize(&self) { + let widget = self.obj(); + let allocation = widget.allocation(); widget.set_realized(true); @@ -188,23 +189,18 @@ impl WidgetImpl for PickerGroupBoxInner { let window = gdk::Window::new(widget.parent_window().as_ref(), &attrs); widget.register_window(&window); - widget.set_window(&window); + widget.set_window(window); } } impl ContainerImpl for PickerGroupBoxInner { - fn forall( - &self, - _obj: &Self::Type, - _include_internals: bool, - cb: >k::subclass::container::Callback, - ) { + fn forall(&self, _include_internals: bool, cb: >k::subclass::container::Callback) { for group in self.groups.iter() { cb.call(group.vbox.upcast_ref()); } } - fn remove(&self, _obj: &Self::Type, child: >k::Widget) { + fn remove(&self, child: >k::Widget) { child.unparent(); } } @@ -216,11 +212,11 @@ glib::wrapper! { impl PickerGroupBox { pub fn new() -> Self { - glib::Object::new(&[]).unwrap() + glib::Object::new() } fn inner(&self) -> &PickerGroupBoxInner { - PickerGroupBoxInner::from_instance(self) + PickerGroupBoxInner::from_obj(self) } fn connect_signals(&self) { diff --git a/src/testing.rs b/src/testing.rs index e15cbea8..e2b9c4f6 100644 --- a/src/testing.rs +++ b/src/testing.rs @@ -80,7 +80,7 @@ impl ObjectSubclass for TestingInner { } impl ObjectImpl for TestingInner { - fn constructed(&self, obj: &Self::Type) { + fn constructed(&self) { fn row(widget: &impl IsA) -> gtk::ListBoxRow { cascade! { gtk::ListBoxRow::new(); @@ -127,7 +127,7 @@ impl ObjectImpl for TestingInner { let reset_button = gtk::Button::with_label("Reset Testing"); - obj.add(&cascade! { + self.obj().add(&cascade! { gtk::ListBox::new(); ..set_valign(gtk::Align::Start); ..style_context().add_class("frame"); @@ -225,7 +225,7 @@ impl ObjectImpl for TestingInner { }); }; - obj.add(&cascade! { + self.obj().add(&cascade! { gtk::Box::new(gtk::Orientation::Horizontal, 18); ..set_valign(gtk::Align::Start); ..add(&cascade! { @@ -253,7 +253,7 @@ impl ObjectImpl for TestingInner { self.selma_stop_button.set(selma_stop_button); cascade! { - obj; + self.obj(); ..set_orientation(gtk::Orientation::Vertical); ..set_spacing(18); ..show_all(); @@ -262,19 +262,15 @@ impl ObjectImpl for TestingInner { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy> = Lazy::new(|| { - vec![glib::ParamSpecBoxed::new( - "colors", - "colors", - "colors", - TestingColors::static_type(), - glib::ParamFlags::READABLE, - )] + vec![glib::ParamSpecBoxed::builder::("colors") + .read_only() + .build()] }); PROPERTIES.as_ref() } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { + fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { match pspec.name() { "colors" => self.colors.borrow().to_value(), _ => unimplemented!(), @@ -557,7 +553,7 @@ impl Testing { } pub fn new(board: &Board, keyboard: &Keyboard) -> Self { - let obj: Self = glib::Object::new(&[]).unwrap(); + let obj: Self = glib::Object::new(); obj.inner().board.set(board.clone()); obj.inner().keyboard.set(keyboard.downgrade()); obj.connect_bench_button(); @@ -573,7 +569,7 @@ impl Testing { } fn inner(&self) -> &TestingInner { - TestingInner::from_instance(self) + TestingInner::from_obj(self) } #[allow(dead_code)] diff --git a/widgets/Cargo.toml b/widgets/Cargo.toml index 596d144c..939a231e 100644 --- a/widgets/Cargo.toml +++ b/widgets/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] cascade = "1" futures = "0.3.13" -gtk = { version = "0.15.0", features = ["v3_22"] } +gtk = { version = "0.17.0" } libc = "0.2" once_cell = "1.4" serde = { version = "1.0", features = ["derive"] } @@ -22,7 +22,7 @@ i18n-embed-fl = "0.5.0" rust-embed = { version = "5.9.0", features = ["debug-embed"] } [build-dependencies] -gio = "0.15.0" +gio = "0.17.0" [target.'cfg(target_os = "windows")'.dependencies] winreg = "0.8" diff --git a/widgets/examples/keyboard_color.rs b/widgets/examples/keyboard_color.rs index 5eceb620..ee1fe090 100644 --- a/widgets/examples/keyboard_color.rs +++ b/widgets/examples/keyboard_color.rs @@ -1,12 +1,11 @@ #![windows_subsystem = "windows"] use cascade::cascade; -use gtk::{gio, prelude::*}; -use std::process; +use gtk::{gio, glib, prelude::*}; use system76_keyboard_configurator_widgets::keyboard_backlight_widget; -fn main() { +fn main() -> glib::ExitCode { gtk::init().unwrap(); let application = cascade! { @@ -29,5 +28,5 @@ fn main() { }); }; - process::exit(application.run()); + application.run() } diff --git a/widgets/src/choose_color.rs b/widgets/src/choose_color.rs index e0d7ffcf..7762f7ba 100644 --- a/widgets/src/choose_color.rs +++ b/widgets/src/choose_color.rs @@ -103,7 +103,7 @@ pub async fn choose_color>( let window = w.toplevel().and_then(|x| x.downcast::().ok()); let dialog = cascade! { - gtk::builders::DialogBuilder::new() + gtk::Dialog::builder() .title(title) .use_header_bar(1) .modal(true) diff --git a/widgets/src/color_circle.rs b/widgets/src/color_circle.rs index ce136ad9..6b822581 100644 --- a/widgets/src/color_circle.rs +++ b/widgets/src/color_circle.rs @@ -21,11 +21,11 @@ impl ObjectSubclass for ColorCircleInner { impl ObjectImpl for ColorCircleInner {} impl WidgetImpl for ColorCircleInner { - fn draw(&self, widget: &ColorCircle, cr: &cairo::Context) -> Inhibit { - let width = f64::from(widget.allocated_width()); - let height = f64::from(widget.allocated_height()); + fn draw(&self, cr: &cairo::Context) -> Inhibit { + let width = f64::from(self.obj().allocated_width()); + let height = f64::from(self.obj().allocated_height()); - let flags = widget.state_flags(); + let flags = self.obj().state_flags(); let radius = width.min(height) / 2.; let alpha = if flags.contains(gtk::StateFlags::INSENSITIVE) { @@ -74,13 +74,13 @@ glib::wrapper! { impl ColorCircle { pub fn new(size: i32) -> Self { cascade! { - glib::Object::new::(&[]).unwrap(); + glib::Object::new::(); ..set_size_request(size, size); } } fn inner(&self) -> &ColorCircleInner { - ColorCircleInner::from_instance(self) + ColorCircleInner::from_obj(self) } pub fn set_colors(&self, colors: BTreeSet) { diff --git a/widgets/src/color_wheel.rs b/widgets/src/color_wheel.rs index 53d91d88..bfd7bfd3 100644 --- a/widgets/src/color_wheel.rs +++ b/widgets/src/color_wheel.rs @@ -32,14 +32,15 @@ impl ObjectSubclass for ColorWheelInner { } impl ObjectImpl for ColorWheelInner { - fn constructed(&self, wheel: &ColorWheel) { - self.parent_constructed(wheel); + fn constructed(&self) { + self.parent_constructed(); self.thread_pool .set(glib::ThreadPool::shared(None).unwrap()); + let wheel = self.obj(); self.gesture_drag.set(cascade! { - gtk::GestureDrag::new(wheel); + gtk::GestureDrag::new(&*wheel); ..set_propagation_phase(gtk::PropagationPhase::Bubble); ..connect_drag_begin(clone!(@weak wheel => move |_, start_x, start_y| { wheel.mouse_select((start_x, start_y)); @@ -56,85 +57,65 @@ impl ObjectImpl for ColorWheelInner { use once_cell::sync::Lazy; static PROPERTIES: Lazy> = Lazy::new(|| { vec![ - glib::ParamSpecBoxed::new( - "hs", - "hs", - "hs", - Hs::static_type(), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecDouble::new( - "hue", - "hue", - "hue", - 0., - 360., - 0., - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecDouble::new( - "saturation", - "saturation", - "saturation", - 0., - 100., - 0., - glib::ParamFlags::READWRITE, - ), + glib::ParamSpecBoxed::builder::("hs").build(), + glib::ParamSpecDouble::builder("hue") + .minimum(0.) + .maximum(360.) + .default_value(0.) + .build(), + glib::ParamSpecDouble::builder("saturation") + .minimum(0.) + .maximum(100.) + .default_value(0.) + .build(), ] }); PROPERTIES.as_ref() } - fn set_property( - &self, - wheel: &ColorWheel, - _id: usize, - value: &glib::Value, - pspec: &glib::ParamSpec, - ) { + fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) { match pspec.name() { "hs" => { - wheel.set_hs(*value.get::<&Hs>().unwrap()); + self.obj().set_hs(*value.get::<&Hs>().unwrap()); } "hue" => { let mut hue: f64 = value.get().unwrap(); hue = (hue * PI / 180.).max(0.).min(2. * PI); - let hs = wheel.hs(); - wheel.set_hs(Hs::new(hue, *hs.s)); + let hs = self.obj().hs(); + self.obj().set_hs(Hs::new(hue, *hs.s)); } "saturation" => { let mut saturation: f64 = value.get().unwrap(); saturation = (saturation / 100.).max(0.).min(1.); - let hs = wheel.hs(); - wheel.set_hs(hs); - wheel.set_hs(Hs::new(*hs.h, saturation)); + let hs = self.obj().hs(); + self.obj().set_hs(hs); + self.obj().set_hs(Hs::new(*hs.h, saturation)); } _ => unimplemented!(), } } - fn property(&self, wheel: &ColorWheel, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { + fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { match pspec.name() { - "hs" => wheel.hs().to_value(), + "hs" => self.obj().hs().to_value(), "hue" => { - let mut hue = *wheel.hs().h * 180. / PI; + let mut hue = *self.obj().hs().h * 180. / PI; hue = (360. + hue) % 360.; hue.to_value() } - "saturation" => (wheel.hs().s * 100.).to_value(), + "saturation" => (self.obj().hs().s * 100.).to_value(), _ => unimplemented!(), } } } impl WidgetImpl for ColorWheelInner { - fn draw(&self, wheel: &ColorWheel, cr: &cairo::Context) -> Inhibit { - self.parent_draw(wheel, cr); + fn draw(&self, cr: &cairo::Context) -> Inhibit { + self.parent_draw(cr); - let width = f64::from(wheel.allocated_width()); - let height = f64::from(wheel.allocated_height()); + let width = f64::from(self.obj().allocated_width()); + let height = f64::from(self.obj().allocated_height()); let radius = width.min(height) / 2.; @@ -155,7 +136,7 @@ impl WidgetImpl for ColorWheelInner { cr.fill().unwrap(); // Draw selector circle - let hs = wheel.hs(); + let hs = self.obj().hs(); let x = radius + hs.h.cos() * (*hs.s) * radius; let y = radius - hs.h.sin() * (*hs.s) * radius; cr.arc(x, y, 7.5, 0., 2. * PI); @@ -168,8 +149,9 @@ impl WidgetImpl for ColorWheelInner { Inhibit(false) } - fn size_allocate(&self, wheel: &ColorWheel, rect: &gdk::Rectangle) { - self.parent_size_allocate(wheel, rect); + fn size_allocate(&self, rect: &gdk::Rectangle) { + self.parent_size_allocate(rect); + let wheel = self.obj(); let (future, abort_handle) = abortable(clone!(@weak wheel, @strong rect => async move { let surface = Some(wheel.generate_surface(&rect).await); wheel.inner().surface.replace(surface); @@ -183,23 +165,23 @@ impl WidgetImpl for ColorWheelInner { }); } - fn request_mode(&self, _widget: &Self::Type) -> gtk::SizeRequestMode { + fn request_mode(&self) -> gtk::SizeRequestMode { gtk::SizeRequestMode::HeightForWidth } - fn preferred_width(&self, _widget: &Self::Type) -> (i32, i32) { + fn preferred_width(&self) -> (i32, i32) { (0, 300) } - fn preferred_height(&self, _widget: &Self::Type) -> (i32, i32) { + fn preferred_height(&self) -> (i32, i32) { (0, 300) } - fn preferred_height_for_width(&self, _widget: &Self::Type, width: i32) -> (i32, i32) { + fn preferred_height_for_width(&self, width: i32) -> (i32, i32) { (0, width) } - fn preferred_width_for_height(&self, _widget: &Self::Type, height: i32) -> (i32, i32) { + fn preferred_width_for_height(&self, height: i32) -> (i32, i32) { (0, height) } } @@ -213,11 +195,11 @@ glib::wrapper! { impl ColorWheel { pub fn new() -> Self { - glib::Object::new(&[]).unwrap() + glib::Object::new() } fn inner(&self) -> &ColorWheelInner { - ColorWheelInner::from_instance(self) + ColorWheelInner::from_obj(self) } pub fn hs(&self) -> Hs { @@ -279,7 +261,8 @@ impl ColorWheel { data }) .unwrap() - .await; + .await + .unwrap(); cairo::ImageSurface::create_for_data(data, cairo::Format::Rgb24, size, size, stride) .unwrap() diff --git a/widgets/src/keyboard_color.rs b/widgets/src/keyboard_color.rs index cdb24b32..e9a9327c 100644 --- a/widgets/src/keyboard_color.rs +++ b/widgets/src/keyboard_color.rs @@ -108,56 +108,39 @@ impl ObjectSubclass for KeyboardColorInner { } impl ObjectImpl for KeyboardColorInner { - fn constructed(&self, obj: &KeyboardColor) { - self.parent_constructed(obj); + fn constructed(&self) { + self.parent_constructed(); + let wheel = self.obj(); let circle = cascade! { ColorCircle::new(30); - ..connect_clicked(clone!(@weak obj => move |_| obj.circle_clicked())); + ..connect_clicked(clone!(@weak wheel => move |_| wheel.circle_clicked())); }; - obj.add(&circle); + self.obj().add(&circle); self.circle.set(circle); } fn properties() -> &'static [glib::ParamSpec] { use once_cell::sync::Lazy; - static PROPERTIES: Lazy> = Lazy::new(|| { - vec![glib::ParamSpecBoxed::new( - "hs", - "hs", - "hs", - Hs::static_type(), - glib::ParamFlags::READWRITE, - )] - }); + static PROPERTIES: Lazy> = + Lazy::new(|| vec![glib::ParamSpecBoxed::builder::("hs").build()]); PROPERTIES.as_ref() } - fn set_property( - &self, - widget: &KeyboardColor, - _id: usize, - value: &glib::Value, - pspec: &glib::ParamSpec, - ) { + fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) { match pspec.name() { "hs" => { let hs: &Hs = value.get().unwrap(); - widget.set_hs(*hs); + self.obj().set_hs(*hs); } _ => unimplemented!(), } } - fn property( - &self, - _widget: &KeyboardColor, - _id: usize, - pspec: &glib::ParamSpec, - ) -> glib::Value { + fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { match pspec.name() { "hs" => self.hs.get().to_value(), _ => unimplemented!(), @@ -166,8 +149,8 @@ impl ObjectImpl for KeyboardColorInner { } impl WidgetImpl for KeyboardColorInner { - fn destroy(&self, widget: &KeyboardColor) { - widget.cancel_dialog(); + fn destroy(&self) { + self.obj().cancel_dialog(); } } @@ -182,14 +165,14 @@ glib::wrapper! { impl KeyboardColor { pub fn new(board: Option, index: KeyboardColorIndex) -> Self { cascade! { - glib::Object::new::(&[]).unwrap(); + glib::Object::new::(); ..set_board(board); ..set_index(index); } } fn inner(&self) -> &KeyboardColorInner { - KeyboardColorInner::from_instance(self) + KeyboardColorInner::from_obj(self) } fn circle_clicked(&self) {