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    ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, Expression, LayoutManager,
10    ListItemFactory, Overflow, Widget,
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::{connect_raw, SignalHandlerId},
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            let f: &F = &*(f as *const F);
941            f(&from_glib_borrow(this))
942        }
943        unsafe {
944            let f: Box_<F> = Box_::new(f);
945            connect_raw(
946                self.as_ptr() as *mut _,
947                c"activate".as_ptr() as *const _,
948                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
949                    activate_trampoline::<F> as *const (),
950                )),
951                Box_::into_raw(f),
952            )
953        }
954    }
955
956    #[cfg(feature = "v4_6")]
957    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
958    pub fn emit_activate(&self) {
959        self.emit_by_name::<()>("activate", &[]);
960    }
961
962    #[doc(alias = "enable-search")]
963    pub fn connect_enable_search_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
964        unsafe extern "C" fn notify_enable_search_trampoline<F: Fn(&DropDown) + 'static>(
965            this: *mut ffi::GtkDropDown,
966            _param_spec: glib::ffi::gpointer,
967            f: glib::ffi::gpointer,
968        ) {
969            let f: &F = &*(f as *const F);
970            f(&from_glib_borrow(this))
971        }
972        unsafe {
973            let f: Box_<F> = Box_::new(f);
974            connect_raw(
975                self.as_ptr() as *mut _,
976                c"notify::enable-search".as_ptr() as *const _,
977                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
978                    notify_enable_search_trampoline::<F> as *const (),
979                )),
980                Box_::into_raw(f),
981            )
982        }
983    }
984
985    #[doc(alias = "expression")]
986    pub fn connect_expression_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
987        unsafe extern "C" fn notify_expression_trampoline<F: Fn(&DropDown) + 'static>(
988            this: *mut ffi::GtkDropDown,
989            _param_spec: glib::ffi::gpointer,
990            f: glib::ffi::gpointer,
991        ) {
992            let f: &F = &*(f as *const F);
993            f(&from_glib_borrow(this))
994        }
995        unsafe {
996            let f: Box_<F> = Box_::new(f);
997            connect_raw(
998                self.as_ptr() as *mut _,
999                c"notify::expression".as_ptr() as *const _,
1000                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1001                    notify_expression_trampoline::<F> as *const (),
1002                )),
1003                Box_::into_raw(f),
1004            )
1005        }
1006    }
1007
1008    #[doc(alias = "factory")]
1009    pub fn connect_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1010        unsafe extern "C" fn notify_factory_trampoline<F: Fn(&DropDown) + 'static>(
1011            this: *mut ffi::GtkDropDown,
1012            _param_spec: glib::ffi::gpointer,
1013            f: glib::ffi::gpointer,
1014        ) {
1015            let f: &F = &*(f as *const F);
1016            f(&from_glib_borrow(this))
1017        }
1018        unsafe {
1019            let f: Box_<F> = Box_::new(f);
1020            connect_raw(
1021                self.as_ptr() as *mut _,
1022                c"notify::factory".as_ptr() as *const _,
1023                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1024                    notify_factory_trampoline::<F> as *const (),
1025                )),
1026                Box_::into_raw(f),
1027            )
1028        }
1029    }
1030
1031    #[cfg(feature = "v4_12")]
1032    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1033    #[doc(alias = "header-factory")]
1034    pub fn connect_header_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1035        unsafe extern "C" fn notify_header_factory_trampoline<F: Fn(&DropDown) + 'static>(
1036            this: *mut ffi::GtkDropDown,
1037            _param_spec: glib::ffi::gpointer,
1038            f: glib::ffi::gpointer,
1039        ) {
1040            let f: &F = &*(f as *const F);
1041            f(&from_glib_borrow(this))
1042        }
1043        unsafe {
1044            let f: Box_<F> = Box_::new(f);
1045            connect_raw(
1046                self.as_ptr() as *mut _,
1047                c"notify::header-factory".as_ptr() as *const _,
1048                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1049                    notify_header_factory_trampoline::<F> as *const (),
1050                )),
1051                Box_::into_raw(f),
1052            )
1053        }
1054    }
1055
1056    #[doc(alias = "list-factory")]
1057    pub fn connect_list_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1058        unsafe extern "C" fn notify_list_factory_trampoline<F: Fn(&DropDown) + 'static>(
1059            this: *mut ffi::GtkDropDown,
1060            _param_spec: glib::ffi::gpointer,
1061            f: glib::ffi::gpointer,
1062        ) {
1063            let f: &F = &*(f as *const F);
1064            f(&from_glib_borrow(this))
1065        }
1066        unsafe {
1067            let f: Box_<F> = Box_::new(f);
1068            connect_raw(
1069                self.as_ptr() as *mut _,
1070                c"notify::list-factory".as_ptr() as *const _,
1071                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1072                    notify_list_factory_trampoline::<F> as *const (),
1073                )),
1074                Box_::into_raw(f),
1075            )
1076        }
1077    }
1078
1079    #[doc(alias = "model")]
1080    pub fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1081        unsafe extern "C" fn notify_model_trampoline<F: Fn(&DropDown) + 'static>(
1082            this: *mut ffi::GtkDropDown,
1083            _param_spec: glib::ffi::gpointer,
1084            f: glib::ffi::gpointer,
1085        ) {
1086            let f: &F = &*(f as *const F);
1087            f(&from_glib_borrow(this))
1088        }
1089        unsafe {
1090            let f: Box_<F> = Box_::new(f);
1091            connect_raw(
1092                self.as_ptr() as *mut _,
1093                c"notify::model".as_ptr() as *const _,
1094                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1095                    notify_model_trampoline::<F> as *const (),
1096                )),
1097                Box_::into_raw(f),
1098            )
1099        }
1100    }
1101
1102    #[cfg(feature = "v4_12")]
1103    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1104    #[doc(alias = "search-match-mode")]
1105    pub fn connect_search_match_mode_notify<F: Fn(&Self) + 'static>(
1106        &self,
1107        f: F,
1108    ) -> SignalHandlerId {
1109        unsafe extern "C" fn notify_search_match_mode_trampoline<F: Fn(&DropDown) + 'static>(
1110            this: *mut ffi::GtkDropDown,
1111            _param_spec: glib::ffi::gpointer,
1112            f: glib::ffi::gpointer,
1113        ) {
1114            let f: &F = &*(f as *const F);
1115            f(&from_glib_borrow(this))
1116        }
1117        unsafe {
1118            let f: Box_<F> = Box_::new(f);
1119            connect_raw(
1120                self.as_ptr() as *mut _,
1121                c"notify::search-match-mode".as_ptr() as *const _,
1122                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1123                    notify_search_match_mode_trampoline::<F> as *const (),
1124                )),
1125                Box_::into_raw(f),
1126            )
1127        }
1128    }
1129
1130    #[doc(alias = "selected")]
1131    pub fn connect_selected_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1132        unsafe extern "C" fn notify_selected_trampoline<F: Fn(&DropDown) + 'static>(
1133            this: *mut ffi::GtkDropDown,
1134            _param_spec: glib::ffi::gpointer,
1135            f: glib::ffi::gpointer,
1136        ) {
1137            let f: &F = &*(f as *const F);
1138            f(&from_glib_borrow(this))
1139        }
1140        unsafe {
1141            let f: Box_<F> = Box_::new(f);
1142            connect_raw(
1143                self.as_ptr() as *mut _,
1144                c"notify::selected".as_ptr() as *const _,
1145                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1146                    notify_selected_trampoline::<F> as *const (),
1147                )),
1148                Box_::into_raw(f),
1149            )
1150        }
1151    }
1152
1153    #[doc(alias = "selected-item")]
1154    pub fn connect_selected_item_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1155        unsafe extern "C" fn notify_selected_item_trampoline<F: Fn(&DropDown) + 'static>(
1156            this: *mut ffi::GtkDropDown,
1157            _param_spec: glib::ffi::gpointer,
1158            f: glib::ffi::gpointer,
1159        ) {
1160            let f: &F = &*(f as *const F);
1161            f(&from_glib_borrow(this))
1162        }
1163        unsafe {
1164            let f: Box_<F> = Box_::new(f);
1165            connect_raw(
1166                self.as_ptr() as *mut _,
1167                c"notify::selected-item".as_ptr() as *const _,
1168                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1169                    notify_selected_item_trampoline::<F> as *const (),
1170                )),
1171                Box_::into_raw(f),
1172            )
1173        }
1174    }
1175
1176    #[cfg(feature = "v4_6")]
1177    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
1178    #[doc(alias = "show-arrow")]
1179    pub fn connect_show_arrow_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1180        unsafe extern "C" fn notify_show_arrow_trampoline<F: Fn(&DropDown) + 'static>(
1181            this: *mut ffi::GtkDropDown,
1182            _param_spec: glib::ffi::gpointer,
1183            f: glib::ffi::gpointer,
1184        ) {
1185            let f: &F = &*(f as *const F);
1186            f(&from_glib_borrow(this))
1187        }
1188        unsafe {
1189            let f: Box_<F> = Box_::new(f);
1190            connect_raw(
1191                self.as_ptr() as *mut _,
1192                c"notify::show-arrow".as_ptr() as *const _,
1193                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1194                    notify_show_arrow_trampoline::<F> as *const (),
1195                )),
1196                Box_::into_raw(f),
1197            )
1198        }
1199    }
1200}
1201
1202impl Default for DropDown {
1203    fn default() -> Self {
1204        glib::object::Object::new::<Self>()
1205    }
1206}
1207
1208// rustdoc-stripper-ignore-next
1209/// A [builder-pattern] type to construct [`DropDown`] objects.
1210///
1211/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1212#[must_use = "The builder must be built to be used"]
1213pub struct DropDownBuilder {
1214    builder: glib::object::ObjectBuilder<'static, DropDown>,
1215}
1216
1217impl DropDownBuilder {
1218    fn new() -> Self {
1219        Self {
1220            builder: glib::object::Object::builder(),
1221        }
1222    }
1223
1224    /// Whether to show a search entry in the popup.
1225    ///
1226    /// Note that search requires [`expression`][struct@crate::DropDown#expression]
1227    /// to be set.
1228    pub fn enable_search(self, enable_search: bool) -> Self {
1229        Self {
1230            builder: self.builder.property("enable-search", enable_search),
1231        }
1232    }
1233
1234    /// An expression to evaluate to obtain strings to match against the search
1235    /// term.
1236    ///
1237    /// See [`enable-search`][struct@crate::DropDown#enable-search] for how to enable search.
1238    /// If [`factory`][struct@crate::DropDown#factory] is not set, the expression is also
1239    /// used to bind strings to labels produced by a default factory.
1240    pub fn expression(self, expression: impl AsRef<Expression>) -> Self {
1241        Self {
1242            builder: self
1243                .builder
1244                .property("expression", expression.as_ref().clone()),
1245        }
1246    }
1247
1248    /// Factory for populating list items.
1249    pub fn factory(self, factory: &impl IsA<ListItemFactory>) -> Self {
1250        Self {
1251            builder: self.builder.property("factory", factory.clone().upcast()),
1252        }
1253    }
1254
1255    /// The factory for creating header widgets for the popup.
1256    #[cfg(feature = "v4_12")]
1257    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1258    pub fn header_factory(self, header_factory: &impl IsA<ListItemFactory>) -> Self {
1259        Self {
1260            builder: self
1261                .builder
1262                .property("header-factory", header_factory.clone().upcast()),
1263        }
1264    }
1265
1266    /// The factory for populating list items in the popup.
1267    ///
1268    /// If this is not set, [`factory`][struct@crate::DropDown#factory] is used.
1269    pub fn list_factory(self, list_factory: &impl IsA<ListItemFactory>) -> Self {
1270        Self {
1271            builder: self
1272                .builder
1273                .property("list-factory", list_factory.clone().upcast()),
1274        }
1275    }
1276
1277    /// Model for the displayed items.
1278    pub fn model(self, model: &impl IsA<gio::ListModel>) -> Self {
1279        Self {
1280            builder: self.builder.property("model", model.clone().upcast()),
1281        }
1282    }
1283
1284    /// The match mode for the search filter.
1285    #[cfg(feature = "v4_12")]
1286    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1287    pub fn search_match_mode(self, search_match_mode: StringFilterMatchMode) -> Self {
1288        Self {
1289            builder: self
1290                .builder
1291                .property("search-match-mode", search_match_mode),
1292        }
1293    }
1294
1295    /// The position of the selected item.
1296    ///
1297    /// If no item is selected, the property has the value
1298    /// `GTK_INVALID_LIST_POSITION`.
1299    pub fn selected(self, selected: u32) -> Self {
1300        Self {
1301            builder: self.builder.property("selected", selected),
1302        }
1303    }
1304
1305    /// Whether to show an arrow within the GtkDropDown widget.
1306    #[cfg(feature = "v4_6")]
1307    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
1308    pub fn show_arrow(self, show_arrow: bool) -> Self {
1309        Self {
1310            builder: self.builder.property("show-arrow", show_arrow),
1311        }
1312    }
1313
1314    /// Whether the widget or any of its descendents can accept
1315    /// the input focus.
1316    ///
1317    /// This property is meant to be set by widget implementations,
1318    /// typically in their instance init function.
1319    pub fn can_focus(self, can_focus: bool) -> Self {
1320        Self {
1321            builder: self.builder.property("can-focus", can_focus),
1322        }
1323    }
1324
1325    /// Whether the widget can receive pointer events.
1326    pub fn can_target(self, can_target: bool) -> Self {
1327        Self {
1328            builder: self.builder.property("can-target", can_target),
1329        }
1330    }
1331
1332    /// A list of css classes applied to this widget.
1333    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1334        Self {
1335            builder: self.builder.property("css-classes", css_classes.into()),
1336        }
1337    }
1338
1339    /// The name of this widget in the CSS tree.
1340    ///
1341    /// This property is meant to be set by widget implementations,
1342    /// typically in their instance init function.
1343    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1344        Self {
1345            builder: self.builder.property("css-name", css_name.into()),
1346        }
1347    }
1348
1349    /// The cursor used by @widget.
1350    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1351        Self {
1352            builder: self.builder.property("cursor", cursor.clone()),
1353        }
1354    }
1355
1356    /// Whether the widget should grab focus when it is clicked with the mouse.
1357    ///
1358    /// This property is only relevant for widgets that can take focus.
1359    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1360        Self {
1361            builder: self.builder.property("focus-on-click", focus_on_click),
1362        }
1363    }
1364
1365    /// Whether this widget itself will accept the input focus.
1366    pub fn focusable(self, focusable: bool) -> Self {
1367        Self {
1368            builder: self.builder.property("focusable", focusable),
1369        }
1370    }
1371
1372    /// How to distribute horizontal space if widget gets extra space.
1373    pub fn halign(self, halign: Align) -> Self {
1374        Self {
1375            builder: self.builder.property("halign", halign),
1376        }
1377    }
1378
1379    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1380    /// signal on @widget.
1381    ///
1382    /// A true value indicates that @widget can have a tooltip, in this case
1383    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1384    /// determine whether it will provide a tooltip or not.
1385    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1386        Self {
1387            builder: self.builder.property("has-tooltip", has_tooltip),
1388        }
1389    }
1390
1391    /// Overrides for height request of the widget.
1392    ///
1393    /// If this is -1, the natural request will be used.
1394    pub fn height_request(self, height_request: i32) -> Self {
1395        Self {
1396            builder: self.builder.property("height-request", height_request),
1397        }
1398    }
1399
1400    /// Whether to expand horizontally.
1401    pub fn hexpand(self, hexpand: bool) -> Self {
1402        Self {
1403            builder: self.builder.property("hexpand", hexpand),
1404        }
1405    }
1406
1407    /// Whether to use the `hexpand` property.
1408    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1409        Self {
1410            builder: self.builder.property("hexpand-set", hexpand_set),
1411        }
1412    }
1413
1414    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1415    /// the preferred size of the widget, and allocate its children.
1416    ///
1417    /// This property is meant to be set by widget implementations,
1418    /// typically in their instance init function.
1419    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1420        Self {
1421            builder: self
1422                .builder
1423                .property("layout-manager", layout_manager.clone().upcast()),
1424        }
1425    }
1426
1427    /// Makes this widget act like a modal dialog, with respect to
1428    /// event delivery.
1429    ///
1430    /// Global event controllers will not handle events with targets
1431    /// inside the widget, unless they are set up to ignore propagation
1432    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1433    #[cfg(feature = "v4_18")]
1434    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1435    pub fn limit_events(self, limit_events: bool) -> Self {
1436        Self {
1437            builder: self.builder.property("limit-events", limit_events),
1438        }
1439    }
1440
1441    /// Margin on bottom side of widget.
1442    ///
1443    /// This property adds margin outside of the widget's normal size
1444    /// request, the margin will be added in addition to the size from
1445    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1446    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1447        Self {
1448            builder: self.builder.property("margin-bottom", margin_bottom),
1449        }
1450    }
1451
1452    /// Margin on end of widget, horizontally.
1453    ///
1454    /// This property supports left-to-right and right-to-left text
1455    /// directions.
1456    ///
1457    /// This property adds margin outside of the widget's normal size
1458    /// request, the margin will be added in addition to the size from
1459    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1460    pub fn margin_end(self, margin_end: i32) -> Self {
1461        Self {
1462            builder: self.builder.property("margin-end", margin_end),
1463        }
1464    }
1465
1466    /// Margin on start of widget, horizontally.
1467    ///
1468    /// This property supports left-to-right and right-to-left text
1469    /// directions.
1470    ///
1471    /// This property adds margin outside of the widget's normal size
1472    /// request, the margin will be added in addition to the size from
1473    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1474    pub fn margin_start(self, margin_start: i32) -> Self {
1475        Self {
1476            builder: self.builder.property("margin-start", margin_start),
1477        }
1478    }
1479
1480    /// Margin on top side of widget.
1481    ///
1482    /// This property adds margin outside of the widget's normal size
1483    /// request, the margin will be added in addition to the size from
1484    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1485    pub fn margin_top(self, margin_top: i32) -> Self {
1486        Self {
1487            builder: self.builder.property("margin-top", margin_top),
1488        }
1489    }
1490
1491    /// The name of the widget.
1492    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1493        Self {
1494            builder: self.builder.property("name", name.into()),
1495        }
1496    }
1497
1498    /// The requested opacity of the widget.
1499    pub fn opacity(self, opacity: f64) -> Self {
1500        Self {
1501            builder: self.builder.property("opacity", opacity),
1502        }
1503    }
1504
1505    /// How content outside the widget's content area is treated.
1506    ///
1507    /// This property is meant to be set by widget implementations,
1508    /// typically in their instance init function.
1509    pub fn overflow(self, overflow: Overflow) -> Self {
1510        Self {
1511            builder: self.builder.property("overflow", overflow),
1512        }
1513    }
1514
1515    /// Whether the widget will receive the default action when it is focused.
1516    pub fn receives_default(self, receives_default: bool) -> Self {
1517        Self {
1518            builder: self.builder.property("receives-default", receives_default),
1519        }
1520    }
1521
1522    /// Whether the widget responds to input.
1523    pub fn sensitive(self, sensitive: bool) -> Self {
1524        Self {
1525            builder: self.builder.property("sensitive", sensitive),
1526        }
1527    }
1528
1529    /// Sets the text of tooltip to be the given string, which is marked up
1530    /// with Pango markup.
1531    ///
1532    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1533    ///
1534    /// This is a convenience property which will take care of getting the
1535    /// tooltip shown if the given string is not `NULL`:
1536    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1537    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1538    /// the default signal handler.
1539    ///
1540    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1541    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1542    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1543        Self {
1544            builder: self
1545                .builder
1546                .property("tooltip-markup", tooltip_markup.into()),
1547        }
1548    }
1549
1550    /// Sets the text of tooltip to be the given string.
1551    ///
1552    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1553    ///
1554    /// This is a convenience property which will take care of getting the
1555    /// tooltip shown if the given string is not `NULL`:
1556    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1557    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1558    /// the default signal handler.
1559    ///
1560    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1561    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1562    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1563        Self {
1564            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1565        }
1566    }
1567
1568    /// How to distribute vertical space if widget gets extra space.
1569    pub fn valign(self, valign: Align) -> Self {
1570        Self {
1571            builder: self.builder.property("valign", valign),
1572        }
1573    }
1574
1575    /// Whether to expand vertically.
1576    pub fn vexpand(self, vexpand: bool) -> Self {
1577        Self {
1578            builder: self.builder.property("vexpand", vexpand),
1579        }
1580    }
1581
1582    /// Whether to use the `vexpand` property.
1583    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1584        Self {
1585            builder: self.builder.property("vexpand-set", vexpand_set),
1586        }
1587    }
1588
1589    /// Whether the widget is visible.
1590    pub fn visible(self, visible: bool) -> Self {
1591        Self {
1592            builder: self.builder.property("visible", visible),
1593        }
1594    }
1595
1596    /// Overrides for width request of the widget.
1597    ///
1598    /// If this is -1, the natural request will be used.
1599    pub fn width_request(self, width_request: i32) -> Self {
1600        Self {
1601            builder: self.builder.property("width-request", width_request),
1602        }
1603    }
1604
1605    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1606    ///
1607    /// The accessible role cannot be changed once set.
1608    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1609        Self {
1610            builder: self.builder.property("accessible-role", accessible_role),
1611        }
1612    }
1613
1614    // rustdoc-stripper-ignore-next
1615    /// Build the [`DropDown`].
1616    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1617    pub fn build(self) -> DropDown {
1618        assert_initialized_main_thread!();
1619        self.builder.build()
1620    }
1621}