From 726a6f4d41e14b9a14ec1a26e8cd49ea9e6a2b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Tue, 29 Nov 2022 08:42:12 +0000 Subject: [PATCH] cargo: update gst/gtk/gst-plugin-gtk4 --- Cargo.lock | 173 ++++++++++++++++++++-------------- Cargo.toml | 6 +- src/gps/element.rs | 41 +++++--- src/graphmanager/graphview.rs | 96 ++++++++----------- src/graphmanager/node.rs | 11 ++- src/graphmanager/port.rs | 13 +-- src/ui/properties.rs | 3 +- 7 files changed, 184 insertions(+), 159 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 499bc41..6d14b08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,6 +32,12 @@ version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" +[[package]] +name = "atomic_refcell" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73b5e5f48b927f04e952dedc932f31995a65a0bf65ec971c74436e51bf6e970d" + [[package]] name = "autocfg" version = "1.0.1" @@ -89,22 +95,23 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cairo-rs" -version = "0.15.1" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b869e97a87170f96762f9f178eae8c461147e722ba21dd8814105bf5716bf14a" +checksum = "247e1183fa769ac22121f92276dae52f89acaf297f24b1320019f439b6e3b46f" dependencies = [ "bitflags 1.3.2", "cairo-sys-rs", "glib", "libc", + "once_cell", "thiserror", ] [[package]] name = "cairo-sys-rs" -version = "0.15.1" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8" +checksum = "7c48f4af05fabdcfa9658178e1326efa061853f040ce7d72e33af6885196f421" dependencies = [ "glib-sys", "libc", @@ -194,9 +201,9 @@ dependencies = [ [[package]] name = "fragile" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da1b8f89c5b5a5b7e59405cfcf0bb9588e5ed19f0b57a4cd542bbba3f164a6d" +checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "futures-channel" @@ -230,6 +237,19 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" +[[package]] +name = "futures-macro" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" +dependencies = [ + "autocfg", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "futures-task" version = "0.3.17" @@ -244,17 +264,20 @@ checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" dependencies = [ "autocfg", "futures-core", + "futures-macro", "futures-task", "pin-project-lite", "pin-utils", + "proc-macro-hack", + "proc-macro-nested", "slab", ] [[package]] name = "gdk-pixbuf" -version = "0.15.1" +version = "0.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "172dfe1d9dfb62936bf7ad3ede2913a1b21b1e3db56990e46e00789201de9070" +checksum = "d3094f2b8578136d1929cade4e0fff82f573521b579e96cfc24af2458431f176" dependencies = [ "bitflags 1.3.2", "gdk-pixbuf-sys", @@ -265,9 +288,9 @@ dependencies = [ [[package]] name = "gdk-pixbuf-sys" -version = "0.15.1" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413424d9818621fa3cfc8a3a915cdb89a7c3c507d56761b4ec83a9a98e587171" +checksum = "3092cf797a5f1210479ea38070d9ae8a5b8e9f8f1be9f32f4643c529c7d70016" dependencies = [ "gio-sys", "glib-sys", @@ -278,9 +301,9 @@ dependencies = [ [[package]] name = "gdk4" -version = "0.4.8" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabb7cf843c26b085a5d68abb95d0c0bf27a9ae2eeff9c4adb503a1eb580876" +checksum = "dc7fc4b05be1159056c57a08102ea494892f75ff8517f5518b0401e466f77c69" dependencies = [ "bitflags 1.3.2", "cairo-rs", @@ -294,9 +317,9 @@ dependencies = [ [[package]] name = "gdk4-sys" -version = "0.4.8" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efe7dcb44f5c00aeabff3f69abfc5673de46559070f89bd3fbb7b66485d9cef2" +checksum = "c057b794185a52862037526fb95aafabce9427fb98a7e9f5fe39a6f832c92822" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -337,26 +360,29 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "gio" -version = "0.15.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e14e0166f772d6295cfda361d227a63194497641a42da81b9e531c9f5a4d77f" +checksum = "1d4a17d999e6e4e05d87c2bb05b7140d47769bc53211711a33e2f91536458714" dependencies = [ "bitflags 1.3.2", "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.1" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04b57719ccaacf2a0d9c79f151be629f3a3ef3991658ee2af0bb66287e4ea86c" +checksum = "e9b693b8e39d042a95547fc258a7b07349b1f0b48f4b2fa3108ba3c51c0b5229" dependencies = [ "glib-sys", "gobject-sys", @@ -367,15 +393,17 @@ dependencies = [ [[package]] name = "glib" -version = "0.15.6" +version = "0.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa570813c504bdf7539a9400180c2dd4b789a819556fb86da7226d7d1b037b49" +checksum = "d5204a4217749b385cefbfb7bf3a2fcde83e4ce6d0945f64440a1f5bd4010305" dependencies = [ "bitflags 1.3.2", "futures-channel", "futures-core", "futures-executor", "futures-task", + "futures-util", + "gio-sys", "glib-macros", "glib-sys", "gobject-sys", @@ -387,9 +415,9 @@ dependencies = [ [[package]] name = "glib-macros" -version = "0.15.1" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54c0c7194ee4c597b334e3ce84d22d929405e94497828e1c54da762cbe8e3d93" +checksum = "e084807350b01348b6d9dbabb724d1a0bb987f47a2c85de200e98e12e30733bf" dependencies = [ "anyhow", "heck 0.4.0", @@ -402,9 +430,9 @@ dependencies = [ [[package]] name = "glib-sys" -version = "0.15.1" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c668102c6e15e0a7f6b99b59f602c2e806967bb86414f617b77e19b1de5b3fac" +checksum = "c61a4f46316d06bfa33a7ac22df6f0524c8be58e3db2d9ca99ccb1f357b62a65" dependencies = [ "libc", "system-deps", @@ -412,9 +440,9 @@ dependencies = [ [[package]] name = "gobject-sys" -version = "0.15.1" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6edb1f0b3e4c08e2a0a490d1082ba9e902cdff8ff07091e85c6caec60d17e2ab" +checksum = "3520bb9c07ae2a12c7f2fbb24d4efc11231c8146a86956413fb1a79bb760a0f1" dependencies = [ "glib-sys", "libc", @@ -423,9 +451,9 @@ dependencies = [ [[package]] name = "graphene-rs" -version = "0.15.1" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c54f9fbbeefdb62c99f892dfca35f83991e2cb5b46a8dc2a715e58612f85570" +checksum = "95ecb4d347e6d09820df3bdfd89a74a8eec07753a06bb92a3aac3ad31d04447b" dependencies = [ "glib", "graphene-sys", @@ -434,9 +462,9 @@ dependencies = [ [[package]] name = "graphene-sys" -version = "0.15.1" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03f311acb023cf7af5537f35de028e03706136eead7f25a31e8fd26f5011e0b3" +checksum = "b9aa82337d3972b4eafdea71e607c23f47be6f27f749aab613f1ad8ddbe6dcd6" dependencies = [ "glib-sys", "libc", @@ -446,9 +474,9 @@ dependencies = [ [[package]] name = "gsk4" -version = "0.4.8" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e9020d333280b3aa38d496495bfa9b50712eebf1ad63f0ec5bcddb5eb61be4" +checksum = "5dcd01e485189515263f6d3ac8a624b1c0cd13c1097991e72d0cc0c145a303c0" dependencies = [ "bitflags 1.3.2", "cairo-rs", @@ -462,9 +490,9 @@ dependencies = [ [[package]] name = "gsk4-sys" -version = "0.4.8" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7add39ccf60078508c838643a2dcc91f045c46ed63b5ea6ab701b2e25bda3fea" +checksum = "f47c49111e33020615a6c6b78d755c8b54b8504143cae1bf972bccc03eaa3f59" dependencies = [ "cairo-sys-rs", "gdk4-sys", @@ -478,9 +506,9 @@ dependencies = [ [[package]] name = "gst-plugin-gtk4" -version = "0.1.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e62e047edb1932887c20105c681203d138ebeb61b83b9e0b368cdec1d0fbc0cc" +checksum = "52832b7e14e43c82e2139a0dbe704e8404bc6e306684cc417ccfdb876f522daa" dependencies = [ "fragile", "gst-plugin-version-helper", @@ -522,9 +550,9 @@ dependencies = [ [[package]] name = "gstreamer" -version = "0.18.8" +version = "0.19.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66363bacf5e4f6eb281564adc2902e44c52ae5c45082423e7439e9012b75456" +checksum = "e52247a9e1c5a2edb082fac77a59f8b40ec4c4eb719ccafe37072daabf4b56a9" dependencies = [ "bitflags 1.3.2", "cfg-if", @@ -546,10 +574,11 @@ dependencies = [ [[package]] name = "gstreamer-base" -version = "0.18.0" +version = "0.19.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224f35f36582407caf58ded74854526beeecc23d0cf64b8d1c3e00584ed6863f" +checksum = "a61a299f9ea2ca892b43e2e428b86c679875e95ba23f8ae06fd730308df630f0" dependencies = [ + "atomic_refcell", "bitflags 1.3.2", "cfg-if", "glib", @@ -560,9 +589,9 @@ dependencies = [ [[package]] name = "gstreamer-base-sys" -version = "0.18.0" +version = "0.19.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a083493c3c340e71fa7c66eebda016e9fafc03eb1b4804cf9b2bad61994b078e" +checksum = "dbc3c4476e1503ae245c89fbe20060c30ec6ade5f44620bcc402cbc70a3911a1" dependencies = [ "glib-sys", "gobject-sys", @@ -573,9 +602,9 @@ dependencies = [ [[package]] name = "gstreamer-sys" -version = "0.18.0" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3517a65d3c2e6f8905b456eba5d53bda158d664863aef960b44f651cb7d33e2" +checksum = "fd119152dff9472ef8fa76afe7fb85a8ec639a5388f5c4b68058ce794a765a2a" dependencies = [ "glib-sys", "gobject-sys", @@ -585,13 +614,12 @@ dependencies = [ [[package]] name = "gstreamer-video" -version = "0.18.1" +version = "0.19.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410c72d885a67aeb7dbfa49c347e6c85d60f54e1cdaf6aadf8b5364892451261" +checksum = "065f78ce526608441f215182b94b624580a1817fe2982d1b1b439ab8d370af30" dependencies = [ "bitflags 1.3.2", "cfg-if", - "fragile", "futures-channel", "glib", "gstreamer", @@ -603,9 +631,9 @@ dependencies = [ [[package]] name = "gstreamer-video-sys" -version = "0.18.0" +version = "0.19.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "255c487bf6dd145e23558eaf1c92ef0946ee1999d22bdadc1e492b463609c4b6" +checksum = "298b78c5980c7ca790c48bab740ca5ffe70d08997987da103bfbfc566bcfd2a9" dependencies = [ "glib-sys", "gobject-sys", @@ -617,9 +645,9 @@ dependencies = [ [[package]] name = "gtk4" -version = "0.4.8" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c64f0c2a3d80e899dc3febddad5bac193ffcf74a0fd7e31037f30dd34d6f7396" +checksum = "b4c61a704ecdedd1c0ca66ff0184bd19e9c488835bb391655bfe6b60f6e2e43e" dependencies = [ "bitflags 1.3.2", "cairo-rs", @@ -640,24 +668,23 @@ dependencies = [ [[package]] name = "gtk4-macros" -version = "0.4.8" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fafbcc920af4eb677d7d164853e7040b9de5a22379c596f570190c675d45f7a7" +checksum = "42f57e7025a8bae8429e07aeeae9c4c3fef5d7cd14834afdd6d6d23f76984246" dependencies = [ "anyhow", "proc-macro-crate", "proc-macro-error", "proc-macro2", - "quick-xml", "quote", "syn", ] [[package]] name = "gtk4-sys" -version = "0.4.8" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc8006eea634b7c72da3ff79e24606e45f21b3b832a3c5a1f543f5f97eb0f63" +checksum = "42e1bb57be47aac6ce77b5281ad64389a19db5aba6db75b07f0049571ad6fe0f" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -881,20 +908,21 @@ checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" [[package]] name = "option-operations" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95d6113415f41b268f1195907427519769e40ee6f28cbb053795098a2c16f447" +checksum = "7c26d27bb1aeab65138e4bf7666045169d1717febcc9ff870166be8348b223d0" dependencies = [ "paste", ] [[package]] name = "pango" -version = "0.15.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79211eff430c29cc38c69e0ab54bc78fa1568121ca9737707eee7f92a8417a94" +checksum = "f6a83cd4015382dbb0f4fcf3ab7b277d4885711a62b2f2c1e6582a120094edad" dependencies = [ "bitflags 1.3.2", + "gio", "glib", "libc", "once_cell", @@ -903,9 +931,9 @@ dependencies = [ [[package]] name = "pango-sys" -version = "0.15.1" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7022c2fb88cd2d9d55e1a708a8c53a3ae8678234c4a54bf623400aeb7f31fac2" +checksum = "9e134909a9a293e04d2cc31928aa95679c5e4df954d0b85483159bd20d8f047f" dependencies = [ "glib-sys", "gobject-sys", @@ -992,6 +1020,18 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro-nested" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" + [[package]] name = "proc-macro2" version = "1.0.30" @@ -1001,15 +1041,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "quick-xml" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b" -dependencies = [ - "memchr", -] - [[package]] name = "quote" version = "1.0.10" diff --git a/Cargo.toml b/Cargo.toml index 12f9aeb..28db425 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,9 +7,9 @@ rust-version = "1.63" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -gtk = { version = "0.4.8", package = "gtk4" } -gst = { package = "gstreamer", version = "0.18.8" } -gst-plugin-gtk4 = { version = "0.1.1", optional=true } +gtk = { version = "0.5.2", package = "gtk4" } +gst = { package = "gstreamer", version = "0.19.3" } +gst-plugin-gtk4 = { version = "0.9.1", optional=true } anyhow = "1" gettext-rs = {version = "0.7", features = ["gettext-system"]} log = "0.4.11" diff --git a/src/gps/element.rs b/src/gps/element.rs index 849b3d2..199faf0 100644 --- a/src/gps/element.rs +++ b/src/gps/element.rs @@ -138,9 +138,12 @@ impl ElementInfo { let factory = feature .downcast::() .expect("Unable to get the factory from the feature"); - let element = factory.create(None)?; + let element = factory.create().build()?; let value = element - .try_property::(property_name) + .property_value(property_name) + .transform::() + .expect("Unable to transform to string") + .get::() .unwrap_or_default(); Ok(value) } @@ -154,20 +157,29 @@ impl ElementInfo { let factory = feature .downcast::() .expect("Unable to get the factory from the feature"); - let element = factory.create(None)?; + let element = factory.create().build()?; let params = element.class().list_properties(); for param in params.iter() { - let value = element - .try_property::(param.name()) - .unwrap_or_default(); - GPS_INFO!( - "Property_name {}={} type={:?}", - param.name(), - value, - param.type_() - ); - properties_list.insert(String::from(param.name()), param.clone()); + GPS_INFO!("Property_name {}", param.name()); + if param.flags().contains(glib::ParamFlags::READABLE) { + match element.property_value(param.name()).transform::() { + Ok(value) => { + GPS_INFO!( + "Property_name {}={} type={:?}", + param.name(), + value.get::().unwrap_or_default(), + param.type_() + ); + properties_list.insert(String::from(param.name()), param.clone()); + } + Err(_e) => { + GPS_ERROR!("Unable to convert the param {} to string ", param.name()) + } + } + } else { + GPS_ERROR!("The param {} is not readable", param.name()) + } } Ok(properties_list) } @@ -179,7 +191,8 @@ impl ElementInfo { .downcast::() .expect("Unable to get the factory from the feature"); let element = factory - .create(None) + .create() + .build() .expect("Unable to create an element from the feature"); match element.dynamic_cast::() { Ok(uri_handler) => uri_handler.uri_type() == gst::URIType::Src, diff --git a/src/graphmanager/graphview.rs b/src/graphmanager/graphview.rs index 077402a..5c59658 100644 --- a/src/graphmanager/graphview.rs +++ b/src/graphmanager/graphview.rs @@ -75,8 +75,9 @@ mod imp { } impl ObjectImpl for GraphView { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); + fn constructed(&self) { + let obj = self.obj(); + self.parent_constructed(); let drag_state = Rc::new(RefCell::new(None)); let drag_controller = gtk::GestureDrag::new(); @@ -238,7 +239,7 @@ mod imp { obj.add_controller(&event_motion); } - fn dispose(&self, _obj: &Self::Type) { + fn dispose(&self) { self.nodes .borrow() .values() @@ -248,56 +249,34 @@ mod imp { fn signals() -> &'static [Signal] { static SIGNALS: Lazy> = Lazy::new(|| { vec![ - Signal::builder( - "port-right-clicked", - &[ - u32::static_type().into(), - u32::static_type().into(), - graphene::Point::static_type().into(), - ], - <()>::static_type().into(), - ) - .build(), - Signal::builder( - "node-right-clicked", - &[ - u32::static_type().into(), - graphene::Point::static_type().into(), - ], - <()>::static_type().into(), - ) - .build(), - Signal::builder( - "graph-right-clicked", - &[graphene::Point::static_type().into()], - <()>::static_type().into(), - ) - .build(), - Signal::builder( - "graph-updated", - // returns graph ID - &[u32::static_type().into()], - <()>::static_type().into(), - ) - .build(), - Signal::builder( - "node-added", - // returns graph ID and Node ID - &[u32::static_type().into(), u32::static_type().into()], - <()>::static_type().into(), - ) - .build(), - Signal::builder( - "port-added", - // returns graph ID, Node ID, Port ID - &[ - u32::static_type().into(), - u32::static_type().into(), - u32::static_type().into(), - ], - <()>::static_type().into(), - ) - .build(), + Signal::builder("port-right-clicked") + .param_types([ + u32::static_type(), + u32::static_type(), + graphene::Point::static_type(), + ]) + .build(), + Signal::builder("node-right-clicked") + .param_types([u32::static_type(), graphene::Point::static_type()]) + .build(), + Signal::builder("graph-right-clicked") + .param_types([graphene::Point::static_type()]) + .build(), + Signal::builder("graph-updated") + .param_types( + // returns graph ID + [u32::static_type()], + ) + .build(), + Signal::builder("node-added") + .param_types( + // returns graph ID and Node ID + [u32::static_type(), u32::static_type()], + ) + .build(), + Signal::builder("port-added") + .param_types([u32::static_type(), u32::static_type(), u32::static_type()]) + .build(), ] }); SIGNALS.as_ref() @@ -305,7 +284,7 @@ mod imp { } impl WidgetImpl for GraphView { - fn snapshot(&self, _widget: &Self::Type, snapshot: >k::Snapshot) { + fn snapshot(&self, snapshot: >k::Snapshot) { /* FIXME: A lot of hardcoded values in here. Try to use relative units (em) and colours from the theme as much as possible. */ @@ -313,7 +292,7 @@ mod imp { self.nodes .borrow() .values() - .for_each(|node| self.instance().snapshot_child(node, snapshot)); + .for_each(|node| self.obj().snapshot_child(node, snapshot)); for link in self.links.borrow().values() { if let Some((from_x, from_y, to_x, to_y)) = self.link_coordinates(link) { @@ -422,7 +401,7 @@ mod imp { point_from: &graphene::Point, point_to: &graphene::Point, ) { - let alloc = self.instance().allocation(); + let alloc = self.obj().allocation(); let link_cr = snapshot.append_cairo(&graphene::Rect::new( 0.0, @@ -473,7 +452,7 @@ impl GraphView { &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION, ); - glib::Object::new(&[]).expect("Failed to create GraphView") + glib::Object::new::(&[]) } /// Set graphview id @@ -1159,8 +1138,7 @@ impl GraphView { let transform = gsk::Transform::new() // Nodes should not be able to be dragged out of the view, so we use `max(coordinate, 0.0)` to prevent that. - .translate(&graphene::Point::new(f32::max(x, 0.0), f32::max(y, 0.0))) - .unwrap(); + .translate(&graphene::Point::new(f32::max(x, 0.0), f32::max(y, 0.0))); layout_manager .layout_child(widget) diff --git a/src/graphmanager/node.rs b/src/graphmanager/node.rs index f1fbc13..67c8566 100644 --- a/src/graphmanager/node.rs +++ b/src/graphmanager/node.rs @@ -114,12 +114,13 @@ mod imp { } impl ObjectImpl for Node { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); - self.layoutgrid.set_parent(obj); + fn constructed(&self) { + let obj = self.obj(); + self.parent_constructed(); + self.layoutgrid.set_parent(&*obj); } - fn dispose(&self, _obj: &Self::Type) { + fn dispose(&self) { self.layoutgrid.unparent(); } } @@ -136,7 +137,7 @@ impl Node { /// Create a new node /// pub fn new(id: u32, name: &str, node_type: NodeType) -> Self { - let res: Self = glib::Object::new(&[]).expect("Failed to create Node"); + let res = glib::Object::new::(&[]); let private = imp::Node::from_instance(&res); private.id.set(id).expect("Node id is already set"); res.set_name(name); diff --git a/src/graphmanager/port.rs b/src/graphmanager/port.rs index 5ce7047..4c444ed 100644 --- a/src/graphmanager/port.rs +++ b/src/graphmanager/port.rs @@ -76,7 +76,7 @@ mod imp { use once_cell::unsync::OnceCell; /// Graphical representation of a port. - #[derive(Default, Clone)] + #[derive(Default)] pub struct Port { pub(super) label: gtk::Label, pub(super) id: OnceCell, @@ -113,11 +113,12 @@ mod imp { } impl ObjectImpl for Port { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); - self.label.set_parent(obj); + fn constructed(&self) { + let obj = self.obj(); + self.parent_constructed(); + self.label.set_parent(&*obj); } - fn dispose(&self, _obj: &Self::Type) { + fn dispose(&self) { self.label.unparent() } } @@ -134,7 +135,7 @@ impl Port { /// pub fn new(id: u32, name: &str, direction: PortDirection, presence: PortPresence) -> Self { // Create the widget and initialize needed fields - let port: Self = glib::Object::new(&[]).expect("Failed to create Port"); + let port: Self = glib::Object::new::(&[]); port.add_css_class("port"); let private = imp::Port::from_instance(&port); private.id.set(id).expect("Port id already set"); diff --git a/src/ui/properties.rs b/src/ui/properties.rs index 82d9dbe..d6c01be 100644 --- a/src/ui/properties.rs +++ b/src/ui/properties.rs @@ -171,7 +171,8 @@ pub fn property_to_widget( pub fn display_plugin_properties(app: &GPSApp, element_name: &str, node_id: u32) { let update_properties: Rc>> = Rc::new(RefCell::new(HashMap::new())); - let properties = GPS::ElementInfo::element_properties(element_name).unwrap(); + let properties = GPS::ElementInfo::element_properties(element_name) + .expect("Should get the list of the properties properly"); let grid = gtk::Grid::new(); grid.set_column_spacing(4);