Skip to main content

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