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 fdc8459b39
This commit is contained in:
Emmanuel Gil Peyrot
2021-03-14 00:21:56 +01:00
parent b348339b4e
commit 279c792345
2 changed files with 3 additions and 16 deletions

View File

@@ -11,33 +11,23 @@ mod imp {
use std::{cell::RefCell, rc::Rc}; use std::{cell::RefCell, rc::Rc};
#[derive(Default)]
pub struct GraphView { pub struct GraphView {
pub(super) nodes: RefCell<HashMap<u32, Node>>, pub(super) nodes: RefCell<HashMap<u32, Node>>,
pub(super) links: RefCell<HashMap<u32, crate::PipewireLink>>, pub(super) links: RefCell<HashMap<u32, crate::PipewireLink>>,
pub(super) dragged: Rc<RefCell<Option<gtk::Widget>>>, pub(super) dragged: Rc<RefCell<Option<gtk::Widget>>>,
} }
#[glib::object_subclass]
impl ObjectSubclass for GraphView { impl ObjectSubclass for GraphView {
const NAME: &'static str = "GraphView"; const NAME: &'static str = "GraphView";
type Type = super::GraphView; type Type = super::GraphView;
type ParentType = gtk::Widget; type ParentType = gtk::Widget;
type Instance = glib::subclass::simple::InstanceStruct<Self>;
type Class = glib::subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn class_init(klass: &mut Self::Class) { fn class_init(klass: &mut Self::Class) {
// The layout manager determines how child widgets are laid out. // The layout manager determines how child widgets are laid out.
klass.set_layout_manager_type::<gtk::FixedLayout>(); klass.set_layout_manager_type::<gtk::FixedLayout>();
} }
fn new() -> Self {
Self {
nodes: RefCell::new(HashMap::new()),
links: RefCell::new(HashMap::new()),
dragged: Rc::new(RefCell::new(None)),
}
}
} }
impl ObjectImpl for GraphView { impl ObjectImpl for GraphView {

View File

@@ -18,14 +18,11 @@ mod imp {
pub(super) num_ports_out: Cell<u32>, pub(super) num_ports_out: Cell<u32>,
} }
#[glib::object_subclass]
impl ObjectSubclass for Node { impl ObjectSubclass for Node {
const NAME: &'static str = "Node"; const NAME: &'static str = "Node";
type Type = super::Node; type Type = super::Node;
type ParentType = gtk::Widget; type ParentType = gtk::Widget;
type Instance = glib::subclass::simple::InstanceStruct<Self>;
type Class = glib::subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn class_init(klass: &mut Self::Class) { fn class_init(klass: &mut Self::Class) {
klass.set_layout_manager_type::<gtk::BinLayout>(); klass.set_layout_manager_type::<gtk::BinLayout>();