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