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