libadwaita/auto/
tab_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, TabView};
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 button that displays the number of [`TabView`][crate::TabView] pages.
17    ///
18    /// <picture>
19    ///   <source srcset="tab-button-dark.png" media="(prefers-color-scheme: dark)">
20    ///   <img src="tab-button.png" alt="tab-button">
21    /// </picture>
22    ///
23    /// [`TabButton`][crate::TabButton] is a button that displays the number of pages in a given
24    /// [`TabView`][crate::TabView], as well as whether one of the inactive pages needs attention.
25    ///
26    /// It's intended to be used as a visible indicator when there's no visible tab
27    /// bar, typically opening an [`TabOverview`][crate::TabOverview] on click, e.g. via the
28    /// `overview.open` action name:
29    ///
30    /// ```xml
31    /// <object class="AdwTabButton">
32    ///   <property name="view">view</property>
33    ///   <property name="action-name">overview.open</property>
34    /// </object>
35    /// ```
36    ///
37    /// ## CSS nodes
38    ///
39    /// [`TabButton`][crate::TabButton] has a main CSS node with name `tabbutton`.
40    ///
41    /// # Accessibility
42    ///
43    /// [`TabButton`][crate::TabButton] uses the `GTK_ACCESSIBLE_ROLE_BUTTON` role.
44    ///
45    /// ## Properties
46    ///
47    ///
48    /// #### `view`
49    ///  The view the tab button displays.
50    ///
51    /// Readable | Writeable
52    /// <details><summary><h4>Widget</h4></summary>
53    ///
54    ///
55    /// #### `can-focus`
56    ///  Whether the widget or any of its descendents can accept
57    /// the input focus.
58    ///
59    /// This property is meant to be set by widget implementations,
60    /// typically in their instance init function.
61    ///
62    /// Readable | Writeable
63    ///
64    ///
65    /// #### `can-target`
66    ///  Whether the widget can receive pointer events.
67    ///
68    /// Readable | Writeable
69    ///
70    ///
71    /// #### `css-classes`
72    ///  A list of css classes applied to this widget.
73    ///
74    /// Readable | Writeable
75    ///
76    ///
77    /// #### `css-name`
78    ///  The name of this widget in the CSS tree.
79    ///
80    /// This property is meant to be set by widget implementations,
81    /// typically in their instance init function.
82    ///
83    /// Readable | Writeable | Construct Only
84    ///
85    ///
86    /// #### `cursor`
87    ///  The cursor used by @widget.
88    ///
89    /// Readable | Writeable
90    ///
91    ///
92    /// #### `focus-on-click`
93    ///  Whether the widget should grab focus when it is clicked with the mouse.
94    ///
95    /// This property is only relevant for widgets that can take focus.
96    ///
97    /// Readable | Writeable
98    ///
99    ///
100    /// #### `focusable`
101    ///  Whether this widget itself will accept the input focus.
102    ///
103    /// Readable | Writeable
104    ///
105    ///
106    /// #### `halign`
107    ///  How to distribute horizontal space if widget gets extra space.
108    ///
109    /// Readable | Writeable
110    ///
111    ///
112    /// #### `has-default`
113    ///  Whether the widget is the default widget.
114    ///
115    /// Readable
116    ///
117    ///
118    /// #### `has-focus`
119    ///  Whether the widget has the input focus.
120    ///
121    /// Readable
122    ///
123    ///
124    /// #### `has-tooltip`
125    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
126    /// signal on @widget.
127    ///
128    /// A true value indicates that @widget can have a tooltip, in this case
129    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
130    /// determine whether it will provide a tooltip or not.
131    ///
132    /// Readable | Writeable
133    ///
134    ///
135    /// #### `height-request`
136    ///  Overrides for height request of the widget.
137    ///
138    /// If this is -1, the natural request will be used.
139    ///
140    /// Readable | Writeable
141    ///
142    ///
143    /// #### `hexpand`
144    ///  Whether to expand horizontally.
145    ///
146    /// Readable | Writeable
147    ///
148    ///
149    /// #### `hexpand-set`
150    ///  Whether to use the `hexpand` property.
151    ///
152    /// Readable | Writeable
153    ///
154    ///
155    /// #### `layout-manager`
156    ///  The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
157    /// the preferred size of the widget, and allocate its children.
158    ///
159    /// This property is meant to be set by widget implementations,
160    /// typically in their instance init function.
161    ///
162    /// Readable | Writeable
163    ///
164    ///
165    /// #### `limit-events`
166    ///  Makes this widget act like a modal dialog, with respect to
167    /// event delivery.
168    ///
169    /// Global event controllers will not handle events with targets
170    /// inside the widget, unless they are set up to ignore propagation
171    /// limits. See `Gtk::EventController::set_propagation_limit()`.
172    ///
173    /// Readable | Writeable
174    ///
175    ///
176    /// #### `margin-bottom`
177    ///  Margin on bottom side of widget.
178    ///
179    /// This property adds margin outside of the widget's normal size
180    /// request, the margin will be added in addition to the size from
181    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
182    ///
183    /// Readable | Writeable
184    ///
185    ///
186    /// #### `margin-end`
187    ///  Margin on end of widget, horizontally.
188    ///
189    /// This property supports left-to-right and right-to-left text
190    /// directions.
191    ///
192    /// This property adds margin outside of the widget's normal size
193    /// request, the margin will be added in addition to the size from
194    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
195    ///
196    /// Readable | Writeable
197    ///
198    ///
199    /// #### `margin-start`
200    ///  Margin on start of widget, horizontally.
201    ///
202    /// This property supports left-to-right and right-to-left text
203    /// directions.
204    ///
205    /// This property adds margin outside of the widget's normal size
206    /// request, the margin will be added in addition to the size from
207    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
208    ///
209    /// Readable | Writeable
210    ///
211    ///
212    /// #### `margin-top`
213    ///  Margin on top side of widget.
214    ///
215    /// This property adds margin outside of the widget's normal size
216    /// request, the margin will be added in addition to the size from
217    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
218    ///
219    /// Readable | Writeable
220    ///
221    ///
222    /// #### `name`
223    ///  The name of the widget.
224    ///
225    /// Readable | Writeable
226    ///
227    ///
228    /// #### `opacity`
229    ///  The requested opacity of the widget.
230    ///
231    /// Readable | Writeable
232    ///
233    ///
234    /// #### `overflow`
235    ///  How content outside the widget's content area is treated.
236    ///
237    /// This property is meant to be set by widget implementations,
238    /// typically in their instance init function.
239    ///
240    /// Readable | Writeable
241    ///
242    ///
243    /// #### `parent`
244    ///  The parent widget of this widget.
245    ///
246    /// Readable
247    ///
248    ///
249    /// #### `receives-default`
250    ///  Whether the widget will receive the default action when it is focused.
251    ///
252    /// Readable | Writeable
253    ///
254    ///
255    /// #### `root`
256    ///  The [`gtk::Root`][crate::gtk::Root] widget of the widget tree containing this widget.
257    ///
258    /// This will be `NULL` if the widget is not contained in a root widget.
259    ///
260    /// Readable
261    ///
262    ///
263    /// #### `scale-factor`
264    ///  The scale factor of the widget.
265    ///
266    /// Readable
267    ///
268    ///
269    /// #### `sensitive`
270    ///  Whether the widget responds to input.
271    ///
272    /// Readable | Writeable
273    ///
274    ///
275    /// #### `tooltip-markup`
276    ///  Sets the text of tooltip to be the given string, which is marked up
277    /// with Pango markup.
278    ///
279    /// Also see `Gtk::Tooltip::set_markup()`.
280    ///
281    /// This is a convenience property which will take care of getting the
282    /// tooltip shown if the given string is not `NULL`:
283    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
284    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
285    /// the default signal handler.
286    ///
287    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
288    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
289    ///
290    /// Readable | Writeable
291    ///
292    ///
293    /// #### `tooltip-text`
294    ///  Sets the text of tooltip to be the given string.
295    ///
296    /// Also see `Gtk::Tooltip::set_text()`.
297    ///
298    /// This is a convenience property which will take care of getting the
299    /// tooltip shown if the given string is not `NULL`:
300    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
301    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
302    /// the default signal handler.
303    ///
304    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
305    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
306    ///
307    /// Readable | Writeable
308    ///
309    ///
310    /// #### `valign`
311    ///  How to distribute vertical space if widget gets extra space.
312    ///
313    /// Readable | Writeable
314    ///
315    ///
316    /// #### `vexpand`
317    ///  Whether to expand vertically.
318    ///
319    /// Readable | Writeable
320    ///
321    ///
322    /// #### `vexpand-set`
323    ///  Whether to use the `vexpand` property.
324    ///
325    /// Readable | Writeable
326    ///
327    ///
328    /// #### `visible`
329    ///  Whether the widget is visible.
330    ///
331    /// Readable | Writeable
332    ///
333    ///
334    /// #### `width-request`
335    ///  Overrides for width request of the widget.
336    ///
337    /// If this is -1, the natural request will be used.
338    ///
339    /// Readable | Writeable
340    /// </details>
341    /// <details><summary><h4>Accessible</h4></summary>
342    ///
343    ///
344    /// #### `accessible-role`
345    ///  The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
346    ///
347    /// The accessible role cannot be changed once set.
348    ///
349    /// Readable | Writeable
350    /// </details>
351    /// <details><summary><h4>Actionable</h4></summary>
352    ///
353    ///
354    /// #### `action-name`
355    ///  The name of the action with which this widget should be associated.
356    ///
357    /// Readable | Writeable
358    ///
359    ///
360    /// #### `action-target`
361    ///  The target value of the actionable widget's action.
362    ///
363    /// Readable | Writeable
364    /// </details>
365    ///
366    /// ## Signals
367    ///
368    ///
369    /// #### `activate`
370    ///  Emitted to animate press then release.
371    ///
372    /// This is an action signal. Applications should never connect to this signal,
373    /// but use the [`clicked`][struct@crate::TabButton#clicked] signal.
374    ///
375    /// Action
376    ///
377    ///
378    /// #### `clicked`
379    ///  Emitted when the button has been activated (pressed and released).
380    ///
381    /// Action
382    /// <details><summary><h4>Widget</h4></summary>
383    ///
384    ///
385    /// #### `destroy`
386    ///  Signals that all holders of a reference to the widget should release
387    /// the reference that they hold.
388    ///
389    /// May result in finalization of the widget if all references are released.
390    ///
391    /// This signal is not suitable for saving widget state.
392    ///
393    ///
394    ///
395    ///
396    /// #### `direction-changed`
397    ///  Emitted when the text direction of a widget changes.
398    ///
399    ///
400    ///
401    ///
402    /// #### `hide`
403    ///  Emitted when @widget is hidden.
404    ///
405    ///
406    ///
407    ///
408    /// #### `keynav-failed`
409    ///  Emitted if keyboard navigation fails.
410    ///
411    /// See [`WidgetExtManual::keynav_failed()`][crate::gtk::prelude::WidgetExtManual::keynav_failed()] for details.
412    ///
413    ///
414    ///
415    ///
416    /// #### `map`
417    ///  Emitted when @widget is going to be mapped.
418    ///
419    /// A widget is mapped when the widget is visible (which is controlled with
420    /// [`visible`][struct@crate::gtk::Widget#visible]) and all its parents up to the toplevel widget
421    /// are also visible.
422    ///
423    /// The `::map` signal can be used to determine whether a widget will be drawn,
424    /// for instance it can resume an animation that was stopped during the
425    /// emission of [`unmap`][struct@crate::gtk::Widget#unmap].
426    ///
427    ///
428    ///
429    ///
430    /// #### `mnemonic-activate`
431    ///  Emitted when a widget is activated via a mnemonic.
432    ///
433    /// The default handler for this signal activates @widget if @group_cycling
434    /// is false, or just makes @widget grab focus if @group_cycling is true.
435    ///
436    ///
437    ///
438    ///
439    /// #### `move-focus`
440    ///  Emitted when the focus is moved.
441    ///
442    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
443    ///
444    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
445    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
446    ///
447    /// Action
448    ///
449    ///
450    /// #### `query-tooltip`
451    ///  Emitted when the widget’s tooltip is about to be shown.
452    ///
453    /// This happens when the [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] property
454    /// is true and the hover timeout has expired with the cursor hovering
455    /// above @widget; or emitted when @widget got focus in keyboard mode.
456    ///
457    /// Using the given coordinates, the signal handler should determine
458    /// whether a tooltip should be shown for @widget. If this is the case
459    /// true should be returned, false otherwise. Note that if @keyboard_mode
460    /// is true, the values of @x and @y are undefined and should not be used.
461    ///
462    /// The signal handler is free to manipulate @tooltip with the therefore
463    /// destined function calls.
464    ///
465    ///
466    ///
467    ///
468    /// #### `realize`
469    ///  Emitted when @widget is associated with a `GdkSurface`.
470    ///
471    /// This means that [`WidgetExtManual::realize()`][crate::gtk::prelude::WidgetExtManual::realize()] has been called
472    /// or the widget has been mapped (that is, it is going to be drawn).
473    ///
474    ///
475    ///
476    ///
477    /// #### `show`
478    ///  Emitted when @widget is shown.
479    ///
480    ///
481    ///
482    ///
483    /// #### `state-flags-changed`
484    ///  Emitted when the widget state changes.
485    ///
486    /// See [`WidgetExtManual::state_flags()`][crate::gtk::prelude::WidgetExtManual::state_flags()].
487    ///
488    ///
489    ///
490    ///
491    /// #### `unmap`
492    ///  Emitted when @widget is going to be unmapped.
493    ///
494    /// A widget is unmapped when either it or any of its parents up to the
495    /// toplevel widget have been set as hidden.
496    ///
497    /// As `::unmap` indicates that a widget will not be shown any longer,
498    /// it can be used to, for example, stop an animation on the widget.
499    ///
500    ///
501    ///
502    ///
503    /// #### `unrealize`
504    ///  Emitted when the `GdkSurface` associated with @widget is destroyed.
505    ///
506    /// This means that [`WidgetExtManual::unrealize()`][crate::gtk::prelude::WidgetExtManual::unrealize()] has been called
507    /// or the widget has been unmapped (that is, it is going to be hidden).
508    ///
509    ///
510    /// </details>
511    ///
512    /// # Implements
513    ///
514    /// [`trait@gtk::prelude::WidgetExt`], [`trait@glib::ObjectExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`], [`trait@gtk::prelude::ActionableExt`]
515    #[doc(alias = "AdwTabButton")]
516    pub struct TabButton(Object<ffi::AdwTabButton, ffi::AdwTabButtonClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Actionable;
517
518    match fn {
519        type_ => || ffi::adw_tab_button_get_type(),
520    }
521}
522
523impl TabButton {
524    /// Creates a new [`TabButton`][crate::TabButton].
525    ///
526    /// # Returns
527    ///
528    /// the newly created [`TabButton`][crate::TabButton]
529    #[doc(alias = "adw_tab_button_new")]
530    pub fn new() -> TabButton {
531        assert_initialized_main_thread!();
532        unsafe { gtk::Widget::from_glib_none(ffi::adw_tab_button_new()).unsafe_cast() }
533    }
534
535    // rustdoc-stripper-ignore-next
536    /// Creates a new builder-pattern struct instance to construct [`TabButton`] objects.
537    ///
538    /// This method returns an instance of [`TabButtonBuilder`](crate::builders::TabButtonBuilder) which can be used to create [`TabButton`] objects.
539    pub fn builder() -> TabButtonBuilder {
540        TabButtonBuilder::new()
541    }
542
543    /// Gets the tab view @self displays.
544    ///
545    /// # Returns
546    ///
547    /// the tab view
548    #[doc(alias = "adw_tab_button_get_view")]
549    #[doc(alias = "get_view")]
550    pub fn view(&self) -> Option<TabView> {
551        unsafe { from_glib_none(ffi::adw_tab_button_get_view(self.to_glib_none().0)) }
552    }
553
554    /// Sets the tab view to display.
555    /// ## `view`
556    /// a tab view
557    #[doc(alias = "adw_tab_button_set_view")]
558    #[doc(alias = "view")]
559    pub fn set_view(&self, view: Option<&TabView>) {
560        unsafe {
561            ffi::adw_tab_button_set_view(self.to_glib_none().0, view.to_glib_none().0);
562        }
563    }
564
565    /// Emitted to animate press then release.
566    ///
567    /// This is an action signal. Applications should never connect to this signal,
568    /// but use the [`clicked`][struct@crate::TabButton#clicked] signal.
569    #[cfg(feature = "v1_3")]
570    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
571    #[doc(alias = "activate")]
572    pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
573        unsafe extern "C" fn activate_trampoline<F: Fn(&TabButton) + 'static>(
574            this: *mut ffi::AdwTabButton,
575            f: glib::ffi::gpointer,
576        ) {
577            let f: &F = &*(f as *const F);
578            f(&from_glib_borrow(this))
579        }
580        unsafe {
581            let f: Box_<F> = Box_::new(f);
582            connect_raw(
583                self.as_ptr() as *mut _,
584                c"activate".as_ptr() as *const _,
585                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
586                    activate_trampoline::<F> as *const (),
587                )),
588                Box_::into_raw(f),
589            )
590        }
591    }
592
593    #[cfg(feature = "v1_3")]
594    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
595    pub fn emit_activate(&self) {
596        self.emit_by_name::<()>("activate", &[]);
597    }
598
599    /// Emitted when the button has been activated (pressed and released).
600    #[cfg(feature = "v1_3")]
601    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
602    #[doc(alias = "clicked")]
603    pub fn connect_clicked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
604        unsafe extern "C" fn clicked_trampoline<F: Fn(&TabButton) + 'static>(
605            this: *mut ffi::AdwTabButton,
606            f: glib::ffi::gpointer,
607        ) {
608            let f: &F = &*(f as *const F);
609            f(&from_glib_borrow(this))
610        }
611        unsafe {
612            let f: Box_<F> = Box_::new(f);
613            connect_raw(
614                self.as_ptr() as *mut _,
615                c"clicked".as_ptr() as *const _,
616                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
617                    clicked_trampoline::<F> as *const (),
618                )),
619                Box_::into_raw(f),
620            )
621        }
622    }
623
624    #[cfg(feature = "v1_3")]
625    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
626    pub fn emit_clicked(&self) {
627        self.emit_by_name::<()>("clicked", &[]);
628    }
629
630    #[cfg(feature = "v1_3")]
631    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
632    #[doc(alias = "view")]
633    pub fn connect_view_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
634        unsafe extern "C" fn notify_view_trampoline<F: Fn(&TabButton) + 'static>(
635            this: *mut ffi::AdwTabButton,
636            _param_spec: glib::ffi::gpointer,
637            f: glib::ffi::gpointer,
638        ) {
639            let f: &F = &*(f as *const F);
640            f(&from_glib_borrow(this))
641        }
642        unsafe {
643            let f: Box_<F> = Box_::new(f);
644            connect_raw(
645                self.as_ptr() as *mut _,
646                c"notify::view".as_ptr() as *const _,
647                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
648                    notify_view_trampoline::<F> as *const (),
649                )),
650                Box_::into_raw(f),
651            )
652        }
653    }
654}
655
656#[cfg(feature = "v1_3")]
657#[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
658impl Default for TabButton {
659    fn default() -> Self {
660        Self::new()
661    }
662}
663
664// rustdoc-stripper-ignore-next
665/// A [builder-pattern] type to construct [`TabButton`] objects.
666///
667/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
668#[must_use = "The builder must be built to be used"]
669pub struct TabButtonBuilder {
670    builder: glib::object::ObjectBuilder<'static, TabButton>,
671}
672
673impl TabButtonBuilder {
674    fn new() -> Self {
675        Self {
676            builder: glib::object::Object::builder(),
677        }
678    }
679
680    /// The view the tab button displays.
681    #[cfg(feature = "v1_3")]
682    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
683    pub fn view(self, view: &TabView) -> Self {
684        Self {
685            builder: self.builder.property("view", view.clone()),
686        }
687    }
688
689    /// Whether the widget or any of its descendents can accept
690    /// the input focus.
691    ///
692    /// This property is meant to be set by widget implementations,
693    /// typically in their instance init function.
694    pub fn can_focus(self, can_focus: bool) -> Self {
695        Self {
696            builder: self.builder.property("can-focus", can_focus),
697        }
698    }
699
700    /// Whether the widget can receive pointer events.
701    pub fn can_target(self, can_target: bool) -> Self {
702        Self {
703            builder: self.builder.property("can-target", can_target),
704        }
705    }
706
707    /// A list of css classes applied to this widget.
708    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
709        Self {
710            builder: self.builder.property("css-classes", css_classes.into()),
711        }
712    }
713
714    /// The name of this widget in the CSS tree.
715    ///
716    /// This property is meant to be set by widget implementations,
717    /// typically in their instance init function.
718    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
719        Self {
720            builder: self.builder.property("css-name", css_name.into()),
721        }
722    }
723
724    /// The cursor used by @widget.
725    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
726        Self {
727            builder: self.builder.property("cursor", cursor.clone()),
728        }
729    }
730
731    /// Whether the widget should grab focus when it is clicked with the mouse.
732    ///
733    /// This property is only relevant for widgets that can take focus.
734    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
735        Self {
736            builder: self.builder.property("focus-on-click", focus_on_click),
737        }
738    }
739
740    /// Whether this widget itself will accept the input focus.
741    pub fn focusable(self, focusable: bool) -> Self {
742        Self {
743            builder: self.builder.property("focusable", focusable),
744        }
745    }
746
747    /// How to distribute horizontal space if widget gets extra space.
748    pub fn halign(self, halign: gtk::Align) -> Self {
749        Self {
750            builder: self.builder.property("halign", halign),
751        }
752    }
753
754    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
755    /// signal on @widget.
756    ///
757    /// A true value indicates that @widget can have a tooltip, in this case
758    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
759    /// determine whether it will provide a tooltip or not.
760    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
761        Self {
762            builder: self.builder.property("has-tooltip", has_tooltip),
763        }
764    }
765
766    /// Overrides for height request of the widget.
767    ///
768    /// If this is -1, the natural request will be used.
769    pub fn height_request(self, height_request: i32) -> Self {
770        Self {
771            builder: self.builder.property("height-request", height_request),
772        }
773    }
774
775    /// Whether to expand horizontally.
776    pub fn hexpand(self, hexpand: bool) -> Self {
777        Self {
778            builder: self.builder.property("hexpand", hexpand),
779        }
780    }
781
782    /// Whether to use the `hexpand` property.
783    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
784        Self {
785            builder: self.builder.property("hexpand-set", hexpand_set),
786        }
787    }
788
789    /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
790    /// the preferred size of the widget, and allocate its children.
791    ///
792    /// This property is meant to be set by widget implementations,
793    /// typically in their instance init function.
794    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
795        Self {
796            builder: self
797                .builder
798                .property("layout-manager", layout_manager.clone().upcast()),
799        }
800    }
801
802    /// Makes this widget act like a modal dialog, with respect to
803    /// event delivery.
804    ///
805    /// Global event controllers will not handle events with targets
806    /// inside the widget, unless they are set up to ignore propagation
807    /// limits. See `Gtk::EventController::set_propagation_limit()`.
808    #[cfg(feature = "gtk_v4_18")]
809    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
810    pub fn limit_events(self, limit_events: bool) -> Self {
811        Self {
812            builder: self.builder.property("limit-events", limit_events),
813        }
814    }
815
816    /// Margin on bottom side of widget.
817    ///
818    /// This property adds margin outside of the widget's normal size
819    /// request, the margin will be added in addition to the size from
820    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
821    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
822        Self {
823            builder: self.builder.property("margin-bottom", margin_bottom),
824        }
825    }
826
827    /// Margin on end of widget, horizontally.
828    ///
829    /// This property supports left-to-right and right-to-left text
830    /// directions.
831    ///
832    /// This property adds margin outside of the widget's normal size
833    /// request, the margin will be added in addition to the size from
834    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
835    pub fn margin_end(self, margin_end: i32) -> Self {
836        Self {
837            builder: self.builder.property("margin-end", margin_end),
838        }
839    }
840
841    /// Margin on start of widget, horizontally.
842    ///
843    /// This property supports left-to-right and right-to-left text
844    /// directions.
845    ///
846    /// This property adds margin outside of the widget's normal size
847    /// request, the margin will be added in addition to the size from
848    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
849    pub fn margin_start(self, margin_start: i32) -> Self {
850        Self {
851            builder: self.builder.property("margin-start", margin_start),
852        }
853    }
854
855    /// Margin on top side of widget.
856    ///
857    /// This property adds margin outside of the widget's normal size
858    /// request, the margin will be added in addition to the size from
859    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
860    pub fn margin_top(self, margin_top: i32) -> Self {
861        Self {
862            builder: self.builder.property("margin-top", margin_top),
863        }
864    }
865
866    /// The name of the widget.
867    pub fn name(self, name: impl Into<glib::GString>) -> Self {
868        Self {
869            builder: self.builder.property("name", name.into()),
870        }
871    }
872
873    /// The requested opacity of the widget.
874    pub fn opacity(self, opacity: f64) -> Self {
875        Self {
876            builder: self.builder.property("opacity", opacity),
877        }
878    }
879
880    /// How content outside the widget's content area is treated.
881    ///
882    /// This property is meant to be set by widget implementations,
883    /// typically in their instance init function.
884    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
885        Self {
886            builder: self.builder.property("overflow", overflow),
887        }
888    }
889
890    /// Whether the widget will receive the default action when it is focused.
891    pub fn receives_default(self, receives_default: bool) -> Self {
892        Self {
893            builder: self.builder.property("receives-default", receives_default),
894        }
895    }
896
897    /// Whether the widget responds to input.
898    pub fn sensitive(self, sensitive: bool) -> Self {
899        Self {
900            builder: self.builder.property("sensitive", sensitive),
901        }
902    }
903
904    /// Sets the text of tooltip to be the given string, which is marked up
905    /// with Pango markup.
906    ///
907    /// Also see `Gtk::Tooltip::set_markup()`.
908    ///
909    /// This is a convenience property which will take care of getting the
910    /// tooltip shown if the given string is not `NULL`:
911    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
912    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
913    /// the default signal handler.
914    ///
915    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
916    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
917    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
918        Self {
919            builder: self
920                .builder
921                .property("tooltip-markup", tooltip_markup.into()),
922        }
923    }
924
925    /// Sets the text of tooltip to be the given string.
926    ///
927    /// Also see `Gtk::Tooltip::set_text()`.
928    ///
929    /// This is a convenience property which will take care of getting the
930    /// tooltip shown if the given string is not `NULL`:
931    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
932    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
933    /// the default signal handler.
934    ///
935    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
936    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
937    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
938        Self {
939            builder: self.builder.property("tooltip-text", tooltip_text.into()),
940        }
941    }
942
943    /// How to distribute vertical space if widget gets extra space.
944    pub fn valign(self, valign: gtk::Align) -> Self {
945        Self {
946            builder: self.builder.property("valign", valign),
947        }
948    }
949
950    /// Whether to expand vertically.
951    pub fn vexpand(self, vexpand: bool) -> Self {
952        Self {
953            builder: self.builder.property("vexpand", vexpand),
954        }
955    }
956
957    /// Whether to use the `vexpand` property.
958    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
959        Self {
960            builder: self.builder.property("vexpand-set", vexpand_set),
961        }
962    }
963
964    /// Whether the widget is visible.
965    pub fn visible(self, visible: bool) -> Self {
966        Self {
967            builder: self.builder.property("visible", visible),
968        }
969    }
970
971    /// Overrides for width request of the widget.
972    ///
973    /// If this is -1, the natural request will be used.
974    pub fn width_request(self, width_request: i32) -> Self {
975        Self {
976            builder: self.builder.property("width-request", width_request),
977        }
978    }
979
980    /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
981    ///
982    /// The accessible role cannot be changed once set.
983    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
984        Self {
985            builder: self.builder.property("accessible-role", accessible_role),
986        }
987    }
988
989    /// The name of the action with which this widget should be associated.
990    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
991        Self {
992            builder: self.builder.property("action-name", action_name.into()),
993        }
994    }
995
996    /// The target value of the actionable widget's action.
997    pub fn action_target(self, action_target: &glib::Variant) -> Self {
998        Self {
999            builder: self
1000                .builder
1001                .property("action-target", action_target.clone()),
1002        }
1003    }
1004
1005    // rustdoc-stripper-ignore-next
1006    /// Build the [`TabButton`].
1007    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1008    pub fn build(self) -> TabButton {
1009        assert_initialized_main_thread!();
1010        self.builder.build()
1011    }
1012}