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
use crate::subclass::prelude::*;
use crate::AccessibleRange;
use glib::translate::*;
use glib::Cast;
pub trait AccessibleRangeImpl: WidgetImpl {
fn set_current_value(&self, accessible_range: &Self::Type, value: f64) -> bool {
self.parent_set_current_value(accessible_range, value)
}
}
pub trait AccessibleRangeImplExt: ObjectSubclass {
fn parent_set_current_value(&self, accessible_range: &Self::Type, value: f64) -> bool;
}
impl<T: AccessibleRangeImpl> AccessibleRangeImplExt for T {
fn parent_set_current_value(&self, accessible_range: &Self::Type, value: f64) -> bool {
unsafe {
let type_data = Self::type_data();
let parent_iface = type_data.as_ref().parent_interface::<AccessibleRange>()
as *const ffi::GtkAccessibleRangeInterface;
let func = (*parent_iface)
.set_current_value
.expect("no parent \"set_current_value\" implementation");
from_glib(func(
accessible_range
.unsafe_cast_ref::<AccessibleRange>()
.to_glib_none()
.0,
value,
))
}
}
}
unsafe impl<T: AccessibleRangeImpl> IsImplementable<T> for AccessibleRange {
fn interface_init(iface: &mut glib::Interface<Self>) {
let iface = iface.as_mut();
iface.set_current_value = Some(accessible_range_set_current_value::<T>);
}
}
unsafe extern "C" fn accessible_range_set_current_value<T: AccessibleRangeImpl>(
accessible_range: *mut ffi::GtkAccessibleRange,
value: f64,
) -> glib::ffi::gboolean {
let instance = &*(accessible_range as *mut T::Instance);
let imp = instance.imp();
imp.set_current_value(
from_glib_borrow::<_, AccessibleRange>(accessible_range).unsafe_cast_ref(),
value,
)
.into_glib()
}