gtk/auto/
combo_box_text.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6    Align, Bin, Buildable, CellArea, CellEditable, CellLayout, ComboBox, Container, ResizeMode,
7    SensitivityType, TreeModel, Widget,
8};
9use glib::{prelude::*, translate::*};
10use std::fmt;
11
12glib::wrapper! {
13    #[doc(alias = "GtkComboBoxText")]
14    pub struct ComboBoxText(Object<ffi::GtkComboBoxText, ffi::GtkComboBoxTextClass>) @extends ComboBox, Bin, Container, Widget, @implements Buildable, CellEditable, CellLayout;
15
16    match fn {
17        type_ => || ffi::gtk_combo_box_text_get_type(),
18    }
19}
20
21impl ComboBoxText {
22    pub const NONE: Option<&'static ComboBoxText> = None;
23
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    #[doc(alias = "gtk_combo_box_text_new_with_entry")]
31    #[doc(alias = "new_with_entry")]
32    pub fn with_entry() -> ComboBoxText {
33        assert_initialized_main_thread!();
34        unsafe { Widget::from_glib_none(ffi::gtk_combo_box_text_new_with_entry()).unsafe_cast() }
35    }
36
37    // rustdoc-stripper-ignore-next
38    /// Creates a new builder-pattern struct instance to construct [`ComboBoxText`] objects.
39    ///
40    /// This method returns an instance of [`ComboBoxTextBuilder`](crate::builders::ComboBoxTextBuilder) which can be used to create [`ComboBoxText`] objects.
41    pub fn builder() -> ComboBoxTextBuilder {
42        ComboBoxTextBuilder::new()
43    }
44}
45
46impl Default for ComboBoxText {
47    fn default() -> Self {
48        Self::new()
49    }
50}
51
52// rustdoc-stripper-ignore-next
53/// A [builder-pattern] type to construct [`ComboBoxText`] objects.
54///
55/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
56#[must_use = "The builder must be built to be used"]
57pub struct ComboBoxTextBuilder {
58    builder: glib::object::ObjectBuilder<'static, ComboBoxText>,
59}
60
61impl ComboBoxTextBuilder {
62    fn new() -> Self {
63        Self {
64            builder: glib::object::Object::builder(),
65        }
66    }
67
68    pub fn active(self, active: i32) -> Self {
69        Self {
70            builder: self.builder.property("active", active),
71        }
72    }
73
74    pub fn active_id(self, active_id: impl Into<glib::GString>) -> Self {
75        Self {
76            builder: self.builder.property("active-id", active_id.into()),
77        }
78    }
79
80    pub fn button_sensitivity(self, button_sensitivity: SensitivityType) -> Self {
81        Self {
82            builder: self
83                .builder
84                .property("button-sensitivity", button_sensitivity),
85        }
86    }
87
88    pub fn cell_area(self, cell_area: &impl IsA<CellArea>) -> Self {
89        Self {
90            builder: self
91                .builder
92                .property("cell-area", cell_area.clone().upcast()),
93        }
94    }
95
96    pub fn column_span_column(self, column_span_column: i32) -> Self {
97        Self {
98            builder: self
99                .builder
100                .property("column-span-column", column_span_column),
101        }
102    }
103
104    pub fn entry_text_column(self, entry_text_column: i32) -> Self {
105        Self {
106            builder: self
107                .builder
108                .property("entry-text-column", entry_text_column),
109        }
110    }
111
112    pub fn has_entry(self, has_entry: bool) -> Self {
113        Self {
114            builder: self.builder.property("has-entry", has_entry),
115        }
116    }
117
118    pub fn has_frame(self, has_frame: bool) -> Self {
119        Self {
120            builder: self.builder.property("has-frame", has_frame),
121        }
122    }
123
124    pub fn id_column(self, id_column: i32) -> Self {
125        Self {
126            builder: self.builder.property("id-column", id_column),
127        }
128    }
129
130    pub fn model(self, model: &impl IsA<TreeModel>) -> Self {
131        Self {
132            builder: self.builder.property("model", model.clone().upcast()),
133        }
134    }
135
136    pub fn popup_fixed_width(self, popup_fixed_width: bool) -> Self {
137        Self {
138            builder: self
139                .builder
140                .property("popup-fixed-width", popup_fixed_width),
141        }
142    }
143
144    pub fn row_span_column(self, row_span_column: i32) -> Self {
145        Self {
146            builder: self.builder.property("row-span-column", row_span_column),
147        }
148    }
149
150    pub fn wrap_width(self, wrap_width: i32) -> Self {
151        Self {
152            builder: self.builder.property("wrap-width", wrap_width),
153        }
154    }
155
156    pub fn border_width(self, border_width: u32) -> Self {
157        Self {
158            builder: self.builder.property("border-width", border_width),
159        }
160    }
161
162    pub fn child(self, child: &impl IsA<Widget>) -> Self {
163        Self {
164            builder: self.builder.property("child", child.clone().upcast()),
165        }
166    }
167
168    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
169        Self {
170            builder: self.builder.property("resize-mode", resize_mode),
171        }
172    }
173
174    pub fn app_paintable(self, app_paintable: bool) -> Self {
175        Self {
176            builder: self.builder.property("app-paintable", app_paintable),
177        }
178    }
179
180    pub fn can_default(self, can_default: bool) -> Self {
181        Self {
182            builder: self.builder.property("can-default", can_default),
183        }
184    }
185
186    pub fn can_focus(self, can_focus: bool) -> Self {
187        Self {
188            builder: self.builder.property("can-focus", can_focus),
189        }
190    }
191
192    pub fn events(self, events: gdk::EventMask) -> Self {
193        Self {
194            builder: self.builder.property("events", events),
195        }
196    }
197
198    pub fn expand(self, expand: bool) -> Self {
199        Self {
200            builder: self.builder.property("expand", expand),
201        }
202    }
203
204    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
205        Self {
206            builder: self.builder.property("focus-on-click", focus_on_click),
207        }
208    }
209
210    pub fn halign(self, halign: Align) -> Self {
211        Self {
212            builder: self.builder.property("halign", halign),
213        }
214    }
215
216    pub fn has_default(self, has_default: bool) -> Self {
217        Self {
218            builder: self.builder.property("has-default", has_default),
219        }
220    }
221
222    pub fn has_focus(self, has_focus: bool) -> Self {
223        Self {
224            builder: self.builder.property("has-focus", has_focus),
225        }
226    }
227
228    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
229        Self {
230            builder: self.builder.property("has-tooltip", has_tooltip),
231        }
232    }
233
234    pub fn height_request(self, height_request: i32) -> Self {
235        Self {
236            builder: self.builder.property("height-request", height_request),
237        }
238    }
239
240    pub fn hexpand(self, hexpand: bool) -> Self {
241        Self {
242            builder: self.builder.property("hexpand", hexpand),
243        }
244    }
245
246    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
247        Self {
248            builder: self.builder.property("hexpand-set", hexpand_set),
249        }
250    }
251
252    pub fn is_focus(self, is_focus: bool) -> Self {
253        Self {
254            builder: self.builder.property("is-focus", is_focus),
255        }
256    }
257
258    pub fn margin(self, margin: i32) -> Self {
259        Self {
260            builder: self.builder.property("margin", margin),
261        }
262    }
263
264    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
265        Self {
266            builder: self.builder.property("margin-bottom", margin_bottom),
267        }
268    }
269
270    pub fn margin_end(self, margin_end: i32) -> Self {
271        Self {
272            builder: self.builder.property("margin-end", margin_end),
273        }
274    }
275
276    pub fn margin_start(self, margin_start: i32) -> Self {
277        Self {
278            builder: self.builder.property("margin-start", margin_start),
279        }
280    }
281
282    pub fn margin_top(self, margin_top: i32) -> Self {
283        Self {
284            builder: self.builder.property("margin-top", margin_top),
285        }
286    }
287
288    pub fn name(self, name: impl Into<glib::GString>) -> Self {
289        Self {
290            builder: self.builder.property("name", name.into()),
291        }
292    }
293
294    pub fn no_show_all(self, no_show_all: bool) -> Self {
295        Self {
296            builder: self.builder.property("no-show-all", no_show_all),
297        }
298    }
299
300    pub fn opacity(self, opacity: f64) -> Self {
301        Self {
302            builder: self.builder.property("opacity", opacity),
303        }
304    }
305
306    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
307        Self {
308            builder: self.builder.property("parent", parent.clone().upcast()),
309        }
310    }
311
312    pub fn receives_default(self, receives_default: bool) -> Self {
313        Self {
314            builder: self.builder.property("receives-default", receives_default),
315        }
316    }
317
318    pub fn sensitive(self, sensitive: bool) -> Self {
319        Self {
320            builder: self.builder.property("sensitive", sensitive),
321        }
322    }
323
324    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
325        Self {
326            builder: self
327                .builder
328                .property("tooltip-markup", tooltip_markup.into()),
329        }
330    }
331
332    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
333        Self {
334            builder: self.builder.property("tooltip-text", tooltip_text.into()),
335        }
336    }
337
338    pub fn valign(self, valign: Align) -> Self {
339        Self {
340            builder: self.builder.property("valign", valign),
341        }
342    }
343
344    pub fn vexpand(self, vexpand: bool) -> Self {
345        Self {
346            builder: self.builder.property("vexpand", vexpand),
347        }
348    }
349
350    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
351        Self {
352            builder: self.builder.property("vexpand-set", vexpand_set),
353        }
354    }
355
356    pub fn visible(self, visible: bool) -> Self {
357        Self {
358            builder: self.builder.property("visible", visible),
359        }
360    }
361
362    pub fn width_request(self, width_request: i32) -> Self {
363        Self {
364            builder: self.builder.property("width-request", width_request),
365        }
366    }
367
368    pub fn editing_canceled(self, editing_canceled: bool) -> Self {
369        Self {
370            builder: self.builder.property("editing-canceled", editing_canceled),
371        }
372    }
373
374    // rustdoc-stripper-ignore-next
375    /// Build the [`ComboBoxText`].
376    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
377    pub fn build(self) -> ComboBoxText {
378        self.builder.build()
379    }
380}
381
382mod sealed {
383    pub trait Sealed {}
384    impl<T: super::IsA<super::ComboBoxText>> Sealed for T {}
385}
386
387pub trait ComboBoxTextExt: IsA<ComboBoxText> + sealed::Sealed + 'static {
388    #[doc(alias = "gtk_combo_box_text_append")]
389    fn append(&self, id: Option<&str>, text: &str) {
390        unsafe {
391            ffi::gtk_combo_box_text_append(
392                self.as_ref().to_glib_none().0,
393                id.to_glib_none().0,
394                text.to_glib_none().0,
395            );
396        }
397    }
398
399    #[doc(alias = "gtk_combo_box_text_append_text")]
400    fn append_text(&self, text: &str) {
401        unsafe {
402            ffi::gtk_combo_box_text_append_text(
403                self.as_ref().to_glib_none().0,
404                text.to_glib_none().0,
405            );
406        }
407    }
408
409    #[doc(alias = "gtk_combo_box_text_get_active_text")]
410    #[doc(alias = "get_active_text")]
411    fn active_text(&self) -> Option<glib::GString> {
412        unsafe {
413            from_glib_full(ffi::gtk_combo_box_text_get_active_text(
414                self.as_ref().to_glib_none().0,
415            ))
416        }
417    }
418
419    #[doc(alias = "gtk_combo_box_text_insert")]
420    fn insert(&self, position: i32, id: Option<&str>, text: &str) {
421        unsafe {
422            ffi::gtk_combo_box_text_insert(
423                self.as_ref().to_glib_none().0,
424                position,
425                id.to_glib_none().0,
426                text.to_glib_none().0,
427            );
428        }
429    }
430
431    #[doc(alias = "gtk_combo_box_text_insert_text")]
432    fn insert_text(&self, position: i32, text: &str) {
433        unsafe {
434            ffi::gtk_combo_box_text_insert_text(
435                self.as_ref().to_glib_none().0,
436                position,
437                text.to_glib_none().0,
438            );
439        }
440    }
441
442    #[doc(alias = "gtk_combo_box_text_prepend")]
443    fn prepend(&self, id: Option<&str>, text: &str) {
444        unsafe {
445            ffi::gtk_combo_box_text_prepend(
446                self.as_ref().to_glib_none().0,
447                id.to_glib_none().0,
448                text.to_glib_none().0,
449            );
450        }
451    }
452
453    #[doc(alias = "gtk_combo_box_text_prepend_text")]
454    fn prepend_text(&self, text: &str) {
455        unsafe {
456            ffi::gtk_combo_box_text_prepend_text(
457                self.as_ref().to_glib_none().0,
458                text.to_glib_none().0,
459            );
460        }
461    }
462
463    #[doc(alias = "gtk_combo_box_text_remove")]
464    fn remove(&self, position: i32) {
465        unsafe {
466            ffi::gtk_combo_box_text_remove(self.as_ref().to_glib_none().0, position);
467        }
468    }
469
470    #[doc(alias = "gtk_combo_box_text_remove_all")]
471    fn remove_all(&self) {
472        unsafe {
473            ffi::gtk_combo_box_text_remove_all(self.as_ref().to_glib_none().0);
474        }
475    }
476}
477
478impl<O: IsA<ComboBoxText>> ComboBoxTextExt for O {}
479
480impl fmt::Display for ComboBoxText {
481    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
482        f.write_str("ComboBoxText")
483    }
484}