1use glib::object::IsA;
6use glib::translate::*;
7use gtk_sys;
8use ComboBox;
9
10pub trait ComboBoxExtManual: 'static {
11 fn set_active(&self, index_: Option<u32>);
12 fn get_active(&self) -> Option<u32>;
13}
14
15impl<O: IsA<ComboBox>> ComboBoxExtManual for O {
16 fn set_active(&self, index_: Option<u32>) {
17 let index_ = match index_ {
18 Some(i) => i as _,
19 None => -1,
20 };
21 unsafe {
22 gtk_sys::gtk_combo_box_set_active(self.as_ref().to_glib_none().0, index_);
23 }
24 }
25
26 fn get_active(&self) -> Option<u32> {
27 match unsafe { gtk_sys::gtk_combo_box_get_active(self.as_ref().to_glib_none().0) } {
28 -1 => None,
29 x => Some(x as _),
30 }
31 }
32}