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 gdk;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::translate::*;
9use glib::GString;
10use glib::StaticType;
11use glib::ToValue;
12use gtk_sys;
13use std::fmt;
14use Align;
15use Bin;
16use Buildable;
17use CellArea;
18use CellEditable;
19use CellLayout;
20use ComboBox;
21use Container;
22use ResizeMode;
23use SensitivityType;
24use TreeModel;
25use Widget;
26
27glib_wrapper! {
28    pub struct ComboBoxText(Object<gtk_sys::GtkComboBoxText, gtk_sys::GtkComboBoxTextClass, ComboBoxTextClass>) @extends ComboBox, Bin, Container, Widget, @implements Buildable, CellEditable, CellLayout;
29
30    match fn {
31        get_type => || gtk_sys::gtk_combo_box_text_get_type(),
32    }
33}
34
35impl ComboBoxText {
36    pub fn new() -> ComboBoxText {
37        assert_initialized_main_thread!();
38        unsafe { Widget::from_glib_none(gtk_sys::gtk_combo_box_text_new()).unsafe_cast() }
39    }
40
41    pub fn new_with_entry() -> ComboBoxText {
42        assert_initialized_main_thread!();
43        unsafe {
44            Widget::from_glib_none(gtk_sys::gtk_combo_box_text_new_with_entry()).unsafe_cast()
45        }
46    }
47}
48
49impl Default for ComboBoxText {
50    fn default() -> Self {
51        Self::new()
52    }
53}
54
55pub struct ComboBoxTextBuilder {
56    active: Option<i32>,
57    active_id: Option<String>,
58    button_sensitivity: Option<SensitivityType>,
59    cell_area: Option<CellArea>,
60    column_span_column: Option<i32>,
61    entry_text_column: Option<i32>,
62    has_entry: Option<bool>,
63    has_frame: Option<bool>,
64    id_column: Option<i32>,
65    model: Option<TreeModel>,
66    popup_fixed_width: Option<bool>,
67    row_span_column: Option<i32>,
68    wrap_width: Option<i32>,
69    border_width: Option<u32>,
70    child: Option<Widget>,
71    resize_mode: Option<ResizeMode>,
72    app_paintable: Option<bool>,
73    can_default: Option<bool>,
74    can_focus: Option<bool>,
75    events: Option<gdk::EventMask>,
76    expand: Option<bool>,
77    #[cfg(any(feature = "v3_20", feature = "dox"))]
78    focus_on_click: Option<bool>,
79    halign: Option<Align>,
80    has_default: Option<bool>,
81    has_focus: Option<bool>,
82    has_tooltip: Option<bool>,
83    height_request: Option<i32>,
84    hexpand: Option<bool>,
85    hexpand_set: Option<bool>,
86    is_focus: Option<bool>,
87    margin: Option<i32>,
88    margin_bottom: Option<i32>,
89    margin_end: Option<i32>,
90    margin_start: Option<i32>,
91    margin_top: Option<i32>,
92    name: Option<String>,
93    no_show_all: Option<bool>,
94    opacity: Option<f64>,
95    parent: Option<Container>,
96    receives_default: Option<bool>,
97    sensitive: Option<bool>,
98    //style: /*Unknown type*/,
99    tooltip_markup: Option<String>,
100    tooltip_text: Option<String>,
101    valign: Option<Align>,
102    vexpand: Option<bool>,
103    vexpand_set: Option<bool>,
104    visible: Option<bool>,
105    width_request: Option<i32>,
106}
107
108impl ComboBoxTextBuilder {
109    pub fn new() -> Self {
110        Self {
111            active: None,
112            active_id: None,
113            button_sensitivity: None,
114            cell_area: None,
115            column_span_column: None,
116            entry_text_column: None,
117            has_entry: None,
118            has_frame: None,
119            id_column: None,
120            model: None,
121            popup_fixed_width: None,
122            row_span_column: None,
123            wrap_width: None,
124            border_width: None,
125            child: None,
126            resize_mode: None,
127            app_paintable: None,
128            can_default: None,
129            can_focus: None,
130            events: None,
131            expand: None,
132            #[cfg(any(feature = "v3_20", feature = "dox"))]
133            focus_on_click: None,
134            halign: None,
135            has_default: None,
136            has_focus: None,
137            has_tooltip: None,
138            height_request: None,
139            hexpand: None,
140            hexpand_set: None,
141            is_focus: None,
142            margin: None,
143            margin_bottom: None,
144            margin_end: None,
145            margin_start: None,
146            margin_top: None,
147            name: None,
148            no_show_all: None,
149            opacity: None,
150            parent: None,
151            receives_default: None,
152            sensitive: None,
153            tooltip_markup: None,
154            tooltip_text: None,
155            valign: None,
156            vexpand: None,
157            vexpand_set: None,
158            visible: None,
159            width_request: None,
160        }
161    }
162
163    pub fn build(self) -> ComboBoxText {
164        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
165        if let Some(ref active) = self.active {
166            properties.push(("active", active));
167        }
168        if let Some(ref active_id) = self.active_id {
169            properties.push(("active-id", active_id));
170        }
171        if let Some(ref button_sensitivity) = self.button_sensitivity {
172            properties.push(("button-sensitivity", button_sensitivity));
173        }
174        if let Some(ref cell_area) = self.cell_area {
175            properties.push(("cell-area", cell_area));
176        }
177        if let Some(ref column_span_column) = self.column_span_column {
178            properties.push(("column-span-column", column_span_column));
179        }
180        if let Some(ref entry_text_column) = self.entry_text_column {
181            properties.push(("entry-text-column", entry_text_column));
182        }
183        if let Some(ref has_entry) = self.has_entry {
184            properties.push(("has-entry", has_entry));
185        }
186        if let Some(ref has_frame) = self.has_frame {
187            properties.push(("has-frame", has_frame));
188        }
189        if let Some(ref id_column) = self.id_column {
190            properties.push(("id-column", id_column));
191        }
192        if let Some(ref model) = self.model {
193            properties.push(("model", model));
194        }
195        if let Some(ref popup_fixed_width) = self.popup_fixed_width {
196            properties.push(("popup-fixed-width", popup_fixed_width));
197        }
198        if let Some(ref row_span_column) = self.row_span_column {
199            properties.push(("row-span-column", row_span_column));
200        }
201        if let Some(ref wrap_width) = self.wrap_width {
202            properties.push(("wrap-width", wrap_width));
203        }
204        if let Some(ref border_width) = self.border_width {
205            properties.push(("border-width", border_width));
206        }
207        if let Some(ref child) = self.child {
208            properties.push(("child", child));
209        }
210        if let Some(ref resize_mode) = self.resize_mode {
211            properties.push(("resize-mode", resize_mode));
212        }
213        if let Some(ref app_paintable) = self.app_paintable {
214            properties.push(("app-paintable", app_paintable));
215        }
216        if let Some(ref can_default) = self.can_default {
217            properties.push(("can-default", can_default));
218        }
219        if let Some(ref can_focus) = self.can_focus {
220            properties.push(("can-focus", can_focus));
221        }
222        if let Some(ref events) = self.events {
223            properties.push(("events", events));
224        }
225        if let Some(ref expand) = self.expand {
226            properties.push(("expand", expand));
227        }
228        #[cfg(any(feature = "v3_20", feature = "dox"))]
229        {
230            if let Some(ref focus_on_click) = self.focus_on_click {
231                properties.push(("focus-on-click", focus_on_click));
232            }
233        }
234        if let Some(ref halign) = self.halign {
235            properties.push(("halign", halign));
236        }
237        if let Some(ref has_default) = self.has_default {
238            properties.push(("has-default", has_default));
239        }
240        if let Some(ref has_focus) = self.has_focus {
241            properties.push(("has-focus", has_focus));
242        }
243        if let Some(ref has_tooltip) = self.has_tooltip {
244            properties.push(("has-tooltip", has_tooltip));
245        }
246        if let Some(ref height_request) = self.height_request {
247            properties.push(("height-request", height_request));
248        }
249        if let Some(ref hexpand) = self.hexpand {
250            properties.push(("hexpand", hexpand));
251        }
252        if let Some(ref hexpand_set) = self.hexpand_set {
253            properties.push(("hexpand-set", hexpand_set));
254        }
255        if let Some(ref is_focus) = self.is_focus {
256            properties.push(("is-focus", is_focus));
257        }
258        if let Some(ref margin) = self.margin {
259            properties.push(("margin", margin));
260        }
261        if let Some(ref margin_bottom) = self.margin_bottom {
262            properties.push(("margin-bottom", margin_bottom));
263        }
264        if let Some(ref margin_end) = self.margin_end {
265            properties.push(("margin-end", margin_end));
266        }
267        if let Some(ref margin_start) = self.margin_start {
268            properties.push(("margin-start", margin_start));
269        }
270        if let Some(ref margin_top) = self.margin_top {
271            properties.push(("margin-top", margin_top));
272        }
273        if let Some(ref name) = self.name {
274            properties.push(("name", name));
275        }
276        if let Some(ref no_show_all) = self.no_show_all {
277            properties.push(("no-show-all", no_show_all));
278        }
279        if let Some(ref opacity) = self.opacity {
280            properties.push(("opacity", opacity));
281        }
282        if let Some(ref parent) = self.parent {
283            properties.push(("parent", parent));
284        }
285        if let Some(ref receives_default) = self.receives_default {
286            properties.push(("receives-default", receives_default));
287        }
288        if let Some(ref sensitive) = self.sensitive {
289            properties.push(("sensitive", sensitive));
290        }
291        if let Some(ref tooltip_markup) = self.tooltip_markup {
292            properties.push(("tooltip-markup", tooltip_markup));
293        }
294        if let Some(ref tooltip_text) = self.tooltip_text {
295            properties.push(("tooltip-text", tooltip_text));
296        }
297        if let Some(ref valign) = self.valign {
298            properties.push(("valign", valign));
299        }
300        if let Some(ref vexpand) = self.vexpand {
301            properties.push(("vexpand", vexpand));
302        }
303        if let Some(ref vexpand_set) = self.vexpand_set {
304            properties.push(("vexpand-set", vexpand_set));
305        }
306        if let Some(ref visible) = self.visible {
307            properties.push(("visible", visible));
308        }
309        if let Some(ref width_request) = self.width_request {
310            properties.push(("width-request", width_request));
311        }
312        glib::Object::new(ComboBoxText::static_type(), &properties)
313            .expect("object new")
314            .downcast()
315            .expect("downcast")
316    }
317
318    pub fn active(mut self, active: i32) -> Self {
319        self.active = Some(active);
320        self
321    }
322
323    pub fn active_id(mut self, active_id: &str) -> Self {
324        self.active_id = Some(active_id.to_string());
325        self
326    }
327
328    pub fn button_sensitivity(mut self, button_sensitivity: SensitivityType) -> Self {
329        self.button_sensitivity = Some(button_sensitivity);
330        self
331    }
332
333    pub fn cell_area(mut self, cell_area: &CellArea) -> Self {
334        self.cell_area = Some(cell_area.clone());
335        self
336    }
337
338    pub fn column_span_column(mut self, column_span_column: i32) -> Self {
339        self.column_span_column = Some(column_span_column);
340        self
341    }
342
343    pub fn entry_text_column(mut self, entry_text_column: i32) -> Self {
344        self.entry_text_column = Some(entry_text_column);
345        self
346    }
347
348    pub fn has_entry(mut self, has_entry: bool) -> Self {
349        self.has_entry = Some(has_entry);
350        self
351    }
352
353    pub fn has_frame(mut self, has_frame: bool) -> Self {
354        self.has_frame = Some(has_frame);
355        self
356    }
357
358    pub fn id_column(mut self, id_column: i32) -> Self {
359        self.id_column = Some(id_column);
360        self
361    }
362
363    pub fn model(mut self, model: &TreeModel) -> Self {
364        self.model = Some(model.clone());
365        self
366    }
367
368    pub fn popup_fixed_width(mut self, popup_fixed_width: bool) -> Self {
369        self.popup_fixed_width = Some(popup_fixed_width);
370        self
371    }
372
373    pub fn row_span_column(mut self, row_span_column: i32) -> Self {
374        self.row_span_column = Some(row_span_column);
375        self
376    }
377
378    pub fn wrap_width(mut self, wrap_width: i32) -> Self {
379        self.wrap_width = Some(wrap_width);
380        self
381    }
382
383    pub fn border_width(mut self, border_width: u32) -> Self {
384        self.border_width = Some(border_width);
385        self
386    }
387
388    pub fn child(mut self, child: &Widget) -> Self {
389        self.child = Some(child.clone());
390        self
391    }
392
393    pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
394        self.resize_mode = Some(resize_mode);
395        self
396    }
397
398    pub fn app_paintable(mut self, app_paintable: bool) -> Self {
399        self.app_paintable = Some(app_paintable);
400        self
401    }
402
403    pub fn can_default(mut self, can_default: bool) -> Self {
404        self.can_default = Some(can_default);
405        self
406    }
407
408    pub fn can_focus(mut self, can_focus: bool) -> Self {
409        self.can_focus = Some(can_focus);
410        self
411    }
412
413    pub fn events(mut self, events: gdk::EventMask) -> Self {
414        self.events = Some(events);
415        self
416    }
417
418    pub fn expand(mut self, expand: bool) -> Self {
419        self.expand = Some(expand);
420        self
421    }
422
423    #[cfg(any(feature = "v3_20", feature = "dox"))]
424    pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
425        self.focus_on_click = Some(focus_on_click);
426        self
427    }
428
429    pub fn halign(mut self, halign: Align) -> Self {
430        self.halign = Some(halign);
431        self
432    }
433
434    pub fn has_default(mut self, has_default: bool) -> Self {
435        self.has_default = Some(has_default);
436        self
437    }
438
439    pub fn has_focus(mut self, has_focus: bool) -> Self {
440        self.has_focus = Some(has_focus);
441        self
442    }
443
444    pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
445        self.has_tooltip = Some(has_tooltip);
446        self
447    }
448
449    pub fn height_request(mut self, height_request: i32) -> Self {
450        self.height_request = Some(height_request);
451        self
452    }
453
454    pub fn hexpand(mut self, hexpand: bool) -> Self {
455        self.hexpand = Some(hexpand);
456        self
457    }
458
459    pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
460        self.hexpand_set = Some(hexpand_set);
461        self
462    }
463
464    pub fn is_focus(mut self, is_focus: bool) -> Self {
465        self.is_focus = Some(is_focus);
466        self
467    }
468
469    pub fn margin(mut self, margin: i32) -> Self {
470        self.margin = Some(margin);
471        self
472    }
473
474    pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
475        self.margin_bottom = Some(margin_bottom);
476        self
477    }
478
479    pub fn margin_end(mut self, margin_end: i32) -> Self {
480        self.margin_end = Some(margin_end);
481        self
482    }
483
484    pub fn margin_start(mut self, margin_start: i32) -> Self {
485        self.margin_start = Some(margin_start);
486        self
487    }
488
489    pub fn margin_top(mut self, margin_top: i32) -> Self {
490        self.margin_top = Some(margin_top);
491        self
492    }
493
494    pub fn name(mut self, name: &str) -> Self {
495        self.name = Some(name.to_string());
496        self
497    }
498
499    pub fn no_show_all(mut self, no_show_all: bool) -> Self {
500        self.no_show_all = Some(no_show_all);
501        self
502    }
503
504    pub fn opacity(mut self, opacity: f64) -> Self {
505        self.opacity = Some(opacity);
506        self
507    }
508
509    pub fn parent(mut self, parent: &Container) -> Self {
510        self.parent = Some(parent.clone());
511        self
512    }
513
514    pub fn receives_default(mut self, receives_default: bool) -> Self {
515        self.receives_default = Some(receives_default);
516        self
517    }
518
519    pub fn sensitive(mut self, sensitive: bool) -> Self {
520        self.sensitive = Some(sensitive);
521        self
522    }
523
524    pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
525        self.tooltip_markup = Some(tooltip_markup.to_string());
526        self
527    }
528
529    pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
530        self.tooltip_text = Some(tooltip_text.to_string());
531        self
532    }
533
534    pub fn valign(mut self, valign: Align) -> Self {
535        self.valign = Some(valign);
536        self
537    }
538
539    pub fn vexpand(mut self, vexpand: bool) -> Self {
540        self.vexpand = Some(vexpand);
541        self
542    }
543
544    pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
545        self.vexpand_set = Some(vexpand_set);
546        self
547    }
548
549    pub fn visible(mut self, visible: bool) -> Self {
550        self.visible = Some(visible);
551        self
552    }
553
554    pub fn width_request(mut self, width_request: i32) -> Self {
555        self.width_request = Some(width_request);
556        self
557    }
558}
559
560pub const NONE_COMBO_BOX_TEXT: Option<&ComboBoxText> = None;
561
562pub trait ComboBoxTextExt: 'static {
563    fn append(&self, id: Option<&str>, text: &str);
564
565    fn append_text(&self, text: &str);
566
567    fn get_active_text(&self) -> Option<GString>;
568
569    fn insert(&self, position: i32, id: Option<&str>, text: &str);
570
571    fn insert_text(&self, position: i32, text: &str);
572
573    fn prepend(&self, id: Option<&str>, text: &str);
574
575    fn prepend_text(&self, text: &str);
576
577    fn remove(&self, position: i32);
578
579    fn remove_all(&self);
580}
581
582impl<O: IsA<ComboBoxText>> ComboBoxTextExt for O {
583    fn append(&self, id: Option<&str>, text: &str) {
584        unsafe {
585            gtk_sys::gtk_combo_box_text_append(
586                self.as_ref().to_glib_none().0,
587                id.to_glib_none().0,
588                text.to_glib_none().0,
589            );
590        }
591    }
592
593    fn append_text(&self, text: &str) {
594        unsafe {
595            gtk_sys::gtk_combo_box_text_append_text(
596                self.as_ref().to_glib_none().0,
597                text.to_glib_none().0,
598            );
599        }
600    }
601
602    fn get_active_text(&self) -> Option<GString> {
603        unsafe {
604            from_glib_full(gtk_sys::gtk_combo_box_text_get_active_text(
605                self.as_ref().to_glib_none().0,
606            ))
607        }
608    }
609
610    fn insert(&self, position: i32, id: Option<&str>, text: &str) {
611        unsafe {
612            gtk_sys::gtk_combo_box_text_insert(
613                self.as_ref().to_glib_none().0,
614                position,
615                id.to_glib_none().0,
616                text.to_glib_none().0,
617            );
618        }
619    }
620
621    fn insert_text(&self, position: i32, text: &str) {
622        unsafe {
623            gtk_sys::gtk_combo_box_text_insert_text(
624                self.as_ref().to_glib_none().0,
625                position,
626                text.to_glib_none().0,
627            );
628        }
629    }
630
631    fn prepend(&self, id: Option<&str>, text: &str) {
632        unsafe {
633            gtk_sys::gtk_combo_box_text_prepend(
634                self.as_ref().to_glib_none().0,
635                id.to_glib_none().0,
636                text.to_glib_none().0,
637            );
638        }
639    }
640
641    fn prepend_text(&self, text: &str) {
642        unsafe {
643            gtk_sys::gtk_combo_box_text_prepend_text(
644                self.as_ref().to_glib_none().0,
645                text.to_glib_none().0,
646            );
647        }
648    }
649
650    fn remove(&self, position: i32) {
651        unsafe {
652            gtk_sys::gtk_combo_box_text_remove(self.as_ref().to_glib_none().0, position);
653        }
654    }
655
656    fn remove_all(&self) {
657        unsafe {
658            gtk_sys::gtk_combo_box_text_remove_all(self.as_ref().to_glib_none().0);
659        }
660    }
661}
662
663impl fmt::Display for ComboBoxText {
664    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
665        write!(f, "ComboBoxText")
666    }
667}