From 279c792345ffc7e2d111b9b95662ec7ca79e1282 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 14 Mar 2021 00:21:56 +0100 Subject: [PATCH] Update to build with latest glib glib replaced its glib::object_subclass!() macro with a #[glib::object_subclass] attribute, to simplify a bunch of things. See https://github.com/gtk-rs/gtk-rs/commit/fdc8459b39f692919bed586abda22793ab42f15f --- src/view/graph_view.rs | 14 ++------------ src/view/node.rs | 5 +---- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/view/graph_view.rs b/src/view/graph_view.rs index ab20316..b107770 100644 --- a/src/view/graph_view.rs +++ b/src/view/graph_view.rs @@ -11,33 +11,23 @@ mod imp { use std::{cell::RefCell, rc::Rc}; + #[derive(Default)] pub struct GraphView { pub(super) nodes: RefCell>, pub(super) links: RefCell>, pub(super) dragged: Rc>>, } + #[glib::object_subclass] impl ObjectSubclass for GraphView { const NAME: &'static str = "GraphView"; type Type = super::GraphView; type ParentType = gtk::Widget; - type Instance = glib::subclass::simple::InstanceStruct; - type Class = glib::subclass::simple::ClassStruct; - - glib::object_subclass!(); fn class_init(klass: &mut Self::Class) { // The layout manager determines how child widgets are laid out. klass.set_layout_manager_type::(); } - - fn new() -> Self { - Self { - nodes: RefCell::new(HashMap::new()), - links: RefCell::new(HashMap::new()), - dragged: Rc::new(RefCell::new(None)), - } - } } impl ObjectImpl for GraphView { diff --git a/src/view/node.rs b/src/view/node.rs index 9f3cac5..9c8b607 100644 --- a/src/view/node.rs +++ b/src/view/node.rs @@ -18,14 +18,11 @@ mod imp { pub(super) num_ports_out: Cell, } + #[glib::object_subclass] impl ObjectSubclass for Node { const NAME: &'static str = "Node"; type Type = super::Node; type ParentType = gtk::Widget; - type Instance = glib::subclass::simple::InstanceStruct; - type Class = glib::subclass::simple::ClassStruct; - - glib::object_subclass!(); fn class_init(klass: &mut Self::Class) { klass.set_layout_manager_type::();