Repository: gtk-rs/gtk3-rs (language: rust)

Issue:
Simplify various IsSubclassable impls
See https://github.com/gtk-rs/gtk-rs-core/pull/241


Discussion / hints:

Fix patch:
diff --git a/gtk/src/subclass/application.rs b/gtk/src/subclass/application.rs
index 85ef98897cde..661b15a3f707 100644
--- a/gtk/src/subclass/application.rs
+++ b/gtk/src/subclass/application.rs
@@ -93,7 +93,7 @@ unsafe impl<T: GtkApplicationImpl> IsSubclassable<T> for Application {
             imp.startup(wrap.unsafe_cast_ref())
         }
 
-        <gio::Application as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.window_added = Some(application_window_added::<T>);
@@ -102,8 +102,4 @@ unsafe impl<T: GtkApplicationImpl> IsSubclassable<T> for Application {
         let klass = &mut class.as_mut().parent_class;
         klass.startup = Some(application_startup::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <gio::Application as IsSubclassable<T>>::instance_init(instance);
-    }
 }
diff --git a/gtk/src/subclass/application_window.rs b/gtk/src/subclass/application_window.rs
index 7b22d5302fc1..250d1cc847ae 100644
--- a/gtk/src/subclass/application_window.rs
+++ b/gtk/src/subclass/application_window.rs
@@ -4,16 +4,11 @@ use glib::subclass::prelude::*;
 
 use super::window::WindowImpl;
 use crate::ApplicationWindow;
-use crate::Window;
 
 pub trait ApplicationWindowImpl: WindowImpl {}
 
 unsafe impl<T: ApplicationWindowImpl> IsSubclassable<T> for ApplicationWindow {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Window as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Window as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/bin.rs b/gtk/src/subclass/bin.rs
index 64ff89db53be..b57ffaa29381 100644
--- a/gtk/src/subclass/bin.rs
+++ b/gtk/src/subclass/bin.rs
@@ -4,16 +4,11 @@ use glib::subclass::prelude::*;
 
 use super::container::ContainerImpl;
 use crate::Bin;
-use crate::Container;
 
 pub trait BinImpl: ContainerImpl {}
 
 unsafe impl<T: BinImpl> IsSubclassable<T> for Bin {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Container as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Container as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/box_.rs b/gtk/src/subclass/box_.rs
index c9739646a6c1..bda2637bffc6 100644
--- a/gtk/src/subclass/box_.rs
+++ b/gtk/src/subclass/box_.rs
@@ -4,16 +4,11 @@ use glib::subclass::prelude::*;
 
 use super::container::ContainerImpl;
 use crate::Box;
-use crate::Container;
 
 pub trait BoxImpl: ContainerImpl {}
 
 unsafe impl<T: BoxImpl> IsSubclassable<T> for Box {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Container as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Container as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/button.rs b/gtk/src/subclass/button.rs
index 23bb5bccbd57..6a47bd4aa02a 100644
--- a/gtk/src/subclass/button.rs
+++ b/gtk/src/subclass/button.rs
@@ -5,7 +5,7 @@ use glib::translate::*;
 use glib::Cast;
 
 use super::bin::BinImpl;
-use crate::{Bin, Button};
+use crate::Button;
 
 pub trait ButtonImpl: ButtonImplExt + BinImpl {
     fn activate(&self, button: &Self::Type) {
@@ -46,16 +46,12 @@ impl<T: ButtonImpl> ButtonImplExt for T {
 
 unsafe impl<T: ButtonImpl> IsSubclassable<T> for Button {
     fn class_init(class: &mut glib::Class<Self>) {
-        <Bin as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.activate = Some(button_activate::<T>);
         klass.clicked = Some(button_clicked::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Bin as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn button_activate<T: ButtonImpl>(ptr: *mut ffi::GtkButton) {
diff --git a/gtk/src/subclass/cell_renderer.rs b/gtk/src/subclass/cell_renderer.rs
index 8fcae22c7af0..4eb626150acb 100644
--- a/gtk/src/subclass/cell_renderer.rs
+++ b/gtk/src/subclass/cell_renderer.rs
@@ -8,7 +8,6 @@ use glib::subclass::prelude::*;
 use glib::translate::*;
 use glib::Cast;
 use glib::GString;
-use glib::Object;
 
 use crate::CellEditable;
 use crate::CellRenderer;
@@ -422,7 +421,7 @@ impl<T: CellRendererImpl> CellRendererImplExt for T {
 
 unsafe impl<T: CellRendererImpl> IsSubclassable<T> for CellRenderer {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Object as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.get_request_mode = Some(cell_renderer_get_request_mode::<T>);
@@ -439,10 +438,6 @@ unsafe impl<T: CellRendererImpl> IsSubclassable<T> for CellRenderer {
         klass.editing_started = Some(cell_renderer_editing_started::<T>);
         klass.editing_canceled = Some(cell_renderer_editing_canceled::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Object as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn cell_renderer_get_request_mode<T: CellRendererImpl>(
diff --git a/gtk/src/subclass/cell_renderer_accel.rs b/gtk/src/subclass/cell_renderer_accel.rs
index 4cf1cb46a2fc..c1b4d12e77b4 100644
--- a/gtk/src/subclass/cell_renderer_accel.rs
+++ b/gtk/src/subclass/cell_renderer_accel.rs
@@ -8,7 +8,6 @@ use glib::{Cast, GString};
 
 use super::cell_renderer_text::CellRendererTextImpl;
 use crate::CellRendererAccel;
-use crate::CellRendererText;
 
 pub trait CellRendererAccelImpl: CellRendererAccelImplExt + CellRendererTextImpl {
     fn accel_edited(
@@ -85,16 +84,12 @@ impl<T: CellRendererAccelImpl> CellRendererAccelImplExt for T {
 
 unsafe impl<T: CellRendererAccelImpl> IsSubclassable<T> for CellRendererAccel {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <CellRendererText as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.accel_edited = Some(cell_renderer_accel_edited::<T>);
         klass.accel_cleared = Some(cell_renderer_accel_cleared::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <CellRendererText as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn cell_renderer_accel_edited<T: CellRendererAccelImpl>(
diff --git a/gtk/src/subclass/cell_renderer_combo.rs b/gtk/src/subclass/cell_renderer_combo.rs
index 702903545fbf..8fbb9de7832c 100644
--- a/gtk/src/subclass/cell_renderer_combo.rs
+++ b/gtk/src/subclass/cell_renderer_combo.rs
@@ -4,16 +4,11 @@ use glib::subclass::prelude::*;
 
 use super::cell_renderer_text::CellRendererTextImpl;
 use crate::CellRendererCombo;
-use crate::CellRendererText;
 
 pub trait CellRendererComboImpl: CellRendererTextImpl {}
 
 unsafe impl<T: CellRendererComboImpl> IsSubclassable<T> for CellRendererCombo {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <CellRendererText as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <CellRendererText as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/cell_renderer_pixbuf.rs b/gtk/src/subclass/cell_renderer_pixbuf.rs
index c36ddcedb1e5..f3b632bfc2d6 100644
--- a/gtk/src/subclass/cell_renderer_pixbuf.rs
+++ b/gtk/src/subclass/cell_renderer_pixbuf.rs
@@ -3,17 +3,13 @@
 use glib::subclass::prelude::*;
 
 use super::cell_renderer::CellRendererImpl;
-use crate::CellRenderer;
+
 use crate::CellRendererPixbuf;
 
 pub trait CellRendererPixbufImpl: CellRendererImpl {}
 
 unsafe impl<T: CellRendererPixbufImpl> IsSubclassable<T> for CellRendererPixbuf {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <CellRenderer as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <CellRenderer as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/cell_renderer_progress.rs b/gtk/src/subclass/cell_renderer_progress.rs
index 356beff397e0..de657fa4b527 100644
--- a/gtk/src/subclass/cell_renderer_progress.rs
+++ b/gtk/src/subclass/cell_renderer_progress.rs
@@ -3,17 +3,13 @@
 use glib::subclass::prelude::*;
 
 use super::cell_renderer::CellRendererImpl;
-use crate::CellRenderer;
+
 use crate::CellRendererProgress;
 
 pub trait CellRendererProgressImpl: CellRendererImpl {}
 
 unsafe impl<T: CellRendererProgressImpl> IsSubclassable<T> for CellRendererProgress {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <CellRenderer as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <CellRenderer as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/cell_renderer_spin.rs b/gtk/src/subclass/cell_renderer_spin.rs
index 99a2bbc04b47..d504e30bdbe9 100644
--- a/gtk/src/subclass/cell_renderer_spin.rs
+++ b/gtk/src/subclass/cell_renderer_spin.rs
@@ -4,16 +4,11 @@ use glib::subclass::prelude::*;
 
 use super::cell_renderer_text::CellRendererTextImpl;
 use crate::CellRendererSpin;
-use crate::CellRendererText;
 
 pub trait CellRendererSpinImpl: CellRendererTextImpl {}
 
 unsafe impl<T: CellRendererSpinImpl> IsSubclassable<T> for CellRendererSpin {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <CellRendererText as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <CellRendererText as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/cell_renderer_spinner.rs b/gtk/src/subclass/cell_renderer_spinner.rs
index b763bfce8ae8..6f6319f3defd 100644
--- a/gtk/src/subclass/cell_renderer_spinner.rs
+++ b/gtk/src/subclass/cell_renderer_spinner.rs
@@ -3,17 +3,13 @@
 use glib::subclass::prelude::*;
 
 use super::cell_renderer::CellRendererImpl;
-use crate::CellRenderer;
+
 use crate::CellRendererSpinner;
 
 pub trait CellRendererSpinnerImpl: CellRendererImpl {}
 
 unsafe impl<T: CellRendererSpinnerImpl> IsSubclassable<T> for CellRendererSpinner {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <CellRenderer as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <CellRenderer as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/cell_renderer_text.rs b/gtk/src/subclass/cell_renderer_text.rs
index 4a0f26565eaf..102e895844d8 100644
--- a/gtk/src/subclass/cell_renderer_text.rs
+++ b/gtk/src/subclass/cell_renderer_text.rs
@@ -7,7 +7,7 @@ use glib::translate::*;
 use glib::{Cast, GString};
 
 use super::cell_renderer::CellRendererImpl;
-use crate::CellRenderer;
+
 use crate::CellRendererText;
 
 pub trait CellRendererTextImpl: CellRendererTextImplExt + CellRendererImpl {
@@ -41,15 +41,11 @@ impl<T: CellRendererTextImpl> CellRendererTextImplExt for T {
 
 unsafe impl<T: CellRendererTextImpl> IsSubclassable<T> for CellRendererText {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <CellRenderer as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.edited = Some(cell_renderer_text_edited::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <CellRenderer as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn cell_renderer_text_edited<T: CellRendererTextImpl>(
diff --git a/gtk/src/subclass/cell_renderer_toggle.rs b/gtk/src/subclass/cell_renderer_toggle.rs
index d309eda92eb3..e20fff552df6 100644
--- a/gtk/src/subclass/cell_renderer_toggle.rs
+++ b/gtk/src/subclass/cell_renderer_toggle.rs
@@ -7,7 +7,7 @@ use glib::translate::*;
 use glib::{Cast, GString};
 
 use super::cell_renderer::CellRendererImpl;
-use crate::CellRenderer;
+
 use crate::CellRendererToggle;
 
 pub trait CellRendererToggleImpl: CellRendererToggleImplExt + CellRendererImpl {
@@ -40,15 +40,11 @@ impl<T: CellRendererToggleImpl> CellRendererToggleImplExt for T {
 
 unsafe impl<T: CellRendererToggleImpl> IsSubclassable<T> for CellRendererToggle {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <CellRenderer as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.toggled = Some(cell_renderer_toggle_toggled::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <CellRenderer as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn cell_renderer_toggle_toggled<T: CellRendererToggleImpl>(
diff --git a/gtk/src/subclass/container.rs b/gtk/src/subclass/container.rs
index 773bd6d42e04..85675cfd4f7e 100644
--- a/gtk/src/subclass/container.rs
+++ b/gtk/src/subclass/container.rs
@@ -146,7 +146,7 @@ impl<T: ContainerImpl> ContainerImplExt for T {
 
 unsafe impl<T: ContainerImpl> IsSubclassable<T> for Container {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Widget as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.add = Some(container_add::<T>);
@@ -157,10 +157,6 @@ unsafe impl<T: ContainerImpl> IsSubclassable<T> for Container {
         klass.get_path_for_child = Some(container_get_path_for_child::<T>);
         klass.forall = Some(container_forall::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Widget as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn container_add<T: ContainerImpl>(
diff --git a/gtk/src/subclass/dialog.rs b/gtk/src/subclass/dialog.rs
index a350da9bdbc3..329fcaba4a33 100644
--- a/gtk/src/subclass/dialog.rs
+++ b/gtk/src/subclass/dialog.rs
@@ -9,7 +9,6 @@ use glib::Cast;
 use super::window::WindowImpl;
 use crate::Dialog;
 use crate::ResponseType;
-use crate::Window;
 
 pub trait DialogImpl: DialogImplExt + WindowImpl {
     fn response(&self, dialog: &Self::Type, response: ResponseType) {
@@ -53,16 +52,12 @@ impl<T: DialogImpl> DialogImplExt for T {
 
 unsafe impl<T: DialogImpl> IsSubclassable<T> for Dialog {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Window as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.response = Some(dialog_response::<T>);
         klass.close = Some(dialog_close::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Window as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn dialog_response<T: DialogImpl>(ptr: *mut ffi::GtkDialog, responseptr: i32) {
diff --git a/gtk/src/subclass/drawing_area.rs b/gtk/src/subclass/drawing_area.rs
index c202e99f581a..cda082cbbbdd 100644
--- a/gtk/src/subclass/drawing_area.rs
+++ b/gtk/src/subclass/drawing_area.rs
@@ -4,16 +4,11 @@ use glib::subclass::prelude::*;
 
 use super::widget::WidgetImpl;
 use crate::DrawingArea;
-use crate::Widget;
 
 pub trait DrawingAreaImpl: WidgetImpl {}
 
 unsafe impl<T: DrawingAreaImpl> IsSubclassable<T> for DrawingArea {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Widget as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Widget as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/event_box.rs b/gtk/src/subclass/event_box.rs
index 4d02d9d71783..00f54c1d7869 100644
--- a/gtk/src/subclass/event_box.rs
+++ b/gtk/src/subclass/event_box.rs
@@ -3,17 +3,13 @@
 use glib::subclass::prelude::*;
 
 use super::bin::BinImpl;
-use crate::Bin;
+
 use crate::EventBox;
 
 pub trait EventBoxImpl: BinImpl {}
 
 unsafe impl<T: EventBoxImpl> IsSubclassable<T> for EventBox {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Bin as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Bin as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/fixed.rs b/gtk/src/subclass/fixed.rs
index 92dbd8fdad1a..43760e610242 100644
--- a/gtk/src/subclass/fixed.rs
+++ b/gtk/src/subclass/fixed.rs
@@ -3,17 +3,13 @@
 use glib::subclass::prelude::*;
 
 use super::container::ContainerImpl;
-use crate::Container;
+
 use crate::Fixed;
 
 pub trait FixedImpl: ContainerImpl {}
 
 unsafe impl<T: FixedImpl> IsSubclassable<T> for Fixed {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Container as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Container as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/header_bar.rs b/gtk/src/subclass/header_bar.rs
index fad4cec1f3c8..dedf8da9fd4c 100644
--- a/gtk/src/subclass/header_bar.rs
+++ b/gtk/src/subclass/header_bar.rs
@@ -3,17 +3,13 @@
 use glib::subclass::prelude::*;
 
 use super::container::ContainerImpl;
-use crate::Container;
+
 use crate::HeaderBar;
 
 pub trait HeaderBarImpl: ContainerImpl {}
 
 unsafe impl<T: HeaderBarImpl> IsSubclassable<T> for HeaderBar {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Container as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Container as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/icon_view.rs b/gtk/src/subclass/icon_view.rs
index da0cc16aad32..3703e58ee7b4 100644
--- a/gtk/src/subclass/icon_view.rs
+++ b/gtk/src/subclass/icon_view.rs
@@ -7,7 +7,7 @@ use glib::translate::*;
 use glib::Cast;
 
 use super::container::ContainerImpl;
-use crate::Container;
+
 use crate::IconView;
 use crate::MovementStep;
 use crate::TreePath;
@@ -145,7 +145,7 @@ impl<T: IconViewImpl> IconViewImplExt for T {
 
 unsafe impl<T: IconViewImpl> IsSubclassable<T> for IconView {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Container as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.item_activated = Some(icon_view_item_activated::<T>);
@@ -157,10 +157,6 @@ unsafe impl<T: IconViewImpl> IsSubclassable<T> for IconView {
         klass.move_cursor = Some(icon_view_move_cursor::<T>);
         klass.activate_cursor_item = Some(icon_view_activate_cursor_item::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Container as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn icon_view_item_activated<T: IconViewImpl>(
diff --git a/gtk/src/subclass/list_box.rs b/gtk/src/subclass/list_box.rs
index a6044f63a468..4d47f2e5d0ea 100644
--- a/gtk/src/subclass/list_box.rs
+++ b/gtk/src/subclass/list_box.rs
@@ -8,7 +8,6 @@ use super::{container::ContainerImpl, widget::WidgetImpl};
 
 use libc::c_int;
 
-use crate::Container;
 use crate::ListBox;
 use crate::ListBoxRow;
 use crate::MovementStep;
@@ -152,7 +151,7 @@ impl<T: ListBoxImpl> ListBoxImplExt for T {
 
 unsafe impl<T: ListBoxImpl> IsSubclassable<T> for ListBox {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Container as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.activate_cursor_row = Some(list_box_activate_cursor_row::<T>);
@@ -164,10 +163,6 @@ unsafe impl<T: ListBoxImpl> IsSubclassable<T> for ListBox {
         klass.toggle_cursor_row = Some(list_box_toggle_cursor_row::<T>);
         klass.unselect_all = Some(list_box_unselect_all::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Container as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn list_box_activate_cursor_row<T: ListBoxImpl>(ptr: *mut ffi::GtkListBox) {
diff --git a/gtk/src/subclass/list_box_row.rs b/gtk/src/subclass/list_box_row.rs
index 01a94a699a34..d43d09f36467 100644
--- a/gtk/src/subclass/list_box_row.rs
+++ b/gtk/src/subclass/list_box_row.rs
@@ -1,6 +1,5 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
-use crate::Bin;
 use crate::ListBoxRow;
 
 use glib::subclass::prelude::*;
@@ -36,15 +35,11 @@ impl<T: ListBoxRowImpl> ListBoxRowImplExt for T {
 
 unsafe impl<T: ListBoxRowImpl> IsSubclassable<T> for ListBoxRow {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Bin as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.activate = Some(list_box_row_activate::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Bin as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn list_box_row_activate<T: ListBoxRowImpl>(ptr: *mut ffi::GtkListBoxRow) {
diff --git a/gtk/src/subclass/plug.rs b/gtk/src/subclass/plug.rs
index 483c6e9e29fb..bf23b3c6f9d4 100644
--- a/gtk/src/subclass/plug.rs
+++ b/gtk/src/subclass/plug.rs
@@ -7,7 +7,6 @@ use glib::Cast;
 
 use super::window::WindowImpl;
 use crate::Plug;
-use crate::Window;
 
 pub trait PlugImpl: PlugImplExt + WindowImpl {
     fn embedded(&self, plug: &Self::Type) {
@@ -33,15 +32,11 @@ impl<T: PlugImpl> PlugImplExt for T {
 
 unsafe impl<T: PlugImpl> IsSubclassable<T> for Plug {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Window as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.embedded = Some(plug_embedded::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Window as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn plug_embedded<T: PlugImpl>(ptr: *mut ffi::GtkPlug) {
diff --git a/gtk/src/subclass/socket.rs b/gtk/src/subclass/socket.rs
index 58fd64c65e75..b4427e2dc110 100644
--- a/gtk/src/subclass/socket.rs
+++ b/gtk/src/subclass/socket.rs
@@ -6,7 +6,7 @@ use glib::translate::*;
 use glib::Cast;
 
 use super::container::ContainerImpl;
-use crate::Container;
+
 use crate::Inhibit;
 use crate::Socket;
 
@@ -54,16 +54,12 @@ impl<T: SocketImpl> SocketImplExt for T {
 
 unsafe impl<T: SocketImpl> IsSubclassable<T> for Socket {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Container as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.plug_added = Some(socket_plug_added::<T>);
         klass.plug_removed = Some(socket_plug_removed::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Container as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn socket_plug_added<T: SocketImpl>(ptr: *mut ffi::GtkSocket) {
diff --git a/gtk/src/subclass/stack.rs b/gtk/src/subclass/stack.rs
index 01b0542a9cb7..cf6aa446dc4b 100644
--- a/gtk/src/subclass/stack.rs
+++ b/gtk/src/subclass/stack.rs
@@ -3,17 +3,13 @@
 use glib::subclass::prelude::*;
 
 use super::container::ContainerImpl;
-use crate::Container;
+
 use crate::Stack;
 
 pub trait StackImpl: ContainerImpl {}
 
 unsafe impl<T: ContainerImpl> IsSubclassable<T> for Stack {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Container as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Container as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/tree_view.rs b/gtk/src/subclass/tree_view.rs
index 5866237373e7..40aae0bce40f 100644
--- a/gtk/src/subclass/tree_view.rs
+++ b/gtk/src/subclass/tree_view.rs
@@ -3,17 +3,13 @@
 use glib::subclass::prelude::*;
 
 use super::container::ContainerImpl;
-use crate::Container;
+
 use crate::TreeView;
 
 pub trait TreeViewImpl: ContainerImpl {}
 
 unsafe impl<T: ContainerImpl> IsSubclassable<T> for TreeView {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Container as IsSubclassable<T>>::class_init(class);
-    }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Container as IsSubclassable<T>>::instance_init(instance);
+        Self::parent_class_init::<T>(class);
     }
 }
diff --git a/gtk/src/subclass/widget.rs b/gtk/src/subclass/widget.rs
index 0df55417b2bb..2d9ad62e9b4d 100644
--- a/gtk/src/subclass/widget.rs
+++ b/gtk/src/subclass/widget.rs
@@ -7,7 +7,6 @@ use glib::translate::*;
 
 use glib::prelude::*;
 use glib::subclass::prelude::*;
-use glib::Object;
 
 use crate::prelude::*;
 use crate::Allocation;
@@ -1027,7 +1026,7 @@ impl<T: WidgetImpl> WidgetImplExt for T {
 
 unsafe impl<T: WidgetImpl> IsSubclassable<T> for Widget {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Object as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.adjust_baseline_allocation = Some(widget_adjust_baseline_allocation::<T>);
@@ -1073,10 +1072,6 @@ unsafe impl<T: WidgetImpl> IsSubclassable<T> for Widget {
         klass.enter_notify_event = Some(widget_enter_notify_event::<T>);
         klass.leave_notify_event = Some(widget_leave_notify_event::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Object as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn widget_adjust_baseline_allocation<T: WidgetImpl>(
diff --git a/gtk/src/subclass/window.rs b/gtk/src/subclass/window.rs
index 03609cdb3b12..83aceb8a7c6d 100644
--- a/gtk/src/subclass/window.rs
+++ b/gtk/src/subclass/window.rs
@@ -7,7 +7,7 @@ use glib::subclass::prelude::*;
 use glib::Cast;
 
 use super::bin::BinImpl;
-use crate::Bin;
+
 use crate::Widget;
 use crate::Window;
 
@@ -103,7 +103,7 @@ impl<T: WindowImpl> WindowImplExt for T {
 
 unsafe impl<T: WindowImpl> IsSubclassable<T> for Window {
     fn class_init(class: &mut ::glib::Class<Self>) {
-        <Bin as IsSubclassable<T>>::class_init(class);
+        Self::parent_class_init::<T>(class);
 
         let klass = class.as_mut();
         klass.set_focus = Some(window_set_focus::<T>);
@@ -112,10 +112,6 @@ unsafe impl<T: WindowImpl> IsSubclassable<T> for Window {
         klass.keys_changed = Some(window_keys_changed::<T>);
         klass.enable_debugging = Some(window_enable_debugging::<T>);
     }
-
-    fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
-        <Bin as IsSubclassable<T>>::instance_init(instance);
-    }
 }
 
 unsafe extern "C" fn window_set_focus<T: WindowImpl>(


Test patch: