Skip to main content

gtk4/auto/
drop_down.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
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::Accessible;
8#[cfg(feature = "v4_12")]
9#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
10use crate::StringFilterMatchMode;
11use crate::{
12    AccessibleRole, Align, Buildable, ConstraintTarget, Expression, LayoutManager, ListItemFactory,
13    Overflow, Widget, ffi,
14};
15#[cfg(feature = "v4_6")]
16#[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
17use glib::object::ObjectType as _;
18use glib::{
19    prelude::*,
20    signal::{SignalHandlerId, connect_raw},
21    translate::*,
22};
23use std::boxed::Box as Box_;
24
25#[cfg(feature = "v4_10")]
26#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
27glib::wrapper! {
28    ///
29    /// ```text
30    ///
31    /// If a [`DropDown`][crate::DropDown] is created in this manner, or with
32    /// [`from_strings()`][Self::from_strings()], for instance, the object returned from
33    /// [`selected_item()`][Self::selected_item()] will be a [`StringObject`][crate::StringObject].
34    ///
35    /// To learn more about the list widget framework, see the
36    /// [overview](section-list-widget.html).
37    ///
38    /// ## CSS nodes
39    ///
40    /// [`DropDown`][crate::DropDown] has a single CSS node with name dropdown,
41    /// with the button and popover nodes as children.
42    ///
43    /// ## Accessibility
44    ///
45    /// [`DropDown`][crate::DropDown] uses the [enum@Gtk.AccessibleRole.combo_box] role.
46    ///
47    /// ## Properties
48    ///
49    ///
50    /// #### `enable-search`
51    ///  Whether to show a search entry in the popup.
52    ///
53    /// Note that search requires [`expression`][struct@crate::DropDown#expression]
54    /// to be set.
55    ///
56    /// Readable | Writable
57    ///
58    ///
59    /// #### `expression`
60    ///  An expression to evaluate to obtain strings to match against the search
61    /// term.
62    ///
63    /// See [`enable-search`][struct@crate::DropDown#enable-search] for how to enable search.
64    /// If [`factory`][struct@crate::DropDown#factory] is not set, the expression is also
65    /// used to bind strings to labels produced by a default factory.
66    ///
67    /// Readable | Writable
68    ///
69    ///
70    /// #### `factory`
71    ///  Factory for populating list items.
72    ///
73    /// Readable | Writable
74    ///
75    ///
76    /// #### `header-factory`
77    ///  The factory for creating header widgets for the popup.
78    ///
79    /// Readable | Writable
80    ///
81    ///
82    /// #### `list-factory`
83    ///  The factory for populating list items in the popup.
84    ///
85    /// If this is not set, [`factory`][struct@crate::DropDown#factory] is used.
86    ///
87    /// Readable | Writable
88    ///
89    ///
90    /// #### `model`
91    ///  Model for the displayed items.
92    ///
93    /// Readable | Writable
94    ///
95    ///
96    /// #### `search-match-mode`
97    ///  The match mode for the search filter.
98    ///
99    /// Readable | Writable
100    ///
101    ///
102    /// #### `selected`
103    ///  The position of the selected item.
104    ///
105    /// If no item is selected, the property has the value
106    /// `GTK_INVALID_LIST_POSITION`.
107    ///
108    /// Readable | Writable
109    ///
110    ///
111    /// #### `selected-item`
112    ///  The selected item.
113    ///
114    /// Readable
115    ///
116    ///
117    /// #### `show-arrow`
118    ///  Whether to show an arrow within the GtkDropDown widget.
119    ///
120    /// Readable | Writable
121    /// <details><summary><h4>Widget</h4></summary>
122    ///
123    ///
124    /// #### `can-focus`
125    ///  Whether the widget or any of its descendents can accept
126    /// the input focus.
127    ///
128    /// This property is meant to be set by widget implementations,
129    /// typically in their instance init function.
130    ///
131    /// Readable | Writable
132    ///
133    ///
134    /// #### `can-target`
135    ///  Whether the widget can receive pointer events.
136    ///
137    /// Readable | Writable
138    ///
139    ///
140    /// #### `css-classes`
141    ///  A list of css classes applied to this widget.
142    ///
143    /// Readable | Writable
144    ///
145    ///
146    /// #### `css-name`
147    ///  The name of this widget in the CSS tree.
148    ///
149    /// This property is meant to be set by widget implementations,
150    /// typically in their instance init function.
151    ///
152    /// Readable | Writable | Construct Only
153    ///
154    ///
155    /// #### `cursor`
156    ///  The cursor used by @widget.
157    ///
158    /// Readable | Writable
159    ///
160    ///
161    /// #### `focus-on-click`
162    ///  Whether the widget should grab focus when it is clicked with the mouse.
163    ///
164    /// This property is only relevant for widgets that can take focus.
165    ///
166    /// Readable | Writable
167    ///
168    ///
169    /// #### `focusable`
170    ///  Whether this widget itself will accept the input focus.
171    ///
172    /// Readable | Writable
173    ///
174    ///
175    /// #### `halign`
176    ///  How to distribute horizontal space if widget gets extra space.
177    ///
178    /// Readable | Writable
179    ///
180    ///
181    /// #### `has-default`
182    ///  Whether the widget is the default widget.
183    ///
184    /// Readable
185    ///
186    ///
187    /// #### `has-focus`
188    ///  Whether the widget has the input focus.
189    ///
190    /// Readable
191    ///
192    ///
193    /// #### `has-tooltip`
194    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
195    /// signal on @widget.
196    ///
197    /// A true value indicates that @widget can have a tooltip, in this case
198    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
199    /// determine whether it will provide a tooltip or not.
200    ///
201    /// Readable | Writable
202    ///
203    ///
204    /// #### `height-request`
205    ///  Overrides for height request of the widget.
206    ///
207    /// If this is -1, the natural request will be used.
208    ///
209    /// Readable | Writable
210    ///
211    ///
212    /// #### `hexpand`
213    ///  Whether to expand horizontally.
214    ///
215    /// Readable | Writable
216    ///
217    ///
218    /// #### `hexpand-set`
219    ///  Whether to use the `hexpand` property.
220    ///
221    /// Readable | Writable
222    ///
223    ///
224    /// #### `layout-manager`
225    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
226    /// the preferred size of the widget, and allocate its children.
227    ///
228    /// This property is meant to be set by widget implementations,
229    /// typically in their instance init function.
230    ///
231    /// Readable | Writable
232    ///
233    ///
234    /// #### `limit-events`
235    ///  Makes this widget act like a modal dialog, with respect to
236    /// event delivery.
237    ///
238    /// Global event controllers will not handle events with targets
239    /// inside the widget, unless they are set up to ignore propagation
240    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
241    ///
242    /// Readable | Writable
243    ///
244    ///
245    /// #### `margin-bottom`
246    ///  Margin on bottom side of widget.
247    ///
248    /// This property adds margin outside of the widget's normal size
249    /// request, the margin will be added in addition to the size from
250    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
251    ///
252    /// Readable | Writable
253    ///
254    ///
255    /// #### `margin-end`
256    ///  Margin on end of widget, horizontally.
257    ///
258    /// This property supports left-to-right and right-to-left text
259    /// directions.
260    ///
261    /// This property adds margin outside of the widget's normal size
262    /// request, the margin will be added in addition to the size from
263    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
264    ///
265    /// Readable | Writable
266    ///
267    ///
268    /// #### `margin-start`
269    ///  Margin on start of widget, horizontally.
270    ///
271    /// This property supports left-to-right and right-to-left text
272    /// directions.
273    ///
274    /// This property adds margin outside of the widget's normal size
275    /// request, the margin will be added in addition to the size from
276    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
277    ///
278    /// Readable | Writable
279    ///
280    ///
281    /// #### `margin-top`
282    ///  Margin on top side of widget.
283    ///
284    /// This property adds margin outside of the widget's normal size
285    /// request, the margin will be added in addition to the size from
286    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
287    ///
288    /// Readable | Writable
289    ///
290    ///
291    /// #### `name`
292    ///  The name of the widget.
293    ///
294    /// Readable | Writable
295    ///
296    ///
297    /// #### `opacity`
298    ///  The requested opacity of the widget.
299    ///
300    /// Readable | Writable
301    ///
302    ///
303    /// #### `overflow`
304    ///  How content outside the widget's content area is treated.
305    ///
306    /// This property is meant to be set by widget implementations,
307    /// typically in their instance init function.
308    ///
309    /// Readable | Writable
310    ///
311    ///
312    /// #### `parent`
313    ///  The parent widget of this widget.
314    ///
315    /// Readable
316    ///
317    ///
318    /// #### `receives-default`
319    ///  Whether the widget will receive the default action when it is focused.
320    ///
321    /// Readable | Writable
322    ///
323    ///
324    /// #### `root`
325    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
326    ///
327    /// This will be `NULL` if the widget is not contained in a root widget.
328    ///
329    /// Readable
330    ///
331    ///
332    /// #### `scale-factor`
333    ///  The scale factor of the widget.
334    ///
335    /// Readable
336    ///
337    ///
338    /// #### `sensitive`
339    ///  Whether the widget responds to input.
340    ///
341    /// Readable | Writable
342    ///
343    ///
344    /// #### `tooltip-markup`
345    ///  Sets the text of tooltip to be the given string, which is marked up
346    /// with Pango markup.
347    ///
348    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
349    ///
350    /// This is a convenience property which will take care of getting the
351    /// tooltip shown if the given string is not `NULL`:
352    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
353    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
354    /// the default signal handler.
355    ///
356    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
357    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
358    ///
359    /// Readable | Writable
360    ///
361    ///
362    /// #### `tooltip-text`
363    ///  Sets the text of tooltip to be the given string.
364    ///
365    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
366    ///
367    /// This is a convenience property which will take care of getting the
368    /// tooltip shown if the given string is not `NULL`:
369    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
370    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
371    /// the default signal handler.
372    ///
373    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
374    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
375    ///
376    /// Readable | Writable
377    ///
378    ///
379    /// #### `valign`
380    ///  How to distribute vertical space if widget gets extra space.
381    ///
382    /// Readable | Writable
383    ///
384    ///
385    /// #### `vexpand`
386    ///  Whether to expand vertically.
387    ///
388    /// Readable | Writable
389    ///
390    ///
391    /// #### `vexpand-set`
392    ///  Whether to use the `vexpand` property.
393    ///
394    /// Readable | Writable
395    ///
396    ///
397    /// #### `visible`
398    ///  Whether the widget is visible.
399    ///
400    /// Readable | Writable
401    ///
402    ///
403    /// #### `width-request`
404    ///  Overrides for width request of the widget.
405    ///
406    /// If this is -1, the natural request will be used.
407    ///
408    /// Readable | Writable
409    /// </details>
410    /// <details><summary><h4>Accessible</h4></summary>
411    ///
412    ///
413    /// #### `accessible-role`
414    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
415    ///
416    /// The accessible role cannot be changed once set.
417    ///
418    /// Readable | Writable
419    /// </details>
420    ///
421    /// ## Signals
422    ///
423    ///
424    /// #### `activate`
425    ///  Emitted to when the drop down is activated.
426    ///
427    /// The `::activate` signal on [`DropDown`][crate::DropDown] is an action signal and
428    /// emitting it causes the drop down to pop up its dropdown.
429    ///
430    /// Action
431    /// <details><summary><h4>Widget</h4></summary>
432    ///
433    ///
434    /// #### `destroy`
435    ///  Signals that all holders of a reference to the widget should release
436    /// the reference that they hold.
437    ///
438    /// May result in finalization of the widget if all references are released.
439    ///
440    /// This signal is not suitable for saving widget state.
441    ///
442    ///
443    ///
444    ///
445    /// #### `direction-changed`
446    ///  Emitted when the text direction of a widget changes.
447    ///
448    ///
449    ///
450    ///
451    /// #### `hide`
452    ///  Emitted when @widget is hidden.
453    ///
454    ///
455    ///
456    ///
457    /// #### `keynav-failed`
458    ///  Emitted if keyboard navigation fails.
459    ///
460    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
461    ///
462    ///
463    ///
464    ///
465    /// #### `map`
466    ///  Emitted when @widget is going to be mapped.
467    ///
468    /// A widget is mapped when the widget is visible (which is controlled with
469    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
470    /// are also visible.
471    ///
472    /// The `::map` signal can be used to determine whether a widget will be drawn,
473    /// for instance it can resume an animation that was stopped during the
474    /// emission of [`unmap`][struct@crate::Widget#unmap].
475    ///
476    ///
477    ///
478    ///
479    /// #### `mnemonic-activate`
480    ///  Emitted when a widget is activated via a mnemonic.
481    ///
482    /// The default handler for this signal activates @widget if @group_cycling
483    /// is false, or just makes @widget grab focus if @group_cycling is true.
484    ///
485    ///
486    ///
487    ///
488    /// #### `move-focus`
489    ///   to move backward.
490    ///
491    /// Action
492    ///
493    ///
494    /// #### `query-tooltip`
495    ///  s tooltip is about to be shown.
496    ///
497    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
498    /// is true and the hover timeout has expired with the cursor hovering
499    /// above @widget; or emitted when @widget got focus in keyboard mode.
500    ///
501    /// Using the given coordinates, the signal handler should determine
502    /// whether a tooltip should be shown for @widget. If this is the case
503    /// true should be returned, false otherwise. Note that if @keyboard_mode
504    /// is true, the values of @x and @y are undefined and should not be used.
505    ///
506    /// The signal handler is free to manipulate @tooltip with the therefore
507    /// destined function calls.
508    ///
509    ///
510    ///
511    ///
512    /// #### `realize`
513    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
514    ///
515    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
516    /// or the widget has been mapped (that is, it is going to be drawn).
517    ///
518    ///
519    ///
520    ///
521    /// #### `show`
522    ///  Emitted when @widget is shown.
523    ///
524    ///
525    ///
526    ///
527    /// #### `state-flags-changed`
528    ///  Emitted when the widget state changes.
529    ///
530    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
531    ///
532    ///
533    ///
534    ///
535    /// #### `unmap`
536    ///  Emitted when @widget is going to be unmapped.
537    ///
538    /// A widget is unmapped when either it or any of its parents up to the
539    /// toplevel widget have been set as hidden.
540    ///
541    /// As `::unmap` indicates that a widget will not be shown any longer,
542    /// it can be used to, for example, stop an animation on the widget.
543    ///
544    ///
545    ///
546    ///
547    /// #### `unrealize`
548    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
549    ///
550    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
551    /// or the widget has been unmapped (that is, it is going to be hidden).
552    ///
553    ///
554    /// </details>
555    ///
556    /// # Implements
557    ///
558    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
559    #[doc(alias = "GtkDropDown")]
560    pub struct DropDown(Object<ffi::GtkDropDown, ffi::GtkDropDownClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
561
562    match fn {
563        type_ => || ffi::gtk_drop_down_get_type(),
564    }
565}
566
567#[cfg(not(feature = "v4_10"))]
568glib::wrapper! {
569    #[doc(alias = "GtkDropDown")]
570    pub struct DropDown(Object<ffi::GtkDropDown, ffi::GtkDropDownClass>) @extends Widget, @implements Buildable, ConstraintTarget;
571
572    match fn {
573        type_ => || ffi::gtk_drop_down_get_type(),
574    }
575}
576
577impl DropDown {
578    /// Creates a new [`DropDown`][crate::DropDown].
579    ///
580    /// You may want to call [`set_factory()`][Self::set_factory()]
581    /// to set up a way to map its items to widgets.
582    /// ## `model`
583    /// the model to use
584    /// ## `expression`
585    /// the expression to use
586    ///
587    /// # Returns
588    ///
589    /// a new [`DropDown`][crate::DropDown]
590    #[doc(alias = "gtk_drop_down_new")]
591    pub fn new(
592        model: Option<impl IsA<gio::ListModel>>,
593        expression: Option<impl AsRef<Expression>>,
594    ) -> DropDown {
595        assert_initialized_main_thread!();
596        unsafe {
597            Widget::from_glib_none(ffi::gtk_drop_down_new(
598                model.map(|p| p.upcast()).into_glib_ptr(),
599                expression
600                    .map(|p| p.as_ref().clone().upcast())
601                    .into_glib_ptr(),
602            ))
603            .unsafe_cast()
604        }
605    }
606
607    /// Creates a new [`DropDown`][crate::DropDown] that is populated with
608    /// the strings.
609    /// ## `strings`
610    /// The strings to put in the dropdown
611    ///
612    /// # Returns
613    ///
614    /// a new [`DropDown`][crate::DropDown]
615    #[doc(alias = "gtk_drop_down_new_from_strings")]
616    #[doc(alias = "new_from_strings")]
617    pub fn from_strings(strings: &[&str]) -> DropDown {
618        assert_initialized_main_thread!();
619        unsafe {
620            Widget::from_glib_none(ffi::gtk_drop_down_new_from_strings(
621                strings.to_glib_none().0,
622            ))
623            .unsafe_cast()
624        }
625    }
626
627    // rustdoc-stripper-ignore-next
628    /// Creates a new builder-pattern struct instance to construct [`DropDown`] objects.
629    ///
630    /// This method returns an instance of [`DropDownBuilder`](crate::builders::DropDownBuilder) which can be used to create [`DropDown`] objects.
631    pub fn builder() -> DropDownBuilder {
632        DropDownBuilder::new()
633    }
634
635    /// Returns whether search is enabled.
636    ///
637    /// # Returns
638    ///
639    /// [`true`] if the popup includes a search entry
640    #[doc(alias = "gtk_drop_down_get_enable_search")]
641    #[doc(alias = "get_enable_search")]
642    #[doc(alias = "enable-search")]
643    pub fn enables_search(&self) -> bool {
644        unsafe { from_glib(ffi::gtk_drop_down_get_enable_search(self.to_glib_none().0)) }
645    }
646
647    /// Gets the expression set that is used to obtain strings from items.
648    ///
649    /// See [`set_expression()`][Self::set_expression()].
650    ///
651    /// # Returns
652    ///
653    /// a [`Expression`][crate::Expression]
654    #[doc(alias = "gtk_drop_down_get_expression")]
655    #[doc(alias = "get_expression")]
656    pub fn expression(&self) -> Option<Expression> {
657        unsafe { from_glib_none(ffi::gtk_drop_down_get_expression(self.to_glib_none().0)) }
658    }
659
660    /// Gets the factory that's currently used to populate list items.
661    ///
662    /// The factory returned by this function is always used for the
663    /// item in the button. It is also used for items in the popup
664    /// if [`list-factory`][struct@crate::DropDown#list-factory] is not set.
665    ///
666    /// # Returns
667    ///
668    /// The factory in use
669    #[doc(alias = "gtk_drop_down_get_factory")]
670    #[doc(alias = "get_factory")]
671    pub fn factory(&self) -> Option<ListItemFactory> {
672        unsafe { from_glib_none(ffi::gtk_drop_down_get_factory(self.to_glib_none().0)) }
673    }
674
675    /// Gets the factory that's currently used to create header widgets for the popup.
676    ///
677    /// # Returns
678    ///
679    /// The factory in use
680    #[cfg(feature = "v4_12")]
681    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
682    #[doc(alias = "gtk_drop_down_get_header_factory")]
683    #[doc(alias = "get_header_factory")]
684    #[doc(alias = "header-factory")]
685    pub fn header_factory(&self) -> Option<ListItemFactory> {
686        unsafe { from_glib_none(ffi::gtk_drop_down_get_header_factory(self.to_glib_none().0)) }
687    }
688
689    /// Gets the factory that's currently used to populate list items in the popup.
690    ///
691    /// # Returns
692    ///
693    /// The factory in use
694    #[doc(alias = "gtk_drop_down_get_list_factory")]
695    #[doc(alias = "get_list_factory")]
696    #[doc(alias = "list-factory")]
697    pub fn list_factory(&self) -> Option<ListItemFactory> {
698        unsafe { from_glib_none(ffi::gtk_drop_down_get_list_factory(self.to_glib_none().0)) }
699    }
700
701    /// Gets the model that provides the displayed items.
702    ///
703    /// # Returns
704    ///
705    /// The model in use
706    #[doc(alias = "gtk_drop_down_get_model")]
707    #[doc(alias = "get_model")]
708    pub fn model(&self) -> Option<gio::ListModel> {
709        unsafe { from_glib_none(ffi::gtk_drop_down_get_model(self.to_glib_none().0)) }
710    }
711
712    /// Returns the match mode that the search filter is using.
713    ///
714    /// # Returns
715    ///
716    /// the match mode of the search filter
717    #[cfg(feature = "v4_12")]
718    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
719    #[doc(alias = "gtk_drop_down_get_search_match_mode")]
720    #[doc(alias = "get_search_match_mode")]
721    #[doc(alias = "search-match-mode")]
722    pub fn search_match_mode(&self) -> StringFilterMatchMode {
723        unsafe {
724            from_glib(ffi::gtk_drop_down_get_search_match_mode(
725                self.to_glib_none().0,
726            ))
727        }
728    }
729
730    /// Gets the position of the selected item.
731    ///
732    /// # Returns
733    ///
734    /// the position of the selected item, or `GTK_INVALID_LIST_POSITION`
735    ///   if no item is selected
736    #[doc(alias = "gtk_drop_down_get_selected")]
737    #[doc(alias = "get_selected")]
738    pub fn selected(&self) -> u32 {
739        unsafe { ffi::gtk_drop_down_get_selected(self.to_glib_none().0) }
740    }
741
742    /// Gets the selected item. If no item is selected, [`None`] is returned.
743    ///
744    /// # Returns
745    ///
746    /// The selected item
747    #[doc(alias = "gtk_drop_down_get_selected_item")]
748    #[doc(alias = "get_selected_item")]
749    #[doc(alias = "selected-item")]
750    pub fn selected_item(&self) -> Option<glib::Object> {
751        unsafe { from_glib_none(ffi::gtk_drop_down_get_selected_item(self.to_glib_none().0)) }
752    }
753
754    /// Returns whether to show an arrow within the widget.
755    ///
756    /// # Returns
757    ///
758    /// [`true`] if an arrow will be shown.
759    #[cfg(feature = "v4_6")]
760    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
761    #[doc(alias = "gtk_drop_down_get_show_arrow")]
762    #[doc(alias = "get_show_arrow")]
763    #[doc(alias = "show-arrow")]
764    pub fn shows_arrow(&self) -> bool {
765        unsafe { from_glib(ffi::gtk_drop_down_get_show_arrow(self.to_glib_none().0)) }
766    }
767
768    /// Sets whether a search entry will be shown in the popup that
769    /// allows to search for items in the list.
770    ///
771    /// Note that [`expression`][struct@crate::DropDown#expression] must be set for
772    /// search to work.
773    /// ## `enable_search`
774    /// whether to enable search
775    #[doc(alias = "gtk_drop_down_set_enable_search")]
776    #[doc(alias = "enable-search")]
777    pub fn set_enable_search(&self, enable_search: bool) {
778        unsafe {
779            ffi::gtk_drop_down_set_enable_search(self.to_glib_none().0, enable_search.into_glib());
780        }
781    }
782
783    /// Sets the expression that gets evaluated to obtain strings from items.
784    ///
785    /// This is used for search in the popup. The expression must have
786    /// a value type of `G_TYPE_STRING`.
787    /// ## `expression`
788    /// a [`Expression`][crate::Expression]
789    #[doc(alias = "gtk_drop_down_set_expression")]
790    #[doc(alias = "expression")]
791    pub fn set_expression(&self, expression: Option<impl AsRef<Expression>>) {
792        unsafe {
793            ffi::gtk_drop_down_set_expression(
794                self.to_glib_none().0,
795                expression.as_ref().map(|p| p.as_ref()).to_glib_none().0,
796            );
797        }
798    }
799
800    /// Sets the [`ListItemFactory`][crate::ListItemFactory] to use for populating list items.
801    /// ## `factory`
802    /// the factory to use
803    #[doc(alias = "gtk_drop_down_set_factory")]
804    #[doc(alias = "factory")]
805    pub fn set_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
806        unsafe {
807            ffi::gtk_drop_down_set_factory(
808                self.to_glib_none().0,
809                factory.map(|p| p.as_ref()).to_glib_none().0,
810            );
811        }
812    }
813
814    /// Sets the [`ListItemFactory`][crate::ListItemFactory] to use for creating header widgets for the popup.
815    /// ## `factory`
816    /// the factory to use
817    #[cfg(feature = "v4_12")]
818    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
819    #[doc(alias = "gtk_drop_down_set_header_factory")]
820    #[doc(alias = "header-factory")]
821    pub fn set_header_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
822        unsafe {
823            ffi::gtk_drop_down_set_header_factory(
824                self.to_glib_none().0,
825                factory.map(|p| p.as_ref()).to_glib_none().0,
826            );
827        }
828    }
829
830    /// Sets the [`ListItemFactory`][crate::ListItemFactory] to use for populating list items in the popup.
831    /// ## `factory`
832    /// the factory to use
833    #[doc(alias = "gtk_drop_down_set_list_factory")]
834    #[doc(alias = "list-factory")]
835    pub fn set_list_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
836        unsafe {
837            ffi::gtk_drop_down_set_list_factory(
838                self.to_glib_none().0,
839                factory.map(|p| p.as_ref()).to_glib_none().0,
840            );
841        }
842    }
843
844    /// Sets the `GListModel` to use.
845    /// ## `model`
846    /// the model to use
847    #[doc(alias = "gtk_drop_down_set_model")]
848    #[doc(alias = "model")]
849    pub fn set_model(&self, model: Option<&impl IsA<gio::ListModel>>) {
850        unsafe {
851            ffi::gtk_drop_down_set_model(
852                self.to_glib_none().0,
853                model.map(|p| p.as_ref()).to_glib_none().0,
854            );
855        }
856    }
857
858    /// Sets the match mode for the search filter.
859    /// ## `search_match_mode`
860    /// the new match mode
861    #[cfg(feature = "v4_12")]
862    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
863    #[doc(alias = "gtk_drop_down_set_search_match_mode")]
864    #[doc(alias = "search-match-mode")]
865    pub fn set_search_match_mode(&self, search_match_mode: StringFilterMatchMode) {
866        unsafe {
867            ffi::gtk_drop_down_set_search_match_mode(
868                self.to_glib_none().0,
869                search_match_mode.into_glib(),
870            );
871        }
872    }
873
874    /// Selects the item at the given position.
875    /// ## `position`
876    /// the position of the item to select, or `GTK_INVALID_LIST_POSITION`
877    #[doc(alias = "gtk_drop_down_set_selected")]
878    #[doc(alias = "selected")]
879    pub fn set_selected(&self, position: u32) {
880        unsafe {
881            ffi::gtk_drop_down_set_selected(self.to_glib_none().0, position);
882        }
883    }
884
885    /// Sets whether an arrow will be displayed within the widget.
886    /// ## `show_arrow`
887    /// whether to show an arrow within the widget
888    #[cfg(feature = "v4_6")]
889    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
890    #[doc(alias = "gtk_drop_down_set_show_arrow")]
891    #[doc(alias = "show-arrow")]
892    pub fn set_show_arrow(&self, show_arrow: bool) {
893        unsafe {
894            ffi::gtk_drop_down_set_show_arrow(self.to_glib_none().0, show_arrow.into_glib());
895        }
896    }
897
898    /// Emitted to when the drop down is activated.
899    ///
900    /// The `::activate` signal on [`DropDown`][crate::DropDown] is an action signal and
901    /// emitting it causes the drop down to pop up its dropdown.
902    #[cfg(feature = "v4_6")]
903    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
904    #[doc(alias = "activate")]
905    pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
906        unsafe extern "C" fn activate_trampoline<F: Fn(&DropDown) + 'static>(
907            this: *mut ffi::GtkDropDown,
908            f: glib::ffi::gpointer,
909        ) {
910            unsafe {
911                let f: &F = &*(f as *const F);
912                f(&from_glib_borrow(this))
913            }
914        }
915        unsafe {
916            let f: Box_<F> = Box_::new(f);
917            connect_raw(
918                self.as_ptr() as *mut _,
919                c"activate".as_ptr(),
920                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
921                    activate_trampoline::<F> as *const (),
922                )),
923                Box_::into_raw(f),
924            )
925        }
926    }
927
928    #[cfg(feature = "v4_6")]
929    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
930    pub fn emit_activate(&self) {
931        self.emit_by_name::<()>("activate", &[]);
932    }
933
934    #[doc(alias = "enable-search")]
935    pub fn connect_enable_search_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
936        unsafe extern "C" fn notify_enable_search_trampoline<F: Fn(&DropDown) + 'static>(
937            this: *mut ffi::GtkDropDown,
938            _param_spec: glib::ffi::gpointer,
939            f: glib::ffi::gpointer,
940        ) {
941            unsafe {
942                let f: &F = &*(f as *const F);
943                f(&from_glib_borrow(this))
944            }
945        }
946        unsafe {
947            let f: Box_<F> = Box_::new(f);
948            connect_raw(
949                self.as_ptr() as *mut _,
950                c"notify::enable-search".as_ptr(),
951                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
952                    notify_enable_search_trampoline::<F> as *const (),
953                )),
954                Box_::into_raw(f),
955            )
956        }
957    }
958
959    #[doc(alias = "expression")]
960    pub fn connect_expression_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
961        unsafe extern "C" fn notify_expression_trampoline<F: Fn(&DropDown) + 'static>(
962            this: *mut ffi::GtkDropDown,
963            _param_spec: glib::ffi::gpointer,
964            f: glib::ffi::gpointer,
965        ) {
966            unsafe {
967                let f: &F = &*(f as *const F);
968                f(&from_glib_borrow(this))
969            }
970        }
971        unsafe {
972            let f: Box_<F> = Box_::new(f);
973            connect_raw(
974                self.as_ptr() as *mut _,
975                c"notify::expression".as_ptr(),
976                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
977                    notify_expression_trampoline::<F> as *const (),
978                )),
979                Box_::into_raw(f),
980            )
981        }
982    }
983
984    #[doc(alias = "factory")]
985    pub fn connect_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
986        unsafe extern "C" fn notify_factory_trampoline<F: Fn(&DropDown) + 'static>(
987            this: *mut ffi::GtkDropDown,
988            _param_spec: glib::ffi::gpointer,
989            f: glib::ffi::gpointer,
990        ) {
991            unsafe {
992                let f: &F = &*(f as *const F);
993                f(&from_glib_borrow(this))
994            }
995        }
996        unsafe {
997            let f: Box_<F> = Box_::new(f);
998            connect_raw(
999                self.as_ptr() as *mut _,
1000                c"notify::factory".as_ptr(),
1001                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1002                    notify_factory_trampoline::<F> as *const (),
1003                )),
1004                Box_::into_raw(f),
1005            )
1006        }
1007    }
1008
1009    #[cfg(feature = "v4_12")]
1010    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1011    #[doc(alias = "header-factory")]
1012    pub fn connect_header_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1013        unsafe extern "C" fn notify_header_factory_trampoline<F: Fn(&DropDown) + 'static>(
1014            this: *mut ffi::GtkDropDown,
1015            _param_spec: glib::ffi::gpointer,
1016            f: glib::ffi::gpointer,
1017        ) {
1018            unsafe {
1019                let f: &F = &*(f as *const F);
1020                f(&from_glib_borrow(this))
1021            }
1022        }
1023        unsafe {
1024            let f: Box_<F> = Box_::new(f);
1025            connect_raw(
1026                self.as_ptr() as *mut _,
1027                c"notify::header-factory".as_ptr(),
1028                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1029                    notify_header_factory_trampoline::<F> as *const (),
1030                )),
1031                Box_::into_raw(f),
1032            )
1033        }
1034    }
1035
1036    #[doc(alias = "list-factory")]
1037    pub fn connect_list_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1038        unsafe extern "C" fn notify_list_factory_trampoline<F: Fn(&DropDown) + 'static>(
1039            this: *mut ffi::GtkDropDown,
1040            _param_spec: glib::ffi::gpointer,
1041            f: glib::ffi::gpointer,
1042        ) {
1043            unsafe {
1044                let f: &F = &*(f as *const F);
1045                f(&from_glib_borrow(this))
1046            }
1047        }
1048        unsafe {
1049            let f: Box_<F> = Box_::new(f);
1050            connect_raw(
1051                self.as_ptr() as *mut _,
1052                c"notify::list-factory".as_ptr(),
1053                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1054                    notify_list_factory_trampoline::<F> as *const (),
1055                )),
1056                Box_::into_raw(f),
1057            )
1058        }
1059    }
1060
1061    #[doc(alias = "model")]
1062    pub fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1063        unsafe extern "C" fn notify_model_trampoline<F: Fn(&DropDown) + 'static>(
1064            this: *mut ffi::GtkDropDown,
1065            _param_spec: glib::ffi::gpointer,
1066            f: glib::ffi::gpointer,
1067        ) {
1068            unsafe {
1069                let f: &F = &*(f as *const F);
1070                f(&from_glib_borrow(this))
1071            }
1072        }
1073        unsafe {
1074            let f: Box_<F> = Box_::new(f);
1075            connect_raw(
1076                self.as_ptr() as *mut _,
1077                c"notify::model".as_ptr(),
1078                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1079                    notify_model_trampoline::<F> as *const (),
1080                )),
1081                Box_::into_raw(f),
1082            )
1083        }
1084    }
1085
1086    #[cfg(feature = "v4_12")]
1087    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1088    #[doc(alias = "search-match-mode")]
1089    pub fn connect_search_match_mode_notify<F: Fn(&Self) + 'static>(
1090        &self,
1091        f: F,
1092    ) -> SignalHandlerId {
1093        unsafe extern "C" fn notify_search_match_mode_trampoline<F: Fn(&DropDown) + 'static>(
1094            this: *mut ffi::GtkDropDown,
1095            _param_spec: glib::ffi::gpointer,
1096            f: glib::ffi::gpointer,
1097        ) {
1098            unsafe {
1099                let f: &F = &*(f as *const F);
1100                f(&from_glib_borrow(this))
1101            }
1102        }
1103        unsafe {
1104            let f: Box_<F> = Box_::new(f);
1105            connect_raw(
1106                self.as_ptr() as *mut _,
1107                c"notify::search-match-mode".as_ptr(),
1108                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1109                    notify_search_match_mode_trampoline::<F> as *const (),
1110                )),
1111                Box_::into_raw(f),
1112            )
1113        }
1114    }
1115
1116    #[doc(alias = "selected")]
1117    pub fn connect_selected_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1118        unsafe extern "C" fn notify_selected_trampoline<F: Fn(&DropDown) + 'static>(
1119            this: *mut ffi::GtkDropDown,
1120            _param_spec: glib::ffi::gpointer,
1121            f: glib::ffi::gpointer,
1122        ) {
1123            unsafe {
1124                let f: &F = &*(f as *const F);
1125                f(&from_glib_borrow(this))
1126            }
1127        }
1128        unsafe {
1129            let f: Box_<F> = Box_::new(f);
1130            connect_raw(
1131                self.as_ptr() as *mut _,
1132                c"notify::selected".as_ptr(),
1133                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1134                    notify_selected_trampoline::<F> as *const (),
1135                )),
1136                Box_::into_raw(f),
1137            )
1138        }
1139    }
1140
1141    #[doc(alias = "selected-item")]
1142    pub fn connect_selected_item_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1143        unsafe extern "C" fn notify_selected_item_trampoline<F: Fn(&DropDown) + 'static>(
1144            this: *mut ffi::GtkDropDown,
1145            _param_spec: glib::ffi::gpointer,
1146            f: glib::ffi::gpointer,
1147        ) {
1148            unsafe {
1149                let f: &F = &*(f as *const F);
1150                f(&from_glib_borrow(this))
1151            }
1152        }
1153        unsafe {
1154            let f: Box_<F> = Box_::new(f);
1155            connect_raw(
1156                self.as_ptr() as *mut _,
1157                c"notify::selected-item".as_ptr(),
1158                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1159                    notify_selected_item_trampoline::<F> as *const (),
1160                )),
1161                Box_::into_raw(f),
1162            )
1163        }
1164    }
1165
1166    #[cfg(feature = "v4_6")]
1167    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
1168    #[doc(alias = "show-arrow")]
1169    pub fn connect_show_arrow_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1170        unsafe extern "C" fn notify_show_arrow_trampoline<F: Fn(&DropDown) + 'static>(
1171            this: *mut ffi::GtkDropDown,
1172            _param_spec: glib::ffi::gpointer,
1173            f: glib::ffi::gpointer,
1174        ) {
1175            unsafe {
1176                let f: &F = &*(f as *const F);
1177                f(&from_glib_borrow(this))
1178            }
1179        }
1180        unsafe {
1181            let f: Box_<F> = Box_::new(f);
1182            connect_raw(
1183                self.as_ptr() as *mut _,
1184                c"notify::show-arrow".as_ptr(),
1185                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1186                    notify_show_arrow_trampoline::<F> as *const (),
1187                )),
1188                Box_::into_raw(f),
1189            )
1190        }
1191    }
1192}
1193
1194impl Default for DropDown {
1195    fn default() -> Self {
1196        glib::object::Object::new::<Self>()
1197    }
1198}
1199
1200// rustdoc-stripper-ignore-next
1201/// A [builder-pattern] type to construct [`DropDown`] objects.
1202///
1203/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1204#[must_use = "The builder must be built to be used"]
1205pub struct DropDownBuilder {
1206    builder: glib::object::ObjectBuilder<'static, DropDown>,
1207}
1208
1209impl DropDownBuilder {
1210    fn new() -> Self {
1211        Self {
1212            builder: glib::object::Object::builder(),
1213        }
1214    }
1215
1216    /// Whether to show a search entry in the popup.
1217    ///
1218    /// Note that search requires [`expression`][struct@crate::DropDown#expression]
1219    /// to be set.
1220    pub fn enable_search(self, enable_search: bool) -> Self {
1221        Self {
1222            builder: self.builder.property("enable-search", enable_search),
1223        }
1224    }
1225
1226    /// An expression to evaluate to obtain strings to match against the search
1227    /// term.
1228    ///
1229    /// See [`enable-search`][struct@crate::DropDown#enable-search] for how to enable search.
1230    /// If [`factory`][struct@crate::DropDown#factory] is not set, the expression is also
1231    /// used to bind strings to labels produced by a default factory.
1232    pub fn expression(self, expression: impl AsRef<Expression>) -> Self {
1233        Self {
1234            builder: self
1235                .builder
1236                .property("expression", expression.as_ref().clone()),
1237        }
1238    }
1239
1240    /// Factory for populating list items.
1241    pub fn factory(self, factory: &impl IsA<ListItemFactory>) -> Self {
1242        Self {
1243            builder: self.builder.property("factory", factory.clone().upcast()),
1244        }
1245    }
1246
1247    /// The factory for creating header widgets for the popup.
1248    #[cfg(feature = "v4_12")]
1249    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1250    pub fn header_factory(self, header_factory: &impl IsA<ListItemFactory>) -> Self {
1251        Self {
1252            builder: self
1253                .builder
1254                .property("header-factory", header_factory.clone().upcast()),
1255        }
1256    }
1257
1258    /// The factory for populating list items in the popup.
1259    ///
1260    /// If this is not set, [`factory`][struct@crate::DropDown#factory] is used.
1261    pub fn list_factory(self, list_factory: &impl IsA<ListItemFactory>) -> Self {
1262        Self {
1263            builder: self
1264                .builder
1265                .property("list-factory", list_factory.clone().upcast()),
1266        }
1267    }
1268
1269    /// Model for the displayed items.
1270    pub fn model(self, model: &impl IsA<gio::ListModel>) -> Self {
1271        Self {
1272            builder: self.builder.property("model", model.clone().upcast()),
1273        }
1274    }
1275
1276    /// The match mode for the search filter.
1277    #[cfg(feature = "v4_12")]
1278    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1279    pub fn search_match_mode(self, search_match_mode: StringFilterMatchMode) -> Self {
1280        Self {
1281            builder: self
1282                .builder
1283                .property("search-match-mode", search_match_mode),
1284        }
1285    }
1286
1287    /// The position of the selected item.
1288    ///
1289    /// If no item is selected, the property has the value
1290    /// `GTK_INVALID_LIST_POSITION`.
1291    pub fn selected(self, selected: u32) -> Self {
1292        Self {
1293            builder: self.builder.property("selected", selected),
1294        }
1295    }
1296
1297    /// Whether to show an arrow within the GtkDropDown widget.
1298    #[cfg(feature = "v4_6")]
1299    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
1300    pub fn show_arrow(self, show_arrow: bool) -> Self {
1301        Self {
1302            builder: self.builder.property("show-arrow", show_arrow),
1303        }
1304    }
1305
1306    /// Whether the widget or any of its descendents can accept
1307    /// the input focus.
1308    ///
1309    /// This property is meant to be set by widget implementations,
1310    /// typically in their instance init function.
1311    pub fn can_focus(self, can_focus: bool) -> Self {
1312        Self {
1313            builder: self.builder.property("can-focus", can_focus),
1314        }
1315    }
1316
1317    /// Whether the widget can receive pointer events.
1318    pub fn can_target(self, can_target: bool) -> Self {
1319        Self {
1320            builder: self.builder.property("can-target", can_target),
1321        }
1322    }
1323
1324    /// A list of css classes applied to this widget.
1325    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1326        Self {
1327            builder: self.builder.property("css-classes", css_classes.into()),
1328        }
1329    }
1330
1331    /// The name of this widget in the CSS tree.
1332    ///
1333    /// This property is meant to be set by widget implementations,
1334    /// typically in their instance init function.
1335    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1336        Self {
1337            builder: self.builder.property("css-name", css_name.into()),
1338        }
1339    }
1340
1341    /// The cursor used by @widget.
1342    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1343        Self {
1344            builder: self.builder.property("cursor", cursor.clone()),
1345        }
1346    }
1347
1348    /// Whether the widget should grab focus when it is clicked with the mouse.
1349    ///
1350    /// This property is only relevant for widgets that can take focus.
1351    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1352        Self {
1353            builder: self.builder.property("focus-on-click", focus_on_click),
1354        }
1355    }
1356
1357    /// Whether this widget itself will accept the input focus.
1358    pub fn focusable(self, focusable: bool) -> Self {
1359        Self {
1360            builder: self.builder.property("focusable", focusable),
1361        }
1362    }
1363
1364    /// How to distribute horizontal space if widget gets extra space.
1365    pub fn halign(self, halign: Align) -> Self {
1366        Self {
1367            builder: self.builder.property("halign", halign),
1368        }
1369    }
1370
1371    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1372    /// signal on @widget.
1373    ///
1374    /// A true value indicates that @widget can have a tooltip, in this case
1375    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1376    /// determine whether it will provide a tooltip or not.
1377    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1378        Self {
1379            builder: self.builder.property("has-tooltip", has_tooltip),
1380        }
1381    }
1382
1383    /// Overrides for height request of the widget.
1384    ///
1385    /// If this is -1, the natural request will be used.
1386    pub fn height_request(self, height_request: i32) -> Self {
1387        Self {
1388            builder: self.builder.property("height-request", height_request),
1389        }
1390    }
1391
1392    /// Whether to expand horizontally.
1393    pub fn hexpand(self, hexpand: bool) -> Self {
1394        Self {
1395            builder: self.builder.property("hexpand", hexpand),
1396        }
1397    }
1398
1399    /// Whether to use the `hexpand` property.
1400    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1401        Self {
1402            builder: self.builder.property("hexpand-set", hexpand_set),
1403        }
1404    }
1405
1406    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1407    /// the preferred size of the widget, and allocate its children.
1408    ///
1409    /// This property is meant to be set by widget implementations,
1410    /// typically in their instance init function.
1411    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1412        Self {
1413            builder: self
1414                .builder
1415                .property("layout-manager", layout_manager.clone().upcast()),
1416        }
1417    }
1418
1419    /// Makes this widget act like a modal dialog, with respect to
1420    /// event delivery.
1421    ///
1422    /// Global event controllers will not handle events with targets
1423    /// inside the widget, unless they are set up to ignore propagation
1424    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1425    #[cfg(feature = "v4_18")]
1426    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1427    pub fn limit_events(self, limit_events: bool) -> Self {
1428        Self {
1429            builder: self.builder.property("limit-events", limit_events),
1430        }
1431    }
1432
1433    /// Margin on bottom side of widget.
1434    ///
1435    /// This property adds margin outside of the widget's normal size
1436    /// request, the margin will be added in addition to the size from
1437    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1438    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1439        Self {
1440            builder: self.builder.property("margin-bottom", margin_bottom),
1441        }
1442    }
1443
1444    /// Margin on end of widget, horizontally.
1445    ///
1446    /// This property supports left-to-right and right-to-left text
1447    /// directions.
1448    ///
1449    /// This property adds margin outside of the widget's normal size
1450    /// request, the margin will be added in addition to the size from
1451    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1452    pub fn margin_end(self, margin_end: i32) -> Self {
1453        Self {
1454            builder: self.builder.property("margin-end", margin_end),
1455        }
1456    }
1457
1458    /// Margin on start of widget, horizontally.
1459    ///
1460    /// This property supports left-to-right and right-to-left text
1461    /// directions.
1462    ///
1463    /// This property adds margin outside of the widget's normal size
1464    /// request, the margin will be added in addition to the size from
1465    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1466    pub fn margin_start(self, margin_start: i32) -> Self {
1467        Self {
1468            builder: self.builder.property("margin-start", margin_start),
1469        }
1470    }
1471
1472    /// Margin on top side of widget.
1473    ///
1474    /// This property adds margin outside of the widget's normal size
1475    /// request, the margin will be added in addition to the size from
1476    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1477    pub fn margin_top(self, margin_top: i32) -> Self {
1478        Self {
1479            builder: self.builder.property("margin-top", margin_top),
1480        }
1481    }
1482
1483    /// The name of the widget.
1484    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1485        Self {
1486            builder: self.builder.property("name", name.into()),
1487        }
1488    }
1489
1490    /// The requested opacity of the widget.
1491    pub fn opacity(self, opacity: f64) -> Self {
1492        Self {
1493            builder: self.builder.property("opacity", opacity),
1494        }
1495    }
1496
1497    /// How content outside the widget's content area is treated.
1498    ///
1499    /// This property is meant to be set by widget implementations,
1500    /// typically in their instance init function.
1501    pub fn overflow(self, overflow: Overflow) -> Self {
1502        Self {
1503            builder: self.builder.property("overflow", overflow),
1504        }
1505    }
1506
1507    /// Whether the widget will receive the default action when it is focused.
1508    pub fn receives_default(self, receives_default: bool) -> Self {
1509        Self {
1510            builder: self.builder.property("receives-default", receives_default),
1511        }
1512    }
1513
1514    /// Whether the widget responds to input.
1515    pub fn sensitive(self, sensitive: bool) -> Self {
1516        Self {
1517            builder: self.builder.property("sensitive", sensitive),
1518        }
1519    }
1520
1521    /// Sets the text of tooltip to be the given string, which is marked up
1522    /// with Pango markup.
1523    ///
1524    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1525    ///
1526    /// This is a convenience property which will take care of getting the
1527    /// tooltip shown if the given string is not `NULL`:
1528    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1529    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1530    /// the default signal handler.
1531    ///
1532    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1533    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1534    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1535        Self {
1536            builder: self
1537                .builder
1538                .property("tooltip-markup", tooltip_markup.into()),
1539        }
1540    }
1541
1542    /// Sets the text of tooltip to be the given string.
1543    ///
1544    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1545    ///
1546    /// This is a convenience property which will take care of getting the
1547    /// tooltip shown if the given string is not `NULL`:
1548    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1549    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1550    /// the default signal handler.
1551    ///
1552    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1553    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1554    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1555        Self {
1556            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1557        }
1558    }
1559
1560    /// How to distribute vertical space if widget gets extra space.
1561    pub fn valign(self, valign: Align) -> Self {
1562        Self {
1563            builder: self.builder.property("valign", valign),
1564        }
1565    }
1566
1567    /// Whether to expand vertically.
1568    pub fn vexpand(self, vexpand: bool) -> Self {
1569        Self {
1570            builder: self.builder.property("vexpand", vexpand),
1571        }
1572    }
1573
1574    /// Whether to use the `vexpand` property.
1575    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1576        Self {
1577            builder: self.builder.property("vexpand-set", vexpand_set),
1578        }
1579    }
1580
1581    /// Whether the widget is visible.
1582    pub fn visible(self, visible: bool) -> Self {
1583        Self {
1584            builder: self.builder.property("visible", visible),
1585        }
1586    }
1587
1588    /// Overrides for width request of the widget.
1589    ///
1590    /// If this is -1, the natural request will be used.
1591    pub fn width_request(self, width_request: i32) -> Self {
1592        Self {
1593            builder: self.builder.property("width-request", width_request),
1594        }
1595    }
1596
1597    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1598    ///
1599    /// The accessible role cannot be changed once set.
1600    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1601        Self {
1602            builder: self.builder.property("accessible-role", accessible_role),
1603        }
1604    }
1605
1606    // rustdoc-stripper-ignore-next
1607    /// Build the [`DropDown`].
1608    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1609    pub fn build(self) -> DropDown {
1610        assert_initialized_main_thread!();
1611        self.builder.build()
1612    }
1613}