Skip to main content

gtk4/auto/
drop_down.rs

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