diff --git a/Cargo.lock b/Cargo.lock index bbd675b..db7b544 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,9 +2,9 @@ # It is not intended for manual editing. [[package]] name = "aho-corasick" -version = "0.7.15" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ "memchr", ] @@ -91,11 +91,10 @@ dependencies = [ [[package]] name = "cairo-rs" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "bitflags", "cairo-sys-rs", - "freetype", "glib", "libc", "thiserror", @@ -104,7 +103,7 @@ dependencies = [ [[package]] name = "cairo-sys-rs" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "glib-sys", "libc", @@ -149,9 +148,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clang-sys" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f54d78e30b388d4815220c8dd03fea5656b6c6d32adb59e89061552a102f8da1" +checksum = "853eda514c284c2287f4bf20ae614f8781f40a81d32ecda6e91449304dfe077c" dependencies = [ "glob", "libc", @@ -173,15 +172,6 @@ dependencies = [ "vec_map", ] -[[package]] -name = "cmake" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855" -dependencies = [ - "cc", -] - [[package]] name = "cookie-factory" version = "0.3.2" @@ -238,27 +228,6 @@ dependencies = [ "rustc_version", ] -[[package]] -name = "freetype" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee38378a9e3db1cc693b4f88d166ae375338a0ff75cb8263e1c601d51f35dc6" -dependencies = [ - "freetype-sys", - "libc", -] - -[[package]] -name = "freetype-sys" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a37d4011c0cc628dfa766fcc195454f4b068d7afdc2adfd28861191d866e731a" -dependencies = [ - "cmake", - "libc", - "pkg-config", -] - [[package]] name = "funty" version = "1.1.0" @@ -267,24 +236,24 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures-channel" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939" +checksum = "ce79c6a52a299137a6013061e0cf0e688fce5d7f1bc60125f520912fdb29ec25" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94" +checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815" [[package]] name = "futures-executor" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891a4b7b96d84d5940084b2a37632dd65deeae662c114ceaa2c879629c9c0ad1" +checksum = "10f6cb7042eda00f0049b1d2080aa4b93442997ee507eb3828e8bd7577f94c9d" dependencies = [ "futures-core", "futures-task", @@ -293,21 +262,21 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59" +checksum = "365a1a1fb30ea1c03a830fdb2158f5236833ac81fa0ad12fe35b29cddc35cb04" [[package]] name = "futures-task" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80" +checksum = "ba7aa51095076f3ba6d9a1f702f74bd05ec65f555d70d2033d55ba8d69f581bc" [[package]] name = "futures-util" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" +checksum = "3c144ad54d60f23927f0a6b6d816e4271278b64f005ad65e4e35291d2de9c025" dependencies = [ "futures-core", "futures-task", @@ -325,7 +294,7 @@ checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "gdk-pixbuf" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "gdk-pixbuf-sys", "gio", @@ -336,7 +305,7 @@ dependencies = [ [[package]] name = "gdk-pixbuf-sys" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "gio-sys", "glib-sys", @@ -348,7 +317,7 @@ dependencies = [ [[package]] name = "gdk4" version = "0.1.0" -source = "git+https://github.com/gtk-rs/gtk4-rs/#2a267d9b2d895d6d1ad94ec7c72aaf51b7cb7f1c" +source = "git+https://github.com/gtk-rs/gtk4-rs/#e90c5752ba5229f874e912e84bc83739003434ed" dependencies = [ "bitflags", "cairo-rs", @@ -363,13 +332,14 @@ dependencies = [ [[package]] name = "gdk4-sys" version = "0.1.0" -source = "git+https://github.com/gtk-rs/gtk4-rs/#2a267d9b2d895d6d1ad94ec7c72aaf51b7cb7f1c" +source = "git+https://github.com/gtk-rs/gtk4-rs/#e90c5752ba5229f874e912e84bc83739003434ed" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", "gio-sys", "glib-sys", "gobject-sys", + "graphene-sys", "libc", "pango-sys", "system-deps", @@ -378,7 +348,7 @@ dependencies = [ [[package]] name = "gio" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "bitflags", "futures-channel", @@ -394,7 +364,7 @@ dependencies = [ [[package]] name = "gio-sys" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "glib-sys", "gobject-sys", @@ -406,7 +376,7 @@ dependencies = [ [[package]] name = "glib" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "bitflags", "futures-channel", @@ -424,7 +394,7 @@ dependencies = [ [[package]] name = "glib-macros" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "anyhow", "heck", @@ -438,7 +408,7 @@ dependencies = [ [[package]] name = "glib-sys" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "libc", "system-deps", @@ -453,7 +423,7 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "gobject-sys" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "glib-sys", "libc", @@ -463,7 +433,7 @@ dependencies = [ [[package]] name = "graphene-rs" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "glib", "graphene-sys", @@ -473,7 +443,7 @@ dependencies = [ [[package]] name = "graphene-sys" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "glib-sys", "libc", @@ -484,7 +454,7 @@ dependencies = [ [[package]] name = "gsk4" version = "0.1.0" -source = "git+https://github.com/gtk-rs/gtk4-rs/#2a267d9b2d895d6d1ad94ec7c72aaf51b7cb7f1c" +source = "git+https://github.com/gtk-rs/gtk4-rs/#e90c5752ba5229f874e912e84bc83739003434ed" dependencies = [ "bitflags", "cairo-rs", @@ -499,7 +469,7 @@ dependencies = [ [[package]] name = "gsk4-sys" version = "0.1.0" -source = "git+https://github.com/gtk-rs/gtk4-rs/#2a267d9b2d895d6d1ad94ec7c72aaf51b7cb7f1c" +source = "git+https://github.com/gtk-rs/gtk4-rs/#e90c5752ba5229f874e912e84bc83739003434ed" dependencies = [ "cairo-sys-rs", "gdk4-sys", @@ -514,7 +484,7 @@ dependencies = [ [[package]] name = "gtk4" version = "0.1.0" -source = "git+https://github.com/gtk-rs/gtk4-rs/#2a267d9b2d895d6d1ad94ec7c72aaf51b7cb7f1c" +source = "git+https://github.com/gtk-rs/gtk4-rs/#e90c5752ba5229f874e912e84bc83739003434ed" dependencies = [ "bitflags", "cairo-rs", @@ -536,11 +506,11 @@ dependencies = [ [[package]] name = "gtk4-macros" version = "0.1.0" -source = "git+https://github.com/gtk-rs/gtk4-rs/#2a267d9b2d895d6d1ad94ec7c72aaf51b7cb7f1c" +source = "git+https://github.com/gtk-rs/gtk4-rs/#e90c5752ba5229f874e912e84bc83739003434ed" dependencies = [ "anyhow", "heck", - "itertools 0.9.0", + "itertools", "proc-macro-crate", "proc-macro-error", "proc-macro2", @@ -551,7 +521,7 @@ dependencies = [ [[package]] name = "gtk4-sys" version = "0.1.0" -source = "git+https://github.com/gtk-rs/gtk4-rs/#2a267d9b2d895d6d1ad94ec7c72aaf51b7cb7f1c" +source = "git+https://github.com/gtk-rs/gtk4-rs/#e90c5752ba5229f874e912e84bc83739003434ed" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -601,15 +571,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "itertools" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.10.0" @@ -633,9 +594,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lexical-core" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21f866863575d0e1d654fbeeabdc927292fdf862873dc3c96c6f753357e13374" +checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" dependencies = [ "arrayvec", "bitflags", @@ -646,9 +607,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.91" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8916b1f6ca17130ec6568feccee27c156ad12037880833a3b842a823236502e7" +checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] name = "libloading" @@ -695,15 +656,15 @@ dependencies = [ [[package]] name = "memchr" -version = "2.3.4" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" [[package]] name = "memoffset" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc14fc54a812b4472b4113facc3e44d099fbc0ea2ce0551fa5c703f8edfbfd38" +checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" dependencies = [ "autocfg", ] @@ -753,7 +714,7 @@ checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" [[package]] name = "pango" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "bitflags", "glib", @@ -765,7 +726,7 @@ dependencies = [ [[package]] name = "pango-sys" version = "0.13.0" -source = "git+https://github.com/gtk-rs/gtk-rs#51fea9aa4aff93a0322e87ea27c090465f43f1f4" +source = "git+https://github.com/gtk-rs/gtk-rs#74a02cdd2855a387ebbe700eb509029c8e338d19" dependencies = [ "glib-sys", "gobject-sys", @@ -835,10 +796,11 @@ checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "proc-macro-crate" -version = "0.1.5" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +checksum = "41fdbd1df62156fbc5945f4762632564d7d038153091c3fcf1067f6aef7cff92" dependencies = [ + "thiserror", "toml", ] @@ -868,9 +830,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ "unicode-xid", ] @@ -892,9 +854,9 @@ checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" [[package]] name = "regex" -version = "1.4.5" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" dependencies = [ "aho-corasick", "memchr", @@ -903,9 +865,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.23" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "rustc-hash" @@ -970,9 +932,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" [[package]] name = "smallvec" @@ -1012,9 +974,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.65" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a1d708c221c5a612956ef9f75b37e454e88d1f7b899fbd3a18d4252012d663" +checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" dependencies = [ "proc-macro2", "quote", @@ -1023,14 +985,14 @@ dependencies = [ [[package]] name = "system-deps" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbb68eac6404c4c357c4a9a0d6395b82c753815d4bc0c4e3114a97b035c6459" +checksum = "c248107ad7bc1ac07066a4d003cae9e9a7bc2e27d3418f7a9cdcdc8699dbea70" dependencies = [ "anyhow", "cfg-expr", "heck", - "itertools 0.10.0", + "itertools", "pkg-config", "strum", "strum_macros", @@ -1112,9 +1074,9 @@ checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "vec_map" diff --git a/src/application.rs b/src/application.rs index 83ac6ff..92f6686 100644 --- a/src/application.rs +++ b/src/application.rs @@ -72,8 +72,8 @@ mod imp { .child(&scrollwindow) .build(); window - .get_settings() - .set_property_gtk_application_prefer_dark_theme(true); + .settings() + .set_gtk_application_prefer_dark_theme(true); window.show(); } @@ -84,7 +84,7 @@ mod imp { let provider = gtk::CssProvider::new(); provider.load_from_data(STYLE.as_bytes()); gtk::StyleContext::add_provider_for_display( - >k::gdk::Display::get_default().expect("Error initializing gtk css provider."), + >k::gdk::Display::default().expect("Error initializing gtk css provider."), &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION, ); @@ -197,8 +197,8 @@ impl Application { false, clone!(@weak self as app => @default-return None, move |args| { // Args always look like this: &[widget, id_port_from, id_port_to] - let port_from = args[1].get_some::().unwrap(); - let port_to = args[2].get_some::().unwrap(); + let port_from = args[1].get::().unwrap(); + let port_to = args[2].get::().unwrap(); app.toggle_link(port_from, port_to); diff --git a/src/main.rs b/src/main.rs index 7e3592b..9c59260 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,7 +62,7 @@ fn main() -> Result<(), Box> { let app = application::Application::new(gtk_receiver, pw_sender.clone()); - app.run(&std::env::args().collect::>()); + app.run(); pw_sender .send(GtkMessage::Terminate) diff --git a/src/view/graph_view.rs b/src/view/graph_view.rs index 75690c7..d317678 100644 --- a/src/view/graph_view.rs +++ b/src/view/graph_view.rs @@ -1,16 +1,16 @@ use super::Node; -use gtk::{glib, graphene, gsk, prelude::*, subclass::prelude::*, WidgetExt}; +use gtk::{gdk, glib, graphene, gsk, prelude::*, subclass::prelude::*}; use std::collections::HashMap; mod imp { use super::*; - use gtk::{gdk, WidgetExt}; - use std::{cell::RefCell, rc::Rc}; + use log::warn; + #[derive(Default)] pub struct GraphView { pub(super) nodes: RefCell>, @@ -38,7 +38,7 @@ mod imp { let motion_controller = gtk::EventControllerMotion::new(); motion_controller.connect_motion(|controller, x, y| { let instance = controller - .get_widget() + .widget() .unwrap() .dynamic_cast::() .unwrap(); @@ -46,9 +46,9 @@ mod imp { if let Some(ref widget) = *this.dragged.borrow() { if controller - .get_current_event() + .current_event() .unwrap() - .get_modifier_state() + .modifier_state() .contains(gdk::ModifierType::BUTTON1_MASK) { instance.move_node(&widget, x as f32, y as f32); @@ -71,7 +71,7 @@ mod imp { /* FIXME: A lot of hardcoded values in here. Try to use relative units (em) and colours from the theme as much as possible. */ - let alloc = widget.get_allocation(); + let alloc = widget.allocation(); let cr = snapshot .append_cairo(&graphene::Rect::new( @@ -83,9 +83,11 @@ mod imp { .expect("Failed to get cairo context"); // Try to replace the background color with a darker one from the theme. - if let Some(rgba) = widget.get_style_context().lookup_color("text_view_bg") { + if let Some(rgba) = widget.style_context().lookup_color("text_view_bg") { cr.set_source_rgb(rgba.red.into(), rgba.green.into(), rgba.blue.into()); - cr.paint(); + if let Err(e) = cr.paint() { + warn!("Failed to paint graphview background: {}", e); + }; } // TODO: else log colour not found // Draw a nice grid on the background. @@ -103,7 +105,9 @@ mod imp { cr.line_to(x, alloc.height as f64); x += 20.0; // TODO: Change to em; } - cr.stroke(); + if let Err(e) = cr.stroke() { + warn!("Failed to draw graphview grid: {}", e); + }; // Draw all links cr.set_line_width(2.0); @@ -112,7 +116,9 @@ mod imp { if let Some((from_x, from_y, to_x, to_y)) = self.get_link_coordinates(link) { cr.move_to(from_x, from_y); cr.curve_to(from_x + 75.0, from_y, to_x - 75.0, to_y, to_x, to_y); - cr.stroke(); + if let Err(e) = cr.stroke() { + warn!("Failed to draw graphview links: {}", e); + }; } else { log::warn!("Could not get allocation of ports of link: {:?}", link); } @@ -122,7 +128,7 @@ mod imp { self.nodes .borrow() .values() - .for_each(|node| self.get_instance().snapshot_child(node, snapshot)); + .for_each(|node| self.instance().snapshot_child(node, snapshot)); } } @@ -143,11 +149,11 @@ mod imp { y: mut fy, width: fw, height: fh, - } = from_port.get_allocation(); + } = from_port.allocation(); let from_node = from_port - .get_ancestor(Node::static_type()) + .ancestor(Node::static_type()) .expect("Port is not a child of a node"); - let gtk::Allocation { x: fnx, y: fny, .. } = from_node.get_allocation(); + let gtk::Allocation { x: fnx, y: fny, .. } = from_node.allocation(); fx += fnx + fw; fy += fny + (fh / 2); @@ -157,11 +163,11 @@ mod imp { y: mut ty, height: th, .. - } = to_port.get_allocation(); + } = to_port.allocation(); let to_node = to_port - .get_ancestor(Node::static_type()) + .ancestor(Node::static_type()) .expect("Port is not a child of a node"); - let gtk::Allocation { x: tnx, y: tny, .. } = to_node.get_allocation(); + let gtk::Allocation { x: tnx, y: tny, .. } = to_node.allocation(); tx += tnx; ty += tny + (th / 2); @@ -249,7 +255,7 @@ impl GraphView { pub(super) fn move_node(&self, node: >k::Widget, x: f32, y: f32) { let layout_manager = self - .get_layout_manager() + .layout_manager() .expect("Failed to get layout manager") .dynamic_cast::() .expect("Failed to cast to FixedLayout"); @@ -260,7 +266,7 @@ impl GraphView { .unwrap(); layout_manager - .get_layout_child(node) + .layout_child(node) .expect("Could not get layout child") .dynamic_cast::() .expect("Could not cast to FixedLayoutChild") diff --git a/src/view/node.rs b/src/view/node.rs index 9f1e8a2..f6756d8 100644 --- a/src/view/node.rs +++ b/src/view/node.rs @@ -1,6 +1,6 @@ use super::graph_view::GraphView; -use gtk::{glib, prelude::*, subclass::prelude::*, WidgetExt}; +use gtk::{glib, prelude::*, subclass::prelude::*}; use pipewire::spa::Direction; use std::{collections::HashMap, rc::Rc}; @@ -38,12 +38,12 @@ mod imp { motion_controller.connect_enter(|controller, _, _| { // Tell the graphview that the Node is the target of a drag when the mouse enters its label let widget = controller - .get_widget() + .widget() .expect("Controller with enter event has no widget") - .get_ancestor(super::Node::static_type()) + .ancestor(super::Node::static_type()) .expect("Node label does not have a node ancestor widget"); widget - .get_ancestor(GraphView::static_type()) + .ancestor(GraphView::static_type()) .expect("Node with enter event is not on graph") .dynamic_cast::() .unwrap() @@ -53,9 +53,9 @@ mod imp { // Tell the graphview that the Node is no longer the target of a drag when the mouse leaves. // FIXME: Check that we are the current target before setting none. controller - .get_widget() + .widget() .expect("Controller with leave event has no widget") - .get_ancestor(GraphView::static_type()) + .ancestor(GraphView::static_type()) .expect("Node with leave event is not on graph") .dynamic_cast::() .unwrap() diff --git a/src/view/port.rs b/src/view/port.rs index 07d7f5c..1819f83 100644 --- a/src/view/port.rs +++ b/src/view/port.rs @@ -80,11 +80,10 @@ impl Port { let drop_target = gtk::DropTarget::new(u32::static_type(), gdk::DragAction::COPY); let this = res.clone(); drop_target.connect_drop(move |drop_target, val, _, _| { - if let Some(source_id) = val.downcast_ref::() { + if let Ok(source_id) = val.get::() { // Get the callback registered in the widget and call it - let source_id = source_id.get_some(); drop_target - .get_widget() + .widget() .expect("Drop target has no widget") .emit_by_name("port-toggled", &[&source_id, &this.id()]) .expect("Failed to send signal"); @@ -99,7 +98,7 @@ impl Port { Direction::Output => { // The port will simply provide its pipewire id to the drag target. let drag_src = gtk::DragSourceBuilder::new() - .content(&gdk::ContentProvider::new_for_value(&(id.to_value()))) + .content(&gdk::ContentProvider::for_value(&(id.to_value()))) .build(); res.add_controller(&drag_src); }