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, ffi};
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
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 | Writable
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 | Writable
46 ///
47 ///
48 /// #### `decoration-layout-set`
49 /// Set to [`true`] if [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] is set.
50 ///
51 /// Readable | Writable
52 ///
53 ///
54 /// #### `has-subtitle`
55 /// If [`true`], reserve space for a subtitle, even if none
56 /// is currently set.
57 ///
58 /// Readable | Writable
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 | Writable
70 ///
71 ///
72 /// #### `spacing`
73 /// Readable | Writable
74 ///
75 ///
76 /// #### `subtitle`
77 /// Readable | Writable
78 ///
79 ///
80 /// #### `title`
81 /// Readable | Writable
82 /// <details><summary><h4>Container</h4></summary>
83 ///
84 ///
85 /// #### `border-width`
86 /// Readable | Writable
87 ///
88 ///
89 /// #### `child`
90 /// Writable
91 ///
92 ///
93 /// #### `resize-mode`
94 /// Readable | Writable
95 /// </details>
96 /// <details><summary><h4>Widget</h4></summary>
97 ///
98 ///
99 /// #### `app-paintable`
100 /// Readable | Writable
101 ///
102 ///
103 /// #### `can-default`
104 /// Readable | Writable
105 ///
106 ///
107 /// #### `can-focus`
108 /// Readable | Writable
109 ///
110 ///
111 /// #### `composite-child`
112 /// Readable
113 ///
114 ///
115 /// #### `double-buffered`
116 /// Whether the widget is double buffered.
117 ///
118 /// Readable | Writable
119 ///
120 ///
121 /// #### `events`
122 /// Readable | Writable
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 | Writable
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 | Writable
140 ///
141 ///
142 /// #### `halign`
143 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
144 ///
145 /// Readable | Writable
146 ///
147 ///
148 /// #### `has-default`
149 /// Readable | Writable
150 ///
151 ///
152 /// #### `has-focus`
153 /// Readable | Writable
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 | Writable
168 ///
169 ///
170 /// #### `height-request`
171 /// Readable | Writable
172 ///
173 ///
174 /// #### `hexpand`
175 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
176 ///
177 /// Readable | Writable
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 | Writable
184 ///
185 ///
186 /// #### `is-focus`
187 /// Readable | Writable
188 ///
189 ///
190 /// #### `margin`
191 /// Sets all four sides' margin at once. If read, returns max
192 /// margin on any side.
193 ///
194 /// Readable | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
257 ///
258 ///
259 /// #### `name`
260 /// Readable | Writable
261 ///
262 ///
263 /// #### `no-show-all`
264 /// Readable | Writable
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 | Writable
274 ///
275 ///
276 /// #### `parent`
277 /// Readable | Writable
278 ///
279 ///
280 /// #### `receives-default`
281 /// Readable | Writable
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 | Writable
293 ///
294 ///
295 /// #### `style`
296 /// The style of the widget, which contains information about how it will look (colors, etc).
297 ///
298 /// Readable | Writable
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 | Writable
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 | Writable
331 ///
332 ///
333 /// #### `valign`
334 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
335 ///
336 /// Readable | Writable
337 ///
338 ///
339 /// #### `vexpand`
340 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
341 ///
342 /// Readable | Writable
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 | Writable
349 ///
350 ///
351 /// #### `visible`
352 /// Readable | Writable
353 ///
354 ///
355 /// #### `width-request`
356 /// Readable | Writable
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 assert_initialized_main_thread!();
781 self.builder.build()
782 }
783}
784
785/// Trait containing all [`struct@HeaderBar`] methods.
786///
787/// # Implementors
788///
789/// [`HeaderBar`][struct@crate::HeaderBar]
790pub trait HeaderBarExt: IsA<HeaderBar> + 'static {
791 /// Retrieves the custom title widget of the header. See
792 /// [`set_custom_title()`][Self::set_custom_title()].
793 ///
794 /// # Returns
795 ///
796 /// the custom title widget
797 /// of the header, or [`None`] if none has been set explicitly.
798 #[doc(alias = "gtk_header_bar_get_custom_title")]
799 #[doc(alias = "get_custom_title")]
800 #[doc(alias = "custom-title")]
801 fn custom_title(&self) -> Option<Widget> {
802 unsafe {
803 from_glib_none(ffi::gtk_header_bar_get_custom_title(
804 self.as_ref().to_glib_none().0,
805 ))
806 }
807 }
808
809 /// Gets the decoration layout set with
810 /// [`set_decoration_layout()`][Self::set_decoration_layout()].
811 ///
812 /// # Returns
813 ///
814 /// the decoration layout
815 #[doc(alias = "gtk_header_bar_get_decoration_layout")]
816 #[doc(alias = "get_decoration_layout")]
817 #[doc(alias = "decoration-layout")]
818 fn decoration_layout(&self) -> Option<glib::GString> {
819 unsafe {
820 from_glib_none(ffi::gtk_header_bar_get_decoration_layout(
821 self.as_ref().to_glib_none().0,
822 ))
823 }
824 }
825
826 /// Retrieves whether the header bar reserves space for
827 /// a subtitle, regardless if one is currently set or not.
828 ///
829 /// # Returns
830 ///
831 /// [`true`] if the header bar reserves space
832 /// for a subtitle
833 #[doc(alias = "gtk_header_bar_get_has_subtitle")]
834 #[doc(alias = "get_has_subtitle")]
835 #[doc(alias = "has-subtitle")]
836 fn has_subtitle(&self) -> bool {
837 unsafe {
838 from_glib(ffi::gtk_header_bar_get_has_subtitle(
839 self.as_ref().to_glib_none().0,
840 ))
841 }
842 }
843
844 /// Returns whether this header bar shows the standard window
845 /// decorations.
846 ///
847 /// # Returns
848 ///
849 /// [`true`] if the decorations are shown
850 #[doc(alias = "gtk_header_bar_get_show_close_button")]
851 #[doc(alias = "get_show_close_button")]
852 #[doc(alias = "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 #[doc(alias = "custom-title")]
937 fn set_custom_title(&self, title_widget: Option<&impl IsA<Widget>>) {
938 unsafe {
939 ffi::gtk_header_bar_set_custom_title(
940 self.as_ref().to_glib_none().0,
941 title_widget.map(|p| p.as_ref()).to_glib_none().0,
942 );
943 }
944 }
945
946 /// Sets the decoration layout for this header bar, overriding
947 /// the [`gtk-decoration-layout`][struct@crate::Settings#gtk-decoration-layout] setting.
948 ///
949 /// There can be valid reasons for overriding the setting, such
950 /// as a header bar design that does not allow for buttons to take
951 /// room on the right, or only offers room for a single close button.
952 /// Split header bars are another example for overriding the
953 /// setting.
954 ///
955 /// The format of the string is button names, separated by commas.
956 /// A colon separates the buttons that should appear on the left
957 /// from those on the right. Recognized button names are minimize,
958 /// maximize, close, icon (the window icon) and menu (a menu button
959 /// for the fallback app menu).
960 ///
961 /// For example, “menu:minimize,maximize,close” specifies a menu
962 /// on the left, and minimize, maximize and close buttons on the right.
963 /// ## `layout`
964 /// a decoration layout, or [`None`] to
965 /// unset the layout
966 #[doc(alias = "gtk_header_bar_set_decoration_layout")]
967 #[doc(alias = "decoration-layout")]
968 fn set_decoration_layout(&self, layout: Option<&str>) {
969 unsafe {
970 ffi::gtk_header_bar_set_decoration_layout(
971 self.as_ref().to_glib_none().0,
972 layout.to_glib_none().0,
973 );
974 }
975 }
976
977 /// Sets whether the header bar should reserve space
978 /// for a subtitle, even if none is currently set.
979 /// ## `setting`
980 /// [`true`] to reserve space for a subtitle
981 #[doc(alias = "gtk_header_bar_set_has_subtitle")]
982 #[doc(alias = "has-subtitle")]
983 fn set_has_subtitle(&self, setting: bool) {
984 unsafe {
985 ffi::gtk_header_bar_set_has_subtitle(
986 self.as_ref().to_glib_none().0,
987 setting.into_glib(),
988 );
989 }
990 }
991
992 /// Sets whether this header bar shows the standard window decorations,
993 /// including close, maximize, and minimize.
994 /// ## `setting`
995 /// [`true`] to show standard window decorations
996 #[doc(alias = "gtk_header_bar_set_show_close_button")]
997 #[doc(alias = "show-close-button")]
998 fn set_show_close_button(&self, setting: bool) {
999 unsafe {
1000 ffi::gtk_header_bar_set_show_close_button(
1001 self.as_ref().to_glib_none().0,
1002 setting.into_glib(),
1003 );
1004 }
1005 }
1006
1007 /// Sets the subtitle of the [`HeaderBar`][crate::HeaderBar]. The title should give a user
1008 /// an additional detail to help him identify the current view.
1009 ///
1010 /// Note that GtkHeaderBar by default reserves room for the subtitle,
1011 /// even if none is currently set. If this is not desired, set the
1012 /// [`has-subtitle`][struct@crate::HeaderBar#has-subtitle] property to [`false`].
1013 /// ## `subtitle`
1014 /// a subtitle, or [`None`]
1015 #[doc(alias = "gtk_header_bar_set_subtitle")]
1016 #[doc(alias = "subtitle")]
1017 fn set_subtitle(&self, subtitle: Option<&str>) {
1018 unsafe {
1019 ffi::gtk_header_bar_set_subtitle(
1020 self.as_ref().to_glib_none().0,
1021 subtitle.to_glib_none().0,
1022 );
1023 }
1024 }
1025
1026 /// Sets the title of the [`HeaderBar`][crate::HeaderBar]. The title should help a user
1027 /// identify the current view. A good title should not include the
1028 /// application name.
1029 /// ## `title`
1030 /// a title, or [`None`]
1031 #[doc(alias = "gtk_header_bar_set_title")]
1032 #[doc(alias = "title")]
1033 fn set_title(&self, title: Option<&str>) {
1034 unsafe {
1035 ffi::gtk_header_bar_set_title(self.as_ref().to_glib_none().0, title.to_glib_none().0);
1036 }
1037 }
1038
1039 /// Set to [`true`] if [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] is set.
1040 #[doc(alias = "decoration-layout-set")]
1041 fn is_decoration_layout_set(&self) -> bool {
1042 ObjectExt::property(self.as_ref(), "decoration-layout-set")
1043 }
1044
1045 /// Set to [`true`] if [`decoration-layout`][struct@crate::HeaderBar#decoration-layout] is set.
1046 #[doc(alias = "decoration-layout-set")]
1047 fn set_decoration_layout_set(&self, decoration_layout_set: bool) {
1048 ObjectExt::set_property(
1049 self.as_ref(),
1050 "decoration-layout-set",
1051 decoration_layout_set,
1052 )
1053 }
1054
1055 fn spacing(&self) -> i32 {
1056 ObjectExt::property(self.as_ref(), "spacing")
1057 }
1058
1059 fn set_spacing(&self, spacing: i32) {
1060 ObjectExt::set_property(self.as_ref(), "spacing", spacing)
1061 }
1062
1063 #[doc(alias = "child.pack-type")]
1064 fn child_pack_type<T: IsA<crate::Widget>>(&self, item: &T) -> PackType {
1065 crate::prelude::ContainerExtManual::child_property(
1066 self.as_ref(),
1067 &item.clone().upcast(),
1068 "pack-type",
1069 )
1070 }
1071
1072 #[doc(alias = "child.pack-type")]
1073 fn set_child_pack_type<T: IsA<crate::Widget>>(&self, item: &T, pack_type: PackType) {
1074 crate::prelude::ContainerExtManual::child_set_property(
1075 self.as_ref(),
1076 &item.clone().upcast(),
1077 "pack-type",
1078 &pack_type,
1079 )
1080 }
1081
1082 fn child_position<T: IsA<crate::Widget>>(&self, item: &T) -> i32 {
1083 crate::prelude::ContainerExtManual::child_property(
1084 self.as_ref(),
1085 &item.clone().upcast(),
1086 "position",
1087 )
1088 }
1089
1090 fn set_child_position<T: IsA<crate::Widget>>(&self, item: &T, position: i32) {
1091 crate::prelude::ContainerExtManual::child_set_property(
1092 self.as_ref(),
1093 &item.clone().upcast(),
1094 "position",
1095 &position,
1096 )
1097 }
1098
1099 #[doc(alias = "custom-title")]
1100 fn connect_custom_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1101 unsafe extern "C" fn notify_custom_title_trampoline<
1102 P: IsA<HeaderBar>,
1103 F: Fn(&P) + 'static,
1104 >(
1105 this: *mut ffi::GtkHeaderBar,
1106 _param_spec: glib::ffi::gpointer,
1107 f: glib::ffi::gpointer,
1108 ) {
1109 unsafe {
1110 let f: &F = &*(f as *const F);
1111 f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1112 }
1113 }
1114 unsafe {
1115 let f: Box_<F> = Box_::new(f);
1116 connect_raw(
1117 self.as_ptr() as *mut _,
1118 c"notify::custom-title".as_ptr(),
1119 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1120 notify_custom_title_trampoline::<Self, F> as *const (),
1121 )),
1122 Box_::into_raw(f),
1123 )
1124 }
1125 }
1126
1127 #[doc(alias = "decoration-layout")]
1128 fn connect_decoration_layout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1129 unsafe extern "C" fn notify_decoration_layout_trampoline<
1130 P: IsA<HeaderBar>,
1131 F: Fn(&P) + 'static,
1132 >(
1133 this: *mut ffi::GtkHeaderBar,
1134 _param_spec: glib::ffi::gpointer,
1135 f: glib::ffi::gpointer,
1136 ) {
1137 unsafe {
1138 let f: &F = &*(f as *const F);
1139 f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1140 }
1141 }
1142 unsafe {
1143 let f: Box_<F> = Box_::new(f);
1144 connect_raw(
1145 self.as_ptr() as *mut _,
1146 c"notify::decoration-layout".as_ptr(),
1147 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1148 notify_decoration_layout_trampoline::<Self, F> as *const (),
1149 )),
1150 Box_::into_raw(f),
1151 )
1152 }
1153 }
1154
1155 #[doc(alias = "decoration-layout-set")]
1156 fn connect_decoration_layout_set_notify<F: Fn(&Self) + 'static>(
1157 &self,
1158 f: F,
1159 ) -> SignalHandlerId {
1160 unsafe extern "C" fn notify_decoration_layout_set_trampoline<
1161 P: IsA<HeaderBar>,
1162 F: Fn(&P) + 'static,
1163 >(
1164 this: *mut ffi::GtkHeaderBar,
1165 _param_spec: glib::ffi::gpointer,
1166 f: glib::ffi::gpointer,
1167 ) {
1168 unsafe {
1169 let f: &F = &*(f as *const F);
1170 f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1171 }
1172 }
1173 unsafe {
1174 let f: Box_<F> = Box_::new(f);
1175 connect_raw(
1176 self.as_ptr() as *mut _,
1177 c"notify::decoration-layout-set".as_ptr(),
1178 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1179 notify_decoration_layout_set_trampoline::<Self, F> as *const (),
1180 )),
1181 Box_::into_raw(f),
1182 )
1183 }
1184 }
1185
1186 #[doc(alias = "has-subtitle")]
1187 fn connect_has_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1188 unsafe extern "C" fn notify_has_subtitle_trampoline<
1189 P: IsA<HeaderBar>,
1190 F: Fn(&P) + 'static,
1191 >(
1192 this: *mut ffi::GtkHeaderBar,
1193 _param_spec: glib::ffi::gpointer,
1194 f: glib::ffi::gpointer,
1195 ) {
1196 unsafe {
1197 let f: &F = &*(f as *const F);
1198 f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1199 }
1200 }
1201 unsafe {
1202 let f: Box_<F> = Box_::new(f);
1203 connect_raw(
1204 self.as_ptr() as *mut _,
1205 c"notify::has-subtitle".as_ptr(),
1206 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1207 notify_has_subtitle_trampoline::<Self, F> as *const (),
1208 )),
1209 Box_::into_raw(f),
1210 )
1211 }
1212 }
1213
1214 #[doc(alias = "show-close-button")]
1215 fn connect_show_close_button_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1216 unsafe extern "C" fn notify_show_close_button_trampoline<
1217 P: IsA<HeaderBar>,
1218 F: Fn(&P) + 'static,
1219 >(
1220 this: *mut ffi::GtkHeaderBar,
1221 _param_spec: glib::ffi::gpointer,
1222 f: glib::ffi::gpointer,
1223 ) {
1224 unsafe {
1225 let f: &F = &*(f as *const F);
1226 f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1227 }
1228 }
1229 unsafe {
1230 let f: Box_<F> = Box_::new(f);
1231 connect_raw(
1232 self.as_ptr() as *mut _,
1233 c"notify::show-close-button".as_ptr(),
1234 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1235 notify_show_close_button_trampoline::<Self, F> as *const (),
1236 )),
1237 Box_::into_raw(f),
1238 )
1239 }
1240 }
1241
1242 #[doc(alias = "spacing")]
1243 fn connect_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1244 unsafe extern "C" fn notify_spacing_trampoline<P: IsA<HeaderBar>, F: Fn(&P) + 'static>(
1245 this: *mut ffi::GtkHeaderBar,
1246 _param_spec: glib::ffi::gpointer,
1247 f: glib::ffi::gpointer,
1248 ) {
1249 unsafe {
1250 let f: &F = &*(f as *const F);
1251 f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1252 }
1253 }
1254 unsafe {
1255 let f: Box_<F> = Box_::new(f);
1256 connect_raw(
1257 self.as_ptr() as *mut _,
1258 c"notify::spacing".as_ptr(),
1259 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1260 notify_spacing_trampoline::<Self, F> as *const (),
1261 )),
1262 Box_::into_raw(f),
1263 )
1264 }
1265 }
1266
1267 #[doc(alias = "subtitle")]
1268 fn connect_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1269 unsafe extern "C" fn notify_subtitle_trampoline<P: IsA<HeaderBar>, F: Fn(&P) + 'static>(
1270 this: *mut ffi::GtkHeaderBar,
1271 _param_spec: glib::ffi::gpointer,
1272 f: glib::ffi::gpointer,
1273 ) {
1274 unsafe {
1275 let f: &F = &*(f as *const F);
1276 f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1277 }
1278 }
1279 unsafe {
1280 let f: Box_<F> = Box_::new(f);
1281 connect_raw(
1282 self.as_ptr() as *mut _,
1283 c"notify::subtitle".as_ptr(),
1284 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1285 notify_subtitle_trampoline::<Self, F> as *const (),
1286 )),
1287 Box_::into_raw(f),
1288 )
1289 }
1290 }
1291
1292 #[doc(alias = "title")]
1293 fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1294 unsafe extern "C" fn notify_title_trampoline<P: IsA<HeaderBar>, F: Fn(&P) + 'static>(
1295 this: *mut ffi::GtkHeaderBar,
1296 _param_spec: glib::ffi::gpointer,
1297 f: glib::ffi::gpointer,
1298 ) {
1299 unsafe {
1300 let f: &F = &*(f as *const F);
1301 f(HeaderBar::from_glib_borrow(this).unsafe_cast_ref())
1302 }
1303 }
1304 unsafe {
1305 let f: Box_<F> = Box_::new(f);
1306 connect_raw(
1307 self.as_ptr() as *mut _,
1308 c"notify::title".as_ptr(),
1309 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1310 notify_title_trampoline::<Self, F> as *const (),
1311 )),
1312 Box_::into_raw(f),
1313 )
1314 }
1315 }
1316}
1317
1318impl<O: IsA<HeaderBar>> HeaderBarExt for O {}