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