From ea6c59e5e9c8c80149d260244c907677768602e2 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Thu, 27 Oct 2022 20:50:40 +0300 Subject: [PATCH] video/gtk4: Rename Object types and struct to something simpler Avoid the confusion caused by SinkPaintable and PaintableSink, and instead refer to the objects as Paintable for the GdkPaintable subclass or PaintalbeSink for the gst element. Part-of: --- video/gtk4/src/sink/imp.rs | 6 +++--- video/gtk4/src/sink/mod.rs | 2 +- video/gtk4/src/sink/paintable/imp.rs | 16 ++++++++-------- video/gtk4/src/sink/paintable/mod.rs | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/video/gtk4/src/sink/imp.rs b/video/gtk4/src/sink/imp.rs index 7aa73a41..f0127b38 100644 --- a/video/gtk4/src/sink/imp.rs +++ b/video/gtk4/src/sink/imp.rs @@ -11,7 +11,7 @@ use super::SinkEvent; use crate::sink::frame::Frame; -use crate::sink::paintable::SinkPaintable; +use crate::sink::paintable::Paintable; use glib::prelude::*; use glib::Sender; @@ -29,7 +29,7 @@ use fragile::Fragile; pub(super) static CAT: Lazy = Lazy::new(|| { gst::DebugCategory::new( - "gtk4paintablesink", + "gstgtk4paintablesink", gst::DebugColorFlags::empty(), Some("GTK4 Paintable sink"), ) @@ -37,7 +37,7 @@ pub(super) static CAT: Lazy = Lazy::new(|| { #[derive(Default)] pub struct PaintableSink { - pub(super) paintable: Mutex>>, + pub(super) paintable: Mutex>>, info: Mutex>, pub(super) sender: Mutex>>, pub(super) pending_frame: Mutex>, diff --git a/video/gtk4/src/sink/mod.rs b/video/gtk4/src/sink/mod.rs index 657c0528..cb17dba1 100644 --- a/video/gtk4/src/sink/mod.rs +++ b/video/gtk4/src/sink/mod.rs @@ -22,7 +22,7 @@ mod imp; mod paintable; use frame::Frame; -use paintable::SinkPaintable; +use paintable::Paintable; enum SinkEvent { FrameChanged, diff --git a/video/gtk4/src/sink/paintable/imp.rs b/video/gtk4/src/sink/paintable/imp.rs index 43f6bb61..ca29fce9 100644 --- a/video/gtk4/src/sink/paintable/imp.rs +++ b/video/gtk4/src/sink/paintable/imp.rs @@ -22,29 +22,29 @@ use once_cell::sync::Lazy; pub(super) static CAT: Lazy = Lazy::new(|| { gst::DebugCategory::new( - "gtk4paintablesink-paintable", + "gstgtk4paintable", gst::DebugColorFlags::empty(), Some("GTK4 Paintable Sink Paintable"), ) }); #[derive(Default)] -pub struct SinkPaintable { +pub struct Paintable { paintables: RefCell>, cached_textures: RefCell>, } #[glib::object_subclass] -impl ObjectSubclass for SinkPaintable { - const NAME: &'static str = "GstGtk4PaintableSinkPaintable"; - type Type = super::SinkPaintable; +impl ObjectSubclass for Paintable { + const NAME: &'static str = "GstGtk4Paintable"; + type Type = super::Paintable; type ParentType = glib::Object; type Interfaces = (gdk::Paintable,); } -impl ObjectImpl for SinkPaintable {} +impl ObjectImpl for Paintable {} -impl PaintableImpl for SinkPaintable { +impl PaintableImpl for Paintable { fn intrinsic_height(&self) -> i32 { if let Some(paintable) = self.paintables.borrow().first() { f32::round(paintable.height) as i32 @@ -134,7 +134,7 @@ impl PaintableImpl for SinkPaintable { } } -impl SinkPaintable { +impl Paintable { pub(super) fn handle_frame_changed(&self, frame: Option) { if let Some(frame) = frame { gst::trace!(CAT, imp: self, "Received new frame"); diff --git a/video/gtk4/src/sink/paintable/mod.rs b/video/gtk4/src/sink/paintable/mod.rs index 60459533..4101f63e 100644 --- a/video/gtk4/src/sink/paintable/mod.rs +++ b/video/gtk4/src/sink/paintable/mod.rs @@ -17,23 +17,23 @@ use gtk::{gdk, glib}; mod imp; glib::wrapper! { - pub struct SinkPaintable(ObjectSubclass) + pub struct Paintable(ObjectSubclass) @implements gdk::Paintable; } -impl SinkPaintable { +impl Paintable { pub fn new() -> Self { glib::Object::new(&[]) } } -impl Default for SinkPaintable { +impl Default for Paintable { fn default() -> Self { Self::new() } } -impl SinkPaintable { +impl Paintable { pub(crate) fn handle_frame_changed(&self, frame: Option) { let imp = self.imp(); imp.handle_frame_changed(frame);