libadwaita/auto/preferences_dialog.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{Dialog, DialogPresentationMode, NavigationPage, PreferencesPage, Toast, ffi};
7use glib::{
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 /// A dialog showing application's preferences.
16 ///
17 /// <picture>
18 /// <source srcset="preferences-dialog-dark.png" media="(prefers-color-scheme: dark)">
19 /// <img src="preferences-dialog.png" alt="preferences-dialog">
20 /// </picture>
21 ///
22 /// The [`PreferencesDialog`][crate::PreferencesDialog] widget presents an application's preferences
23 /// gathered into pages and groups. The preferences are searchable by the user.
24 ///
25 /// ## Actions
26 ///
27 /// `AdwPrefencesDialog` defines the `navigation.pop` action, it doesn't take any
28 /// parameters and pops the current subpage from the navigation stack, equivalent
29 /// to calling [`PreferencesDialogExt::pop_subpage()`][crate::prelude::PreferencesDialogExt::pop_subpage()].
30 ///
31 /// ## CSS nodes
32 ///
33 /// [`PreferencesDialog`][crate::PreferencesDialog] has a main CSS node with the name `dialog` and the
34 /// style class `.preferences`.
35 ///
36 /// ## Properties
37 ///
38 ///
39 /// #### `search-enabled`
40 /// Whether search is enabled.
41 ///
42 /// Readable | Writeable
43 ///
44 ///
45 /// #### `visible-page`
46 /// The currently visible page.
47 ///
48 /// Readable | Writeable
49 ///
50 ///
51 /// #### `visible-page-name`
52 /// The name of the currently visible page.
53 ///
54 /// See [`visible-page`][struct@crate::AdwPreferencesDialog#visible-page].
55 ///
56 /// Readable | Writeable
57 /// <details><summary><h4>Dialog</h4></summary>
58 ///
59 ///
60 /// #### `can-close`
61 /// Whether the dialog can be closed.
62 ///
63 /// If set to `FALSE`, the close button, shortcuts and
64 /// [`AdwDialogExt::close()`][crate::prelude::AdwDialogExt::close()] will result in [`close-attempt`][struct@crate::Dialog#close-attempt] being
65 /// emitted instead, and bottom sheet close swipe will be disabled.
66 /// [`AdwDialogExt::force_close()`][crate::prelude::AdwDialogExt::force_close()] still works.
67 ///
68 /// Readable | Writeable
69 ///
70 ///
71 /// #### `child`
72 /// The child widget of the [`Dialog`][crate::Dialog].
73 ///
74 /// Readable | Writeable
75 ///
76 ///
77 /// #### `content-height`
78 /// The height of the dialog's contents.
79 ///
80 /// Set it to -1 to reset it to the content's natural height.
81 ///
82 /// See also: [`default-height`][struct@crate::gtk::Window#default-height]
83 ///
84 /// Readable | Writeable
85 ///
86 ///
87 /// #### `content-width`
88 /// The width of the dialog's contents.
89 ///
90 /// Set it to -1 to reset it to the content's natural width.
91 ///
92 /// See also: [`default-width`][struct@crate::gtk::Window#default-width]
93 ///
94 /// Readable | Writeable
95 ///
96 ///
97 /// #### `current-breakpoint`
98 /// The current breakpoint.
99 ///
100 /// Readable
101 ///
102 ///
103 /// #### `default-widget`
104 /// The default widget.
105 ///
106 /// It's activated when the user presses Enter.
107 ///
108 /// Readable | Writeable
109 ///
110 ///
111 /// #### `focus-widget`
112 /// The focus widget.
113 ///
114 /// Readable | Writeable
115 ///
116 ///
117 /// #### `follows-content-size`
118 /// Whether to size content automatically.
119 ///
120 /// If set to `TRUE`, always use the content's natural size instead of
121 /// [`content-width`][struct@crate::Dialog#content-width] and [`content-height`][struct@crate::Dialog#content-height]. If
122 /// the content resizes, the dialog will immediately resize as well.
123 ///
124 /// See also: [`resizable`][struct@crate::gtk::Window#resizable]
125 ///
126 /// Readable | Writeable
127 ///
128 ///
129 /// #### `presentation-mode`
130 /// The dialog's presentation mode.
131 ///
132 /// When set to [enum@Adw.DialogPresentationMode.auto], the dialog appears as a
133 /// bottom sheet when the following condition is met:
134 /// `max-width: 450px or max-height: 360px`, and as a floating window otherwise.
135 ///
136 /// Set it to [enum@Adw.DialogPresentationMode.floating] or
137 /// [enum@Adw.DialogPresentationMode.bottom-sheet] to always present it a
138 /// floating window or a bottom sheet respectively, regardless of available
139 /// size.
140 ///
141 /// Presentation mode does nothing for dialogs presented as a window.
142 ///
143 /// Readable | Writeable
144 ///
145 ///
146 /// #### `title`
147 /// The title of the dialog.
148 ///
149 /// Readable | Writeable
150 /// </details>
151 /// <details><summary><h4>Widget</h4></summary>
152 ///
153 ///
154 /// #### `can-focus`
155 /// Whether the widget or any of its descendents can accept
156 /// the input focus.
157 ///
158 /// This property is meant to be set by widget implementations,
159 /// typically in their instance init function.
160 ///
161 /// Readable | Writeable
162 ///
163 ///
164 /// #### `can-target`
165 /// Whether the widget can receive pointer events.
166 ///
167 /// Readable | Writeable
168 ///
169 ///
170 /// #### `css-classes`
171 /// A list of css classes applied to this widget.
172 ///
173 /// Readable | Writeable
174 ///
175 ///
176 /// #### `css-name`
177 /// The name of this widget in the CSS tree.
178 ///
179 /// This property is meant to be set by widget implementations,
180 /// typically in their instance init function.
181 ///
182 /// Readable | Writeable | Construct Only
183 ///
184 ///
185 /// #### `cursor`
186 /// The cursor used by @widget.
187 ///
188 /// Readable | Writeable
189 ///
190 ///
191 /// #### `focus-on-click`
192 /// Whether the widget should grab focus when it is clicked with the mouse.
193 ///
194 /// This property is only relevant for widgets that can take focus.
195 ///
196 /// Readable | Writeable
197 ///
198 ///
199 /// #### `focusable`
200 /// Whether this widget itself will accept the input focus.
201 ///
202 /// Readable | Writeable
203 ///
204 ///
205 /// #### `halign`
206 /// How to distribute horizontal space if widget gets extra space.
207 ///
208 /// Readable | Writeable
209 ///
210 ///
211 /// #### `has-default`
212 /// Whether the widget is the default widget.
213 ///
214 /// Readable
215 ///
216 ///
217 /// #### `has-focus`
218 /// Whether the widget has the input focus.
219 ///
220 /// Readable
221 ///
222 ///
223 /// #### `has-tooltip`
224 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
225 /// signal on @widget.
226 ///
227 /// A true value indicates that @widget can have a tooltip, in this case
228 /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
229 /// determine whether it will provide a tooltip or not.
230 ///
231 /// Readable | Writeable
232 ///
233 ///
234 /// #### `height-request`
235 /// Overrides for height request of the widget.
236 ///
237 /// If this is -1, the natural request will be used.
238 ///
239 /// Readable | Writeable
240 ///
241 ///
242 /// #### `hexpand`
243 /// Whether to expand horizontally.
244 ///
245 /// Readable | Writeable
246 ///
247 ///
248 /// #### `hexpand-set`
249 /// Whether to use the `hexpand` property.
250 ///
251 /// Readable | Writeable
252 ///
253 ///
254 /// #### `layout-manager`
255 /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
256 /// the preferred size of the widget, and allocate its children.
257 ///
258 /// This property is meant to be set by widget implementations,
259 /// typically in their instance init function.
260 ///
261 /// Readable | Writeable
262 ///
263 ///
264 /// #### `limit-events`
265 /// Makes this widget act like a modal dialog, with respect to
266 /// event delivery.
267 ///
268 /// Global event controllers will not handle events with targets
269 /// inside the widget, unless they are set up to ignore propagation
270 /// limits. See `Gtk::EventController::set_propagation_limit()`.
271 ///
272 /// Readable | Writeable
273 ///
274 ///
275 /// #### `margin-bottom`
276 /// Margin on bottom side of widget.
277 ///
278 /// This property adds margin outside of the widget's normal size
279 /// request, the margin will be added in addition to the size from
280 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
281 ///
282 /// Readable | Writeable
283 ///
284 ///
285 /// #### `margin-end`
286 /// Margin on end of widget, horizontally.
287 ///
288 /// This property supports left-to-right and right-to-left text
289 /// directions.
290 ///
291 /// This property adds margin outside of the widget's normal size
292 /// request, the margin will be added in addition to the size from
293 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
294 ///
295 /// Readable | Writeable
296 ///
297 ///
298 /// #### `margin-start`
299 /// Margin on start of widget, horizontally.
300 ///
301 /// This property supports left-to-right and right-to-left text
302 /// directions.
303 ///
304 /// This property adds margin outside of the widget's normal size
305 /// request, the margin will be added in addition to the size from
306 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
307 ///
308 /// Readable | Writeable
309 ///
310 ///
311 /// #### `margin-top`
312 /// Margin on top side of widget.
313 ///
314 /// This property adds margin outside of the widget's normal size
315 /// request, the margin will be added in addition to the size from
316 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
317 ///
318 /// Readable | Writeable
319 ///
320 ///
321 /// #### `name`
322 /// The name of the widget.
323 ///
324 /// Readable | Writeable
325 ///
326 ///
327 /// #### `opacity`
328 /// The requested opacity of the widget.
329 ///
330 /// Readable | Writeable
331 ///
332 ///
333 /// #### `overflow`
334 /// How content outside the widget's content area is treated.
335 ///
336 /// This property is meant to be set by widget implementations,
337 /// typically in their instance init function.
338 ///
339 /// Readable | Writeable
340 ///
341 ///
342 /// #### `parent`
343 /// The parent widget of this widget.
344 ///
345 /// Readable
346 ///
347 ///
348 /// #### `receives-default`
349 /// Whether the widget will receive the default action when it is focused.
350 ///
351 /// Readable | Writeable
352 ///
353 ///
354 /// #### `root`
355 /// The [`gtk::Root`][crate::gtk::Root] widget of the widget tree containing this widget.
356 ///
357 /// This will be `NULL` if the widget is not contained in a root widget.
358 ///
359 /// Readable
360 ///
361 ///
362 /// #### `scale-factor`
363 /// The scale factor of the widget.
364 ///
365 /// Readable
366 ///
367 ///
368 /// #### `sensitive`
369 /// Whether the widget responds to input.
370 ///
371 /// Readable | Writeable
372 ///
373 ///
374 /// #### `tooltip-markup`
375 /// Sets the text of tooltip to be the given string, which is marked up
376 /// with Pango markup.
377 ///
378 /// Also see `Gtk::Tooltip::set_markup()`.
379 ///
380 /// This is a convenience property which will take care of getting the
381 /// tooltip shown if the given string is not `NULL`:
382 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
383 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
384 /// the default signal handler.
385 ///
386 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
387 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
388 ///
389 /// Readable | Writeable
390 ///
391 ///
392 /// #### `tooltip-text`
393 /// Sets the text of tooltip to be the given string.
394 ///
395 /// Also see `Gtk::Tooltip::set_text()`.
396 ///
397 /// This is a convenience property which will take care of getting the
398 /// tooltip shown if the given string is not `NULL`:
399 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
400 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
401 /// the default signal handler.
402 ///
403 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
404 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
405 ///
406 /// Readable | Writeable
407 ///
408 ///
409 /// #### `valign`
410 /// How to distribute vertical space if widget gets extra space.
411 ///
412 /// Readable | Writeable
413 ///
414 ///
415 /// #### `vexpand`
416 /// Whether to expand vertically.
417 ///
418 /// Readable | Writeable
419 ///
420 ///
421 /// #### `vexpand-set`
422 /// Whether to use the `vexpand` property.
423 ///
424 /// Readable | Writeable
425 ///
426 ///
427 /// #### `visible`
428 /// Whether the widget is visible.
429 ///
430 /// Readable | Writeable
431 ///
432 ///
433 /// #### `width-request`
434 /// Overrides for width request of the widget.
435 ///
436 /// If this is -1, the natural request will be used.
437 ///
438 /// Readable | Writeable
439 /// </details>
440 /// <details><summary><h4>Accessible</h4></summary>
441 ///
442 ///
443 /// #### `accessible-role`
444 /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
445 ///
446 /// The accessible role cannot be changed once set.
447 ///
448 /// Readable | Writeable
449 /// </details>
450 ///
451 /// # Implements
452 ///
453 /// [`PreferencesDialogExt`][trait@crate::prelude::PreferencesDialogExt], [`AdwDialogExt`][trait@crate::prelude::AdwDialogExt], [`trait@gtk::prelude::WidgetExt`], [`trait@glib::ObjectExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`], [`trait@gtk::prelude::ShortcutManagerExt`]
454 #[doc(alias = "AdwPreferencesDialog")]
455 pub struct PreferencesDialog(Object<ffi::AdwPreferencesDialog, ffi::AdwPreferencesDialogClass>) @extends Dialog, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::ShortcutManager;
456
457 match fn {
458 type_ => || ffi::adw_preferences_dialog_get_type(),
459 }
460}
461
462impl PreferencesDialog {
463 pub const NONE: Option<&'static PreferencesDialog> = None;
464
465 /// Creates a new [`PreferencesDialog`][crate::PreferencesDialog].
466 ///
467 /// # Returns
468 ///
469 /// the newly created [`PreferencesDialog`][crate::PreferencesDialog]
470 #[doc(alias = "adw_preferences_dialog_new")]
471 pub fn new() -> PreferencesDialog {
472 assert_initialized_main_thread!();
473 unsafe { Dialog::from_glib_none(ffi::adw_preferences_dialog_new()).unsafe_cast() }
474 }
475
476 // rustdoc-stripper-ignore-next
477 /// Creates a new builder-pattern struct instance to construct [`PreferencesDialog`] objects.
478 ///
479 /// This method returns an instance of [`PreferencesDialogBuilder`](crate::builders::PreferencesDialogBuilder) which can be used to create [`PreferencesDialog`] objects.
480 pub fn builder() -> PreferencesDialogBuilder {
481 PreferencesDialogBuilder::new()
482 }
483}
484
485#[cfg(feature = "v1_5")]
486#[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
487impl Default for PreferencesDialog {
488 fn default() -> Self {
489 Self::new()
490 }
491}
492
493// rustdoc-stripper-ignore-next
494/// A [builder-pattern] type to construct [`PreferencesDialog`] objects.
495///
496/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
497#[must_use = "The builder must be built to be used"]
498pub struct PreferencesDialogBuilder {
499 builder: glib::object::ObjectBuilder<'static, PreferencesDialog>,
500}
501
502impl PreferencesDialogBuilder {
503 fn new() -> Self {
504 Self {
505 builder: glib::object::Object::builder(),
506 }
507 }
508
509 /// Whether search is enabled.
510 #[cfg(feature = "v1_5")]
511 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
512 pub fn search_enabled(self, search_enabled: bool) -> Self {
513 Self {
514 builder: self.builder.property("search-enabled", search_enabled),
515 }
516 }
517
518 /// The currently visible page.
519 #[cfg(feature = "v1_5")]
520 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
521 pub fn visible_page(self, visible_page: &impl IsA<gtk::Widget>) -> Self {
522 Self {
523 builder: self
524 .builder
525 .property("visible-page", visible_page.clone().upcast()),
526 }
527 }
528
529 /// The name of the currently visible page.
530 ///
531 /// See [`visible-page`][struct@crate::AdwPreferencesDialog#visible-page].
532 #[cfg(feature = "v1_5")]
533 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
534 pub fn visible_page_name(self, visible_page_name: impl Into<glib::GString>) -> Self {
535 Self {
536 builder: self
537 .builder
538 .property("visible-page-name", visible_page_name.into()),
539 }
540 }
541
542 /// Whether the dialog can be closed.
543 ///
544 /// If set to `FALSE`, the close button, shortcuts and
545 /// [`AdwDialogExt::close()`][crate::prelude::AdwDialogExt::close()] will result in [`close-attempt`][struct@crate::Dialog#close-attempt] being
546 /// emitted instead, and bottom sheet close swipe will be disabled.
547 /// [`AdwDialogExt::force_close()`][crate::prelude::AdwDialogExt::force_close()] still works.
548 #[cfg(feature = "v1_5")]
549 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
550 pub fn can_close(self, can_close: bool) -> Self {
551 Self {
552 builder: self.builder.property("can-close", can_close),
553 }
554 }
555
556 /// The child widget of the [`Dialog`][crate::Dialog].
557 #[cfg(feature = "v1_5")]
558 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
559 pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
560 Self {
561 builder: self.builder.property("child", child.clone().upcast()),
562 }
563 }
564
565 /// The height of the dialog's contents.
566 ///
567 /// Set it to -1 to reset it to the content's natural height.
568 ///
569 /// See also: [`default-height`][struct@crate::gtk::Window#default-height]
570 #[cfg(feature = "v1_5")]
571 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
572 pub fn content_height(self, content_height: i32) -> Self {
573 Self {
574 builder: self.builder.property("content-height", content_height),
575 }
576 }
577
578 /// The width of the dialog's contents.
579 ///
580 /// Set it to -1 to reset it to the content's natural width.
581 ///
582 /// See also: [`default-width`][struct@crate::gtk::Window#default-width]
583 #[cfg(feature = "v1_5")]
584 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
585 pub fn content_width(self, content_width: i32) -> Self {
586 Self {
587 builder: self.builder.property("content-width", content_width),
588 }
589 }
590
591 /// The default widget.
592 ///
593 /// It's activated when the user presses Enter.
594 #[cfg(feature = "v1_5")]
595 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
596 pub fn default_widget(self, default_widget: &impl IsA<gtk::Widget>) -> Self {
597 Self {
598 builder: self
599 .builder
600 .property("default-widget", default_widget.clone().upcast()),
601 }
602 }
603
604 /// The focus widget.
605 #[cfg(feature = "v1_5")]
606 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
607 pub fn focus_widget(self, focus_widget: &impl IsA<gtk::Widget>) -> Self {
608 Self {
609 builder: self
610 .builder
611 .property("focus-widget", focus_widget.clone().upcast()),
612 }
613 }
614
615 /// Whether to size content automatically.
616 ///
617 /// If set to `TRUE`, always use the content's natural size instead of
618 /// [`content-width`][struct@crate::Dialog#content-width] and [`content-height`][struct@crate::Dialog#content-height]. If
619 /// the content resizes, the dialog will immediately resize as well.
620 ///
621 /// See also: [`resizable`][struct@crate::gtk::Window#resizable]
622 #[cfg(feature = "v1_5")]
623 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
624 pub fn follows_content_size(self, follows_content_size: bool) -> Self {
625 Self {
626 builder: self
627 .builder
628 .property("follows-content-size", follows_content_size),
629 }
630 }
631
632 /// The dialog's presentation mode.
633 ///
634 /// When set to [enum@Adw.DialogPresentationMode.auto], the dialog appears as a
635 /// bottom sheet when the following condition is met:
636 /// `max-width: 450px or max-height: 360px`, and as a floating window otherwise.
637 ///
638 /// Set it to [enum@Adw.DialogPresentationMode.floating] or
639 /// [enum@Adw.DialogPresentationMode.bottom-sheet] to always present it a
640 /// floating window or a bottom sheet respectively, regardless of available
641 /// size.
642 ///
643 /// Presentation mode does nothing for dialogs presented as a window.
644 #[cfg(feature = "v1_5")]
645 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
646 pub fn presentation_mode(self, presentation_mode: DialogPresentationMode) -> Self {
647 Self {
648 builder: self
649 .builder
650 .property("presentation-mode", presentation_mode),
651 }
652 }
653
654 /// The title of the dialog.
655 #[cfg(feature = "v1_5")]
656 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
657 pub fn title(self, title: impl Into<glib::GString>) -> Self {
658 Self {
659 builder: self.builder.property("title", title.into()),
660 }
661 }
662
663 /// Whether the widget or any of its descendents can accept
664 /// the input focus.
665 ///
666 /// This property is meant to be set by widget implementations,
667 /// typically in their instance init function.
668 pub fn can_focus(self, can_focus: bool) -> Self {
669 Self {
670 builder: self.builder.property("can-focus", can_focus),
671 }
672 }
673
674 /// Whether the widget can receive pointer events.
675 pub fn can_target(self, can_target: bool) -> Self {
676 Self {
677 builder: self.builder.property("can-target", can_target),
678 }
679 }
680
681 /// A list of css classes applied to this widget.
682 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
683 Self {
684 builder: self.builder.property("css-classes", css_classes.into()),
685 }
686 }
687
688 /// The name of this widget in the CSS tree.
689 ///
690 /// This property is meant to be set by widget implementations,
691 /// typically in their instance init function.
692 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
693 Self {
694 builder: self.builder.property("css-name", css_name.into()),
695 }
696 }
697
698 /// The cursor used by @widget.
699 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
700 Self {
701 builder: self.builder.property("cursor", cursor.clone()),
702 }
703 }
704
705 /// Whether the widget should grab focus when it is clicked with the mouse.
706 ///
707 /// This property is only relevant for widgets that can take focus.
708 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
709 Self {
710 builder: self.builder.property("focus-on-click", focus_on_click),
711 }
712 }
713
714 /// Whether this widget itself will accept the input focus.
715 pub fn focusable(self, focusable: bool) -> Self {
716 Self {
717 builder: self.builder.property("focusable", focusable),
718 }
719 }
720
721 /// How to distribute horizontal space if widget gets extra space.
722 pub fn halign(self, halign: gtk::Align) -> Self {
723 Self {
724 builder: self.builder.property("halign", halign),
725 }
726 }
727
728 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
729 /// signal on @widget.
730 ///
731 /// A true value indicates that @widget can have a tooltip, in this case
732 /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
733 /// determine whether it will provide a tooltip or not.
734 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
735 Self {
736 builder: self.builder.property("has-tooltip", has_tooltip),
737 }
738 }
739
740 /// Overrides for height request of the widget.
741 ///
742 /// If this is -1, the natural request will be used.
743 pub fn height_request(self, height_request: i32) -> Self {
744 Self {
745 builder: self.builder.property("height-request", height_request),
746 }
747 }
748
749 /// Whether to expand horizontally.
750 pub fn hexpand(self, hexpand: bool) -> Self {
751 Self {
752 builder: self.builder.property("hexpand", hexpand),
753 }
754 }
755
756 /// Whether to use the `hexpand` property.
757 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
758 Self {
759 builder: self.builder.property("hexpand-set", hexpand_set),
760 }
761 }
762
763 /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
764 /// the preferred size of the widget, and allocate its children.
765 ///
766 /// This property is meant to be set by widget implementations,
767 /// typically in their instance init function.
768 pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
769 Self {
770 builder: self
771 .builder
772 .property("layout-manager", layout_manager.clone().upcast()),
773 }
774 }
775
776 /// Makes this widget act like a modal dialog, with respect to
777 /// event delivery.
778 ///
779 /// Global event controllers will not handle events with targets
780 /// inside the widget, unless they are set up to ignore propagation
781 /// limits. See `Gtk::EventController::set_propagation_limit()`.
782 #[cfg(feature = "gtk_v4_18")]
783 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
784 pub fn limit_events(self, limit_events: bool) -> Self {
785 Self {
786 builder: self.builder.property("limit-events", limit_events),
787 }
788 }
789
790 /// Margin on bottom side of widget.
791 ///
792 /// This property adds margin outside of the widget's normal size
793 /// request, the margin will be added in addition to the size from
794 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
795 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
796 Self {
797 builder: self.builder.property("margin-bottom", margin_bottom),
798 }
799 }
800
801 /// Margin on end of widget, horizontally.
802 ///
803 /// This property supports left-to-right and right-to-left text
804 /// directions.
805 ///
806 /// This property adds margin outside of the widget's normal size
807 /// request, the margin will be added in addition to the size from
808 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
809 pub fn margin_end(self, margin_end: i32) -> Self {
810 Self {
811 builder: self.builder.property("margin-end", margin_end),
812 }
813 }
814
815 /// Margin on start of widget, horizontally.
816 ///
817 /// This property supports left-to-right and right-to-left text
818 /// directions.
819 ///
820 /// This property adds margin outside of the widget's normal size
821 /// request, the margin will be added in addition to the size from
822 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
823 pub fn margin_start(self, margin_start: i32) -> Self {
824 Self {
825 builder: self.builder.property("margin-start", margin_start),
826 }
827 }
828
829 /// Margin on top side of widget.
830 ///
831 /// This property adds margin outside of the widget's normal size
832 /// request, the margin will be added in addition to the size from
833 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
834 pub fn margin_top(self, margin_top: i32) -> Self {
835 Self {
836 builder: self.builder.property("margin-top", margin_top),
837 }
838 }
839
840 /// The name of the widget.
841 pub fn name(self, name: impl Into<glib::GString>) -> Self {
842 Self {
843 builder: self.builder.property("name", name.into()),
844 }
845 }
846
847 /// The requested opacity of the widget.
848 pub fn opacity(self, opacity: f64) -> Self {
849 Self {
850 builder: self.builder.property("opacity", opacity),
851 }
852 }
853
854 /// How content outside the widget's content area is treated.
855 ///
856 /// This property is meant to be set by widget implementations,
857 /// typically in their instance init function.
858 pub fn overflow(self, overflow: gtk::Overflow) -> Self {
859 Self {
860 builder: self.builder.property("overflow", overflow),
861 }
862 }
863
864 /// Whether the widget will receive the default action when it is focused.
865 pub fn receives_default(self, receives_default: bool) -> Self {
866 Self {
867 builder: self.builder.property("receives-default", receives_default),
868 }
869 }
870
871 /// Whether the widget responds to input.
872 pub fn sensitive(self, sensitive: bool) -> Self {
873 Self {
874 builder: self.builder.property("sensitive", sensitive),
875 }
876 }
877
878 /// Sets the text of tooltip to be the given string, which is marked up
879 /// with Pango markup.
880 ///
881 /// Also see `Gtk::Tooltip::set_markup()`.
882 ///
883 /// This is a convenience property which will take care of getting the
884 /// tooltip shown if the given string is not `NULL`:
885 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
886 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
887 /// the default signal handler.
888 ///
889 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
890 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
891 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
892 Self {
893 builder: self
894 .builder
895 .property("tooltip-markup", tooltip_markup.into()),
896 }
897 }
898
899 /// Sets the text of tooltip to be the given string.
900 ///
901 /// Also see `Gtk::Tooltip::set_text()`.
902 ///
903 /// This is a convenience property which will take care of getting the
904 /// tooltip shown if the given string is not `NULL`:
905 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
906 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
907 /// the default signal handler.
908 ///
909 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
910 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
911 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
912 Self {
913 builder: self.builder.property("tooltip-text", tooltip_text.into()),
914 }
915 }
916
917 /// How to distribute vertical space if widget gets extra space.
918 pub fn valign(self, valign: gtk::Align) -> Self {
919 Self {
920 builder: self.builder.property("valign", valign),
921 }
922 }
923
924 /// Whether to expand vertically.
925 pub fn vexpand(self, vexpand: bool) -> Self {
926 Self {
927 builder: self.builder.property("vexpand", vexpand),
928 }
929 }
930
931 /// Whether to use the `vexpand` property.
932 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
933 Self {
934 builder: self.builder.property("vexpand-set", vexpand_set),
935 }
936 }
937
938 /// Whether the widget is visible.
939 pub fn visible(self, visible: bool) -> Self {
940 Self {
941 builder: self.builder.property("visible", visible),
942 }
943 }
944
945 /// Overrides for width request of the widget.
946 ///
947 /// If this is -1, the natural request will be used.
948 pub fn width_request(self, width_request: i32) -> Self {
949 Self {
950 builder: self.builder.property("width-request", width_request),
951 }
952 }
953
954 /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
955 ///
956 /// The accessible role cannot be changed once set.
957 pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
958 Self {
959 builder: self.builder.property("accessible-role", accessible_role),
960 }
961 }
962
963 // rustdoc-stripper-ignore-next
964 /// Build the [`PreferencesDialog`].
965 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
966 pub fn build(self) -> PreferencesDialog {
967 assert_initialized_main_thread!();
968 self.builder.build()
969 }
970}
971
972/// Trait containing all [`struct@PreferencesDialog`] methods.
973///
974/// # Implementors
975///
976/// [`PreferencesDialog`][struct@crate::PreferencesDialog]
977pub trait PreferencesDialogExt: IsA<PreferencesDialog> + 'static {
978 /// Adds a preferences page to @self.
979 /// ## `page`
980 /// the page to add
981 #[doc(alias = "adw_preferences_dialog_add")]
982 fn add(&self, page: &impl IsA<PreferencesPage>) {
983 unsafe {
984 ffi::adw_preferences_dialog_add(
985 self.as_ref().to_glib_none().0,
986 page.as_ref().to_glib_none().0,
987 );
988 }
989 }
990
991 /// Displays @toast.
992 ///
993 /// See [`ToastOverlay::add_toast()`][crate::ToastOverlay::add_toast()].
994 /// ## `toast`
995 /// a toast
996 #[doc(alias = "adw_preferences_dialog_add_toast")]
997 fn add_toast(&self, toast: Toast) {
998 unsafe {
999 ffi::adw_preferences_dialog_add_toast(
1000 self.as_ref().to_glib_none().0,
1001 toast.into_glib_ptr(),
1002 );
1003 }
1004 }
1005
1006 /// Gets whether search is enabled for @self.
1007 ///
1008 /// # Returns
1009 ///
1010 /// whether search is enabled for @self.
1011 #[doc(alias = "adw_preferences_dialog_get_search_enabled")]
1012 #[doc(alias = "get_search_enabled")]
1013 #[doc(alias = "search-enabled")]
1014 fn is_search_enabled(&self) -> bool {
1015 unsafe {
1016 from_glib(ffi::adw_preferences_dialog_get_search_enabled(
1017 self.as_ref().to_glib_none().0,
1018 ))
1019 }
1020 }
1021
1022 /// Gets the currently visible page of @self.
1023 ///
1024 /// # Returns
1025 ///
1026 /// the visible page
1027 #[doc(alias = "adw_preferences_dialog_get_visible_page")]
1028 #[doc(alias = "get_visible_page")]
1029 #[doc(alias = "visible-page")]
1030 fn visible_page(&self) -> Option<PreferencesPage> {
1031 unsafe {
1032 from_glib_none(ffi::adw_preferences_dialog_get_visible_page(
1033 self.as_ref().to_glib_none().0,
1034 ))
1035 }
1036 }
1037
1038 /// Gets the name of currently visible page of @self.
1039 ///
1040 /// # Returns
1041 ///
1042 /// the name of the visible page
1043 #[doc(alias = "adw_preferences_dialog_get_visible_page_name")]
1044 #[doc(alias = "get_visible_page_name")]
1045 #[doc(alias = "visible-page-name")]
1046 fn visible_page_name(&self) -> Option<glib::GString> {
1047 unsafe {
1048 from_glib_none(ffi::adw_preferences_dialog_get_visible_page_name(
1049 self.as_ref().to_glib_none().0,
1050 ))
1051 }
1052 }
1053
1054 /// Pop the visible page from the subpage stack of @self.
1055 ///
1056 /// # Returns
1057 ///
1058 /// `TRUE` if a page has been popped
1059 #[doc(alias = "adw_preferences_dialog_pop_subpage")]
1060 fn pop_subpage(&self) -> bool {
1061 unsafe {
1062 from_glib(ffi::adw_preferences_dialog_pop_subpage(
1063 self.as_ref().to_glib_none().0,
1064 ))
1065 }
1066 }
1067
1068 /// Pushes @page onto the subpage stack of @self.
1069 ///
1070 /// The page will be automatically removed when popped.
1071 /// ## `page`
1072 /// the subpage
1073 #[doc(alias = "adw_preferences_dialog_push_subpage")]
1074 fn push_subpage(&self, page: &impl IsA<NavigationPage>) {
1075 unsafe {
1076 ffi::adw_preferences_dialog_push_subpage(
1077 self.as_ref().to_glib_none().0,
1078 page.as_ref().to_glib_none().0,
1079 );
1080 }
1081 }
1082
1083 /// Removes a page from @self.
1084 /// ## `page`
1085 /// the page to remove
1086 #[doc(alias = "adw_preferences_dialog_remove")]
1087 fn remove(&self, page: &impl IsA<PreferencesPage>) {
1088 unsafe {
1089 ffi::adw_preferences_dialog_remove(
1090 self.as_ref().to_glib_none().0,
1091 page.as_ref().to_glib_none().0,
1092 );
1093 }
1094 }
1095
1096 /// Sets whether search is enabled for @self.
1097 /// ## `search_enabled`
1098 /// whether search is enabled
1099 #[doc(alias = "adw_preferences_dialog_set_search_enabled")]
1100 #[doc(alias = "search-enabled")]
1101 fn set_search_enabled(&self, search_enabled: bool) {
1102 unsafe {
1103 ffi::adw_preferences_dialog_set_search_enabled(
1104 self.as_ref().to_glib_none().0,
1105 search_enabled.into_glib(),
1106 );
1107 }
1108 }
1109
1110 /// Makes @page the visible page of @self.
1111 /// ## `page`
1112 /// a page of @self
1113 #[doc(alias = "adw_preferences_dialog_set_visible_page")]
1114 #[doc(alias = "visible-page")]
1115 fn set_visible_page(&self, page: &impl IsA<PreferencesPage>) {
1116 unsafe {
1117 ffi::adw_preferences_dialog_set_visible_page(
1118 self.as_ref().to_glib_none().0,
1119 page.as_ref().to_glib_none().0,
1120 );
1121 }
1122 }
1123
1124 /// Makes the page with the given name visible.
1125 ///
1126 /// See [`visible-page`][struct@crate::PreferencesDialog#visible-page].
1127 /// ## `name`
1128 /// the name of the page to make visible
1129 #[doc(alias = "adw_preferences_dialog_set_visible_page_name")]
1130 #[doc(alias = "visible-page-name")]
1131 fn set_visible_page_name(&self, name: &str) {
1132 unsafe {
1133 ffi::adw_preferences_dialog_set_visible_page_name(
1134 self.as_ref().to_glib_none().0,
1135 name.to_glib_none().0,
1136 );
1137 }
1138 }
1139
1140 #[cfg(feature = "v1_5")]
1141 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1142 #[doc(alias = "search-enabled")]
1143 fn connect_search_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1144 unsafe extern "C" fn notify_search_enabled_trampoline<
1145 P: IsA<PreferencesDialog>,
1146 F: Fn(&P) + 'static,
1147 >(
1148 this: *mut ffi::AdwPreferencesDialog,
1149 _param_spec: glib::ffi::gpointer,
1150 f: glib::ffi::gpointer,
1151 ) {
1152 unsafe {
1153 let f: &F = &*(f as *const F);
1154 f(PreferencesDialog::from_glib_borrow(this).unsafe_cast_ref())
1155 }
1156 }
1157 unsafe {
1158 let f: Box_<F> = Box_::new(f);
1159 connect_raw(
1160 self.as_ptr() as *mut _,
1161 c"notify::search-enabled".as_ptr() as *const _,
1162 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1163 notify_search_enabled_trampoline::<Self, F> as *const (),
1164 )),
1165 Box_::into_raw(f),
1166 )
1167 }
1168 }
1169
1170 #[cfg(feature = "v1_5")]
1171 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1172 #[doc(alias = "visible-page")]
1173 fn connect_visible_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1174 unsafe extern "C" fn notify_visible_page_trampoline<
1175 P: IsA<PreferencesDialog>,
1176 F: Fn(&P) + 'static,
1177 >(
1178 this: *mut ffi::AdwPreferencesDialog,
1179 _param_spec: glib::ffi::gpointer,
1180 f: glib::ffi::gpointer,
1181 ) {
1182 unsafe {
1183 let f: &F = &*(f as *const F);
1184 f(PreferencesDialog::from_glib_borrow(this).unsafe_cast_ref())
1185 }
1186 }
1187 unsafe {
1188 let f: Box_<F> = Box_::new(f);
1189 connect_raw(
1190 self.as_ptr() as *mut _,
1191 c"notify::visible-page".as_ptr() as *const _,
1192 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1193 notify_visible_page_trampoline::<Self, F> as *const (),
1194 )),
1195 Box_::into_raw(f),
1196 )
1197 }
1198 }
1199
1200 #[cfg(feature = "v1_5")]
1201 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1202 #[doc(alias = "visible-page-name")]
1203 fn connect_visible_page_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1204 unsafe extern "C" fn notify_visible_page_name_trampoline<
1205 P: IsA<PreferencesDialog>,
1206 F: Fn(&P) + 'static,
1207 >(
1208 this: *mut ffi::AdwPreferencesDialog,
1209 _param_spec: glib::ffi::gpointer,
1210 f: glib::ffi::gpointer,
1211 ) {
1212 unsafe {
1213 let f: &F = &*(f as *const F);
1214 f(PreferencesDialog::from_glib_borrow(this).unsafe_cast_ref())
1215 }
1216 }
1217 unsafe {
1218 let f: Box_<F> = Box_::new(f);
1219 connect_raw(
1220 self.as_ptr() as *mut _,
1221 c"notify::visible-page-name".as_ptr() as *const _,
1222 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1223 notify_visible_page_name_trampoline::<Self, F> as *const (),
1224 )),
1225 Box_::into_raw(f),
1226 )
1227 }
1228 }
1229}
1230
1231impl<O: IsA<PreferencesDialog>> PreferencesDialogExt for O {}