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