libadwaita/auto/
split_button.rs

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