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
use crate::ComboBox;
use glib::object::IsA;
use glib::translate::*;
pub trait ComboBoxExtManual: 'static {
#[doc(alias = "gtk_combo_box_set_active")]
fn set_active(&self, index_: Option<u32>);
#[doc(alias = "gtk_combo_box_get_active")]
#[doc(alias = "get_active")]
fn active(&self) -> Option<u32>;
}
impl<O: IsA<ComboBox>> ComboBoxExtManual for O {
fn set_active(&self, index_: Option<u32>) {
let index_ = match index_ {
Some(i) => i as _,
None => -1,
};
unsafe {
ffi::gtk_combo_box_set_active(self.as_ref().to_glib_none().0, index_);
}
}
fn active(&self) -> Option<u32> {
match unsafe { ffi::gtk_combo_box_get_active(self.as_ref().to_glib_none().0) } {
-1 => None,
x => Some(x as _),
}
}
}