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::{TabView, ffi};
7use glib::{
8 object::ObjectType as _,
9 prelude::*,
10 signal::{SignalHandlerId, connect_raw},
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 [enum@Gtk.AccessibleRole.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 unsafe {
578 let f: &F = &*(f as *const F);
579 f(&from_glib_borrow(this))
580 }
581 }
582 unsafe {
583 let f: Box_<F> = Box_::new(f);
584 connect_raw(
585 self.as_ptr() as *mut _,
586 c"activate".as_ptr(),
587 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
588 activate_trampoline::<F> as *const (),
589 )),
590 Box_::into_raw(f),
591 )
592 }
593 }
594
595 #[cfg(feature = "v1_3")]
596 #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
597 pub fn emit_activate(&self) {
598 self.emit_by_name::<()>("activate", &[]);
599 }
600
601 /// Emitted when the button has been activated (pressed and released).
602 #[cfg(feature = "v1_3")]
603 #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
604 #[doc(alias = "clicked")]
605 pub fn connect_clicked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
606 unsafe extern "C" fn clicked_trampoline<F: Fn(&TabButton) + 'static>(
607 this: *mut ffi::AdwTabButton,
608 f: glib::ffi::gpointer,
609 ) {
610 unsafe {
611 let f: &F = &*(f as *const F);
612 f(&from_glib_borrow(this))
613 }
614 }
615 unsafe {
616 let f: Box_<F> = Box_::new(f);
617 connect_raw(
618 self.as_ptr() as *mut _,
619 c"clicked".as_ptr(),
620 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
621 clicked_trampoline::<F> as *const (),
622 )),
623 Box_::into_raw(f),
624 )
625 }
626 }
627
628 #[cfg(feature = "v1_3")]
629 #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
630 pub fn emit_clicked(&self) {
631 self.emit_by_name::<()>("clicked", &[]);
632 }
633
634 #[cfg(feature = "v1_3")]
635 #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
636 #[doc(alias = "view")]
637 pub fn connect_view_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
638 unsafe extern "C" fn notify_view_trampoline<F: Fn(&TabButton) + 'static>(
639 this: *mut ffi::AdwTabButton,
640 _param_spec: glib::ffi::gpointer,
641 f: glib::ffi::gpointer,
642 ) {
643 unsafe {
644 let f: &F = &*(f as *const F);
645 f(&from_glib_borrow(this))
646 }
647 }
648 unsafe {
649 let f: Box_<F> = Box_::new(f);
650 connect_raw(
651 self.as_ptr() as *mut _,
652 c"notify::view".as_ptr(),
653 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
654 notify_view_trampoline::<F> as *const (),
655 )),
656 Box_::into_raw(f),
657 )
658 }
659 }
660}
661
662#[cfg(feature = "v1_3")]
663#[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
664impl Default for TabButton {
665 fn default() -> Self {
666 Self::new()
667 }
668}
669
670// rustdoc-stripper-ignore-next
671/// A [builder-pattern] type to construct [`TabButton`] objects.
672///
673/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
674#[must_use = "The builder must be built to be used"]
675pub struct TabButtonBuilder {
676 builder: glib::object::ObjectBuilder<'static, TabButton>,
677}
678
679impl TabButtonBuilder {
680 fn new() -> Self {
681 Self {
682 builder: glib::object::Object::builder(),
683 }
684 }
685
686 /// The view the tab button displays.
687 #[cfg(feature = "v1_3")]
688 #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
689 pub fn view(self, view: &TabView) -> Self {
690 Self {
691 builder: self.builder.property("view", view.clone()),
692 }
693 }
694
695 /// Whether the widget or any of its descendents can accept
696 /// the input focus.
697 ///
698 /// This property is meant to be set by widget implementations,
699 /// typically in their instance init function.
700 pub fn can_focus(self, can_focus: bool) -> Self {
701 Self {
702 builder: self.builder.property("can-focus", can_focus),
703 }
704 }
705
706 /// Whether the widget can receive pointer events.
707 pub fn can_target(self, can_target: bool) -> Self {
708 Self {
709 builder: self.builder.property("can-target", can_target),
710 }
711 }
712
713 /// A list of css classes applied to this widget.
714 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
715 Self {
716 builder: self.builder.property("css-classes", css_classes.into()),
717 }
718 }
719
720 /// The name of this widget in the CSS tree.
721 ///
722 /// This property is meant to be set by widget implementations,
723 /// typically in their instance init function.
724 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
725 Self {
726 builder: self.builder.property("css-name", css_name.into()),
727 }
728 }
729
730 /// The cursor used by @widget.
731 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
732 Self {
733 builder: self.builder.property("cursor", cursor.clone()),
734 }
735 }
736
737 /// Whether the widget should grab focus when it is clicked with the mouse.
738 ///
739 /// This property is only relevant for widgets that can take focus.
740 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
741 Self {
742 builder: self.builder.property("focus-on-click", focus_on_click),
743 }
744 }
745
746 /// Whether this widget itself will accept the input focus.
747 pub fn focusable(self, focusable: bool) -> Self {
748 Self {
749 builder: self.builder.property("focusable", focusable),
750 }
751 }
752
753 /// How to distribute horizontal space if widget gets extra space.
754 pub fn halign(self, halign: gtk::Align) -> Self {
755 Self {
756 builder: self.builder.property("halign", halign),
757 }
758 }
759
760 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
761 /// signal on @widget.
762 ///
763 /// A true value indicates that @widget can have a tooltip, in this case
764 /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
765 /// determine whether it will provide a tooltip or not.
766 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
767 Self {
768 builder: self.builder.property("has-tooltip", has_tooltip),
769 }
770 }
771
772 /// Overrides for height request of the widget.
773 ///
774 /// If this is -1, the natural request will be used.
775 pub fn height_request(self, height_request: i32) -> Self {
776 Self {
777 builder: self.builder.property("height-request", height_request),
778 }
779 }
780
781 /// Whether to expand horizontally.
782 pub fn hexpand(self, hexpand: bool) -> Self {
783 Self {
784 builder: self.builder.property("hexpand", hexpand),
785 }
786 }
787
788 /// Whether to use the `hexpand` property.
789 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
790 Self {
791 builder: self.builder.property("hexpand-set", hexpand_set),
792 }
793 }
794
795 /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
796 /// the preferred size of the widget, and allocate its children.
797 ///
798 /// This property is meant to be set by widget implementations,
799 /// typically in their instance init function.
800 pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
801 Self {
802 builder: self
803 .builder
804 .property("layout-manager", layout_manager.clone().upcast()),
805 }
806 }
807
808 /// Makes this widget act like a modal dialog, with respect to
809 /// event delivery.
810 ///
811 /// Global event controllers will not handle events with targets
812 /// inside the widget, unless they are set up to ignore propagation
813 /// limits. See `Gtk::EventController::set_propagation_limit()`.
814 #[cfg(feature = "gtk_v4_18")]
815 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
816 pub fn limit_events(self, limit_events: bool) -> Self {
817 Self {
818 builder: self.builder.property("limit-events", limit_events),
819 }
820 }
821
822 /// Margin on bottom side of widget.
823 ///
824 /// This property adds margin outside of the widget's normal size
825 /// request, the margin will be added in addition to the size from
826 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
827 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
828 Self {
829 builder: self.builder.property("margin-bottom", margin_bottom),
830 }
831 }
832
833 /// Margin on end of widget, horizontally.
834 ///
835 /// This property supports left-to-right and right-to-left text
836 /// directions.
837 ///
838 /// This property adds margin outside of the widget's normal size
839 /// request, the margin will be added in addition to the size from
840 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
841 pub fn margin_end(self, margin_end: i32) -> Self {
842 Self {
843 builder: self.builder.property("margin-end", margin_end),
844 }
845 }
846
847 /// Margin on start of widget, horizontally.
848 ///
849 /// This property supports left-to-right and right-to-left text
850 /// directions.
851 ///
852 /// This property adds margin outside of the widget's normal size
853 /// request, the margin will be added in addition to the size from
854 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
855 pub fn margin_start(self, margin_start: i32) -> Self {
856 Self {
857 builder: self.builder.property("margin-start", margin_start),
858 }
859 }
860
861 /// Margin on top side of widget.
862 ///
863 /// This property adds margin outside of the widget's normal size
864 /// request, the margin will be added in addition to the size from
865 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
866 pub fn margin_top(self, margin_top: i32) -> Self {
867 Self {
868 builder: self.builder.property("margin-top", margin_top),
869 }
870 }
871
872 /// The name of the widget.
873 pub fn name(self, name: impl Into<glib::GString>) -> Self {
874 Self {
875 builder: self.builder.property("name", name.into()),
876 }
877 }
878
879 /// The requested opacity of the widget.
880 pub fn opacity(self, opacity: f64) -> Self {
881 Self {
882 builder: self.builder.property("opacity", opacity),
883 }
884 }
885
886 /// How content outside the widget's content area is treated.
887 ///
888 /// This property is meant to be set by widget implementations,
889 /// typically in their instance init function.
890 pub fn overflow(self, overflow: gtk::Overflow) -> Self {
891 Self {
892 builder: self.builder.property("overflow", overflow),
893 }
894 }
895
896 /// Whether the widget will receive the default action when it is focused.
897 pub fn receives_default(self, receives_default: bool) -> Self {
898 Self {
899 builder: self.builder.property("receives-default", receives_default),
900 }
901 }
902
903 /// Whether the widget responds to input.
904 pub fn sensitive(self, sensitive: bool) -> Self {
905 Self {
906 builder: self.builder.property("sensitive", sensitive),
907 }
908 }
909
910 /// Sets the text of tooltip to be the given string, which is marked up
911 /// with Pango markup.
912 ///
913 /// Also see `Gtk::Tooltip::set_markup()`.
914 ///
915 /// This is a convenience property which will take care of getting the
916 /// tooltip shown if the given string is not `NULL`:
917 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
918 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
919 /// the default signal handler.
920 ///
921 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
922 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
923 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
924 Self {
925 builder: self
926 .builder
927 .property("tooltip-markup", tooltip_markup.into()),
928 }
929 }
930
931 /// Sets the text of tooltip to be the given string.
932 ///
933 /// Also see `Gtk::Tooltip::set_text()`.
934 ///
935 /// This is a convenience property which will take care of getting the
936 /// tooltip shown if the given string is not `NULL`:
937 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
938 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
939 /// the default signal handler.
940 ///
941 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
942 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
943 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
944 Self {
945 builder: self.builder.property("tooltip-text", tooltip_text.into()),
946 }
947 }
948
949 /// How to distribute vertical space if widget gets extra space.
950 pub fn valign(self, valign: gtk::Align) -> Self {
951 Self {
952 builder: self.builder.property("valign", valign),
953 }
954 }
955
956 /// Whether to expand vertically.
957 pub fn vexpand(self, vexpand: bool) -> Self {
958 Self {
959 builder: self.builder.property("vexpand", vexpand),
960 }
961 }
962
963 /// Whether to use the `vexpand` property.
964 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
965 Self {
966 builder: self.builder.property("vexpand-set", vexpand_set),
967 }
968 }
969
970 /// Whether the widget is visible.
971 pub fn visible(self, visible: bool) -> Self {
972 Self {
973 builder: self.builder.property("visible", visible),
974 }
975 }
976
977 /// Overrides for width request of the widget.
978 ///
979 /// If this is -1, the natural request will be used.
980 pub fn width_request(self, width_request: i32) -> Self {
981 Self {
982 builder: self.builder.property("width-request", width_request),
983 }
984 }
985
986 /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
987 ///
988 /// The accessible role cannot be changed once set.
989 pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
990 Self {
991 builder: self.builder.property("accessible-role", accessible_role),
992 }
993 }
994
995 /// The name of the action with which this widget should be associated.
996 pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
997 Self {
998 builder: self.builder.property("action-name", action_name.into()),
999 }
1000 }
1001
1002 /// The target value of the actionable widget's action.
1003 pub fn action_target(self, action_target: &glib::Variant) -> Self {
1004 Self {
1005 builder: self
1006 .builder
1007 .property("action-target", action_target.clone()),
1008 }
1009 }
1010
1011 // rustdoc-stripper-ignore-next
1012 /// Build the [`TabButton`].
1013 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1014 pub fn build(self) -> TabButton {
1015 assert_initialized_main_thread!();
1016 self.builder.build()
1017 }
1018}