Skip to main content

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    /// A GtkComboBoxText is a simple variant of [`ComboBox`][crate::ComboBox] that hides
14    /// the model-view complexity for simple text-only use cases.
15    ///
16    /// To create a GtkComboBoxText, use [`new()`][Self::new()] or
17    /// [`with_entry()`][Self::with_entry()].
18    ///
19    /// You can add items to a GtkComboBoxText with
20    /// [`ComboBoxTextExt::append_text()`][crate::prelude::ComboBoxTextExt::append_text()], [`ComboBoxTextExt::insert_text()`][crate::prelude::ComboBoxTextExt::insert_text()]
21    /// or [`ComboBoxTextExt::prepend_text()`][crate::prelude::ComboBoxTextExt::prepend_text()] and remove options with
22    /// [`ComboBoxTextExt::remove()`][crate::prelude::ComboBoxTextExt::remove()].
23    ///
24    /// If the GtkComboBoxText contains an entry (via the “has-entry” property),
25    /// its contents can be retrieved using [`ComboBoxTextExt::active_text()`][crate::prelude::ComboBoxTextExt::active_text()].
26    /// The entry itself can be accessed by calling [`BinExt::child()`][crate::prelude::BinExt::child()] on the
27    /// combo box.
28    ///
29    /// You should not call [`ComboBoxExt::set_model()`][crate::prelude::ComboBoxExt::set_model()] or attempt to pack more cells
30    /// into this combo box via its GtkCellLayout interface.
31    ///
32    /// # GtkComboBoxText as GtkBuildable
33    ///
34    /// The GtkComboBoxText implementation of the GtkBuildable interface supports
35    /// adding items directly using the ``<items>`` element and specifying ``<item>``
36    /// elements for each item. Each ``<item>`` element can specify the “id”
37    /// corresponding to the appended text and also supports the regular
38    /// translation attributes “translatable”, “context” and “comments”.
39    ///
40    /// Here is a UI definition fragment specifying GtkComboBoxText items:
41    ///
42    ///
43    ///
44    /// **⚠️ The following code is in xml ⚠️**
45    ///
46    /// ```xml
47    /// <object class="GtkComboBoxText">
48    ///   <items>
49    ///     <item translatable="yes" id="factory">Factory</item>
50    ///     <item translatable="yes" id="home">Home</item>
51    ///     <item translatable="yes" id="subway">Subway</item>
52    ///   </items>
53    /// </object>
54    /// ```
55    ///
56    /// # CSS nodes
57    ///
58    ///
59    ///
60    /// **⚠️ The following code is in plain ⚠️**
61    ///
62    /// ```plain
63    /// combobox
64    /// ╰── box.linked
65    ///     ├── entry.combo
66    ///     ├── button.combo
67    ///     ╰── window.popup
68    /// ```
69    ///
70    /// GtkComboBoxText has a single CSS node with name combobox. It adds
71    /// the style class .combo to the main CSS nodes of its entry and button
72    /// children, and the .linked class to the node of its internal box.
73    ///
74    /// # Implements
75    ///
76    /// [`ComboBoxTextExt`][trait@crate::prelude::ComboBoxTextExt], [`ComboBoxExt`][trait@crate::prelude::ComboBoxExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`CellEditableExt`][trait@crate::prelude::CellEditableExt], [`CellLayoutExt`][trait@crate::prelude::CellLayoutExt], [`ComboBoxExtManual`][trait@crate::prelude::ComboBoxExtManual], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
77    #[doc(alias = "GtkComboBoxText")]
78    pub struct ComboBoxText(Object<ffi::GtkComboBoxText, ffi::GtkComboBoxTextClass>) @extends ComboBox, Bin, Container, Widget, @implements Buildable, CellEditable, CellLayout;
79
80    match fn {
81        type_ => || ffi::gtk_combo_box_text_get_type(),
82    }
83}
84
85impl ComboBoxText {
86    pub const NONE: Option<&'static ComboBoxText> = None;
87
88    /// Creates a new [`ComboBoxText`][crate::ComboBoxText], which is a [`ComboBox`][crate::ComboBox] just displaying
89    /// strings.
90    ///
91    /// # Returns
92    ///
93    /// A new [`ComboBoxText`][crate::ComboBoxText]
94    #[doc(alias = "gtk_combo_box_text_new")]
95    pub fn new() -> ComboBoxText {
96        assert_initialized_main_thread!();
97        unsafe { Widget::from_glib_none(ffi::gtk_combo_box_text_new()).unsafe_cast() }
98    }
99
100    /// Creates a new [`ComboBoxText`][crate::ComboBoxText], which is a [`ComboBox`][crate::ComboBox] just displaying
101    /// strings. The combo box created by this function has an entry.
102    ///
103    /// # Returns
104    ///
105    /// a new [`ComboBoxText`][crate::ComboBoxText]
106    #[doc(alias = "gtk_combo_box_text_new_with_entry")]
107    #[doc(alias = "new_with_entry")]
108    pub fn with_entry() -> ComboBoxText {
109        assert_initialized_main_thread!();
110        unsafe { Widget::from_glib_none(ffi::gtk_combo_box_text_new_with_entry()).unsafe_cast() }
111    }
112
113    // rustdoc-stripper-ignore-next
114    /// Creates a new builder-pattern struct instance to construct [`ComboBoxText`] objects.
115    ///
116    /// This method returns an instance of [`ComboBoxTextBuilder`](crate::builders::ComboBoxTextBuilder) which can be used to create [`ComboBoxText`] objects.
117    pub fn builder() -> ComboBoxTextBuilder {
118        ComboBoxTextBuilder::new()
119    }
120}
121
122impl Default for ComboBoxText {
123    fn default() -> Self {
124        Self::new()
125    }
126}
127
128// rustdoc-stripper-ignore-next
129/// A [builder-pattern] type to construct [`ComboBoxText`] objects.
130///
131/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
132#[must_use = "The builder must be built to be used"]
133pub struct ComboBoxTextBuilder {
134    builder: glib::object::ObjectBuilder<'static, ComboBoxText>,
135}
136
137impl ComboBoxTextBuilder {
138    fn new() -> Self {
139        Self {
140            builder: glib::object::Object::builder(),
141        }
142    }
143
144    /// The item which is currently active. If the model is a non-flat treemodel,
145    /// and the active item is not an immediate child of the root of the tree,
146    /// this property has the value
147    /// `gtk_tree_path_get_indices (path)[0]`,
148    /// where `path` is the [`TreePath`][crate::TreePath] of the active item.
149    pub fn active(self, active: i32) -> Self {
150        Self {
151            builder: self.builder.property("active", active),
152        }
153    }
154
155    /// The value of the ID column of the active row.
156    pub fn active_id(self, active_id: impl Into<glib::GString>) -> Self {
157        Self {
158            builder: self.builder.property("active-id", active_id.into()),
159        }
160    }
161
162    /// Whether the dropdown button is sensitive when
163    /// the model is empty.
164    pub fn button_sensitivity(self, button_sensitivity: SensitivityType) -> Self {
165        Self {
166            builder: self
167                .builder
168                .property("button-sensitivity", button_sensitivity),
169        }
170    }
171
172    /// The [`CellArea`][crate::CellArea] used to layout cell renderers for this combo box.
173    ///
174    /// If no area is specified when creating the combo box with [`ComboBox::with_area()`][crate::ComboBox::with_area()]
175    /// a horizontally oriented [`CellAreaBox`][crate::CellAreaBox] will be used.
176    pub fn cell_area(self, cell_area: &impl IsA<CellArea>) -> Self {
177        Self {
178            builder: self
179                .builder
180                .property("cell-area", cell_area.clone().upcast()),
181        }
182    }
183
184    /// If this is set to a non-negative value, it must be the index of a column
185    /// of type `G_TYPE_INT` in the model. The value in that column for each item
186    /// will determine how many columns that item will span in the popup.
187    /// Therefore, values in this column must be greater than zero, and the sum of
188    /// an item’s column position + span should not exceed [`wrap-width`][struct@crate::ComboBox#wrap-width].
189    pub fn column_span_column(self, column_span_column: i32) -> Self {
190        Self {
191            builder: self
192                .builder
193                .property("column-span-column", column_span_column),
194        }
195    }
196
197    /// The column in the combo box's model to associate with strings from the entry
198    /// if the combo was created with [`has-entry`][struct@crate::ComboBox#has-entry] = [`true`].
199    pub fn entry_text_column(self, entry_text_column: i32) -> Self {
200        Self {
201            builder: self
202                .builder
203                .property("entry-text-column", entry_text_column),
204        }
205    }
206
207    /// Whether the combo box has an entry.
208    pub fn has_entry(self, has_entry: bool) -> Self {
209        Self {
210            builder: self.builder.property("has-entry", has_entry),
211        }
212    }
213
214    /// The has-frame property controls whether a frame
215    /// is drawn around the entry.
216    pub fn has_frame(self, has_frame: bool) -> Self {
217        Self {
218            builder: self.builder.property("has-frame", has_frame),
219        }
220    }
221
222    /// The column in the combo box's model that provides string
223    /// IDs for the values in the model, if != -1.
224    pub fn id_column(self, id_column: i32) -> Self {
225        Self {
226            builder: self.builder.property("id-column", id_column),
227        }
228    }
229
230    /// The model from which the combo box takes the values shown
231    /// in the list.
232    pub fn model(self, model: &impl IsA<TreeModel>) -> Self {
233        Self {
234            builder: self.builder.property("model", model.clone().upcast()),
235        }
236    }
237
238    /// Whether the popup's width should be a fixed width matching the
239    /// allocated width of the combo box.
240    pub fn popup_fixed_width(self, popup_fixed_width: bool) -> Self {
241        Self {
242            builder: self
243                .builder
244                .property("popup-fixed-width", popup_fixed_width),
245        }
246    }
247
248    /// If this is set to a non-negative value, it must be the index of a column
249    /// of type `G_TYPE_INT` in the model. The value in that column for each item
250    /// will determine how many rows that item will span in the popup. Therefore,
251    /// values in this column must be greater than zero.
252    pub fn row_span_column(self, row_span_column: i32) -> Self {
253        Self {
254            builder: self.builder.property("row-span-column", row_span_column),
255        }
256    }
257
258    /// If wrap-width is set to a positive value, items in the popup will be laid
259    /// out along multiple columns, starting a new row on reaching the wrap width.
260    pub fn wrap_width(self, wrap_width: i32) -> Self {
261        Self {
262            builder: self.builder.property("wrap-width", wrap_width),
263        }
264    }
265
266    pub fn border_width(self, border_width: u32) -> Self {
267        Self {
268            builder: self.builder.property("border-width", border_width),
269        }
270    }
271
272    pub fn child(self, child: &impl IsA<Widget>) -> Self {
273        Self {
274            builder: self.builder.property("child", child.clone().upcast()),
275        }
276    }
277
278    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
279        Self {
280            builder: self.builder.property("resize-mode", resize_mode),
281        }
282    }
283
284    pub fn app_paintable(self, app_paintable: bool) -> Self {
285        Self {
286            builder: self.builder.property("app-paintable", app_paintable),
287        }
288    }
289
290    pub fn can_default(self, can_default: bool) -> Self {
291        Self {
292            builder: self.builder.property("can-default", can_default),
293        }
294    }
295
296    pub fn can_focus(self, can_focus: bool) -> Self {
297        Self {
298            builder: self.builder.property("can-focus", can_focus),
299        }
300    }
301
302    pub fn events(self, events: gdk::EventMask) -> Self {
303        Self {
304            builder: self.builder.property("events", events),
305        }
306    }
307
308    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
309    pub fn expand(self, expand: bool) -> Self {
310        Self {
311            builder: self.builder.property("expand", expand),
312        }
313    }
314
315    /// Whether the widget should grab focus when it is clicked with the mouse.
316    ///
317    /// This property is only relevant for widgets that can take focus.
318    ///
319    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
320    /// GtkComboBox) implemented this property individually.
321    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
322        Self {
323            builder: self.builder.property("focus-on-click", focus_on_click),
324        }
325    }
326
327    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
328    pub fn halign(self, halign: Align) -> Self {
329        Self {
330            builder: self.builder.property("halign", halign),
331        }
332    }
333
334    pub fn has_default(self, has_default: bool) -> Self {
335        Self {
336            builder: self.builder.property("has-default", has_default),
337        }
338    }
339
340    pub fn has_focus(self, has_focus: bool) -> Self {
341        Self {
342            builder: self.builder.property("has-focus", has_focus),
343        }
344    }
345
346    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
347    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
348    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
349    /// whether it will provide a tooltip or not.
350    ///
351    /// Note that setting this property to [`true`] for the first time will change
352    /// the event masks of the GdkWindows of this widget to include leave-notify
353    /// and motion-notify events. This cannot and will not be undone when the
354    /// property is set to [`false`] again.
355    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
356        Self {
357            builder: self.builder.property("has-tooltip", has_tooltip),
358        }
359    }
360
361    pub fn height_request(self, height_request: i32) -> Self {
362        Self {
363            builder: self.builder.property("height-request", height_request),
364        }
365    }
366
367    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
368    pub fn hexpand(self, hexpand: bool) -> Self {
369        Self {
370            builder: self.builder.property("hexpand", hexpand),
371        }
372    }
373
374    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
375    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
376        Self {
377            builder: self.builder.property("hexpand-set", hexpand_set),
378        }
379    }
380
381    pub fn is_focus(self, is_focus: bool) -> Self {
382        Self {
383            builder: self.builder.property("is-focus", is_focus),
384        }
385    }
386
387    /// Sets all four sides' margin at once. If read, returns max
388    /// margin on any side.
389    pub fn margin(self, margin: i32) -> Self {
390        Self {
391            builder: self.builder.property("margin", margin),
392        }
393    }
394
395    /// Margin on bottom side of widget.
396    ///
397    /// This property adds margin outside of the widget's normal size
398    /// request, the margin will be added in addition to the size from
399    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
400    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
401        Self {
402            builder: self.builder.property("margin-bottom", margin_bottom),
403        }
404    }
405
406    /// Margin on end of widget, horizontally. This property supports
407    /// left-to-right and right-to-left text directions.
408    ///
409    /// This property adds margin outside of the widget's normal size
410    /// request, the margin will be added in addition to the size from
411    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
412    pub fn margin_end(self, margin_end: i32) -> Self {
413        Self {
414            builder: self.builder.property("margin-end", margin_end),
415        }
416    }
417
418    /// Margin on start of widget, horizontally. This property supports
419    /// left-to-right and right-to-left text directions.
420    ///
421    /// This property adds margin outside of the widget's normal size
422    /// request, the margin will be added in addition to the size from
423    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
424    pub fn margin_start(self, margin_start: i32) -> Self {
425        Self {
426            builder: self.builder.property("margin-start", margin_start),
427        }
428    }
429
430    /// Margin on top side of widget.
431    ///
432    /// This property adds margin outside of the widget's normal size
433    /// request, the margin will be added in addition to the size from
434    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
435    pub fn margin_top(self, margin_top: i32) -> Self {
436        Self {
437            builder: self.builder.property("margin-top", margin_top),
438        }
439    }
440
441    pub fn name(self, name: impl Into<glib::GString>) -> Self {
442        Self {
443            builder: self.builder.property("name", name.into()),
444        }
445    }
446
447    pub fn no_show_all(self, no_show_all: bool) -> Self {
448        Self {
449            builder: self.builder.property("no-show-all", no_show_all),
450        }
451    }
452
453    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
454    /// more details about window opacity.
455    ///
456    /// Before 3.8 this was only available in GtkWindow
457    pub fn opacity(self, opacity: f64) -> Self {
458        Self {
459            builder: self.builder.property("opacity", opacity),
460        }
461    }
462
463    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
464        Self {
465            builder: self.builder.property("parent", parent.clone().upcast()),
466        }
467    }
468
469    pub fn receives_default(self, receives_default: bool) -> Self {
470        Self {
471            builder: self.builder.property("receives-default", receives_default),
472        }
473    }
474
475    pub fn sensitive(self, sensitive: bool) -> Self {
476        Self {
477            builder: self.builder.property("sensitive", sensitive),
478        }
479    }
480
481    /// Sets the text of tooltip to be the given string, which is marked up
482    /// with the [Pango text markup language][PangoMarkupFormat].
483    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
484    ///
485    /// This is a convenience property which will take care of getting the
486    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
487    /// will automatically be set to [`true`] and there will be taken care of
488    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
489    ///
490    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
491    /// are set, the last one wins.
492    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
493        Self {
494            builder: self
495                .builder
496                .property("tooltip-markup", tooltip_markup.into()),
497        }
498    }
499
500    /// Sets the text of tooltip to be the given string.
501    ///
502    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
503    ///
504    /// This is a convenience property which will take care of getting the
505    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
506    /// will automatically be set to [`true`] and there will be taken care of
507    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
508    ///
509    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
510    /// are set, the last one wins.
511    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
512        Self {
513            builder: self.builder.property("tooltip-text", tooltip_text.into()),
514        }
515    }
516
517    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
518    pub fn valign(self, valign: Align) -> Self {
519        Self {
520            builder: self.builder.property("valign", valign),
521        }
522    }
523
524    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
525    pub fn vexpand(self, vexpand: bool) -> Self {
526        Self {
527            builder: self.builder.property("vexpand", vexpand),
528        }
529    }
530
531    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
532    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
533        Self {
534            builder: self.builder.property("vexpand-set", vexpand_set),
535        }
536    }
537
538    pub fn visible(self, visible: bool) -> Self {
539        Self {
540            builder: self.builder.property("visible", visible),
541        }
542    }
543
544    pub fn width_request(self, width_request: i32) -> Self {
545        Self {
546            builder: self.builder.property("width-request", width_request),
547        }
548    }
549
550    /// Indicates whether editing on the cell has been canceled.
551    pub fn editing_canceled(self, editing_canceled: bool) -> Self {
552        Self {
553            builder: self.builder.property("editing-canceled", editing_canceled),
554        }
555    }
556
557    // rustdoc-stripper-ignore-next
558    /// Build the [`ComboBoxText`].
559    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
560    pub fn build(self) -> ComboBoxText {
561        self.builder.build()
562    }
563}
564
565mod sealed {
566    pub trait Sealed {}
567    impl<T: super::IsA<super::ComboBoxText>> Sealed for T {}
568}
569
570/// Trait containing all [`struct@ComboBoxText`] methods.
571///
572/// # Implementors
573///
574/// [`ComboBoxText`][struct@crate::ComboBoxText]
575pub trait ComboBoxTextExt: IsA<ComboBoxText> + sealed::Sealed + 'static {
576    /// Appends `text` to the list of strings stored in `self`.
577    /// If `id` is non-[`None`] then it is used as the ID of the row.
578    ///
579    /// This is the same as calling [`insert()`][Self::insert()] with a
580    /// position of -1.
581    /// ## `id`
582    /// a string ID for this value, or [`None`]
583    /// ## `text`
584    /// A string
585    #[doc(alias = "gtk_combo_box_text_append")]
586    fn append(&self, id: Option<&str>, text: &str) {
587        unsafe {
588            ffi::gtk_combo_box_text_append(
589                self.as_ref().to_glib_none().0,
590                id.to_glib_none().0,
591                text.to_glib_none().0,
592            );
593        }
594    }
595
596    /// Appends `text` to the list of strings stored in `self`.
597    ///
598    /// This is the same as calling [`insert_text()`][Self::insert_text()] with a
599    /// position of -1.
600    /// ## `text`
601    /// A string
602    #[doc(alias = "gtk_combo_box_text_append_text")]
603    fn append_text(&self, text: &str) {
604        unsafe {
605            ffi::gtk_combo_box_text_append_text(
606                self.as_ref().to_glib_none().0,
607                text.to_glib_none().0,
608            );
609        }
610    }
611
612    /// Returns the currently active string in `self`, or [`None`]
613    /// if none is selected. If `self` contains an entry, this
614    /// function will return its contents (which will not necessarily
615    /// be an item from the list).
616    ///
617    /// # Returns
618    ///
619    /// a newly allocated string containing the
620    ///  currently active text. Must be freed with `g_free()`.
621    #[doc(alias = "gtk_combo_box_text_get_active_text")]
622    #[doc(alias = "get_active_text")]
623    fn active_text(&self) -> Option<glib::GString> {
624        unsafe {
625            from_glib_full(ffi::gtk_combo_box_text_get_active_text(
626                self.as_ref().to_glib_none().0,
627            ))
628        }
629    }
630
631    /// Inserts `text` at `position` in the list of strings stored in `self`.
632    /// If `id` is non-[`None`] then it is used as the ID of the row. See
633    /// [`id-column`][struct@crate::ComboBox#id-column].
634    ///
635    /// If `position` is negative then `text` is appended.
636    /// ## `position`
637    /// An index to insert `text`
638    /// ## `id`
639    /// a string ID for this value, or [`None`]
640    /// ## `text`
641    /// A string to display
642    #[doc(alias = "gtk_combo_box_text_insert")]
643    fn insert(&self, position: i32, id: Option<&str>, text: &str) {
644        unsafe {
645            ffi::gtk_combo_box_text_insert(
646                self.as_ref().to_glib_none().0,
647                position,
648                id.to_glib_none().0,
649                text.to_glib_none().0,
650            );
651        }
652    }
653
654    /// Inserts `text` at `position` in the list of strings stored in `self`.
655    ///
656    /// If `position` is negative then `text` is appended.
657    ///
658    /// This is the same as calling [`insert()`][Self::insert()] with a [`None`]
659    /// ID string.
660    /// ## `position`
661    /// An index to insert `text`
662    /// ## `text`
663    /// A string
664    #[doc(alias = "gtk_combo_box_text_insert_text")]
665    fn insert_text(&self, position: i32, text: &str) {
666        unsafe {
667            ffi::gtk_combo_box_text_insert_text(
668                self.as_ref().to_glib_none().0,
669                position,
670                text.to_glib_none().0,
671            );
672        }
673    }
674
675    /// Prepends `text` to the list of strings stored in `self`.
676    /// If `id` is non-[`None`] then it is used as the ID of the row.
677    ///
678    /// This is the same as calling [`insert()`][Self::insert()] with a
679    /// position of 0.
680    /// ## `id`
681    /// a string ID for this value, or [`None`]
682    /// ## `text`
683    /// a string
684    #[doc(alias = "gtk_combo_box_text_prepend")]
685    fn prepend(&self, id: Option<&str>, text: &str) {
686        unsafe {
687            ffi::gtk_combo_box_text_prepend(
688                self.as_ref().to_glib_none().0,
689                id.to_glib_none().0,
690                text.to_glib_none().0,
691            );
692        }
693    }
694
695    /// Prepends `text` to the list of strings stored in `self`.
696    ///
697    /// This is the same as calling [`insert_text()`][Self::insert_text()] with a
698    /// position of 0.
699    /// ## `text`
700    /// A string
701    #[doc(alias = "gtk_combo_box_text_prepend_text")]
702    fn prepend_text(&self, text: &str) {
703        unsafe {
704            ffi::gtk_combo_box_text_prepend_text(
705                self.as_ref().to_glib_none().0,
706                text.to_glib_none().0,
707            );
708        }
709    }
710
711    /// Removes the string at `position` from `self`.
712    /// ## `position`
713    /// Index of the item to remove
714    #[doc(alias = "gtk_combo_box_text_remove")]
715    fn remove(&self, position: i32) {
716        unsafe {
717            ffi::gtk_combo_box_text_remove(self.as_ref().to_glib_none().0, position);
718        }
719    }
720
721    /// Removes all the text entries from the combo box.
722    #[doc(alias = "gtk_combo_box_text_remove_all")]
723    fn remove_all(&self) {
724        unsafe {
725            ffi::gtk_combo_box_text_remove_all(self.as_ref().to_glib_none().0);
726        }
727    }
728}
729
730impl<O: IsA<ComboBoxText>> ComboBoxTextExt for O {}
731
732impl fmt::Display for ComboBoxText {
733    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
734        f.write_str("ComboBoxText")
735    }
736}