Skip to content

Commit 706e5bf

Browse files
jf2048bilelmoussaoui
authored andcommitted
move function bodies from ExtManual impls to traits
1 parent 4b9b0e7 commit 706e5bf

30 files changed

+247
-448
lines changed

gdk4-wayland/src/wayland_surface.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@ use wayland_client::{backend::ObjectId, protocol::wl_surface::WlSurface, Proxy};
1111

1212
// rustdoc-stripper-ignore-next
1313
/// Trait containing manually implemented methods of [`WaylandSurface`](crate::WaylandSurface).
14-
pub trait WaylandSurfaceExtManual: 'static {
14+
pub trait WaylandSurfaceExtManual: IsA<WaylandSurface> + 'static {
1515
#[doc(alias = "gdk_wayland_surface_get_wl_surface")]
1616
#[doc(alias = "get_wl_surface")]
17-
#[cfg(any(feature = "wayland_crate", docsrs))]
18-
#[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))]
19-
fn wl_surface(&self) -> Option<WlSurface>;
20-
}
21-
22-
impl<O: IsA<WaylandSurface>> WaylandSurfaceExtManual for O {
2317
#[cfg(any(feature = "wayland_crate", docsrs))]
2418
#[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))]
2519
fn wl_surface(&self) -> Option<WlSurface> {
@@ -42,3 +36,5 @@ impl<O: IsA<WaylandSurface>> WaylandSurfaceExtManual for O {
4236
}
4337
}
4438
}
39+
40+
impl<O: IsA<WaylandSurface>> WaylandSurfaceExtManual for O {}

gdk4/src/content_provider.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ use glib::translate::*;
55

66
// rustdoc-stripper-ignore-next
77
/// Trait containing manually implemented methods of [`ContentProvider`](crate::ContentProvider).
8-
pub trait ContentProviderExtManual {
8+
pub trait ContentProviderExtManual: IsA<ContentProvider> {
99
#[doc(alias = "gdk_content_provider_get_value")]
10-
fn value(&self, type_: glib::Type) -> Result<glib::Value, glib::Error>;
11-
}
12-
13-
impl<O: IsA<ContentProvider>> ContentProviderExtManual for O {
1410
fn value(&self, type_: glib::Type) -> Result<glib::Value, glib::Error> {
1511
unsafe {
1612
let mut error = std::ptr::null_mut();
@@ -28,3 +24,5 @@ impl<O: IsA<ContentProvider>> ContentProviderExtManual for O {
2824
}
2925
}
3026
}
27+
28+
impl<O: IsA<ContentProvider>> ContentProviderExtManual for O {}

gdk4/src/display.rs

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,8 @@ impl Backend {
5252

5353
// rustdoc-stripper-ignore-next
5454
/// Trait containing manually implemented methods of [`Display`](crate::Display).
55-
pub trait DisplayExtManual: 'static {
55+
pub trait DisplayExtManual: IsA<Display> + 'static {
5656
#[doc(alias = "gdk_display_translate_key")]
57-
fn translate_key(
58-
&self,
59-
keycode: u32,
60-
state: ModifierType,
61-
group: i32,
62-
) -> Option<(Key, i32, i32, ModifierType)>;
63-
64-
#[doc(alias = "gdk_display_get_setting")]
65-
fn get_setting(&self, name: impl IntoGStr) -> Option<glib::Value>;
66-
67-
#[doc(alias = "gdk_display_map_keyval")]
68-
fn map_keyval(&self, keyval: Key) -> Option<Vec<KeymapKey>>;
69-
70-
#[doc(alias = "gdk_display_map_keycode")]
71-
fn map_keycode(&self, keycode: u32) -> Option<Vec<(KeymapKey, Key)>>;
72-
73-
// rustdoc-stripper-ignore-next
74-
/// Get the currently used display backend
75-
fn backend(&self) -> Backend;
76-
}
77-
78-
impl<O: IsA<Display>> DisplayExtManual for O {
7957
fn translate_key(
8058
&self,
8159
keycode: u32,
@@ -114,6 +92,7 @@ impl<O: IsA<Display>> DisplayExtManual for O {
11492
}
11593
}
11694

95+
#[doc(alias = "gdk_display_get_setting")]
11796
fn get_setting(&self, name: impl IntoGStr) -> Option<glib::Value> {
11897
unsafe {
11998
name.run_with_gstr(|name| {
@@ -132,6 +111,7 @@ impl<O: IsA<Display>> DisplayExtManual for O {
132111
}
133112
}
134113

114+
#[doc(alias = "gdk_display_map_keyval")]
135115
fn map_keyval(&self, keyval: Key) -> Option<Vec<KeymapKey>> {
136116
unsafe {
137117
let mut keys = ptr::null_mut();
@@ -153,6 +133,7 @@ impl<O: IsA<Display>> DisplayExtManual for O {
153133
}
154134
}
155135

136+
#[doc(alias = "gdk_display_map_keycode")]
156137
fn map_keycode(&self, keycode: u32) -> Option<Vec<(KeymapKey, Key)>> {
157138
unsafe {
158139
let mut keys = ptr::null_mut();
@@ -178,6 +159,8 @@ impl<O: IsA<Display>> DisplayExtManual for O {
178159
}
179160
}
180161

162+
// rustdoc-stripper-ignore-next
163+
/// Get the currently used display backend
181164
fn backend(&self) -> Backend {
182165
match self.as_ref().type_().name() {
183166
"GdkWaylandDisplay" => Backend::Wayland,
@@ -189,3 +172,5 @@ impl<O: IsA<Display>> DisplayExtManual for O {
189172
}
190173
}
191174
}
175+
176+
impl<O: IsA<Display>> DisplayExtManual for O {}

gdk4/src/drag_surface.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,10 @@ use std::{boxed::Box as Box_, mem::transmute};
99

1010
// rustdoc-stripper-ignore-next
1111
/// Trait containing manually implemented methods of [`DragSurface`](crate::DragSurface).
12-
pub trait DragSurfaceExtManual {
12+
pub trait DragSurfaceExtManual: IsA<DragSurface> {
1313
#[cfg(any(feature = "v4_12", docsrs))]
1414
#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1515
#[doc(alias = "compute-size")]
16-
fn connect_compute_size<F: Fn(&DragSurface, &mut DragSurfaceSize) + 'static>(
17-
&self,
18-
f: F,
19-
) -> SignalHandlerId;
20-
}
21-
22-
impl<O: IsA<DragSurface>> DragSurfaceExtManual for O {
23-
#[cfg(any(feature = "v4_12", docsrs))]
24-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
2516
fn connect_compute_size<F: Fn(&DragSurface, &mut DragSurfaceSize) + 'static>(
2617
&self,
2718
f: F,
@@ -52,3 +43,5 @@ impl<O: IsA<DragSurface>> DragSurfaceExtManual for O {
5243
}
5344
}
5445
}
46+
47+
impl<O: IsA<DragSurface>> DragSurfaceExtManual for O {}

gdk4/src/draw_context.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ use glib::translate::*;
55

66
// rustdoc-stripper-ignore-next
77
/// Trait containing manually implemented methods of [`DrawContext`](crate::DrawContext).
8-
pub trait DrawContextExtManual: 'static {
8+
pub trait DrawContextExtManual: IsA<DrawContext> + 'static {
99
#[doc(alias = "gdk_draw_context_get_frame_region")]
1010
#[doc(alias = "get_frame_region")]
11-
fn frame_region(&self) -> Option<cairo::Region>;
12-
}
13-
14-
impl<O: IsA<DrawContext>> DrawContextExtManual for O {
1511
fn frame_region(&self) -> Option<cairo::Region> {
1612
unsafe {
1713
from_glib_none(
@@ -21,3 +17,5 @@ impl<O: IsA<DrawContext>> DrawContextExtManual for O {
2117
}
2218
}
2319
}
20+
21+
impl<O: IsA<DrawContext>> DrawContextExtManual for O {}

gdk4/src/surface.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,8 @@ use glib::translate::*;
55

66
// rustdoc-stripper-ignore-next
77
/// Trait containing manually implemented methods of [`Surface`](crate::Surface).
8-
pub trait SurfaceExtManual: 'static {
8+
pub trait SurfaceExtManual: IsA<Surface> + 'static {
99
#[doc(alias = "gdk_surface_create_similar_surface")]
10-
fn create_similar_surface(
11-
&self,
12-
content: cairo::Content,
13-
width: i32,
14-
height: i32,
15-
) -> cairo::Surface;
16-
17-
#[doc(alias = "gdk_surface_translate_coordinates")]
18-
fn translate_coordinates(&self, to: &Surface, x: f64, y: f64) -> bool;
19-
}
20-
21-
impl<O: IsA<Surface>> SurfaceExtManual for O {
2210
fn create_similar_surface(
2311
&self,
2412
content: cairo::Content,
@@ -35,6 +23,7 @@ impl<O: IsA<Surface>> SurfaceExtManual for O {
3523
}
3624
}
3725

26+
#[doc(alias = "gdk_surface_translate_coordinates")]
3827
fn translate_coordinates(&self, to: &Surface, mut x: f64, mut y: f64) -> bool {
3928
unsafe {
4029
from_glib(ffi::gdk_surface_translate_coordinates(
@@ -46,3 +35,5 @@ impl<O: IsA<Surface>> SurfaceExtManual for O {
4635
}
4736
}
4837
}
38+
39+
impl<O: IsA<Surface>> SurfaceExtManual for O {}

gdk4/src/texture.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ use glib::translate::*;
55

66
// rustdoc-stripper-ignore-next
77
/// Trait containing manually implemented methods of [`Texture`](crate::Texture).
8-
pub trait TextureExtManual: 'static {
8+
pub trait TextureExtManual: IsA<Texture> + 'static {
99
#[doc(alias = "gdk_texture_download")]
10-
fn download(&self, data: &mut [u8], stride: usize);
11-
}
12-
13-
impl<O: IsA<Texture>> TextureExtManual for O {
1410
fn download(&self, data: &mut [u8], stride: usize) {
1511
unsafe {
1612
assert!(
@@ -29,3 +25,5 @@ impl<O: IsA<Texture>> TextureExtManual for O {
2925
}
3026
}
3127
}
28+
29+
impl<O: IsA<Texture>> TextureExtManual for O {}

gdk4/src/toplevel.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,7 @@ use std::{boxed::Box as Box_, mem::transmute};
99

1010
// rustdoc-stripper-ignore-next
1111
/// Trait containing manually implemented methods of [`Toplevel`](crate::Toplevel).
12-
pub trait ToplevelExtManual {
13-
fn connect_compute_size<F: Fn(&Toplevel, &mut ToplevelSize) + 'static>(
14-
&self,
15-
f: F,
16-
) -> SignalHandlerId;
17-
}
18-
19-
impl<O: IsA<Toplevel>> ToplevelExtManual for O {
12+
pub trait ToplevelExtManual: IsA<Toplevel> {
2013
fn connect_compute_size<F: Fn(&Toplevel, &mut ToplevelSize) + 'static>(
2114
&self,
2215
f: F,
@@ -44,3 +37,5 @@ impl<O: IsA<Toplevel>> ToplevelExtManual for O {
4437
}
4538
}
4639
}
40+
41+
impl<O: IsA<Toplevel>> ToplevelExtManual for O {}

gtk4/src/accessible.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,9 @@ use glib::{translate::*, Value};
2525
/// gtk::accessible::State::Invalid(gtk::AccessibleInvalidState::Grammar),
2626
/// ]);
2727
/// ```
28-
pub trait AccessibleExtManual {
28+
pub trait AccessibleExtManual: IsA<Accessible> {
2929
#[doc(alias = "gtk_accessible_update_property")]
3030
#[doc(alias = "gtk_accessible_update_property_value")]
31-
fn update_property(&self, properties: &[Property]);
32-
33-
#[doc(alias = "gtk_accessible_update_relation")]
34-
#[doc(alias = "gtk_accessible_update_relation_value")]
35-
fn update_relation(&self, relations: &[Relation]);
36-
37-
#[doc(alias = "gtk_accessible_update_state")]
38-
#[doc(alias = "gtk_accessible_update_state_value")]
39-
fn update_state(&self, states: &[State]);
40-
}
41-
42-
impl<O: IsA<Accessible>> AccessibleExtManual for O {
4331
fn update_property(&self, properties: &[Property]) {
4432
let mut properties_ptr = vec![];
4533
let mut values = vec![];
@@ -59,6 +47,8 @@ impl<O: IsA<Accessible>> AccessibleExtManual for O {
5947
}
6048
}
6149

50+
#[doc(alias = "gtk_accessible_update_relation")]
51+
#[doc(alias = "gtk_accessible_update_relation_value")]
6252
fn update_relation(&self, relations: &[Relation]) {
6353
let mut relations_ptr = vec![];
6454
let mut values = vec![];
@@ -78,6 +68,8 @@ impl<O: IsA<Accessible>> AccessibleExtManual for O {
7868
}
7969
}
8070

71+
#[doc(alias = "gtk_accessible_update_state")]
72+
#[doc(alias = "gtk_accessible_update_state_value")]
8173
fn update_state(&self, states: &[State]) {
8274
let mut states_ptr = vec![];
8375
let mut values = vec![];
@@ -98,6 +90,8 @@ impl<O: IsA<Accessible>> AccessibleExtManual for O {
9890
}
9991
}
10092

93+
impl<O: IsA<Accessible>> AccessibleExtManual for O {}
94+
10195
// rustdoc-stripper-ignore-next
10296
/// Type-safe enum container for [`AccessibleProperty`](crate::AccessibleProperty) values.
10397
#[derive(Debug)]

gtk4/src/actionable.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ use glib::{translate::*, Variant};
55

66
// rustdoc-stripper-ignore-next
77
/// Trait containing manually implemented methods of [`Actionable`](crate::Actionable).
8-
pub trait ActionableExtManual: 'static {
8+
pub trait ActionableExtManual: IsA<Actionable> + 'static {
99
#[doc(alias = "gtk_actionable_set_action_target")]
1010
#[doc(alias = "gtk_actionable_set_action_target_value")]
11-
fn set_action_target(&self, target: Option<impl Into<Variant>>);
12-
}
13-
14-
impl<O: IsA<Actionable>> ActionableExtManual for O {
1511
fn set_action_target(&self, target: Option<impl Into<Variant>>) {
1612
unsafe {
1713
ffi::gtk_actionable_set_action_target_value(
@@ -21,3 +17,5 @@ impl<O: IsA<Actionable>> ActionableExtManual for O {
2117
}
2218
}
2319
}
20+
21+
impl<O: IsA<Actionable>> ActionableExtManual for O {}

0 commit comments

Comments
 (0)