Skip to content

Commit 39ee5fd

Browse files
Generate trait signature once for manual code
1 parent 05239ea commit 39ee5fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+330
-853
lines changed

gdk4/src/subclass/content_provider.rs

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -43,42 +43,9 @@ pub trait ContentProviderImpl: ContentProviderImplExt + ObjectImpl {
4343
}
4444

4545
pub trait ContentProviderImplExt: ObjectSubclass {
46-
fn parent_content_changed(&self);
47-
48-
fn parent_attach_clipboard(&self, clipboard: &Clipboard);
49-
50-
fn parent_detach_clipboard(&self, clipboard: &Clipboard);
51-
52-
fn parent_formats(&self) -> ContentFormats;
53-
54-
fn parent_storable_formats(&self) -> ContentFormats;
55-
56-
fn parent_write_mime_type_async<
57-
Q: IsA<gio::Cancellable>,
58-
R: FnOnce(Result<(), glib::Error>) + 'static,
59-
>(
60-
&self,
61-
mime_type: &str,
62-
stream: &gio::OutputStream,
63-
io_priority: glib::Priority,
64-
cancellable: Option<&Q>,
65-
callback: R,
66-
);
67-
68-
fn parent_write_mime_type_future(
69-
&self,
70-
mime_type: &str,
71-
stream: &gio::OutputStream,
72-
io_priority: glib::Priority,
73-
) -> Pin<Box<dyn Future<Output = Result<(), glib::Error>> + 'static>>;
74-
75-
fn parent_value(&self, type_: glib::Type) -> Result<Value, glib::Error>;
76-
}
77-
78-
impl<T: ContentProviderImpl> ContentProviderImplExt for T {
7946
fn parent_content_changed(&self) {
8047
unsafe {
81-
let data = T::type_data();
48+
let data = Self::type_data();
8249
let parent_class = data.as_ref().parent_class() as *mut ffi::GdkContentProviderClass;
8350
if let Some(f) = (*parent_class).content_changed {
8451
f(self
@@ -92,7 +59,7 @@ impl<T: ContentProviderImpl> ContentProviderImplExt for T {
9259

9360
fn parent_attach_clipboard(&self, clipboard: &Clipboard) {
9461
unsafe {
95-
let data = T::type_data();
62+
let data = Self::type_data();
9663
let parent_class = data.as_ref().parent_class() as *mut ffi::GdkContentProviderClass;
9764
if let Some(f) = (*parent_class).attach_clipboard {
9865
f(
@@ -108,7 +75,7 @@ impl<T: ContentProviderImpl> ContentProviderImplExt for T {
10875

10976
fn parent_detach_clipboard(&self, clipboard: &Clipboard) {
11077
unsafe {
111-
let data = T::type_data();
78+
let data = Self::type_data();
11279
let parent_class = data.as_ref().parent_class() as *mut ffi::GdkContentProviderClass;
11380
if let Some(f) = (*parent_class).detach_clipboard {
11481
f(
@@ -124,7 +91,7 @@ impl<T: ContentProviderImpl> ContentProviderImplExt for T {
12491

12592
fn parent_formats(&self) -> ContentFormats {
12693
unsafe {
127-
let data = T::type_data();
94+
let data = Self::type_data();
12895
let parent_class = data.as_ref().parent_class() as *mut ffi::GdkContentProviderClass;
12996
let f = (*parent_class)
13097
.ref_formats
@@ -141,7 +108,7 @@ impl<T: ContentProviderImpl> ContentProviderImplExt for T {
141108

142109
fn parent_storable_formats(&self) -> ContentFormats {
143110
unsafe {
144-
let data = T::type_data();
111+
let data = Self::type_data();
145112
let parent_class = data.as_ref().parent_class() as *mut ffi::GdkContentProviderClass;
146113
let f = (*parent_class)
147114
.ref_storable_formats
@@ -179,7 +146,7 @@ impl<T: ContentProviderImpl> ContentProviderImplExt for T {
179146
"Async operations only allowed if the thread is owning the MainContext"
180147
);
181148

182-
let data = T::type_data();
149+
let data = Self::type_data();
183150
let parent_class = data.as_ref().parent_class() as *mut ffi::GdkContentProviderClass;
184151
let f = (*parent_class)
185152
.write_mime_type_async
@@ -260,7 +227,7 @@ impl<T: ContentProviderImpl> ContentProviderImplExt for T {
260227

261228
fn parent_value(&self, type_: glib::Type) -> Result<Value, glib::Error> {
262229
unsafe {
263-
let data = T::type_data();
230+
let data = Self::type_data();
264231
let parent_class = data.as_ref().parent_class() as *mut ffi::GdkContentProviderClass;
265232
let f = (*parent_class)
266233
.get_value
@@ -286,6 +253,8 @@ impl<T: ContentProviderImpl> ContentProviderImplExt for T {
286253
}
287254
}
288255

256+
impl<T: ContentProviderImpl> ContentProviderImplExt for T {}
257+
289258
unsafe impl<T: ContentProviderImpl> IsSubclassable<T> for ContentProvider {
290259
fn class_init(class: &mut glib::Class<Self>) {
291260
Self::parent_class_init::<T>(class);

gdk4/src/subclass/paintable.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ pub trait PaintableImpl: ObjectImpl {
3636
}
3737

3838
pub trait PaintableImplExt: ObjectSubclass {
39-
fn parent_current_image(&self) -> Paintable;
40-
fn parent_flags(&self) -> PaintableFlags;
41-
fn parent_intrinsic_width(&self) -> i32;
42-
fn parent_intrinsic_height(&self) -> i32;
43-
fn parent_intrinsic_aspect_ratio(&self) -> f64;
44-
fn parent_snapshot(&self, snapshot: &Snapshot, width: f64, height: f64);
45-
}
46-
47-
impl<T: PaintableImpl> PaintableImplExt for T {
4839
fn parent_current_image(&self) -> Paintable {
4940
unsafe {
5041
let type_data = Self::type_data();
@@ -133,6 +124,8 @@ impl<T: PaintableImpl> PaintableImplExt for T {
133124
}
134125
}
135126

127+
impl<T: PaintableImpl> PaintableImplExt for T {}
128+
136129
unsafe impl<T: PaintableImpl> IsImplementable<T> for Paintable {
137130
fn interface_init(iface: &mut glib::Interface<Self>) {
138131
let iface = iface.as_mut();

gtk4/src/editable.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ use std::{ffi::CStr, mem::transmute, slice, str};
1010

1111
// rustdoc-stripper-ignore-next
1212
/// Trait containing manually implemented methods of [`Editable`](crate::Editable).
13-
pub trait EditableExtManual: 'static {
14-
fn connect_insert_text<F>(&self, f: F) -> SignalHandlerId
15-
where
16-
F: Fn(&Self, &str, &mut i32) + 'static;
17-
}
18-
19-
impl<T: IsA<Editable>> EditableExtManual for T {
13+
pub trait EditableExtManual: IsA<Editable> + 'static {
2014
fn connect_insert_text<F>(&self, f: F) -> SignalHandlerId
2115
where
2216
F: Fn(&Self, &str, &mut i32) + 'static,
@@ -33,6 +27,8 @@ impl<T: IsA<Editable>> EditableExtManual for T {
3327
}
3428
}
3529

30+
impl<O: IsA<Editable>> EditableExtManual for O {}
31+
3632
unsafe extern "C" fn insert_text_trampoline<T, F: Fn(&T, &str, &mut i32) + 'static>(
3733
this: *mut ffi::GtkEditable,
3834
new_text: *mut c_char,

gtk4/src/expression.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -230,37 +230,31 @@ impl From<Expression> for glib::Value {
230230
///
231231
/// let label_expression = button.property_expression("label");
232232
/// ```
233-
pub trait GObjectPropertyExpressionExt {
233+
pub trait GObjectPropertyExpressionExt: IsA<glib::Object> {
234234
// rustdoc-stripper-ignore-next
235235
/// Create an expression looking up an object's property.
236-
fn property_expression(&self, property_name: &str) -> crate::PropertyExpression;
237-
238-
// rustdoc-stripper-ignore-next
239-
/// Create an expression looking up an object's property with a weak reference.
240-
fn property_expression_weak(&self, property_name: &str) -> crate::PropertyExpression;
241-
242-
// rustdoc-stripper-ignore-next
243-
/// Create an expression looking up a property in the bound `this` object.
244-
fn this_expression(property_name: &str) -> crate::PropertyExpression;
245-
}
246-
247-
impl<T: IsA<glib::Object>> GObjectPropertyExpressionExt for T {
248236
fn property_expression(&self, property_name: &str) -> crate::PropertyExpression {
249237
let obj_expr = crate::ConstantExpression::new(self);
250-
crate::PropertyExpression::new(T::static_type(), Some(&obj_expr), property_name)
238+
crate::PropertyExpression::new(Self::static_type(), Some(&obj_expr), property_name)
251239
}
252240

241+
// rustdoc-stripper-ignore-next
242+
/// Create an expression looking up an object's property with a weak reference.
253243
fn property_expression_weak(&self, property_name: &str) -> crate::PropertyExpression {
254244
let obj_expr = crate::ObjectExpression::new(self);
255-
crate::PropertyExpression::new(T::static_type(), Some(&obj_expr), property_name)
245+
crate::PropertyExpression::new(Self::static_type(), Some(&obj_expr), property_name)
256246
}
257247

248+
// rustdoc-stripper-ignore-next
249+
/// Create an expression looking up a property in the bound `this` object.
258250
fn this_expression(property_name: &str) -> crate::PropertyExpression {
259251
skip_assert_initialized!();
260-
crate::PropertyExpression::new(T::static_type(), Expression::NONE, property_name)
252+
crate::PropertyExpression::new(Self::static_type(), Expression::NONE, property_name)
261253
}
262254
}
263255

256+
impl<O: IsA<glib::Object>> GObjectPropertyExpressionExt for O {}
257+
264258
macro_rules! define_expression {
265259
($rust_type:ident, $ffi_type:path) => {
266260
impl std::ops::Deref for $rust_type {

gtk4/src/snapshot.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,8 @@ use std::borrow::Borrow;
55
use crate::{prelude::*, Snapshot};
66
use glib::{translate::*, IntoGStr};
77

8-
pub trait SnapshotExtManual {
8+
pub trait SnapshotExtManual: IsA<Snapshot> + 'static {
99
#[doc(alias = "gtk_snapshot_append_border")]
10-
fn append_border(
11-
&self,
12-
outline: &gsk::RoundedRect,
13-
border_width: &[f32; 4],
14-
border_color: &[gdk::RGBA; 4],
15-
);
16-
17-
#[doc(alias = "gtk_snapshot_push_debug")]
18-
fn push_debug(&self, message: impl IntoGStr);
19-
}
20-
21-
impl<T: IsA<Snapshot>> SnapshotExtManual for T {
2210
fn append_border(
2311
&self,
2412
outline: &gsk::RoundedRect,
@@ -37,6 +25,7 @@ impl<T: IsA<Snapshot>> SnapshotExtManual for T {
3725
}
3826
}
3927

28+
#[doc(alias = "gtk_snapshot_push_debug")]
4029
fn push_debug(&self, message: impl IntoGStr) {
4130
unsafe {
4231
message.run_with_gstr(|message| {
@@ -46,6 +35,8 @@ impl<T: IsA<Snapshot>> SnapshotExtManual for T {
4635
}
4736
}
4837

38+
impl<O: IsA<Snapshot>> SnapshotExtManual for O {}
39+
4940
impl AsRef<Snapshot> for gdk::Snapshot {
5041
#[inline]
5142
fn as_ref(&self) -> &Snapshot {

gtk4/src/subclass/accessible.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@ pub trait AccessibleImpl: ObjectImpl {
4040
}
4141

4242
pub trait AccessibleImplExt: ObjectSubclass {
43-
fn parent_platform_state(&self, state: AccessiblePlatformState) -> bool;
44-
fn parent_bounds(&self) -> Option<(i32, i32, i32, i32)>;
45-
fn parent_at_context(&self) -> Option<ATContext>;
46-
fn parent_accessible_parent(&self) -> Option<Accessible>;
47-
fn parent_first_accessible_child(&self) -> Option<Accessible>;
48-
fn parent_next_accessible_sibling(&self) -> Option<Accessible>;
49-
}
50-
51-
impl<T: AccessibleImpl> AccessibleImplExt for T {
5243
fn parent_platform_state(&self, state: AccessiblePlatformState) -> bool {
5344
unsafe {
5445
let type_data = Self::type_data();
@@ -165,6 +156,8 @@ impl<T: AccessibleImpl> AccessibleImplExt for T {
165156
}
166157
}
167158

159+
impl<T: AccessibleImpl> AccessibleImplExt for T {}
160+
168161
unsafe impl<T: AccessibleImpl> IsImplementable<T> for Accessible {
169162
fn interface_init(iface: &mut glib::Interface<Self>) {
170163
let iface = iface.as_mut();

gtk4/src/subclass/accessible_range.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ pub trait AccessibleRangeImpl: WidgetImpl {
1313
}
1414

1515
pub trait AccessibleRangeImplExt: ObjectSubclass {
16-
fn parent_set_current_value(&self, accessible_range: &Self::Type, value: f64) -> bool;
17-
}
18-
19-
impl<T: AccessibleRangeImpl> AccessibleRangeImplExt for T {
2016
fn parent_set_current_value(&self, accessible_range: &Self::Type, value: f64) -> bool {
2117
unsafe {
2218
let type_data = Self::type_data();
@@ -38,6 +34,8 @@ impl<T: AccessibleRangeImpl> AccessibleRangeImplExt for T {
3834
}
3935
}
4036

37+
impl<T: AccessibleRangeImpl> AccessibleRangeImplExt for T {}
38+
4139
unsafe impl<T: AccessibleRangeImpl> IsImplementable<T> for AccessibleRange {
4240
fn interface_init(iface: &mut glib::Interface<Self>) {
4341
let iface = iface.as_mut();

gtk4/src/subclass/actionable.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ pub trait ActionableImpl: WidgetImpl {
1616
}
1717

1818
pub trait ActionableImplExt: ObjectSubclass {
19-
fn parent_action_name(&self) -> Option<GString>;
20-
fn parent_action_target_value(&self) -> Option<Variant>;
21-
fn parent_set_action_name(&self, name: Option<&str>);
22-
fn parent_set_action_target_value(&self, value: Option<&Variant>);
23-
}
24-
25-
impl<T: ActionableImpl> ActionableImplExt for T {
2619
fn parent_action_name(&self) -> Option<GString> {
2720
unsafe {
2821
let type_data = Self::type_data();
@@ -90,6 +83,8 @@ impl<T: ActionableImpl> ActionableImplExt for T {
9083
}
9184
}
9285

86+
impl<T: ActionableImpl> ActionableImplExt for T {}
87+
9388
unsafe impl<T: ActionableImpl> IsImplementable<T> for Actionable {
9489
fn interface_init(iface: &mut glib::Interface<Self>) {
9590
let iface = iface.as_mut();

gtk4/src/subclass/adjustment.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@ pub trait AdjustmentImpl: AdjustmentImplExt + ObjectImpl {
1717
}
1818

1919
pub trait AdjustmentImplExt: ObjectSubclass {
20-
fn parent_changed(&self);
21-
fn parent_value_changed(&self);
22-
}
23-
24-
impl<T: AdjustmentImpl> AdjustmentImplExt for T {
2520
fn parent_changed(&self) {
2621
unsafe {
27-
let data = T::type_data();
22+
let data = Self::type_data();
2823
let parent_class = data.as_ref().parent_class() as *mut ffi::GtkAdjustmentClass;
2924
if let Some(f) = (*parent_class).changed {
3025
f(self.obj().unsafe_cast_ref::<Adjustment>().to_glib_none().0)
@@ -34,7 +29,7 @@ impl<T: AdjustmentImpl> AdjustmentImplExt for T {
3429

3530
fn parent_value_changed(&self) {
3631
unsafe {
37-
let data = T::type_data();
32+
let data = Self::type_data();
3833
let parent_class = data.as_ref().parent_class() as *mut ffi::GtkAdjustmentClass;
3934
if let Some(f) = (*parent_class).value_changed {
4035
f(self.obj().unsafe_cast_ref::<Adjustment>().to_glib_none().0)
@@ -43,6 +38,8 @@ impl<T: AdjustmentImpl> AdjustmentImplExt for T {
4338
}
4439
}
4540

41+
impl<T: AdjustmentImpl> AdjustmentImplExt for T {}
42+
4643
unsafe impl<T: AdjustmentImpl> IsSubclassable<T> for Adjustment {
4744
fn class_init(class: &mut glib::Class<Self>) {
4845
Self::parent_class_init::<T>(class);

gtk4/src/subclass/application.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,9 @@ pub trait GtkApplicationImpl: ObjectImpl + GtkApplicationImplExt + ApplicationIm
1818
}
1919

2020
pub trait GtkApplicationImplExt: ObjectSubclass {
21-
fn parent_window_added(&self, window: &Window);
22-
fn parent_window_removed(&self, window: &Window);
23-
}
24-
25-
impl<T: GtkApplicationImpl> GtkApplicationImplExt for T {
2621
fn parent_window_added(&self, window: &Window) {
2722
unsafe {
28-
let data = T::type_data();
23+
let data = Self::type_data();
2924
let parent_class = data.as_ref().parent_class() as *mut ffi::GtkApplicationClass;
3025
if let Some(f) = (*parent_class).window_added {
3126
f(
@@ -38,7 +33,7 @@ impl<T: GtkApplicationImpl> GtkApplicationImplExt for T {
3833

3934
fn parent_window_removed(&self, window: &Window) {
4035
unsafe {
41-
let data = T::type_data();
36+
let data = Self::type_data();
4237
let parent_class = data.as_ref().parent_class() as *mut ffi::GtkApplicationClass;
4338
if let Some(f) = (*parent_class).window_removed {
4439
f(
@@ -50,6 +45,8 @@ impl<T: GtkApplicationImpl> GtkApplicationImplExt for T {
5045
}
5146
}
5247

48+
impl<T: GtkApplicationImpl> GtkApplicationImplExt for T {}
49+
5350
unsafe impl<T: GtkApplicationImpl> IsSubclassable<T> for Application {
5451
fn class_init(class: &mut ::glib::Class<Self>) {
5552
// Override the original `GtkApplication` startup implementation so that

0 commit comments

Comments
 (0)