1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
use crate::{Actor, ChildMeta};
use glib::{
object::{Cast, IsA},
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
use std::{fmt, mem, mem::transmute};
glib_wrapper! {
pub struct Container(Interface<ffi::ClutterContainer>);
match fn {
get_type => || ffi::clutter_container_get_type(),
}
}
impl Container {
// /// Looks up the `gobject::ParamSpec` for a child property of `klass`.
// /// ## `klass`
// /// a `gobject::ObjectClass` implementing the `Container` interface.
// /// ## `property_name`
// /// a property name.
// ///
// /// # Returns
// ///
// /// The `gobject::ParamSpec` for the property or `None`
// /// if no such property exist.
// pub fn class_find_child_property(
// klass: &mut glib::ObjectClass,
// property_name: &str,
// ) -> Option<glib::ParamSpec> {
// unsafe {
// from_glib_none(ffi::clutter_container_class_find_child_property(
// klass.to_glib_none_mut().0,
// property_name.to_glib_none().0,
// ))
// }
// }
// /// Returns an array of `gobject::ParamSpec` for all child properties.
// /// ## `klass`
// /// a `gobject::ObjectClass` implementing the `Container` interface.
// /// ## `n_properties`
// /// return location for length of returned array.
// ///
// /// # Returns
// ///
// /// an array
// /// of `gobject::ParamSpec`<!-- -->s which should be freed after use.
// pub fn class_list_child_properties(klass: &mut glib::ObjectClass) -> Vec<glib::ParamSpec> {
// unsafe {
// let mut n_properties = mem::MaybeUninit::uninit();
// let ret = FromGlibContainer::from_glib_full_num(
// ffi::clutter_container_class_list_child_properties(
// klass.to_glib_none_mut().0,
// n_properties.as_mut_ptr(),
// ),
// n_properties.assume_init() as usize,
// );
// ret
// }
// }
}
/// Trait containing all `Container` methods.
///
/// # Implementors
///
/// [`Actor`](struct.Actor.html), [`Box`](struct.Box.html), [`Clone`](struct.Clone.html), [`Container`](struct.Container.html), [`Group`](struct.Group.html), [`Rectangle`](struct.Rectangle.html), [`ScrollActor`](struct.ScrollActor.html), [`Stage`](struct.Stage.html), [`Text`](struct.Text.html), [`Texture`](struct.Texture.html)
pub trait ContainerExt: 'static {
//fn child_get<P: IsA<Actor>>(&self, actor: &P, first_prop: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);
/// Gets a container specific property of a child of `self`, In general,
/// a copy is made of the property contents and the caller is responsible for
/// freeing the memory by calling `gobject::Value::unset`.
///
/// Note that `Container::child_set_property` is really intended for
/// language bindings, `Container::child_set` is much more convenient
/// for C programming.
/// ## `child`
/// a `Actor` that is a child of `self`.
/// ## `property`
/// the name of the property to set.
/// ## `value`
/// the value.
fn child_get_property<P: IsA<Actor>>(&self, child: &P, property: &str, value: &mut glib::Value);
/// Calls the `ContainerIface.child_notify`() virtual function
/// of `Container`. The default implementation will emit the
/// `Container::child-notify` signal.
/// ## `child`
/// a `Actor`
/// ## `pspec`
/// a `gobject::ParamSpec`
// fn child_notify<P: IsA<Actor>, Q: IsA<glib::ParamSpec>>(&self, child: &P, pspec: &Q);
//fn child_set<P: IsA<Actor>>(&self, actor: &P, first_prop: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);
/// Sets a container-specific property on a child of `self`.
/// ## `child`
/// a `Actor` that is a child of `self`.
/// ## `property`
/// the name of the property to set.
/// ## `value`
/// the value.
fn child_set_property<P: IsA<Actor>>(&self, child: &P, property: &str, value: &glib::Value);
/// Creates the `ChildMeta` wrapping `actor` inside the
/// `self`, if the `ContainerIface::child_meta_type`
/// class member is not set to `G_TYPE_INVALID`.
///
/// This function is only useful when adding a `Actor` to
/// a `Container` implementation outside of the
/// `Container::add`() virtual function implementation.
///
/// Applications should not call this function.
/// ## `actor`
/// a `Actor`
fn create_child_meta<P: IsA<Actor>>(&self, actor: &P);
/// Destroys the `ChildMeta` wrapping `actor` inside the
/// `self`, if any.
///
/// This function is only useful when removing a `Actor` to
/// a `Container` implementation outside of the
/// `Container::add`() virtual function implementation.
///
/// Applications should not call this function.
/// ## `actor`
/// a `Actor`
fn destroy_child_meta<P: IsA<Actor>>(&self, actor: &P);
/// Finds a child actor of a container by its name. Search recurses
/// into any child container.
/// ## `child_name`
/// the name of the requested child.
///
/// # Returns
///
/// The child actor with the requested name,
/// or `None` if no actor with that name was found.
fn find_child_by_name(&self, child_name: &str) -> Option<Actor>;
/// Retrieves the `ChildMeta` which contains the data about the
/// `self` specific state for `actor`.
/// ## `actor`
/// a `Actor` that is a child of `self`.
///
/// # Returns
///
/// the `ChildMeta` for the `actor` child
/// of `self` or `None` if the specifiec actor does not exist or the
/// container is not configured to provide `ChildMeta`<!-- -->s
fn get_child_meta<P: IsA<Actor>>(&self, actor: &P) -> Option<ChildMeta>;
/// The ::actor-added signal is emitted each time an actor
/// has been added to `container`.
/// ## `actor`
/// the new child that has been added to `container`
fn connect_actor_added<F: Fn(&Self, &Actor) + 'static>(&self, f: F) -> SignalHandlerId;
/// The ::actor-removed signal is emitted each time an actor
/// is removed from `container`.
/// ## `actor`
/// the child that has been removed from `container`
fn connect_actor_removed<F: Fn(&Self, &Actor) + 'static>(&self, f: F) -> SignalHandlerId;
/// The ::child-notify signal is emitted each time a property is
/// being set through the `Container::child_set` and
/// `Container::child_set_property` calls.
/// ## `actor`
/// the child that has had a property set
/// ## `pspec`
/// the `gobject::ParamSpec` of the property set
fn connect_child_notify<F: Fn(&Self, &Actor, &glib::ParamSpec) + 'static>(
&self,
f: F,
) -> SignalHandlerId;
}
impl<O: IsA<Container>> ContainerExt for O {
//fn child_get<P: IsA<Actor>>(&self, actor: &P, first_prop: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
// unsafe { TODO: call clutter_sys:clutter_container_child_get() }
//}
fn child_get_property<P: IsA<Actor>>(
&self,
child: &P,
property: &str,
value: &mut glib::Value,
) {
unsafe {
ffi::clutter_container_child_get_property(
self.as_ref().to_glib_none().0,
child.as_ref().to_glib_none().0,
property.to_glib_none().0,
value.to_glib_none_mut().0,
);
}
}
// fn child_notify<P: IsA<Actor>, Q: IsA<glib::ParamSpec>>(&self, child: &P, pspec: &Q) {
// unsafe {
// ffi::clutter_container_child_notify(
// self.as_ref().to_glib_none().0,
// child.as_ref().to_glib_none().0,
// pspec.as_ref().to_glib_none().0,
// );
// }
// }
//fn child_set<P: IsA<Actor>>(&self, actor: &P, first_prop: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
// unsafe { TODO: call clutter_sys:clutter_container_child_set() }
//}
fn child_set_property<P: IsA<Actor>>(&self, child: &P, property: &str, value: &glib::Value) {
unsafe {
ffi::clutter_container_child_set_property(
self.as_ref().to_glib_none().0,
child.as_ref().to_glib_none().0,
property.to_glib_none().0,
value.to_glib_none().0,
);
}
}
fn create_child_meta<P: IsA<Actor>>(&self, actor: &P) {
unsafe {
ffi::clutter_container_create_child_meta(
self.as_ref().to_glib_none().0,
actor.as_ref().to_glib_none().0,
);
}
}
fn destroy_child_meta<P: IsA<Actor>>(&self, actor: &P) {
unsafe {
ffi::clutter_container_destroy_child_meta(
self.as_ref().to_glib_none().0,
actor.as_ref().to_glib_none().0,
);
}
}
fn find_child_by_name(&self, child_name: &str) -> Option<Actor> {
unsafe {
from_glib_none(ffi::clutter_container_find_child_by_name(
self.as_ref().to_glib_none().0,
child_name.to_glib_none().0,
))
}
}
fn get_child_meta<P: IsA<Actor>>(&self, actor: &P) -> Option<ChildMeta> {
unsafe {
from_glib_none(ffi::clutter_container_get_child_meta(
self.as_ref().to_glib_none().0,
actor.as_ref().to_glib_none().0,
))
}
}
fn connect_actor_added<F: Fn(&Self, &Actor) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn actor_added_trampoline<P, F: Fn(&P, &Actor) + 'static>(
this: *mut ffi::ClutterContainer,
actor: *mut ffi::ClutterActor,
f: glib_sys::gpointer,
) where
P: IsA<Container>,
{
let f: &F = &*(f as *const F);
f(
&Container::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(actor),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"actor-added\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
actor_added_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_actor_removed<F: Fn(&Self, &Actor) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn actor_removed_trampoline<P, F: Fn(&P, &Actor) + 'static>(
this: *mut ffi::ClutterContainer,
actor: *mut ffi::ClutterActor,
f: glib_sys::gpointer,
) where
P: IsA<Container>,
{
let f: &F = &*(f as *const F);
f(
&Container::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(actor),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"actor-removed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
actor_removed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_child_notify<F: Fn(&Self, &Actor, &glib::ParamSpec) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn child_notify_trampoline<
P,
F: Fn(&P, &Actor, &glib::ParamSpec) + 'static,
>(
this: *mut ffi::ClutterContainer,
actor: *mut ffi::ClutterActor,
pspec: *mut gobject_sys::GParamSpec,
f: glib_sys::gpointer,
) where
P: IsA<Container>,
{
let f: &F = &*(f as *const F);
f(
&Container::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(actor),
&from_glib_borrow(pspec),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"child-notify\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
child_notify_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl fmt::Display for Container {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Container")
}
}