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
use Bin;
use CellEditable;
use CellLayout;
use ComboBox;
use Container;
use Widget;
use ffi;
use glib::object::Downcast;
use glib::object::IsA;
use glib::translate::*;
use gobject_ffi;
glib_wrapper! {
pub struct ComboBoxText(Object<ffi::GtkComboBoxText>): ComboBox, Bin, Container, Widget, CellEditable, CellLayout;
match fn {
get_type => || ffi::gtk_combo_box_text_get_type(),
}
}
impl ComboBoxText {
pub fn new() -> ComboBoxText {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_combo_box_text_new()).downcast_unchecked()
}
}
pub fn new_with_entry() -> ComboBoxText {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_combo_box_text_new_with_entry()).downcast_unchecked()
}
}
}
pub trait ComboBoxTextExt {
fn append<'a, P: Into<Option<&'a str>>>(&self, id: P, text: &str);
fn append_text(&self, text: &str);
fn get_active_text(&self) -> Option<String>;
fn insert<'a, P: Into<Option<&'a str>>>(&self, position: i32, id: P, text: &str);
fn insert_text(&self, position: i32, text: &str);
fn prepend<'a, P: Into<Option<&'a str>>>(&self, id: P, text: &str);
fn prepend_text(&self, text: &str);
fn remove(&self, position: i32);
fn remove_all(&self);
}
impl<O: IsA<ComboBoxText>> ComboBoxTextExt for O {
fn append<'a, P: Into<Option<&'a str>>>(&self, id: P, text: &str) {
let id = id.into();
let id = id.to_glib_none();
unsafe {
ffi::gtk_combo_box_text_append(self.to_glib_none().0, id.0, text.to_glib_none().0);
}
}
fn append_text(&self, text: &str) {
unsafe {
ffi::gtk_combo_box_text_append_text(self.to_glib_none().0, text.to_glib_none().0);
}
}
fn get_active_text(&self) -> Option<String> {
unsafe {
from_glib_full(ffi::gtk_combo_box_text_get_active_text(self.to_glib_none().0))
}
}
fn insert<'a, P: Into<Option<&'a str>>>(&self, position: i32, id: P, text: &str) {
let id = id.into();
let id = id.to_glib_none();
unsafe {
ffi::gtk_combo_box_text_insert(self.to_glib_none().0, position, id.0, text.to_glib_none().0);
}
}
fn insert_text(&self, position: i32, text: &str) {
unsafe {
ffi::gtk_combo_box_text_insert_text(self.to_glib_none().0, position, text.to_glib_none().0);
}
}
fn prepend<'a, P: Into<Option<&'a str>>>(&self, id: P, text: &str) {
let id = id.into();
let id = id.to_glib_none();
unsafe {
ffi::gtk_combo_box_text_prepend(self.to_glib_none().0, id.0, text.to_glib_none().0);
}
}
fn prepend_text(&self, text: &str) {
unsafe {
ffi::gtk_combo_box_text_prepend_text(self.to_glib_none().0, text.to_glib_none().0);
}
}
fn remove(&self, position: i32) {
unsafe {
ffi::gtk_combo_box_text_remove(self.to_glib_none().0, position);
}
}
fn remove_all(&self) {
unsafe {
ffi::gtk_combo_box_text_remove_all(self.to_glib_none().0);
}
}
}