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
use glib::object::Cast;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::fmt;
glib::wrapper! {
pub struct EnumListModel(Object<ffi::HdyEnumListModel, ffi::HdyEnumListModelClass>) @implements gio::ListModel;
match fn {
get_type => || ffi::hdy_enum_list_model_get_type(),
}
}
impl EnumListModel {
#[doc(alias = "hdy_enum_list_model_new")]
pub fn new(enum_type: glib::types::Type) -> EnumListModel {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::hdy_enum_list_model_new(enum_type.to_glib())) }
}
#[doc(alias = "hdy_enum_list_model_find_position")]
pub fn find_position(&self, value: i32) -> u32 {
unsafe { ffi::hdy_enum_list_model_find_position(self.to_glib_none().0, value) }
}
#[doc(alias = "hdy_enum_list_model_get_enum_type")]
pub fn get_enum_type(&self) -> glib::types::Type {
unsafe {
from_glib(ffi::hdy_enum_list_model_get_enum_type(
self.to_glib_none().0,
))
}
}
}
#[derive(Clone, Default)]
pub struct EnumListModelBuilder {
enum_type: Option<glib::types::Type>,
}
impl EnumListModelBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn build(self) -> EnumListModel {
let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
if let Some(ref enum_type) = self.enum_type {
properties.push(("enum-type", enum_type));
}
let ret = glib::Object::new::<EnumListModel>(&properties).expect("object new");
ret
}
pub fn enum_type(mut self, enum_type: glib::types::Type) -> Self {
self.enum_type = Some(enum_type);
self
}
}
impl fmt::Display for EnumListModel {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("EnumListModel")
}
}