@@ -19,6 +19,19 @@ pub trait SymbolicPaintableImpl:
19
19
) {
20
20
self . parent_snapshot_symbolic ( snapshot, width, height, colors)
21
21
}
22
+
23
+ #[ cfg( feature = "v4_22" ) ]
24
+ #[ cfg_attr( docsrs, doc( cfg( feature = "v4_22" ) ) ) ]
25
+ fn snapshot_with_weight (
26
+ & self ,
27
+ snapshot : & gdk:: Snapshot ,
28
+ width : f64 ,
29
+ height : f64 ,
30
+ colors : & [ gdk:: RGBA ] ,
31
+ weight : f64 ,
32
+ ) {
33
+ self . parent_snapshot_with_weight ( snapshot, width, height, colors, weight)
34
+ }
22
35
}
23
36
24
37
pub trait SymbolicPaintableImplExt : SymbolicPaintableImpl {
@@ -43,8 +56,39 @@ pub trait SymbolicPaintableImplExt: SymbolicPaintableImpl {
43
56
snapshot. to_glib_none ( ) . 0 ,
44
57
width,
45
58
height,
46
- colors. to_glib_none ( ) . 0 ,
59
+ colors. as_ptr ( ) as * const gdk:: ffi:: GdkRGBA ,
60
+ colors. len ( ) as _ ,
61
+ )
62
+ }
63
+ }
64
+
65
+ #[ cfg( feature = "v4_22" ) ]
66
+ #[ cfg_attr( docsrs, doc( cfg( feature = "v4_22" ) ) ) ]
67
+ fn parent_snapshot_with_weight (
68
+ & self ,
69
+ snapshot : & gdk:: Snapshot ,
70
+ width : f64 ,
71
+ height : f64 ,
72
+ colors : & [ gdk:: RGBA ] ,
73
+ weight : f64 ,
74
+ ) {
75
+ unsafe {
76
+ let type_data = Self :: type_data ( ) ;
77
+ let parent_iface = type_data. as_ref ( ) . parent_interface :: < SymbolicPaintable > ( )
78
+ as * const ffi:: GtkSymbolicPaintableInterface ;
79
+
80
+ let func = ( * parent_iface) . snapshot_with_weight . unwrap ( ) ;
81
+ func (
82
+ self . obj ( )
83
+ . unsafe_cast_ref :: < SymbolicPaintable > ( )
84
+ . to_glib_none ( )
85
+ . 0 ,
86
+ snapshot. to_glib_none ( ) . 0 ,
87
+ width,
88
+ height,
89
+ colors. as_ptr ( ) as * const gdk:: ffi:: GdkRGBA ,
47
90
colors. len ( ) as _ ,
91
+ weight,
48
92
)
49
93
}
50
94
}
@@ -59,6 +103,10 @@ unsafe impl<T: SymbolicPaintableImpl> IsImplementable<T> for SymbolicPaintable {
59
103
assert_initialized_main_thread ! ( ) ;
60
104
61
105
iface. snapshot_symbolic = Some ( symbolic_paintable_snapshot_symbolic :: < T > ) ;
106
+ #[ cfg( feature = "v4_22" ) ]
107
+ {
108
+ iface. snapshot_with_weight = Some ( symbolic_paintable_snapshot_with_weight :: < T > ) ;
109
+ }
62
110
}
63
111
}
64
112
@@ -86,3 +134,31 @@ unsafe extern "C" fn symbolic_paintable_snapshot_symbolic<T: SymbolicPaintableIm
86
134
} ,
87
135
)
88
136
}
137
+
138
+ #[ cfg( feature = "v4_22" ) ]
139
+ unsafe extern "C" fn symbolic_paintable_snapshot_with_weight < T : SymbolicPaintableImpl > (
140
+ paintable : * mut ffi:: GtkSymbolicPaintable ,
141
+ snapshotptr : * mut gdk:: ffi:: GdkSnapshot ,
142
+ width : f64 ,
143
+ height : f64 ,
144
+ colors : * const gdk:: ffi:: GdkRGBA ,
145
+ n_colors : usize ,
146
+ weight : f64 ,
147
+ ) {
148
+ let instance = & * ( paintable as * mut T :: Instance ) ;
149
+ let imp = instance. imp ( ) ;
150
+
151
+ let snapshot: Borrowed < gdk:: Snapshot > = from_glib_borrow ( snapshotptr) ;
152
+
153
+ imp. snapshot_with_weight (
154
+ & snapshot,
155
+ width,
156
+ height,
157
+ if n_colors == 0 {
158
+ & [ ]
159
+ } else {
160
+ std:: slice:: from_raw_parts ( colors as * const gdk:: RGBA , n_colors)
161
+ } ,
162
+ weight,
163
+ )
164
+ }
0 commit comments