Skip to main content

gtk/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::{Align, Buildable, Container, PackType, ResizeMode, Widget};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute};
12
13glib::wrapper! {
14    /// GtkHeaderBar is similar to a horizontal [`Box`][crate::Box]. It allows children to
15    /// be placed at the start or the end. In addition, it allows a title and
16    /// subtitle to be displayed. The title will be centered with respect to
17    /// the width of the box, even if the children at either side take up
18    /// different amounts of space. The height of the titlebar will be
19    /// set to provide sufficient space for the subtitle, even if none is
20    /// currently set. If a subtitle is not needed, the space reservation
21    /// can be turned off with [`HeaderBarExt::set_has_subtitle()`][crate::prelude::HeaderBarExt::set_has_subtitle()].
22    ///
23    /// GtkHeaderBar can add typical window frame controls, such as minimize,
24    /// maximize and close buttons, or the window icon.
25    ///
26    /// For these reasons, GtkHeaderBar is the natural choice for use as the custom
27    /// titlebar widget of a [`Window`][crate::Window] (see [`GtkWindowExt::set_titlebar()`][crate::prelude::GtkWindowExt::set_titlebar()]), as it gives
28    /// features typical of titlebars while allowing the addition of child widgets.
29    ///
30    /// ## Properties
31    ///
32    ///
33    /// #### `custom-title`
34    ///  Readable | Writeable
35    ///
36    ///
37    /// #### `decoration-layout`
38    ///  The decoration layout for buttons. If this property is
39    /// not set, the [`gtk-decoration-layout`][struct@crate::Settings#gtk-decoration-layout] setting
40    /// is used.
41    ///
42    /// See [`HeaderBarExt::set_decoration_layout()`][crate::prelude::HeaderBarExt::set_decoration_layout()] for information
43    /// about the format of this string.
44    ///
45    /// Readable | Writeable
46    ///
47    ///
48    /// #### `decoration-layout-set`
49    ///  Set to [`true`] if [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] is set.
50    ///
51    /// Readable | Writeable
52    ///
53    ///
54    /// #### `has-subtitle`
55    ///  If [`true`], reserve space for a subtitle, even if none
56    /// is currently set.
57    ///
58    /// Readable | Writeable
59    ///
60    ///
61    /// #### `show-close-button`
62    ///  Whether to show window decorations.
63    ///
64    /// Which buttons are actually shown and where is determined
65    /// by the [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] property, and by
66    /// the state of the window (e.g. a close button will not be
67    /// shown if the window can't be closed).
68    ///
69    /// Readable | Writeable
70    ///
71    ///
72    /// #### `spacing`
73    ///  Readable | Writeable
74    ///
75    ///
76    /// #### `subtitle`
77    ///  Readable | Writeable
78    ///
79    ///
80    /// #### `title`
81    ///  Readable | Writeable
82    /// <details><summary><h4>Container</h4></summary>
83    ///
84    ///
85    /// #### `border-width`
86    ///  Readable | Writeable
87    ///
88    ///
89    /// #### `child`
90    ///  Writeable
91    ///
92    ///
93    /// #### `resize-mode`
94    ///  Readable | Writeable
95    /// </details>
96    /// <details><summary><h4>Widget</h4></summary>
97    ///
98    ///
99    /// #### `app-paintable`
100    ///  Readable | Writeable
101    ///
102    ///
103    /// #### `can-default`
104    ///  Readable | Writeable
105    ///
106    ///
107    /// #### `can-focus`
108    ///  Readable | Writeable
109    ///
110    ///
111    /// #### `composite-child`
112    ///  Readable
113    ///
114    ///
115    /// #### `double-buffered`
116    ///  Whether the widget is double buffered.
117    ///
118    /// Readable | Writeable
119    ///
120    ///
121    /// #### `events`
122    ///  Readable | Writeable
123    ///
124    ///
125    /// #### `expand`
126    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
127    ///
128    /// Readable | Writeable
129    ///
130    ///
131    /// #### `focus-on-click`
132    ///  Whether the widget should grab focus when it is clicked with the mouse.
133    ///
134    /// This property is only relevant for widgets that can take focus.
135    ///
136    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
137    /// GtkComboBox) implemented this property individually.
138    ///
139    /// Readable | Writeable
140    ///
141    ///
142    /// #### `halign`
143    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
144    ///
145    /// Readable | Writeable
146    ///
147    ///
148    /// #### `has-default`
149    ///  Readable | Writeable
150    ///
151    ///
152    /// #### `has-focus`
153    ///  Readable | Writeable
154    ///
155    ///
156    /// #### `has-tooltip`
157    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
158    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
159    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
160    /// whether it will provide a tooltip or not.
161    ///
162    /// Note that setting this property to [`true`] for the first time will change
163    /// the event masks of the GdkWindows of this widget to include leave-notify
164    /// and motion-notify events. This cannot and will not be undone when the
165    /// property is set to [`false`] again.
166    ///
167    /// Readable | Writeable
168    ///
169    ///
170    /// #### `height-request`
171    ///  Readable | Writeable
172    ///
173    ///
174    /// #### `hexpand`
175    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
176    ///
177    /// Readable | Writeable
178    ///
179    ///
180    /// #### `hexpand-set`
181    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
182    ///
183    /// Readable | Writeable
184    ///
185    ///
186    /// #### `is-focus`
187    ///  Readable | Writeable
188    ///
189    ///
190    /// #### `margin`
191    ///  Sets all four sides' margin at once. If read, returns max
192    /// margin on any side.
193    ///
194    /// Readable | Writeable
195    ///
196    ///
197    /// #### `margin-bottom`
198    ///  Margin on bottom side of widget.
199    ///
200    /// This property adds margin outside of the widget's normal size
201    /// request, the margin will be added in addition to the size from
202    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
203    ///
204    /// Readable | Writeable
205    ///
206    ///
207    /// #### `margin-end`
208    ///  Margin on end of widget, horizontally. This property supports
209    /// left-to-right and right-to-left text directions.
210    ///
211    /// This property adds margin outside of the widget's normal size
212    /// request, the margin will be added in addition to the size from
213    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
214    ///
215    /// Readable | Writeable
216    ///
217    ///
218    /// #### `margin-left`
219    ///  Margin on left side of widget.
220    ///
221    /// This property adds margin outside of the widget's normal size
222    /// request, the margin will be added in addition to the size from
223    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
224    ///
225    /// Readable | Writeable
226    ///
227    ///
228    /// #### `margin-right`
229    ///  Margin on right side of widget.
230    ///
231    /// This property adds margin outside of the widget's normal size
232    /// request, the margin will be added in addition to the size from
233    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
234    ///
235    /// Readable | Writeable
236    ///
237    ///
238    /// #### `margin-start`
239    ///  Margin on start of widget, horizontally. This property supports
240    /// left-to-right and right-to-left text directions.
241    ///
242    /// This property adds margin outside of the widget's normal size
243    /// request, the margin will be added in addition to the size from
244    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
245    ///
246    /// Readable | Writeable
247    ///
248    ///
249    /// #### `margin-top`
250    ///  Margin on top side of widget.
251    ///
252    /// This property adds margin outside of the widget's normal size
253    /// request, the margin will be added in addition to the size from
254    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
255    ///
256    /// Readable | Writeable
257    ///
258    ///
259    /// #### `name`
260    ///  Readable | Writeable
261    ///
262    ///
263    /// #### `no-show-all`
264    ///  Readable | Writeable
265    ///
266    ///
267    /// #### `opacity`
268    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
269    /// more details about window opacity.
270    ///
271    /// Before 3.8 this was only available in GtkWindow
272    ///
273    /// Readable | Writeable
274    ///
275    ///
276    /// #### `parent`
277    ///  Readable | Writeable
278    ///
279    ///
280    /// #### `receives-default`
281    ///  Readable | Writeable
282    ///
283    ///
284    /// #### `scale-factor`
285    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
286    /// more details about widget scaling.
287    ///
288    /// Readable
289    ///
290    ///
291    /// #### `sensitive`
292    ///  Readable | Writeable
293    ///
294    ///
295    /// #### `style`
296    ///  The style of the widget, which contains information about how it will look (colors, etc).
297    ///
298    /// Readable | Writeable
299    ///
300    ///
301    /// #### `tooltip-markup`
302    ///  Sets the text of tooltip to be the given string, which is marked up
303    /// with the [Pango text markup language][PangoMarkupFormat].
304    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
305    ///
306    /// This is a convenience property which will take care of getting the
307    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
308    /// will automatically be set to [`true`] and there will be taken care of
309    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
310    ///
311    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
312    /// are set, the last one wins.
313    ///
314    /// Readable | Writeable
315    ///
316    ///
317    /// #### `tooltip-text`
318    ///  Sets the text of tooltip to be the given string.
319    ///
320    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
321    ///
322    /// This is a convenience property which will take care of getting the
323    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
324    /// will automatically be set to [`true`] and there will be taken care of
325    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
326    ///
327    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
328    /// are set, the last one wins.
329    ///
330    /// Readable | Writeable
331    ///
332    ///
333    /// #### `valign`
334    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
335    ///
336    /// Readable | Writeable
337    ///
338    ///
339    /// #### `vexpand`
340    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
341    ///
342    /// Readable | Writeable
343    ///
344    ///
345    /// #### `vexpand-set`
346    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
347    ///
348    /// Readable | Writeable
349    ///
350    ///
351    /// #### `visible`
352    ///  Readable | Writeable
353    ///
354    ///
355    /// #### `width-request`
356    ///  Readable | Writeable
357    ///
358    ///
359    /// #### `window`
360    ///  The widget's window if it is realized, [`None`] otherwise.
361    ///
362    /// Readable
363    /// </details>
364    ///
365    /// # Implements
366    ///
367    /// [`HeaderBarExt`][trait@crate::prelude::HeaderBarExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
368    #[doc(alias = "GtkHeaderBar")]
369    pub struct HeaderBar(Object<ffi::GtkHeaderBar, ffi::GtkHeaderBarClass>) @extends Container, Widget, @implements Buildable;
370
371    match fn {
372        type_ => || ffi::gtk_header_bar_get_type(),
373    }
374}
375
376impl HeaderBar {
377    pub const NONE: Option<&'static HeaderBar> = None;
378
379    /// Creates a new [`HeaderBar`][crate::HeaderBar] widget.
380    ///
381    /// # Returns
382    ///
383    /// a new [`HeaderBar`][crate::HeaderBar]
384    #[doc(alias = "gtk_header_bar_new")]
385    pub fn new() -> HeaderBar {
386        assert_initialized_main_thread!();
387        unsafe { Widget::from_glib_none(ffi::gtk_header_bar_new()).unsafe_cast() }
388    }
389
390    // rustdoc-stripper-ignore-next
391    /// Creates a new builder-pattern struct instance to construct [`HeaderBar`] objects.
392    ///
393    /// This method returns an instance of [`HeaderBarBuilder`](crate::builders::HeaderBarBuilder) which can be used to create [`HeaderBar`] objects.
394    pub fn builder() -> HeaderBarBuilder {
395        HeaderBarBuilder::new()
396    }
397}
398
399impl Default for HeaderBar {
400    fn default() -> Self {
401        Self::new()
402    }
403}
404
405// rustdoc-stripper-ignore-next
406/// A [builder-pattern] type to construct [`HeaderBar`] objects.
407///
408/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
409#[must_use = "The builder must be built to be used"]
410pub struct HeaderBarBuilder {
411    builder: glib::object::ObjectBuilder<'static, HeaderBar>,
412}
413
414impl HeaderBarBuilder {
415    fn new() -> Self {
416        Self {
417            builder: glib::object::Object::builder(),
418        }
419    }
420
421    pub fn custom_title(self, custom_title: &impl IsA<Widget>) -> Self {
422        Self {
423            builder: self
424                .builder
425                .property("custom-title", custom_title.clone().upcast()),
426        }
427    }
428
429    /// The decoration layout for buttons. If this property is
430    /// not set, the [`gtk-decoration-layout`][struct@crate::Settings#gtk-decoration-layout] setting
431    /// is used.
432    ///
433    /// See [`HeaderBarExt::set_decoration_layout()`][crate::prelude::HeaderBarExt::set_decoration_layout()] for information
434    /// about the format of this string.
435    pub fn decoration_layout(self, decoration_layout: impl Into<glib::GString>) -> Self {
436        Self {
437            builder: self
438                .builder
439                .property("decoration-layout", decoration_layout.into()),
440        }
441    }
442
443    /// Set to [`true`] if [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] is set.
444    pub fn decoration_layout_set(self, decoration_layout_set: bool) -> Self {
445        Self {
446            builder: self
447                .builder
448                .property("decoration-layout-set", decoration_layout_set),
449        }
450    }
451
452    /// If [`true`], reserve space for a subtitle, even if none
453    /// is currently set.
454    pub fn has_subtitle(self, has_subtitle: bool) -> Self {
455        Self {
456            builder: self.builder.property("has-subtitle", has_subtitle),
457        }
458    }
459
460    /// Whether to show window decorations.
461    ///
462    /// Which buttons are actually shown and where is determined
463    /// by the [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] property, and by
464    /// the state of the window (e.g. a close button will not be
465    /// shown if the window can't be closed).
466    pub fn show_close_button(self, show_close_button: bool) -> Self {
467        Self {
468            builder: self
469                .builder
470                .property("show-close-button", show_close_button),
471        }
472    }
473
474    pub fn spacing(self, spacing: i32) -> Self {
475        Self {
476            builder: self.builder.property("spacing", spacing),
477        }
478    }
479
480    pub fn subtitle(self, subtitle: impl Into<glib::GString>) -> Self {
481        Self {
482            builder: self.builder.property("subtitle", subtitle.into()),
483        }
484    }
485
486    pub fn title(self, title: impl Into<glib::GString>) -> Self {
487        Self {
488            builder: self.builder.property("title", title.into()),
489        }
490    }
491
492    pub fn border_width(self, border_width: u32) -> Self {
493        Self {
494            builder: self.builder.property("border-width", border_width),
495        }
496    }
497
498    pub fn child(self, child: &impl IsA<Widget>) -> Self {
499        Self {
500            builder: self.builder.property("child", child.clone().upcast()),
501        }
502    }
503
504    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
505        Self {
506            builder: self.builder.property("resize-mode", resize_mode),
507        }
508    }
509
510    pub fn app_paintable(self, app_paintable: bool) -> Self {
511        Self {
512            builder: self.builder.property("app-paintable", app_paintable),
513        }
514    }
515
516    pub fn can_default(self, can_default: bool) -> Self {
517        Self {
518            builder: self.builder.property("can-default", can_default),
519        }
520    }
521
522    pub fn can_focus(self, can_focus: bool) -> Self {
523        Self {
524            builder: self.builder.property("can-focus", can_focus),
525        }
526    }
527
528    pub fn events(self, events: gdk::EventMask) -> Self {
529        Self {
530            builder: self.builder.property("events", events),
531        }
532    }
533
534    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
535    pub fn expand(self, expand: bool) -> Self {
536        Self {
537            builder: self.builder.property("expand", expand),
538        }
539    }
540
541    /// Whether the widget should grab focus when it is clicked with the mouse.
542    ///
543    /// This property is only relevant for widgets that can take focus.
544    ///
545    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
546    /// GtkComboBox) implemented this property individually.
547    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
548        Self {
549            builder: self.builder.property("focus-on-click", focus_on_click),
550        }
551    }
552
553    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
554    pub fn halign(self, halign: Align) -> Self {
555        Self {
556            builder: self.builder.property("halign", halign),
557        }
558    }
559
560    pub fn has_default(self, has_default: bool) -> Self {
561        Self {
562            builder: self.builder.property("has-default", has_default),
563        }
564    }
565
566    pub fn has_focus(self, has_focus: bool) -> Self {
567        Self {
568            builder: self.builder.property("has-focus", has_focus),
569        }
570    }
571
572    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
573    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
574    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
575    /// whether it will provide a tooltip or not.
576    ///
577    /// Note that setting this property to [`true`] for the first time will change
578    /// the event masks of the GdkWindows of this widget to include leave-notify
579    /// and motion-notify events. This cannot and will not be undone when the
580    /// property is set to [`false`] again.
581    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
582        Self {
583            builder: self.builder.property("has-tooltip", has_tooltip),
584        }
585    }
586
587    pub fn height_request(self, height_request: i32) -> Self {
588        Self {
589            builder: self.builder.property("height-request", height_request),
590        }
591    }
592
593    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
594    pub fn hexpand(self, hexpand: bool) -> Self {
595        Self {
596            builder: self.builder.property("hexpand", hexpand),
597        }
598    }
599
600    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
601    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
602        Self {
603            builder: self.builder.property("hexpand-set", hexpand_set),
604        }
605    }
606
607    pub fn is_focus(self, is_focus: bool) -> Self {
608        Self {
609            builder: self.builder.property("is-focus", is_focus),
610        }
611    }
612
613    /// Sets all four sides' margin at once. If read, returns max
614    /// margin on any side.
615    pub fn margin(self, margin: i32) -> Self {
616        Self {
617            builder: self.builder.property("margin", margin),
618        }
619    }
620
621    /// Margin on bottom side of widget.
622    ///
623    /// This property adds margin outside of the widget's normal size
624    /// request, the margin will be added in addition to the size from
625    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
626    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
627        Self {
628            builder: self.builder.property("margin-bottom", margin_bottom),
629        }
630    }
631
632    /// Margin on end of widget, horizontally. This property supports
633    /// left-to-right and right-to-left text directions.
634    ///
635    /// This property adds margin outside of the widget's normal size
636    /// request, the margin will be added in addition to the size from
637    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
638    pub fn margin_end(self, margin_end: i32) -> Self {
639        Self {
640            builder: self.builder.property("margin-end", margin_end),
641        }
642    }
643
644    /// Margin on start of widget, horizontally. This property supports
645    /// left-to-right and right-to-left text directions.
646    ///
647    /// This property adds margin outside of the widget's normal size
648    /// request, the margin will be added in addition to the size from
649    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
650    pub fn margin_start(self, margin_start: i32) -> Self {
651        Self {
652            builder: self.builder.property("margin-start", margin_start),
653        }
654    }
655
656    /// Margin on top side of widget.
657    ///
658    /// This property adds margin outside of the widget's normal size
659    /// request, the margin will be added in addition to the size from
660    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
661    pub fn margin_top(self, margin_top: i32) -> Self {
662        Self {
663            builder: self.builder.property("margin-top", margin_top),
664        }
665    }
666
667    pub fn name(self, name: impl Into<glib::GString>) -> Self {
668        Self {
669            builder: self.builder.property("name", name.into()),
670        }
671    }
672
673    pub fn no_show_all(self, no_show_all: bool) -> Self {
674        Self {
675            builder: self.builder.property("no-show-all", no_show_all),
676        }
677    }
678
679    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
680    /// more details about window opacity.
681    ///
682    /// Before 3.8 this was only available in GtkWindow
683    pub fn opacity(self, opacity: f64) -> Self {
684        Self {
685            builder: self.builder.property("opacity", opacity),
686        }
687    }
688
689    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
690        Self {
691            builder: self.builder.property("parent", parent.clone().upcast()),
692        }
693    }
694
695    pub fn receives_default(self, receives_default: bool) -> Self {
696        Self {
697            builder: self.builder.property("receives-default", receives_default),
698        }
699    }
700
701    pub fn sensitive(self, sensitive: bool) -> Self {
702        Self {
703            builder: self.builder.property("sensitive", sensitive),
704        }
705    }
706
707    /// Sets the text of tooltip to be the given string, which is marked up
708    /// with the [Pango text markup language][PangoMarkupFormat].
709    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
710    ///
711    /// This is a convenience property which will take care of getting the
712    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
713    /// will automatically be set to [`true`] and there will be taken care of
714    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
715    ///
716    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
717    /// are set, the last one wins.
718    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
719        Self {
720            builder: self
721                .builder
722                .property("tooltip-markup", tooltip_markup.into()),
723        }
724    }
725
726    /// Sets the text of tooltip to be the given string.
727    ///
728    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
729    ///
730    /// This is a convenience property which will take care of getting the
731    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
732    /// will automatically be set to [`true`] and there will be taken care of
733    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
734    ///
735    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
736    /// are set, the last one wins.
737    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
738        Self {
739            builder: self.builder.property("tooltip-text", tooltip_text.into()),
740        }
741    }
742
743    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
744    pub fn valign(self, valign: Align) -> Self {
745        Self {
746            builder: self.builder.property("valign", valign),
747        }
748    }
749
750    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
751    pub fn vexpand(self, vexpand: bool) -> Self {
752        Self {
753            builder: self.builder.property("vexpand", vexpand),
754        }
755    }
756
757    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
758    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
759        Self {
760            builder: self.builder.property("vexpand-set", vexpand_set),
761        }
762    }
763
764    pub fn visible(self, visible: bool) -> Self {
765        Self {
766            builder: self.builder.property("visible", visible),
767        }
768    }
769
770    pub fn width_request(self, width_request: i32) -> Self {
771        Self {
772            builder: self.builder.property("width-request", width_request),
773        }
774    }
775
776    // rustdoc-stripper-ignore-next
777    /// Build the [`HeaderBar`].
778    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
779    pub fn build(self) -> HeaderBar {
780        self.builder.build()
781    }
782}
783
784mod sealed {
785    pub trait Sealed {}
786    impl<T: super::IsA<super::HeaderBar>> Sealed for T {}
787}
788
789/// Trait containing all [`struct@HeaderBar`] methods.
790///
791/// # Implementors
792///
793/// [`HeaderBar`][struct@crate::HeaderBar]
794pub trait HeaderBarExt: IsA<HeaderBar> + sealed::Sealed + 'static {
795    /// Retrieves the custom title widget of the header. See
796    /// [`set_custom_title()`][Self::set_custom_title()].
797    ///
798    /// # Returns
799    ///
800    /// the custom title widget
801    ///  of the header, or [`None`] if none has been set explicitly.
802    #[doc(alias = "gtk_header_bar_get_custom_title")]
803    #[doc(alias = "get_custom_title")]
804    fn custom_title(&self) -> Option<Widget> {
805        unsafe {
806            from_glib_none(ffi::gtk_header_bar_get_custom_title(
807                self.as_ref().to_glib_none().0,
808            ))
809        }
810    }
811
812    /// Gets the decoration layout set with
813    /// [`set_decoration_layout()`][Self::set_decoration_layout()].
814    ///
815    /// # Returns
816    ///
817    /// the decoration layout
818    #[doc(alias = "gtk_header_bar_get_decoration_layout")]
819    #[doc(alias = "get_decoration_layout")]
820    fn decoration_layout(&self) -> Option<glib::GString> {
821        unsafe {
822            from_glib_none(ffi::gtk_header_bar_get_decoration_layout(
823                self.as_ref().to_glib_none().0,
824            ))
825        }
826    }
827
828    /// Retrieves whether the header bar reserves space for
829    /// a subtitle, regardless if one is currently set or not.
830    ///
831    /// # Returns
832    ///
833    /// [`true`] if the header bar reserves space
834    ///  for a subtitle
835    #[doc(alias = "gtk_header_bar_get_has_subtitle")]
836    #[doc(alias = "get_has_subtitle")]
837    fn has_subtitle(&self) -> bool {
838        unsafe {
839            from_glib(ffi::gtk_header_bar_get_has_subtitle(
840                self.as_ref().to_glib_none().0,
841            ))
842        }
843    }
844
845    /// Returns whether this header bar shows the standard window
846    /// decorations.
847    ///
848    /// # Returns
849    ///
850    /// [`true`] if the decorations are shown
851    #[doc(alias = "gtk_header_bar_get_show_close_button")]
852    #[doc(alias = "get_show_close_button")]
853    fn shows_close_button(&self) -> bool {
854        unsafe {
855            from_glib(ffi::gtk_header_bar_get_show_close_button(
856                self.as_ref().to_glib_none().0,
857            ))
858        }
859    }
860
861    /// Retrieves the subtitle of the header. See [`set_subtitle()`][Self::set_subtitle()].
862    ///
863    /// # Returns
864    ///
865    /// the subtitle of the header, or [`None`] if none has
866    ///  been set explicitly. The returned string is owned by the widget
867    ///  and must not be modified or freed.
868    #[doc(alias = "gtk_header_bar_get_subtitle")]
869    #[doc(alias = "get_subtitle")]
870    fn subtitle(&self) -> Option<glib::GString> {
871        unsafe {
872            from_glib_none(ffi::gtk_header_bar_get_subtitle(
873                self.as_ref().to_glib_none().0,
874            ))
875        }
876    }
877
878    /// Retrieves the title of the header. See [`set_title()`][Self::set_title()].
879    ///
880    /// # Returns
881    ///
882    /// the title of the header, or [`None`] if none has
883    ///  been set explicitly. The returned string is owned by the widget
884    ///  and must not be modified or freed.
885    #[doc(alias = "gtk_header_bar_get_title")]
886    #[doc(alias = "get_title")]
887    fn title(&self) -> Option<glib::GString> {
888        unsafe {
889            from_glib_none(ffi::gtk_header_bar_get_title(
890                self.as_ref().to_glib_none().0,
891            ))
892        }
893    }
894
895    /// Adds `child` to `self`, packed with reference to the
896    /// end of the `self`.
897    /// ## `child`
898    /// the [`Widget`][crate::Widget] to be added to `self`
899    #[doc(alias = "gtk_header_bar_pack_end")]
900    fn pack_end(&self, child: &impl IsA<Widget>) {
901        unsafe {
902            ffi::gtk_header_bar_pack_end(
903                self.as_ref().to_glib_none().0,
904                child.as_ref().to_glib_none().0,
905            );
906        }
907    }
908
909    /// Adds `child` to `self`, packed with reference to the
910    /// start of the `self`.
911    /// ## `child`
912    /// the [`Widget`][crate::Widget] to be added to `self`
913    #[doc(alias = "gtk_header_bar_pack_start")]
914    fn pack_start(&self, child: &impl IsA<Widget>) {
915        unsafe {
916            ffi::gtk_header_bar_pack_start(
917                self.as_ref().to_glib_none().0,
918                child.as_ref().to_glib_none().0,
919            );
920        }
921    }
922
923    /// Sets a custom title for the [`HeaderBar`][crate::HeaderBar].
924    ///
925    /// The title should help a user identify the current view. This
926    /// supersedes any title set by [`set_title()`][Self::set_title()] or
927    /// [`set_subtitle()`][Self::set_subtitle()]. To achieve the same style as
928    /// the builtin title and subtitle, use the “title” and “subtitle”
929    /// style classes.
930    ///
931    /// You should set the custom title to [`None`], for the header title
932    /// label to be visible again.
933    /// ## `title_widget`
934    /// a custom widget to use for a title
935    #[doc(alias = "gtk_header_bar_set_custom_title")]
936    fn set_custom_title(&self, title_widget: Option<&impl IsA<Widget>>) {
937        unsafe {
938            ffi::gtk_header_bar_set_custom_title(
939                self.as_ref().to_glib_none().0,
940                title_widget.map(|p| p.as_ref()).to_glib_none().0,
941            );
942        }
943    }
944
945    /// Sets the decoration layout for this header bar, overriding
946    /// the [`gtk-decoration-layout`][struct@crate::Settings#gtk-decoration-layout] setting.
947    ///
948    /// There can be valid reasons for overriding the setting, such
949    /// as a header bar design that does not allow for buttons to take
950    /// room on the right, or only offers room for a single close button.
951    /// Split header bars are another example for overriding the
952    /// setting.
953    ///
954    /// The format of the string is button names, separated by commas.
955    /// A colon separates the buttons that should appear on the left
956    /// from those on the right. Recognized button names are minimize,
957    /// maximize, close, icon (the window icon) and menu (a menu button
958    /// for the fallback app menu).
959    ///
960    /// For example, “menu:minimize,maximize,close” specifies a menu
961    /// on the left, and minimize, maximize and close buttons on the right.
962    /// ## `layout`
963    /// a decoration layout, or [`None`] to
964    ///  unset the layout
965    #[doc(alias = "gtk_header_bar_set_decoration_layout")]
966    fn set_decoration_layout(&self, layout: Option<&str>) {
967        unsafe {
968            ffi::gtk_header_bar_set_decoration_layout(
969                self.as_ref().to_glib_none().0,
970                layout.to_glib_none().0,
971            );
972        }
973    }
974
975    /// Sets whether the header bar should reserve space
976    /// for a subtitle, even if none is currently set.
977    /// ## `setting`
978    /// [`true`] to reserve space for a subtitle
979    #[doc(alias = "gtk_header_bar_set_has_subtitle")]
980    fn set_has_subtitle(&self, setting: bool) {
981        unsafe {
982            ffi::gtk_header_bar_set_has_subtitle(
983                self.as_ref().to_glib_none().0,
984                setting.into_glib(),
985            );
986        }
987    }
988
989    /// Sets whether this header bar shows the standard window decorations,
990    /// including close, maximize, and minimize.
991    /// ## `setting`
992    /// [`true`] to show standard window decorations
993    #[doc(alias = "gtk_header_bar_set_show_close_button")]
994    fn set_show_close_button(&self, setting: bool) {
995        unsafe {
996            ffi::gtk_header_bar_set_show_close_button(
997                self.as_ref().to_glib_none().0,
998                setting.into_glib(),
999            );
1000        }
1001    }
1002
1003    /// Sets the subtitle of the [`HeaderBar`][crate::HeaderBar]. The title should give a user
1004    /// an additional detail to help him identify the current view.
1005    ///
1006    /// Note that GtkHeaderBar by default reserves room for the subtitle,
1007    /// even if none is currently set. If this is not desired, set the
1008    /// [`has-subtitle`][struct@crate::HeaderBar#has-subtitle] property to [`false`].
1009    /// ## `subtitle`
1010    /// a subtitle, or [`None`]
1011    #[doc(alias = "gtk_header_bar_set_subtitle")]
1012    fn set_subtitle(&self, subtitle: Option<&str>) {
1013        unsafe {
1014            ffi::gtk_header_bar_set_subtitle(
1015                self.as_ref().to_glib_none().0,
1016                subtitle.to_glib_none().0,
1017            );
1018        }
1019    }
1020
1021    /// Sets the title of the [`HeaderBar`][crate::HeaderBar]. The title should help a user
1022    /// identify the current view. A good title should not include the
1023    /// application name.
1024    /// ## `title`
1025    /// a title, or [`None`]
1026    #[doc(alias = "gtk_header_bar_set_title")]
1027    fn set_title(&self, title: Option<&str>) {
1028        unsafe {
1029            ffi::gtk_header_bar_set_title(self.as_ref().to_glib_none().0, title.to_glib_none().0);
1030        }
1031    }
1032
1033    /// Set to [`true`] if [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] is set.
1034    #[doc(alias = "decoration-layout-set")]
1035    fn is_decoration_layout_set(&self) -> bool {
1036        ObjectExt::property(self.as_ref(), "decoration-layout-set")
1037    }
1038
1039    /// Set to [`true`] if [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] is set.
1040    #[doc(alias = "decoration-layout-set")]
1041    fn set_decoration_layout_set(&self, decoration_layout_set: bool) {
1042        ObjectExt::set_property(
1043            self.as_ref(),
1044            "decoration-layout-set",
1045            decoration_layout_set,
1046        )
1047    }
1048
1049    fn spacing(&self) -> i32 {
1050        ObjectExt::property(self.as_ref(), "spacing")
1051    }
1052
1053    fn set_spacing(&self, spacing: i32) {
1054        ObjectExt::set_property(self.as_ref(), "spacing", spacing)
1055    }
1056
1057    #[doc(alias = "child.pack-type")]
1058    fn child_pack_type<T: IsA<crate::Widget>>(&self, item: &T) -> PackType {
1059        crate::prelude::ContainerExtManual::child_property(
1060            self.as_ref(),
1061            &item.clone().upcast(),
1062            "pack-type",
1063        )
1064    }
1065
1066    #[doc(alias = "child.pack-type")]
1067    fn set_child_pack_type<T: IsA<crate::Widget>>(&self, item: &T, pack_type: PackType) {
1068        crate::prelude::ContainerExtManual::child_set_property(
1069            self.as_ref(),
1070            &item.clone().upcast(),
1071            "pack-type",
1072            &pack_type,
1073        )
1074    }
1075
1076    fn child_position<T: IsA<crate::Widget>>(&self, item: &T) -> i32 {
1077        crate::prelude::ContainerExtManual::child_property(
1078            self.as_ref(),
1079            &item.clone().upcast(),
1080            "position",
1081        )
1082    }
1083
1084    fn set_child_position<T: IsA<crate::Widget>>(&self, item: &T, position: i32) {
1085        crate::prelude::ContainerExtManual::child_set_property(
1086            self.as_ref(),
1087            &item.clone().upcast(),
1088            "position",
1089            &position,
1090        )
1091    }
1092
1093    #[doc(alias = "custom-title")]
1094    fn connect_custom_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1095        unsafe extern "C" fn notify_custom_title_trampoline<
1096            P: IsA<HeaderBar>,
1097            F: Fn(&P) + 'static,
1098        >(
1099            this: *mut ffi::GtkHeaderBar,
1100            _param_spec: glib::ffi::gpointer,
1101            f: glib::ffi::gpointer,
1102        ) {
1103            let f: &F = &*(f as *const F);
1104            f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1105        }
1106        unsafe {
1107            let f: Box_<F> = Box_::new(f);
1108            connect_raw(
1109                self.as_ptr() as *mut _,
1110                b"notify::custom-title\0".as_ptr() as *const _,
1111                Some(transmute::<_, unsafe extern "C" fn()>(
1112                    notify_custom_title_trampoline::<Self, F> as *const (),
1113                )),
1114                Box_::into_raw(f),
1115            )
1116        }
1117    }
1118
1119    #[doc(alias = "decoration-layout")]
1120    fn connect_decoration_layout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1121        unsafe extern "C" fn notify_decoration_layout_trampoline<
1122            P: IsA<HeaderBar>,
1123            F: Fn(&P) + 'static,
1124        >(
1125            this: *mut ffi::GtkHeaderBar,
1126            _param_spec: glib::ffi::gpointer,
1127            f: glib::ffi::gpointer,
1128        ) {
1129            let f: &F = &*(f as *const F);
1130            f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1131        }
1132        unsafe {
1133            let f: Box_<F> = Box_::new(f);
1134            connect_raw(
1135                self.as_ptr() as *mut _,
1136                b"notify::decoration-layout\0".as_ptr() as *const _,
1137                Some(transmute::<_, unsafe extern "C" fn()>(
1138                    notify_decoration_layout_trampoline::<Self, F> as *const (),
1139                )),
1140                Box_::into_raw(f),
1141            )
1142        }
1143    }
1144
1145    #[doc(alias = "decoration-layout-set")]
1146    fn connect_decoration_layout_set_notify<F: Fn(&Self) + 'static>(
1147        &self,
1148        f: F,
1149    ) -> SignalHandlerId {
1150        unsafe extern "C" fn notify_decoration_layout_set_trampoline<
1151            P: IsA<HeaderBar>,
1152            F: Fn(&P) + 'static,
1153        >(
1154            this: *mut ffi::GtkHeaderBar,
1155            _param_spec: glib::ffi::gpointer,
1156            f: glib::ffi::gpointer,
1157        ) {
1158            let f: &F = &*(f as *const F);
1159            f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1160        }
1161        unsafe {
1162            let f: Box_<F> = Box_::new(f);
1163            connect_raw(
1164                self.as_ptr() as *mut _,
1165                b"notify::decoration-layout-set\0".as_ptr() as *const _,
1166                Some(transmute::<_, unsafe extern "C" fn()>(
1167                    notify_decoration_layout_set_trampoline::<Self, F> as *const (),
1168                )),
1169                Box_::into_raw(f),
1170            )
1171        }
1172    }
1173
1174    #[doc(alias = "has-subtitle")]
1175    fn connect_has_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1176        unsafe extern "C" fn notify_has_subtitle_trampoline<
1177            P: IsA<HeaderBar>,
1178            F: Fn(&P) + 'static,
1179        >(
1180            this: *mut ffi::GtkHeaderBar,
1181            _param_spec: glib::ffi::gpointer,
1182            f: glib::ffi::gpointer,
1183        ) {
1184            let f: &F = &*(f as *const F);
1185            f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1186        }
1187        unsafe {
1188            let f: Box_<F> = Box_::new(f);
1189            connect_raw(
1190                self.as_ptr() as *mut _,
1191                b"notify::has-subtitle\0".as_ptr() as *const _,
1192                Some(transmute::<_, unsafe extern "C" fn()>(
1193                    notify_has_subtitle_trampoline::<Self, F> as *const (),
1194                )),
1195                Box_::into_raw(f),
1196            )
1197        }
1198    }
1199
1200    #[doc(alias = "show-close-button")]
1201    fn connect_show_close_button_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1202        unsafe extern "C" fn notify_show_close_button_trampoline<
1203            P: IsA<HeaderBar>,
1204            F: Fn(&P) + 'static,
1205        >(
1206            this: *mut ffi::GtkHeaderBar,
1207            _param_spec: glib::ffi::gpointer,
1208            f: glib::ffi::gpointer,
1209        ) {
1210            let f: &F = &*(f as *const F);
1211            f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1212        }
1213        unsafe {
1214            let f: Box_<F> = Box_::new(f);
1215            connect_raw(
1216                self.as_ptr() as *mut _,
1217                b"notify::show-close-button\0".as_ptr() as *const _,
1218                Some(transmute::<_, unsafe extern "C" fn()>(
1219                    notify_show_close_button_trampoline::<Self, F> as *const (),
1220                )),
1221                Box_::into_raw(f),
1222            )
1223        }
1224    }
1225
1226    #[doc(alias = "spacing")]
1227    fn connect_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1228        unsafe extern "C" fn notify_spacing_trampoline<P: IsA<HeaderBar>, F: Fn(&P) + 'static>(
1229            this: *mut ffi::GtkHeaderBar,
1230            _param_spec: glib::ffi::gpointer,
1231            f: glib::ffi::gpointer,
1232        ) {
1233            let f: &F = &*(f as *const F);
1234            f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1235        }
1236        unsafe {
1237            let f: Box_<F> = Box_::new(f);
1238            connect_raw(
1239                self.as_ptr() as *mut _,
1240                b"notify::spacing\0".as_ptr() as *const _,
1241                Some(transmute::<_, unsafe extern "C" fn()>(
1242                    notify_spacing_trampoline::<Self, F> as *const (),
1243                )),
1244                Box_::into_raw(f),
1245            )
1246        }
1247    }
1248
1249    #[doc(alias = "subtitle")]
1250    fn connect_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1251        unsafe extern "C" fn notify_subtitle_trampoline<P: IsA<HeaderBar>, F: Fn(&P) + 'static>(
1252            this: *mut ffi::GtkHeaderBar,
1253            _param_spec: glib::ffi::gpointer,
1254            f: glib::ffi::gpointer,
1255        ) {
1256            let f: &F = &*(f as *const F);
1257            f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1258        }
1259        unsafe {
1260            let f: Box_<F> = Box_::new(f);
1261            connect_raw(
1262                self.as_ptr() as *mut _,
1263                b"notify::subtitle\0".as_ptr() as *const _,
1264                Some(transmute::<_, unsafe extern "C" fn()>(
1265                    notify_subtitle_trampoline::<Self, F> as *const (),
1266                )),
1267                Box_::into_raw(f),
1268            )
1269        }
1270    }
1271
1272    #[doc(alias = "title")]
1273    fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1274        unsafe extern "C" fn notify_title_trampoline<P: IsA<HeaderBar>, F: Fn(&P) + 'static>(
1275            this: *mut ffi::GtkHeaderBar,
1276            _param_spec: glib::ffi::gpointer,
1277            f: glib::ffi::gpointer,
1278        ) {
1279            let f: &F = &*(f as *const F);
1280            f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1281        }
1282        unsafe {
1283            let f: Box_<F> = Box_::new(f);
1284            connect_raw(
1285                self.as_ptr() as *mut _,
1286                b"notify::title\0".as_ptr() as *const _,
1287                Some(transmute::<_, unsafe extern "C" fn()>(
1288                    notify_title_trampoline::<Self, F> as *const (),
1289                )),
1290                Box_::into_raw(f),
1291            )
1292        }
1293    }
1294}
1295
1296impl<O: IsA<HeaderBar>> HeaderBarExt for O {}
1297
1298impl fmt::Display for HeaderBar {
1299    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1300        f.write_str("HeaderBar")
1301    }
1302}