gtk4/auto/action_bar.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::Accessible;
8use crate::{
9 AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow, Widget, ffi,
10};
11use glib::{
12 prelude::*,
13 signal::{SignalHandlerId, connect_raw},
14 translate::*,
15};
16use std::boxed::Box as Box_;
17
18#[cfg(feature = "v4_10")]
19#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
20glib::wrapper! {
21 /// Presents contextual actions.
22 ///
23 /// <picture>
24 /// <source srcset="action-bar-dark.png" media="(prefers-color-scheme: dark)">
25 /// <img alt="An example GtkActionBar" src="action-bar.png">
26 /// </picture>
27 ///
28 /// [`ActionBar`][crate::ActionBar] is expected to be displayed below the content and expand
29 /// horizontally to fill the area.
30 ///
31 /// It allows placing children at the start or the end. In addition, it
32 /// contains an internal centered box which is centered with respect to
33 /// the full width of the box, even if the children at either side take
34 /// up different amounts of space.
35 ///
36 /// # GtkActionBar as GtkBuildable
37 ///
38 /// The [`ActionBar`][crate::ActionBar] implementation of the [`Buildable`][crate::Buildable] interface supports
39 /// adding children at the start or end sides by specifying “start” or “end” as
40 /// the “type” attribute of a `<child>` element, or setting the center widget
41 /// by specifying “center” value.
42 ///
43 /// # CSS nodes
44 ///
45 /// ```text
46 /// actionbar
47 /// ╰── revealer
48 /// ╰── box
49 /// ├── box.start
50 /// │ ╰── [start children]
51 /// ├── [center widget]
52 /// ╰── box.end
53 /// ╰── [end children]
54 /// ```
55 ///
56 /// A [`ActionBar`][crate::ActionBar]'s CSS node is called `actionbar`. It contains a `revealer`
57 /// subnode, which contains a `box` subnode, which contains two `box` subnodes at
58 /// the start and end of the action bar, with `start` and `end` style classes
59 /// respectively, as well as a center node that represents the center child.
60 ///
61 /// Each of the boxes contains children packed for that side.
62 ///
63 /// ## Properties
64 ///
65 ///
66 /// #### `revealed`
67 /// Controls whether the action bar shows its contents.
68 ///
69 /// Readable | Writable
70 /// <details><summary><h4>Widget</h4></summary>
71 ///
72 ///
73 /// #### `can-focus`
74 /// Whether the widget or any of its descendents can accept
75 /// the input focus.
76 ///
77 /// This property is meant to be set by widget implementations,
78 /// typically in their instance init function.
79 ///
80 /// Readable | Writable
81 ///
82 ///
83 /// #### `can-target`
84 /// Whether the widget can receive pointer events.
85 ///
86 /// Readable | Writable
87 ///
88 ///
89 /// #### `css-classes`
90 /// A list of css classes applied to this widget.
91 ///
92 /// Readable | Writable
93 ///
94 ///
95 /// #### `css-name`
96 /// The name of this widget in the CSS tree.
97 ///
98 /// This property is meant to be set by widget implementations,
99 /// typically in their instance init function.
100 ///
101 /// Readable | Writable | Construct Only
102 ///
103 ///
104 /// #### `cursor`
105 /// The cursor used by @widget.
106 ///
107 /// Readable | Writable
108 ///
109 ///
110 /// #### `focus-on-click`
111 /// Whether the widget should grab focus when it is clicked with the mouse.
112 ///
113 /// This property is only relevant for widgets that can take focus.
114 ///
115 /// Readable | Writable
116 ///
117 ///
118 /// #### `focusable`
119 /// Whether this widget itself will accept the input focus.
120 ///
121 /// Readable | Writable
122 ///
123 ///
124 /// #### `halign`
125 /// How to distribute horizontal space if widget gets extra space.
126 ///
127 /// Readable | Writable
128 ///
129 ///
130 /// #### `has-default`
131 /// Whether the widget is the default widget.
132 ///
133 /// Readable
134 ///
135 ///
136 /// #### `has-focus`
137 /// Whether the widget has the input focus.
138 ///
139 /// Readable
140 ///
141 ///
142 /// #### `has-tooltip`
143 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
144 /// signal on @widget.
145 ///
146 /// A true value indicates that @widget can have a tooltip, in this case
147 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
148 /// determine whether it will provide a tooltip or not.
149 ///
150 /// Readable | Writable
151 ///
152 ///
153 /// #### `height-request`
154 /// Overrides for height request of the widget.
155 ///
156 /// If this is -1, the natural request will be used.
157 ///
158 /// Readable | Writable
159 ///
160 ///
161 /// #### `hexpand`
162 /// Whether to expand horizontally.
163 ///
164 /// Readable | Writable
165 ///
166 ///
167 /// #### `hexpand-set`
168 /// Whether to use the `hexpand` property.
169 ///
170 /// Readable | Writable
171 ///
172 ///
173 /// #### `layout-manager`
174 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
175 /// the preferred size of the widget, and allocate its children.
176 ///
177 /// This property is meant to be set by widget implementations,
178 /// typically in their instance init function.
179 ///
180 /// Readable | Writable
181 ///
182 ///
183 /// #### `limit-events`
184 /// Makes this widget act like a modal dialog, with respect to
185 /// event delivery.
186 ///
187 /// Global event controllers will not handle events with targets
188 /// inside the widget, unless they are set up to ignore propagation
189 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
190 ///
191 /// Readable | Writable
192 ///
193 ///
194 /// #### `margin-bottom`
195 /// Margin on bottom side of widget.
196 ///
197 /// This property adds margin outside of the widget's normal size
198 /// request, the margin will be added in addition to the size from
199 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
200 ///
201 /// Readable | Writable
202 ///
203 ///
204 /// #### `margin-end`
205 /// Margin on end of widget, horizontally.
206 ///
207 /// This property supports left-to-right and right-to-left text
208 /// directions.
209 ///
210 /// This property adds margin outside of the widget's normal size
211 /// request, the margin will be added in addition to the size from
212 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
213 ///
214 /// Readable | Writable
215 ///
216 ///
217 /// #### `margin-start`
218 /// Margin on start of widget, horizontally.
219 ///
220 /// This property supports left-to-right and right-to-left text
221 /// directions.
222 ///
223 /// This property adds margin outside of the widget's normal size
224 /// request, the margin will be added in addition to the size from
225 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
226 ///
227 /// Readable | Writable
228 ///
229 ///
230 /// #### `margin-top`
231 /// Margin on top side of widget.
232 ///
233 /// This property adds margin outside of the widget's normal size
234 /// request, the margin will be added in addition to the size from
235 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
236 ///
237 /// Readable | Writable
238 ///
239 ///
240 /// #### `name`
241 /// The name of the widget.
242 ///
243 /// Readable | Writable
244 ///
245 ///
246 /// #### `opacity`
247 /// The requested opacity of the widget.
248 ///
249 /// Readable | Writable
250 ///
251 ///
252 /// #### `overflow`
253 /// How content outside the widget's content area is treated.
254 ///
255 /// This property is meant to be set by widget implementations,
256 /// typically in their instance init function.
257 ///
258 /// Readable | Writable
259 ///
260 ///
261 /// #### `parent`
262 /// The parent widget of this widget.
263 ///
264 /// Readable
265 ///
266 ///
267 /// #### `receives-default`
268 /// Whether the widget will receive the default action when it is focused.
269 ///
270 /// Readable | Writable
271 ///
272 ///
273 /// #### `root`
274 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
275 ///
276 /// This will be `NULL` if the widget is not contained in a root widget.
277 ///
278 /// Readable
279 ///
280 ///
281 /// #### `scale-factor`
282 /// The scale factor of the widget.
283 ///
284 /// Readable
285 ///
286 ///
287 /// #### `sensitive`
288 /// Whether the widget responds to input.
289 ///
290 /// Readable | Writable
291 ///
292 ///
293 /// #### `tooltip-markup`
294 /// Sets the text of tooltip to be the given string, which is marked up
295 /// with Pango markup.
296 ///
297 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
298 ///
299 /// This is a convenience property which will take care of getting the
300 /// tooltip shown if the given string is not `NULL`:
301 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
302 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
303 /// the default signal handler.
304 ///
305 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
306 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
307 ///
308 /// Readable | Writable
309 ///
310 ///
311 /// #### `tooltip-text`
312 /// Sets the text of tooltip to be the given string.
313 ///
314 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
315 ///
316 /// This is a convenience property which will take care of getting the
317 /// tooltip shown if the given string is not `NULL`:
318 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
319 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
320 /// the default signal handler.
321 ///
322 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
323 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
324 ///
325 /// Readable | Writable
326 ///
327 ///
328 /// #### `valign`
329 /// How to distribute vertical space if widget gets extra space.
330 ///
331 /// Readable | Writable
332 ///
333 ///
334 /// #### `vexpand`
335 /// Whether to expand vertically.
336 ///
337 /// Readable | Writable
338 ///
339 ///
340 /// #### `vexpand-set`
341 /// Whether to use the `vexpand` property.
342 ///
343 /// Readable | Writable
344 ///
345 ///
346 /// #### `visible`
347 /// Whether the widget is visible.
348 ///
349 /// Readable | Writable
350 ///
351 ///
352 /// #### `width-request`
353 /// Overrides for width request of the widget.
354 ///
355 /// If this is -1, the natural request will be used.
356 ///
357 /// Readable | Writable
358 /// </details>
359 /// <details><summary><h4>Accessible</h4></summary>
360 ///
361 ///
362 /// #### `accessible-role`
363 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
364 ///
365 /// The accessible role cannot be changed once set.
366 ///
367 /// Readable | Writable
368 /// </details>
369 ///
370 /// # Implements
371 ///
372 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
373 #[doc(alias = "GtkActionBar")]
374 pub struct ActionBar(Object<ffi::GtkActionBar>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
375
376 match fn {
377 type_ => || ffi::gtk_action_bar_get_type(),
378 }
379}
380
381#[cfg(not(feature = "v4_10"))]
382glib::wrapper! {
383 #[doc(alias = "GtkActionBar")]
384 pub struct ActionBar(Object<ffi::GtkActionBar>) @extends Widget, @implements Buildable, ConstraintTarget;
385
386 match fn {
387 type_ => || ffi::gtk_action_bar_get_type(),
388 }
389}
390
391impl ActionBar {
392 /// Creates a new action bar widget.
393 ///
394 /// # Returns
395 ///
396 /// a new [`ActionBar`][crate::ActionBar]
397 #[doc(alias = "gtk_action_bar_new")]
398 pub fn new() -> ActionBar {
399 assert_initialized_main_thread!();
400 unsafe { Widget::from_glib_none(ffi::gtk_action_bar_new()).unsafe_cast() }
401 }
402
403 // rustdoc-stripper-ignore-next
404 /// Creates a new builder-pattern struct instance to construct [`ActionBar`] objects.
405 ///
406 /// This method returns an instance of [`ActionBarBuilder`](crate::builders::ActionBarBuilder) which can be used to create [`ActionBar`] objects.
407 pub fn builder() -> ActionBarBuilder {
408 ActionBarBuilder::new()
409 }
410
411 /// Retrieves the center bar widget of the bar.
412 ///
413 /// # Returns
414 ///
415 /// the center widget
416 #[doc(alias = "gtk_action_bar_get_center_widget")]
417 #[doc(alias = "get_center_widget")]
418 pub fn center_widget(&self) -> Option<Widget> {
419 unsafe { from_glib_none(ffi::gtk_action_bar_get_center_widget(self.to_glib_none().0)) }
420 }
421
422 /// Gets whether the contents of the action bar are revealed.
423 ///
424 /// # Returns
425 ///
426 /// the current value of the [`revealed`][struct@crate::ActionBar#revealed]
427 /// property
428 #[doc(alias = "gtk_action_bar_get_revealed")]
429 #[doc(alias = "get_revealed")]
430 #[doc(alias = "revealed")]
431 pub fn is_revealed(&self) -> bool {
432 unsafe { from_glib(ffi::gtk_action_bar_get_revealed(self.to_glib_none().0)) }
433 }
434
435 /// Adds a child to the action bar, packed with reference to the
436 /// end of the action bar.
437 /// ## `child`
438 /// the widget to be added
439 #[doc(alias = "gtk_action_bar_pack_end")]
440 pub fn pack_end(&self, child: &impl IsA<Widget>) {
441 unsafe {
442 ffi::gtk_action_bar_pack_end(self.to_glib_none().0, child.as_ref().to_glib_none().0);
443 }
444 }
445
446 /// Adds a child to the action, packed with reference to the
447 /// start of the action bar.
448 /// ## `child`
449 /// the widget to be added
450 #[doc(alias = "gtk_action_bar_pack_start")]
451 pub fn pack_start(&self, child: &impl IsA<Widget>) {
452 unsafe {
453 ffi::gtk_action_bar_pack_start(self.to_glib_none().0, child.as_ref().to_glib_none().0);
454 }
455 }
456
457 /// Removes a child from the action bar.
458 /// ## `child`
459 /// the widget to be removed
460 #[doc(alias = "gtk_action_bar_remove")]
461 pub fn remove(&self, child: &impl IsA<Widget>) {
462 unsafe {
463 ffi::gtk_action_bar_remove(self.to_glib_none().0, child.as_ref().to_glib_none().0);
464 }
465 }
466
467 /// Sets the center widget for the action bar.
468 /// ## `center_widget`
469 /// a widget to use for the center
470 #[doc(alias = "gtk_action_bar_set_center_widget")]
471 pub fn set_center_widget(&self, center_widget: Option<&impl IsA<Widget>>) {
472 unsafe {
473 ffi::gtk_action_bar_set_center_widget(
474 self.to_glib_none().0,
475 center_widget.map(|p| p.as_ref()).to_glib_none().0,
476 );
477 }
478 }
479
480 /// Reveals or conceals the content of the action bar.
481 ///
482 /// Note: this does not show or hide the action bar in the
483 /// [`visible`][struct@crate::Widget#visible] sense, so revealing has
484 /// no effect if the action bar is hidden.
485 /// ## `revealed`
486 /// the new value for the property
487 #[doc(alias = "gtk_action_bar_set_revealed")]
488 #[doc(alias = "revealed")]
489 pub fn set_revealed(&self, revealed: bool) {
490 unsafe {
491 ffi::gtk_action_bar_set_revealed(self.to_glib_none().0, revealed.into_glib());
492 }
493 }
494
495 #[doc(alias = "revealed")]
496 pub fn connect_revealed_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
497 unsafe extern "C" fn notify_revealed_trampoline<F: Fn(&ActionBar) + 'static>(
498 this: *mut ffi::GtkActionBar,
499 _param_spec: glib::ffi::gpointer,
500 f: glib::ffi::gpointer,
501 ) {
502 unsafe {
503 let f: &F = &*(f as *const F);
504 f(&from_glib_borrow(this))
505 }
506 }
507 unsafe {
508 let f: Box_<F> = Box_::new(f);
509 connect_raw(
510 self.as_ptr() as *mut _,
511 c"notify::revealed".as_ptr(),
512 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
513 notify_revealed_trampoline::<F> as *const (),
514 )),
515 Box_::into_raw(f),
516 )
517 }
518 }
519}
520
521impl Default for ActionBar {
522 fn default() -> Self {
523 Self::new()
524 }
525}
526
527// rustdoc-stripper-ignore-next
528/// A [builder-pattern] type to construct [`ActionBar`] objects.
529///
530/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
531#[must_use = "The builder must be built to be used"]
532pub struct ActionBarBuilder {
533 builder: glib::object::ObjectBuilder<'static, ActionBar>,
534}
535
536impl ActionBarBuilder {
537 fn new() -> Self {
538 Self {
539 builder: glib::object::Object::builder(),
540 }
541 }
542
543 /// Controls whether the action bar shows its contents.
544 pub fn revealed(self, revealed: bool) -> Self {
545 Self {
546 builder: self.builder.property("revealed", revealed),
547 }
548 }
549
550 /// Whether the widget or any of its descendents can accept
551 /// the input focus.
552 ///
553 /// This property is meant to be set by widget implementations,
554 /// typically in their instance init function.
555 pub fn can_focus(self, can_focus: bool) -> Self {
556 Self {
557 builder: self.builder.property("can-focus", can_focus),
558 }
559 }
560
561 /// Whether the widget can receive pointer events.
562 pub fn can_target(self, can_target: bool) -> Self {
563 Self {
564 builder: self.builder.property("can-target", can_target),
565 }
566 }
567
568 /// A list of css classes applied to this widget.
569 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
570 Self {
571 builder: self.builder.property("css-classes", css_classes.into()),
572 }
573 }
574
575 /// The name of this widget in the CSS tree.
576 ///
577 /// This property is meant to be set by widget implementations,
578 /// typically in their instance init function.
579 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
580 Self {
581 builder: self.builder.property("css-name", css_name.into()),
582 }
583 }
584
585 /// The cursor used by @widget.
586 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
587 Self {
588 builder: self.builder.property("cursor", cursor.clone()),
589 }
590 }
591
592 /// Whether the widget should grab focus when it is clicked with the mouse.
593 ///
594 /// This property is only relevant for widgets that can take focus.
595 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
596 Self {
597 builder: self.builder.property("focus-on-click", focus_on_click),
598 }
599 }
600
601 /// Whether this widget itself will accept the input focus.
602 pub fn focusable(self, focusable: bool) -> Self {
603 Self {
604 builder: self.builder.property("focusable", focusable),
605 }
606 }
607
608 /// How to distribute horizontal space if widget gets extra space.
609 pub fn halign(self, halign: Align) -> Self {
610 Self {
611 builder: self.builder.property("halign", halign),
612 }
613 }
614
615 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
616 /// signal on @widget.
617 ///
618 /// A true value indicates that @widget can have a tooltip, in this case
619 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
620 /// determine whether it will provide a tooltip or not.
621 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
622 Self {
623 builder: self.builder.property("has-tooltip", has_tooltip),
624 }
625 }
626
627 /// Overrides for height request of the widget.
628 ///
629 /// If this is -1, the natural request will be used.
630 pub fn height_request(self, height_request: i32) -> Self {
631 Self {
632 builder: self.builder.property("height-request", height_request),
633 }
634 }
635
636 /// Whether to expand horizontally.
637 pub fn hexpand(self, hexpand: bool) -> Self {
638 Self {
639 builder: self.builder.property("hexpand", hexpand),
640 }
641 }
642
643 /// Whether to use the `hexpand` property.
644 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
645 Self {
646 builder: self.builder.property("hexpand-set", hexpand_set),
647 }
648 }
649
650 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
651 /// the preferred size of the widget, and allocate its children.
652 ///
653 /// This property is meant to be set by widget implementations,
654 /// typically in their instance init function.
655 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
656 Self {
657 builder: self
658 .builder
659 .property("layout-manager", layout_manager.clone().upcast()),
660 }
661 }
662
663 /// Makes this widget act like a modal dialog, with respect to
664 /// event delivery.
665 ///
666 /// Global event controllers will not handle events with targets
667 /// inside the widget, unless they are set up to ignore propagation
668 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
669 #[cfg(feature = "v4_18")]
670 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
671 pub fn limit_events(self, limit_events: bool) -> Self {
672 Self {
673 builder: self.builder.property("limit-events", limit_events),
674 }
675 }
676
677 /// Margin on bottom side of widget.
678 ///
679 /// This property adds margin outside of the widget's normal size
680 /// request, the margin will be added in addition to the size from
681 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
682 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
683 Self {
684 builder: self.builder.property("margin-bottom", margin_bottom),
685 }
686 }
687
688 /// Margin on end of widget, horizontally.
689 ///
690 /// This property supports left-to-right and right-to-left text
691 /// directions.
692 ///
693 /// This property adds margin outside of the widget's normal size
694 /// request, the margin will be added in addition to the size from
695 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
696 pub fn margin_end(self, margin_end: i32) -> Self {
697 Self {
698 builder: self.builder.property("margin-end", margin_end),
699 }
700 }
701
702 /// Margin on start of widget, horizontally.
703 ///
704 /// This property supports left-to-right and right-to-left text
705 /// directions.
706 ///
707 /// This property adds margin outside of the widget's normal size
708 /// request, the margin will be added in addition to the size from
709 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
710 pub fn margin_start(self, margin_start: i32) -> Self {
711 Self {
712 builder: self.builder.property("margin-start", margin_start),
713 }
714 }
715
716 /// Margin on top side of widget.
717 ///
718 /// This property adds margin outside of the widget's normal size
719 /// request, the margin will be added in addition to the size from
720 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
721 pub fn margin_top(self, margin_top: i32) -> Self {
722 Self {
723 builder: self.builder.property("margin-top", margin_top),
724 }
725 }
726
727 /// The name of the widget.
728 pub fn name(self, name: impl Into<glib::GString>) -> Self {
729 Self {
730 builder: self.builder.property("name", name.into()),
731 }
732 }
733
734 /// The requested opacity of the widget.
735 pub fn opacity(self, opacity: f64) -> Self {
736 Self {
737 builder: self.builder.property("opacity", opacity),
738 }
739 }
740
741 /// How content outside the widget's content area is treated.
742 ///
743 /// This property is meant to be set by widget implementations,
744 /// typically in their instance init function.
745 pub fn overflow(self, overflow: Overflow) -> Self {
746 Self {
747 builder: self.builder.property("overflow", overflow),
748 }
749 }
750
751 /// Whether the widget will receive the default action when it is focused.
752 pub fn receives_default(self, receives_default: bool) -> Self {
753 Self {
754 builder: self.builder.property("receives-default", receives_default),
755 }
756 }
757
758 /// Whether the widget responds to input.
759 pub fn sensitive(self, sensitive: bool) -> Self {
760 Self {
761 builder: self.builder.property("sensitive", sensitive),
762 }
763 }
764
765 /// Sets the text of tooltip to be the given string, which is marked up
766 /// with Pango markup.
767 ///
768 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
769 ///
770 /// This is a convenience property which will take care of getting the
771 /// tooltip shown if the given string is not `NULL`:
772 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
773 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
774 /// the default signal handler.
775 ///
776 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
777 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
778 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
779 Self {
780 builder: self
781 .builder
782 .property("tooltip-markup", tooltip_markup.into()),
783 }
784 }
785
786 /// Sets the text of tooltip to be the given string.
787 ///
788 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
789 ///
790 /// This is a convenience property which will take care of getting the
791 /// tooltip shown if the given string is not `NULL`:
792 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
793 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
794 /// the default signal handler.
795 ///
796 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
797 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
798 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
799 Self {
800 builder: self.builder.property("tooltip-text", tooltip_text.into()),
801 }
802 }
803
804 /// How to distribute vertical space if widget gets extra space.
805 pub fn valign(self, valign: Align) -> Self {
806 Self {
807 builder: self.builder.property("valign", valign),
808 }
809 }
810
811 /// Whether to expand vertically.
812 pub fn vexpand(self, vexpand: bool) -> Self {
813 Self {
814 builder: self.builder.property("vexpand", vexpand),
815 }
816 }
817
818 /// Whether to use the `vexpand` property.
819 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
820 Self {
821 builder: self.builder.property("vexpand-set", vexpand_set),
822 }
823 }
824
825 /// Whether the widget is visible.
826 pub fn visible(self, visible: bool) -> Self {
827 Self {
828 builder: self.builder.property("visible", visible),
829 }
830 }
831
832 /// Overrides for width request of the widget.
833 ///
834 /// If this is -1, the natural request will be used.
835 pub fn width_request(self, width_request: i32) -> Self {
836 Self {
837 builder: self.builder.property("width-request", width_request),
838 }
839 }
840
841 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
842 ///
843 /// The accessible role cannot be changed once set.
844 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
845 Self {
846 builder: self.builder.property("accessible-role", accessible_role),
847 }
848 }
849
850 // rustdoc-stripper-ignore-next
851 /// Build the [`ActionBar`].
852 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
853 pub fn build(self) -> ActionBar {
854 assert_initialized_main_thread!();
855 self.builder.build()
856 }
857}