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