gtk4/auto/header_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
5use crate::{
6 ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
7 Widget,
8};
9use glib::{
10 prelude::*,
11 signal::{connect_raw, SignalHandlerId},
12 translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17 /// A widget for creating custom title bars for windows.
18 ///
19 /// 
20 ///
21 /// [`HeaderBar`][crate::HeaderBar] is similar to a horizontal [`CenterBox`][crate::CenterBox]. It allows
22 /// children to be placed at the start or the end. In addition, it allows
23 /// the window title to be displayed. The title will be centered with respect
24 /// to the width of the box, even if the children at either side take up
25 /// different amounts of space.
26 ///
27 /// [`HeaderBar`][crate::HeaderBar] can add typical window frame controls, such as minimize,
28 /// maximize and close buttons, or the window icon.
29 ///
30 /// For these reasons, [`HeaderBar`][crate::HeaderBar] is the natural choice for use as the
31 /// custom titlebar widget of a [`Window`][crate::Window] (see [`GtkWindowExt::set_titlebar()`][crate::prelude::GtkWindowExt::set_titlebar()]),
32 /// as it gives features typical of titlebars while allowing the addition of
33 /// child widgets.
34 ///
35 /// ## GtkHeaderBar as GtkBuildable
36 ///
37 /// The [`HeaderBar`][crate::HeaderBar] implementation of the [`Buildable`][crate::Buildable] interface supports
38 /// adding children at the start or end sides by specifying “start” or “end” as
39 /// the “type” attribute of a `<child>` element, or setting the title widget by
40 /// specifying “title” value.
41 ///
42 /// By default the [`HeaderBar`][crate::HeaderBar] uses a [`Label`][crate::Label] displaying the title of the
43 /// window it is contained in as the title widget, equivalent to the following
44 /// UI definition:
45 ///
46 /// ```xml
47 /// <object class="GtkHeaderBar">
48 /// <property name="title-widget">
49 /// <object class="GtkLabel">
50 /// <property name="label" translatable="yes">Label</property>
51 /// <property name="single-line-mode">True</property>
52 /// <property name="ellipsize">end</property>
53 /// <property name="width-chars">5</property>
54 /// <style>
55 /// <class name="title"/>
56 /// </style>
57 /// </object>
58 /// </property>
59 /// </object>
60 /// ```
61 ///
62 /// # CSS nodes
63 ///
64 /// ```text
65 /// headerbar
66 /// ╰── windowhandle
67 /// ╰── box
68 /// ├── box.start
69 /// │ ├── windowcontrols.start
70 /// │ ╰── [other children]
71 /// ├── [Title Widget]
72 /// ╰── box.end
73 /// ├── [other children]
74 /// ╰── windowcontrols.end
75 /// ```
76 ///
77 /// A [`HeaderBar`][crate::HeaderBar]'s CSS node is called `headerbar`. It contains a `windowhandle`
78 /// subnode, which contains a `box` subnode, which contains two `box` subnodes at
79 /// the start and end of the header bar, as well as a center node that represents
80 /// the title.
81 ///
82 /// Each of the boxes contains a `windowcontrols` subnode, see
83 /// [`WindowControls`][crate::WindowControls] for details, as well as other children.
84 ///
85 /// # Accessibility
86 ///
87 /// [`HeaderBar`][crate::HeaderBar] uses the [enum@Gtk.AccessibleRole.group] role.
88 ///
89 /// ## Properties
90 ///
91 ///
92 /// #### `decoration-layout`
93 /// The decoration layout for buttons.
94 ///
95 /// If this property is not set, the
96 /// [`gtk-decoration-layout`][struct@crate::Settings#gtk-decoration-layout] setting is used.
97 ///
98 /// Readable | Writeable
99 ///
100 ///
101 /// #### `show-title-buttons`
102 /// Whether to show title buttons like close, minimize, maximize.
103 ///
104 /// Which buttons are actually shown and where is determined
105 /// by the [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] property,
106 /// and by the state of the window (e.g. a close button will not
107 /// be shown if the window can't be closed).
108 ///
109 /// Readable | Writeable
110 ///
111 ///
112 /// #### `title-widget`
113 /// The title widget to display.
114 ///
115 /// Readable | Writeable
116 /// <details><summary><h4>Widget</h4></summary>
117 ///
118 ///
119 /// #### `can-focus`
120 /// Whether the widget or any of its descendents can accept
121 /// the input focus.
122 ///
123 /// This property is meant to be set by widget implementations,
124 /// typically in their instance init function.
125 ///
126 /// Readable | Writeable
127 ///
128 ///
129 /// #### `can-target`
130 /// Whether the widget can receive pointer events.
131 ///
132 /// Readable | Writeable
133 ///
134 ///
135 /// #### `css-classes`
136 /// A list of css classes applied to this widget.
137 ///
138 /// Readable | Writeable
139 ///
140 ///
141 /// #### `css-name`
142 /// The name of this widget in the CSS tree.
143 ///
144 /// This property is meant to be set by widget implementations,
145 /// typically in their instance init function.
146 ///
147 /// Readable | Writeable | Construct Only
148 ///
149 ///
150 /// #### `cursor`
151 /// The cursor used by @widget.
152 ///
153 /// Readable | Writeable
154 ///
155 ///
156 /// #### `focus-on-click`
157 /// Whether the widget should grab focus when it is clicked with the mouse.
158 ///
159 /// This property is only relevant for widgets that can take focus.
160 ///
161 /// Readable | Writeable
162 ///
163 ///
164 /// #### `focusable`
165 /// Whether this widget itself will accept the input focus.
166 ///
167 /// Readable | Writeable
168 ///
169 ///
170 /// #### `halign`
171 /// How to distribute horizontal space if widget gets extra space.
172 ///
173 /// Readable | Writeable
174 ///
175 ///
176 /// #### `has-default`
177 /// Whether the widget is the default widget.
178 ///
179 /// Readable
180 ///
181 ///
182 /// #### `has-focus`
183 /// Whether the widget has the input focus.
184 ///
185 /// Readable
186 ///
187 ///
188 /// #### `has-tooltip`
189 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
190 /// signal on @widget.
191 ///
192 /// A true value indicates that @widget can have a tooltip, in this case
193 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
194 /// determine whether it will provide a tooltip or not.
195 ///
196 /// Readable | Writeable
197 ///
198 ///
199 /// #### `height-request`
200 /// Overrides for height request of the widget.
201 ///
202 /// If this is -1, the natural request will be used.
203 ///
204 /// Readable | Writeable
205 ///
206 ///
207 /// #### `hexpand`
208 /// Whether to expand horizontally.
209 ///
210 /// Readable | Writeable
211 ///
212 ///
213 /// #### `hexpand-set`
214 /// Whether to use the `hexpand` property.
215 ///
216 /// Readable | Writeable
217 ///
218 ///
219 /// #### `layout-manager`
220 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
221 /// the preferred size of the widget, and allocate its children.
222 ///
223 /// This property is meant to be set by widget implementations,
224 /// typically in their instance init function.
225 ///
226 /// Readable | Writeable
227 ///
228 ///
229 /// #### `limit-events`
230 /// Makes this widget act like a modal dialog, with respect to
231 /// event delivery.
232 ///
233 /// Global event controllers will not handle events with targets
234 /// inside the widget, unless they are set up to ignore propagation
235 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
236 ///
237 /// Readable | Writeable
238 ///
239 ///
240 /// #### `margin-bottom`
241 /// Margin on bottom side of widget.
242 ///
243 /// This property adds margin outside of the widget's normal size
244 /// request, the margin will be added in addition to the size from
245 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
246 ///
247 /// Readable | Writeable
248 ///
249 ///
250 /// #### `margin-end`
251 /// Margin on end of widget, horizontally.
252 ///
253 /// This property supports left-to-right and right-to-left text
254 /// directions.
255 ///
256 /// This property adds margin outside of the widget's normal size
257 /// request, the margin will be added in addition to the size from
258 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
259 ///
260 /// Readable | Writeable
261 ///
262 ///
263 /// #### `margin-start`
264 /// Margin on start of widget, horizontally.
265 ///
266 /// This property supports left-to-right and right-to-left text
267 /// directions.
268 ///
269 /// This property adds margin outside of the widget's normal size
270 /// request, the margin will be added in addition to the size from
271 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
272 ///
273 /// Readable | Writeable
274 ///
275 ///
276 /// #### `margin-top`
277 /// Margin on top side of widget.
278 ///
279 /// This property adds margin outside of the widget's normal size
280 /// request, the margin will be added in addition to the size from
281 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
282 ///
283 /// Readable | Writeable
284 ///
285 ///
286 /// #### `name`
287 /// The name of the widget.
288 ///
289 /// Readable | Writeable
290 ///
291 ///
292 /// #### `opacity`
293 /// The requested opacity of the widget.
294 ///
295 /// Readable | Writeable
296 ///
297 ///
298 /// #### `overflow`
299 /// How content outside the widget's content area is treated.
300 ///
301 /// This property is meant to be set by widget implementations,
302 /// typically in their instance init function.
303 ///
304 /// Readable | Writeable
305 ///
306 ///
307 /// #### `parent`
308 /// The parent widget of this widget.
309 ///
310 /// Readable
311 ///
312 ///
313 /// #### `receives-default`
314 /// Whether the widget will receive the default action when it is focused.
315 ///
316 /// Readable | Writeable
317 ///
318 ///
319 /// #### `root`
320 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
321 ///
322 /// This will be `NULL` if the widget is not contained in a root widget.
323 ///
324 /// Readable
325 ///
326 ///
327 /// #### `scale-factor`
328 /// The scale factor of the widget.
329 ///
330 /// Readable
331 ///
332 ///
333 /// #### `sensitive`
334 /// Whether the widget responds to input.
335 ///
336 /// Readable | Writeable
337 ///
338 ///
339 /// #### `tooltip-markup`
340 /// Sets the text of tooltip to be the given string, which is marked up
341 /// with Pango markup.
342 ///
343 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
344 ///
345 /// This is a convenience property which will take care of getting the
346 /// tooltip shown if the given string is not `NULL`:
347 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
348 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
349 /// the default signal handler.
350 ///
351 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
352 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
353 ///
354 /// Readable | Writeable
355 ///
356 ///
357 /// #### `tooltip-text`
358 /// Sets the text of tooltip to be the given string.
359 ///
360 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
361 ///
362 /// This is a convenience property which will take care of getting the
363 /// tooltip shown if the given string is not `NULL`:
364 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
365 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
366 /// the default signal handler.
367 ///
368 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
369 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
370 ///
371 /// Readable | Writeable
372 ///
373 ///
374 /// #### `valign`
375 /// How to distribute vertical space if widget gets extra space.
376 ///
377 /// Readable | Writeable
378 ///
379 ///
380 /// #### `vexpand`
381 /// Whether to expand vertically.
382 ///
383 /// Readable | Writeable
384 ///
385 ///
386 /// #### `vexpand-set`
387 /// Whether to use the `vexpand` property.
388 ///
389 /// Readable | Writeable
390 ///
391 ///
392 /// #### `visible`
393 /// Whether the widget is visible.
394 ///
395 /// Readable | Writeable
396 ///
397 ///
398 /// #### `width-request`
399 /// Overrides for width request of the widget.
400 ///
401 /// If this is -1, the natural request will be used.
402 ///
403 /// Readable | Writeable
404 /// </details>
405 /// <details><summary><h4>Accessible</h4></summary>
406 ///
407 ///
408 /// #### `accessible-role`
409 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
410 ///
411 /// The accessible role cannot be changed once set.
412 ///
413 /// Readable | Writeable
414 /// </details>
415 ///
416 /// # Implements
417 ///
418 /// [`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]
419 #[doc(alias = "GtkHeaderBar")]
420 pub struct HeaderBar(Object<ffi::GtkHeaderBar>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
421
422 match fn {
423 type_ => || ffi::gtk_header_bar_get_type(),
424 }
425}
426
427impl HeaderBar {
428 /// Creates a new [`HeaderBar`][crate::HeaderBar] widget.
429 ///
430 /// # Returns
431 ///
432 /// a new [`HeaderBar`][crate::HeaderBar]
433 #[doc(alias = "gtk_header_bar_new")]
434 pub fn new() -> HeaderBar {
435 assert_initialized_main_thread!();
436 unsafe { Widget::from_glib_none(ffi::gtk_header_bar_new()).unsafe_cast() }
437 }
438
439 // rustdoc-stripper-ignore-next
440 /// Creates a new builder-pattern struct instance to construct [`HeaderBar`] objects.
441 ///
442 /// This method returns an instance of [`HeaderBarBuilder`](crate::builders::HeaderBarBuilder) which can be used to create [`HeaderBar`] objects.
443 pub fn builder() -> HeaderBarBuilder {
444 HeaderBarBuilder::new()
445 }
446
447 /// Gets the decoration layout of the header bar.
448 ///
449 /// # Returns
450 ///
451 /// the decoration layout
452 #[doc(alias = "gtk_header_bar_get_decoration_layout")]
453 #[doc(alias = "get_decoration_layout")]
454 #[doc(alias = "decoration-layout")]
455 pub fn decoration_layout(&self) -> Option<glib::GString> {
456 unsafe {
457 from_glib_none(ffi::gtk_header_bar_get_decoration_layout(
458 self.to_glib_none().0,
459 ))
460 }
461 }
462
463 /// Returns whether this header bar shows the standard window
464 /// title buttons.
465 ///
466 /// # Returns
467 ///
468 /// true if title buttons are shown
469 #[doc(alias = "gtk_header_bar_get_show_title_buttons")]
470 #[doc(alias = "get_show_title_buttons")]
471 #[doc(alias = "show-title-buttons")]
472 pub fn shows_title_buttons(&self) -> bool {
473 unsafe {
474 from_glib(ffi::gtk_header_bar_get_show_title_buttons(
475 self.to_glib_none().0,
476 ))
477 }
478 }
479
480 /// Retrieves the title widget of the header bar.
481 ///
482 /// See [`set_title_widget()`][Self::set_title_widget()].
483 ///
484 /// # Returns
485 ///
486 /// the title widget
487 #[doc(alias = "gtk_header_bar_get_title_widget")]
488 #[doc(alias = "get_title_widget")]
489 #[doc(alias = "title-widget")]
490 pub fn title_widget(&self) -> Option<Widget> {
491 unsafe { from_glib_none(ffi::gtk_header_bar_get_title_widget(self.to_glib_none().0)) }
492 }
493
494 /// Adds a child to the header bar, packed with reference to the end.
495 /// ## `child`
496 /// the widget to be added to @self
497 #[doc(alias = "gtk_header_bar_pack_end")]
498 pub fn pack_end(&self, child: &impl IsA<Widget>) {
499 unsafe {
500 ffi::gtk_header_bar_pack_end(self.to_glib_none().0, child.as_ref().to_glib_none().0);
501 }
502 }
503
504 /// Adds a child to the header bar, packed with reference to the start.
505 /// ## `child`
506 /// the widget to be added to @self
507 #[doc(alias = "gtk_header_bar_pack_start")]
508 pub fn pack_start(&self, child: &impl IsA<Widget>) {
509 unsafe {
510 ffi::gtk_header_bar_pack_start(self.to_glib_none().0, child.as_ref().to_glib_none().0);
511 }
512 }
513
514 /// Removes a child from the header bar.
515 ///
516 /// The child must have been added with
517 /// [`pack_start()`][Self::pack_start()],
518 /// [`pack_end()`][Self::pack_end()] or
519 /// [`set_title_widget()`][Self::set_title_widget()].
520 /// ## `child`
521 /// the child to remove
522 #[doc(alias = "gtk_header_bar_remove")]
523 pub fn remove(&self, child: &impl IsA<Widget>) {
524 unsafe {
525 ffi::gtk_header_bar_remove(self.to_glib_none().0, child.as_ref().to_glib_none().0);
526 }
527 }
528
529 /// Sets the decoration layout for this header bar.
530 ///
531 /// This property overrides the
532 /// [`gtk-decoration-layout`][struct@crate::Settings#gtk-decoration-layout] setting.
533 ///
534 /// There can be valid reasons for overriding the setting, such
535 /// as a header bar design that does not allow for buttons to take
536 /// room on the right, or only offers room for a single close button.
537 /// Split header bars are another example for overriding the setting.
538 ///
539 /// The format of the string is button names, separated by commas.
540 /// A colon separates the buttons that should appear on the left
541 /// from those on the right. Recognized button names are minimize,
542 /// maximize, close and icon (the window icon).
543 ///
544 /// For example, “icon:minimize,maximize,close” specifies an icon
545 /// on the left, and minimize, maximize and close buttons on the right.
546 /// ## `layout`
547 /// a decoration layout
548 #[doc(alias = "gtk_header_bar_set_decoration_layout")]
549 #[doc(alias = "decoration-layout")]
550 pub fn set_decoration_layout(&self, layout: Option<&str>) {
551 unsafe {
552 ffi::gtk_header_bar_set_decoration_layout(
553 self.to_glib_none().0,
554 layout.to_glib_none().0,
555 );
556 }
557 }
558
559 /// Sets whether this header bar shows the standard window
560 /// title buttons.
561 /// ## `setting`
562 /// true to show standard title buttons
563 #[doc(alias = "gtk_header_bar_set_show_title_buttons")]
564 #[doc(alias = "show-title-buttons")]
565 pub fn set_show_title_buttons(&self, setting: bool) {
566 unsafe {
567 ffi::gtk_header_bar_set_show_title_buttons(self.to_glib_none().0, setting.into_glib());
568 }
569 }
570
571 /// Sets the title for the header bar.
572 ///
573 /// When set to `NULL`, the headerbar will display the title of
574 /// the window it is contained in.
575 ///
576 /// The title should help a user identify the current view.
577 /// To achieve the same style as the builtin title, use the
578 /// “title” style class.
579 ///
580 /// You should set the title widget to `NULL`, for the window
581 /// title label to be visible again.
582 /// ## `title_widget`
583 /// a widget to use for a title
584 #[doc(alias = "gtk_header_bar_set_title_widget")]
585 #[doc(alias = "title-widget")]
586 pub fn set_title_widget(&self, title_widget: Option<&impl IsA<Widget>>) {
587 unsafe {
588 ffi::gtk_header_bar_set_title_widget(
589 self.to_glib_none().0,
590 title_widget.map(|p| p.as_ref()).to_glib_none().0,
591 );
592 }
593 }
594
595 #[doc(alias = "decoration-layout")]
596 pub fn connect_decoration_layout_notify<F: Fn(&Self) + 'static>(
597 &self,
598 f: F,
599 ) -> SignalHandlerId {
600 unsafe extern "C" fn notify_decoration_layout_trampoline<F: Fn(&HeaderBar) + 'static>(
601 this: *mut ffi::GtkHeaderBar,
602 _param_spec: glib::ffi::gpointer,
603 f: glib::ffi::gpointer,
604 ) {
605 let f: &F = &*(f as *const F);
606 f(&from_glib_borrow(this))
607 }
608 unsafe {
609 let f: Box_<F> = Box_::new(f);
610 connect_raw(
611 self.as_ptr() as *mut _,
612 b"notify::decoration-layout\0".as_ptr() as *const _,
613 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
614 notify_decoration_layout_trampoline::<F> as *const (),
615 )),
616 Box_::into_raw(f),
617 )
618 }
619 }
620
621 #[doc(alias = "show-title-buttons")]
622 pub fn connect_show_title_buttons_notify<F: Fn(&Self) + 'static>(
623 &self,
624 f: F,
625 ) -> SignalHandlerId {
626 unsafe extern "C" fn notify_show_title_buttons_trampoline<F: Fn(&HeaderBar) + 'static>(
627 this: *mut ffi::GtkHeaderBar,
628 _param_spec: glib::ffi::gpointer,
629 f: glib::ffi::gpointer,
630 ) {
631 let f: &F = &*(f as *const F);
632 f(&from_glib_borrow(this))
633 }
634 unsafe {
635 let f: Box_<F> = Box_::new(f);
636 connect_raw(
637 self.as_ptr() as *mut _,
638 b"notify::show-title-buttons\0".as_ptr() as *const _,
639 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
640 notify_show_title_buttons_trampoline::<F> as *const (),
641 )),
642 Box_::into_raw(f),
643 )
644 }
645 }
646
647 #[doc(alias = "title-widget")]
648 pub fn connect_title_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
649 unsafe extern "C" fn notify_title_widget_trampoline<F: Fn(&HeaderBar) + 'static>(
650 this: *mut ffi::GtkHeaderBar,
651 _param_spec: glib::ffi::gpointer,
652 f: glib::ffi::gpointer,
653 ) {
654 let f: &F = &*(f as *const F);
655 f(&from_glib_borrow(this))
656 }
657 unsafe {
658 let f: Box_<F> = Box_::new(f);
659 connect_raw(
660 self.as_ptr() as *mut _,
661 b"notify::title-widget\0".as_ptr() as *const _,
662 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
663 notify_title_widget_trampoline::<F> as *const (),
664 )),
665 Box_::into_raw(f),
666 )
667 }
668 }
669}
670
671impl Default for HeaderBar {
672 fn default() -> Self {
673 Self::new()
674 }
675}
676
677// rustdoc-stripper-ignore-next
678/// A [builder-pattern] type to construct [`HeaderBar`] objects.
679///
680/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
681#[must_use = "The builder must be built to be used"]
682pub struct HeaderBarBuilder {
683 builder: glib::object::ObjectBuilder<'static, HeaderBar>,
684}
685
686impl HeaderBarBuilder {
687 fn new() -> Self {
688 Self {
689 builder: glib::object::Object::builder(),
690 }
691 }
692
693 /// The decoration layout for buttons.
694 ///
695 /// If this property is not set, the
696 /// [`gtk-decoration-layout`][struct@crate::Settings#gtk-decoration-layout] setting is used.
697 pub fn decoration_layout(self, decoration_layout: impl Into<glib::GString>) -> Self {
698 Self {
699 builder: self
700 .builder
701 .property("decoration-layout", decoration_layout.into()),
702 }
703 }
704
705 /// Whether to show title buttons like close, minimize, maximize.
706 ///
707 /// Which buttons are actually shown and where is determined
708 /// by the [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] property,
709 /// and by the state of the window (e.g. a close button will not
710 /// be shown if the window can't be closed).
711 pub fn show_title_buttons(self, show_title_buttons: bool) -> Self {
712 Self {
713 builder: self
714 .builder
715 .property("show-title-buttons", show_title_buttons),
716 }
717 }
718
719 /// The title widget to display.
720 pub fn title_widget(self, title_widget: &impl IsA<Widget>) -> Self {
721 Self {
722 builder: self
723 .builder
724 .property("title-widget", title_widget.clone().upcast()),
725 }
726 }
727
728 /// Whether the widget or any of its descendents can accept
729 /// the input focus.
730 ///
731 /// This property is meant to be set by widget implementations,
732 /// typically in their instance init function.
733 pub fn can_focus(self, can_focus: bool) -> Self {
734 Self {
735 builder: self.builder.property("can-focus", can_focus),
736 }
737 }
738
739 /// Whether the widget can receive pointer events.
740 pub fn can_target(self, can_target: bool) -> Self {
741 Self {
742 builder: self.builder.property("can-target", can_target),
743 }
744 }
745
746 /// A list of css classes applied to this widget.
747 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
748 Self {
749 builder: self.builder.property("css-classes", css_classes.into()),
750 }
751 }
752
753 /// The name of this widget in the CSS tree.
754 ///
755 /// This property is meant to be set by widget implementations,
756 /// typically in their instance init function.
757 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
758 Self {
759 builder: self.builder.property("css-name", css_name.into()),
760 }
761 }
762
763 /// The cursor used by @widget.
764 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
765 Self {
766 builder: self.builder.property("cursor", cursor.clone()),
767 }
768 }
769
770 /// Whether the widget should grab focus when it is clicked with the mouse.
771 ///
772 /// This property is only relevant for widgets that can take focus.
773 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
774 Self {
775 builder: self.builder.property("focus-on-click", focus_on_click),
776 }
777 }
778
779 /// Whether this widget itself will accept the input focus.
780 pub fn focusable(self, focusable: bool) -> Self {
781 Self {
782 builder: self.builder.property("focusable", focusable),
783 }
784 }
785
786 /// How to distribute horizontal space if widget gets extra space.
787 pub fn halign(self, halign: Align) -> Self {
788 Self {
789 builder: self.builder.property("halign", halign),
790 }
791 }
792
793 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
794 /// signal on @widget.
795 ///
796 /// A true value indicates that @widget can have a tooltip, in this case
797 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
798 /// determine whether it will provide a tooltip or not.
799 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
800 Self {
801 builder: self.builder.property("has-tooltip", has_tooltip),
802 }
803 }
804
805 /// Overrides for height request of the widget.
806 ///
807 /// If this is -1, the natural request will be used.
808 pub fn height_request(self, height_request: i32) -> Self {
809 Self {
810 builder: self.builder.property("height-request", height_request),
811 }
812 }
813
814 /// Whether to expand horizontally.
815 pub fn hexpand(self, hexpand: bool) -> Self {
816 Self {
817 builder: self.builder.property("hexpand", hexpand),
818 }
819 }
820
821 /// Whether to use the `hexpand` property.
822 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
823 Self {
824 builder: self.builder.property("hexpand-set", hexpand_set),
825 }
826 }
827
828 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
829 /// the preferred size of the widget, and allocate its children.
830 ///
831 /// This property is meant to be set by widget implementations,
832 /// typically in their instance init function.
833 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
834 Self {
835 builder: self
836 .builder
837 .property("layout-manager", layout_manager.clone().upcast()),
838 }
839 }
840
841 /// Makes this widget act like a modal dialog, with respect to
842 /// event delivery.
843 ///
844 /// Global event controllers will not handle events with targets
845 /// inside the widget, unless they are set up to ignore propagation
846 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
847 #[cfg(feature = "v4_18")]
848 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
849 pub fn limit_events(self, limit_events: bool) -> Self {
850 Self {
851 builder: self.builder.property("limit-events", limit_events),
852 }
853 }
854
855 /// Margin on bottom 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 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
860 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
861 Self {
862 builder: self.builder.property("margin-bottom", margin_bottom),
863 }
864 }
865
866 /// Margin on end of widget, horizontally.
867 ///
868 /// This property supports left-to-right and right-to-left text
869 /// directions.
870 ///
871 /// This property adds margin outside of the widget's normal size
872 /// request, the margin will be added in addition to the size from
873 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
874 pub fn margin_end(self, margin_end: i32) -> Self {
875 Self {
876 builder: self.builder.property("margin-end", margin_end),
877 }
878 }
879
880 /// Margin on start of widget, horizontally.
881 ///
882 /// This property supports left-to-right and right-to-left text
883 /// directions.
884 ///
885 /// This property adds margin outside of the widget's normal size
886 /// request, the margin will be added in addition to the size from
887 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
888 pub fn margin_start(self, margin_start: i32) -> Self {
889 Self {
890 builder: self.builder.property("margin-start", margin_start),
891 }
892 }
893
894 /// Margin on top side of widget.
895 ///
896 /// This property adds margin outside of the widget's normal size
897 /// request, the margin will be added in addition to the size from
898 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
899 pub fn margin_top(self, margin_top: i32) -> Self {
900 Self {
901 builder: self.builder.property("margin-top", margin_top),
902 }
903 }
904
905 /// The name of the widget.
906 pub fn name(self, name: impl Into<glib::GString>) -> Self {
907 Self {
908 builder: self.builder.property("name", name.into()),
909 }
910 }
911
912 /// The requested opacity of the widget.
913 pub fn opacity(self, opacity: f64) -> Self {
914 Self {
915 builder: self.builder.property("opacity", opacity),
916 }
917 }
918
919 /// How content outside the widget's content area is treated.
920 ///
921 /// This property is meant to be set by widget implementations,
922 /// typically in their instance init function.
923 pub fn overflow(self, overflow: Overflow) -> Self {
924 Self {
925 builder: self.builder.property("overflow", overflow),
926 }
927 }
928
929 /// Whether the widget will receive the default action when it is focused.
930 pub fn receives_default(self, receives_default: bool) -> Self {
931 Self {
932 builder: self.builder.property("receives-default", receives_default),
933 }
934 }
935
936 /// Whether the widget responds to input.
937 pub fn sensitive(self, sensitive: bool) -> Self {
938 Self {
939 builder: self.builder.property("sensitive", sensitive),
940 }
941 }
942
943 /// Sets the text of tooltip to be the given string, which is marked up
944 /// with Pango markup.
945 ///
946 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
947 ///
948 /// This is a convenience property which will take care of getting the
949 /// tooltip shown if the given string is not `NULL`:
950 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
951 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
952 /// the default signal handler.
953 ///
954 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
955 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
956 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
957 Self {
958 builder: self
959 .builder
960 .property("tooltip-markup", tooltip_markup.into()),
961 }
962 }
963
964 /// Sets the text of tooltip to be the given string.
965 ///
966 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
967 ///
968 /// This is a convenience property which will take care of getting the
969 /// tooltip shown if the given string is not `NULL`:
970 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
971 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
972 /// the default signal handler.
973 ///
974 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
975 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
976 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
977 Self {
978 builder: self.builder.property("tooltip-text", tooltip_text.into()),
979 }
980 }
981
982 /// How to distribute vertical space if widget gets extra space.
983 pub fn valign(self, valign: Align) -> Self {
984 Self {
985 builder: self.builder.property("valign", valign),
986 }
987 }
988
989 /// Whether to expand vertically.
990 pub fn vexpand(self, vexpand: bool) -> Self {
991 Self {
992 builder: self.builder.property("vexpand", vexpand),
993 }
994 }
995
996 /// Whether to use the `vexpand` property.
997 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
998 Self {
999 builder: self.builder.property("vexpand-set", vexpand_set),
1000 }
1001 }
1002
1003 /// Whether the widget is visible.
1004 pub fn visible(self, visible: bool) -> Self {
1005 Self {
1006 builder: self.builder.property("visible", visible),
1007 }
1008 }
1009
1010 /// Overrides for width request of the widget.
1011 ///
1012 /// If this is -1, the natural request will be used.
1013 pub fn width_request(self, width_request: i32) -> Self {
1014 Self {
1015 builder: self.builder.property("width-request", width_request),
1016 }
1017 }
1018
1019 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1020 ///
1021 /// The accessible role cannot be changed once set.
1022 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1023 Self {
1024 builder: self.builder.property("accessible-role", accessible_role),
1025 }
1026 }
1027
1028 // rustdoc-stripper-ignore-next
1029 /// Build the [`HeaderBar`].
1030 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1031 pub fn build(self) -> HeaderBar {
1032 assert_initialized_main_thread!();
1033 self.builder.build()
1034 }
1035}