1#![allow(deprecated)]
5
6use crate::{
7 ffi, Accessible, AccessibleRole, Align, Buildable, CellEditable, CellLayout, ComboBox,
8 ConstraintTarget, LayoutManager, Overflow, SensitivityType, TreeModel, Widget,
9};
10use glib::{prelude::*, translate::*};
11
12glib::wrapper! {
13 #[doc(alias = "GtkComboBoxText")]
14 pub struct ComboBoxText(Object<ffi::GtkComboBoxText>) @extends ComboBox, Widget, @implements Accessible, Buildable, ConstraintTarget, CellEditable, CellLayout;
15
16 match fn {
17 type_ => || ffi::gtk_combo_box_text_get_type(),
18 }
19}
20
21impl ComboBoxText {
22 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
23 #[allow(deprecated)]
24 #[doc(alias = "gtk_combo_box_text_new")]
25 pub fn new() -> ComboBoxText {
26 assert_initialized_main_thread!();
27 unsafe { Widget::from_glib_none(ffi::gtk_combo_box_text_new()).unsafe_cast() }
28 }
29
30 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
31 #[allow(deprecated)]
32 #[doc(alias = "gtk_combo_box_text_new_with_entry")]
33 #[doc(alias = "new_with_entry")]
34 pub fn with_entry() -> ComboBoxText {
35 assert_initialized_main_thread!();
36 unsafe { Widget::from_glib_none(ffi::gtk_combo_box_text_new_with_entry()).unsafe_cast() }
37 }
38
39 pub fn builder() -> ComboBoxTextBuilder {
44 ComboBoxTextBuilder::new()
45 }
46
47 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
48 #[allow(deprecated)]
49 #[doc(alias = "gtk_combo_box_text_append")]
50 pub fn append(&self, id: Option<&str>, text: &str) {
51 unsafe {
52 ffi::gtk_combo_box_text_append(
53 self.to_glib_none().0,
54 id.to_glib_none().0,
55 text.to_glib_none().0,
56 );
57 }
58 }
59
60 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
61 #[allow(deprecated)]
62 #[doc(alias = "gtk_combo_box_text_append_text")]
63 pub fn append_text(&self, text: &str) {
64 unsafe {
65 ffi::gtk_combo_box_text_append_text(self.to_glib_none().0, text.to_glib_none().0);
66 }
67 }
68
69 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
70 #[allow(deprecated)]
71 #[doc(alias = "gtk_combo_box_text_get_active_text")]
72 #[doc(alias = "get_active_text")]
73 pub fn active_text(&self) -> Option<glib::GString> {
74 unsafe {
75 from_glib_full(ffi::gtk_combo_box_text_get_active_text(
76 self.to_glib_none().0,
77 ))
78 }
79 }
80
81 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
82 #[allow(deprecated)]
83 #[doc(alias = "gtk_combo_box_text_insert")]
84 pub fn insert(&self, position: i32, id: Option<&str>, text: &str) {
85 unsafe {
86 ffi::gtk_combo_box_text_insert(
87 self.to_glib_none().0,
88 position,
89 id.to_glib_none().0,
90 text.to_glib_none().0,
91 );
92 }
93 }
94
95 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
96 #[allow(deprecated)]
97 #[doc(alias = "gtk_combo_box_text_insert_text")]
98 pub fn insert_text(&self, position: i32, text: &str) {
99 unsafe {
100 ffi::gtk_combo_box_text_insert_text(
101 self.to_glib_none().0,
102 position,
103 text.to_glib_none().0,
104 );
105 }
106 }
107
108 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
109 #[allow(deprecated)]
110 #[doc(alias = "gtk_combo_box_text_prepend")]
111 pub fn prepend(&self, id: Option<&str>, text: &str) {
112 unsafe {
113 ffi::gtk_combo_box_text_prepend(
114 self.to_glib_none().0,
115 id.to_glib_none().0,
116 text.to_glib_none().0,
117 );
118 }
119 }
120
121 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
122 #[allow(deprecated)]
123 #[doc(alias = "gtk_combo_box_text_prepend_text")]
124 pub fn prepend_text(&self, text: &str) {
125 unsafe {
126 ffi::gtk_combo_box_text_prepend_text(self.to_glib_none().0, text.to_glib_none().0);
127 }
128 }
129
130 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
131 #[allow(deprecated)]
132 #[doc(alias = "gtk_combo_box_text_remove")]
133 pub fn remove(&self, position: i32) {
134 unsafe {
135 ffi::gtk_combo_box_text_remove(self.to_glib_none().0, position);
136 }
137 }
138
139 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
140 #[allow(deprecated)]
141 #[doc(alias = "gtk_combo_box_text_remove_all")]
142 pub fn remove_all(&self) {
143 unsafe {
144 ffi::gtk_combo_box_text_remove_all(self.to_glib_none().0);
145 }
146 }
147}
148
149impl Default for ComboBoxText {
150 fn default() -> Self {
151 Self::new()
152 }
153}
154
155#[must_use = "The builder must be built to be used"]
160pub struct ComboBoxTextBuilder {
161 builder: glib::object::ObjectBuilder<'static, ComboBoxText>,
162}
163
164impl ComboBoxTextBuilder {
165 fn new() -> Self {
166 Self {
167 builder: glib::object::Object::builder(),
168 }
169 }
170
171 pub fn active(self, active: i32) -> Self {
172 Self {
173 builder: self.builder.property("active", active),
174 }
175 }
176
177 pub fn active_id(self, active_id: impl Into<glib::GString>) -> Self {
178 Self {
179 builder: self.builder.property("active-id", active_id.into()),
180 }
181 }
182
183 pub fn button_sensitivity(self, button_sensitivity: SensitivityType) -> Self {
184 Self {
185 builder: self
186 .builder
187 .property("button-sensitivity", button_sensitivity),
188 }
189 }
190
191 pub fn child(self, child: &impl IsA<Widget>) -> Self {
192 Self {
193 builder: self.builder.property("child", child.clone().upcast()),
194 }
195 }
196
197 pub fn entry_text_column(self, entry_text_column: i32) -> Self {
198 Self {
199 builder: self
200 .builder
201 .property("entry-text-column", entry_text_column),
202 }
203 }
204
205 pub fn has_entry(self, has_entry: bool) -> Self {
206 Self {
207 builder: self.builder.property("has-entry", has_entry),
208 }
209 }
210
211 pub fn has_frame(self, has_frame: bool) -> Self {
212 Self {
213 builder: self.builder.property("has-frame", has_frame),
214 }
215 }
216
217 pub fn id_column(self, id_column: i32) -> Self {
218 Self {
219 builder: self.builder.property("id-column", id_column),
220 }
221 }
222
223 pub fn model(self, model: &impl IsA<TreeModel>) -> Self {
224 Self {
225 builder: self.builder.property("model", model.clone().upcast()),
226 }
227 }
228
229 pub fn popup_fixed_width(self, popup_fixed_width: bool) -> Self {
230 Self {
231 builder: self
232 .builder
233 .property("popup-fixed-width", popup_fixed_width),
234 }
235 }
236
237 pub fn can_focus(self, can_focus: bool) -> Self {
238 Self {
239 builder: self.builder.property("can-focus", can_focus),
240 }
241 }
242
243 pub fn can_target(self, can_target: bool) -> Self {
244 Self {
245 builder: self.builder.property("can-target", can_target),
246 }
247 }
248
249 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
250 Self {
251 builder: self.builder.property("css-classes", css_classes.into()),
252 }
253 }
254
255 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
256 Self {
257 builder: self.builder.property("css-name", css_name.into()),
258 }
259 }
260
261 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
262 Self {
263 builder: self.builder.property("cursor", cursor.clone()),
264 }
265 }
266
267 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
268 Self {
269 builder: self.builder.property("focus-on-click", focus_on_click),
270 }
271 }
272
273 pub fn focusable(self, focusable: bool) -> Self {
274 Self {
275 builder: self.builder.property("focusable", focusable),
276 }
277 }
278
279 pub fn halign(self, halign: Align) -> Self {
280 Self {
281 builder: self.builder.property("halign", halign),
282 }
283 }
284
285 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
286 Self {
287 builder: self.builder.property("has-tooltip", has_tooltip),
288 }
289 }
290
291 pub fn height_request(self, height_request: i32) -> Self {
292 Self {
293 builder: self.builder.property("height-request", height_request),
294 }
295 }
296
297 pub fn hexpand(self, hexpand: bool) -> Self {
298 Self {
299 builder: self.builder.property("hexpand", hexpand),
300 }
301 }
302
303 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
304 Self {
305 builder: self.builder.property("hexpand-set", hexpand_set),
306 }
307 }
308
309 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
310 Self {
311 builder: self
312 .builder
313 .property("layout-manager", layout_manager.clone().upcast()),
314 }
315 }
316
317 #[cfg(feature = "v4_18")]
318 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
319 pub fn limit_events(self, limit_events: bool) -> Self {
320 Self {
321 builder: self.builder.property("limit-events", limit_events),
322 }
323 }
324
325 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
326 Self {
327 builder: self.builder.property("margin-bottom", margin_bottom),
328 }
329 }
330
331 pub fn margin_end(self, margin_end: i32) -> Self {
332 Self {
333 builder: self.builder.property("margin-end", margin_end),
334 }
335 }
336
337 pub fn margin_start(self, margin_start: i32) -> Self {
338 Self {
339 builder: self.builder.property("margin-start", margin_start),
340 }
341 }
342
343 pub fn margin_top(self, margin_top: i32) -> Self {
344 Self {
345 builder: self.builder.property("margin-top", margin_top),
346 }
347 }
348
349 pub fn name(self, name: impl Into<glib::GString>) -> Self {
350 Self {
351 builder: self.builder.property("name", name.into()),
352 }
353 }
354
355 pub fn opacity(self, opacity: f64) -> Self {
356 Self {
357 builder: self.builder.property("opacity", opacity),
358 }
359 }
360
361 pub fn overflow(self, overflow: Overflow) -> Self {
362 Self {
363 builder: self.builder.property("overflow", overflow),
364 }
365 }
366
367 pub fn receives_default(self, receives_default: bool) -> Self {
368 Self {
369 builder: self.builder.property("receives-default", receives_default),
370 }
371 }
372
373 pub fn sensitive(self, sensitive: bool) -> Self {
374 Self {
375 builder: self.builder.property("sensitive", sensitive),
376 }
377 }
378
379 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
380 Self {
381 builder: self
382 .builder
383 .property("tooltip-markup", tooltip_markup.into()),
384 }
385 }
386
387 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
388 Self {
389 builder: self.builder.property("tooltip-text", tooltip_text.into()),
390 }
391 }
392
393 pub fn valign(self, valign: Align) -> Self {
394 Self {
395 builder: self.builder.property("valign", valign),
396 }
397 }
398
399 pub fn vexpand(self, vexpand: bool) -> Self {
400 Self {
401 builder: self.builder.property("vexpand", vexpand),
402 }
403 }
404
405 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
406 Self {
407 builder: self.builder.property("vexpand-set", vexpand_set),
408 }
409 }
410
411 pub fn visible(self, visible: bool) -> Self {
412 Self {
413 builder: self.builder.property("visible", visible),
414 }
415 }
416
417 pub fn width_request(self, width_request: i32) -> Self {
418 Self {
419 builder: self.builder.property("width-request", width_request),
420 }
421 }
422
423 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
424 Self {
425 builder: self.builder.property("accessible-role", accessible_role),
426 }
427 }
428
429 pub fn editing_canceled(self, editing_canceled: bool) -> Self {
430 Self {
431 builder: self.builder.property("editing-canceled", editing_canceled),
432 }
433 }
434
435 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
438 pub fn build(self) -> ComboBoxText {
439 assert_initialized_main_thread!();
440 self.builder.build()
441 }
442}