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    ffi, Accessible, AccessibleRole, Align, Application, Buildable, ColorChooser, ConstraintTarget,
11    Dialog, LayoutManager, Native, Overflow, Root, ShortcutManager, Widget, Window,
12};
13use glib::{
14    prelude::*,
15    signal::{connect_raw, SignalHandlerId},
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            let f: &F = &*(f as *const F);
671            f(&from_glib_borrow(this))
672        }
673        unsafe {
674            let f: Box_<F> = Box_::new(f);
675            connect_raw(
676                self.as_ptr() as *mut _,
677                c"notify::show-editor".as_ptr() as *const _,
678                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
679                    notify_show_editor_trampoline::<F> as *const (),
680                )),
681                Box_::into_raw(f),
682            )
683        }
684    }
685}
686
687impl Default for ColorChooserDialog {
688    fn default() -> Self {
689        glib::object::Object::new::<Self>()
690    }
691}
692
693// rustdoc-stripper-ignore-next
694/// A [builder-pattern] type to construct [`ColorChooserDialog`] objects.
695///
696/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
697#[must_use = "The builder must be built to be used"]
698pub struct ColorChooserDialogBuilder {
699    builder: glib::object::ObjectBuilder<'static, ColorChooserDialog>,
700}
701
702impl ColorChooserDialogBuilder {
703    fn new() -> Self {
704        Self {
705            builder: glib::object::Object::builder(),
706        }
707    }
708
709    /// Whether the color chooser dialog is showing the single-color editor.
710    ///
711    /// It can be set to switch the color chooser into single-color editing mode.
712    pub fn show_editor(self, show_editor: bool) -> Self {
713        Self {
714            builder: self.builder.property("show-editor", show_editor),
715        }
716    }
717
718    /// [`true`] if the dialog uses a headerbar for action buttons
719    /// instead of the action-area.
720    ///
721    /// For technical reasons, this property is declared as an integer
722    /// property, but you should only set it to [`true`] or [`false`].
723    ///
724    /// ## Creating a dialog with headerbar
725    ///
726    /// Builtin [`Dialog`][crate::Dialog] subclasses such as [`ColorChooserDialog`][crate::ColorChooserDialog]
727    /// set this property according to platform conventions (using the
728    /// [`gtk-dialogs-use-header`][struct@crate::Settings#gtk-dialogs-use-header] setting).
729    ///
730    /// Here is how you can achieve the same:
731    ///
732    /// **⚠️ The following code is in c ⚠️**
733    ///
734    /// ```c
735    /// g_object_get (settings, "gtk-dialogs-use-header", &header, NULL);
736    /// dialog = g_object_new (GTK_TYPE_DIALOG, header, TRUE, NULL);
737    /// ```
738    /// Use [`Window`][crate::Window] instead
739    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
740    pub fn use_header_bar(self, use_header_bar: i32) -> Self {
741        Self {
742            builder: self.builder.property("use-header-bar", use_header_bar),
743        }
744    }
745
746    /// The [`Application`][crate::Application] associated with the window.
747    ///
748    /// The application will be kept alive for at least as long as it
749    /// has any windows associated with it (see g_application_hold()
750    /// for a way to keep it alive without windows).
751    ///
752    /// Normally, the connection between the application and the window
753    /// will remain until the window is destroyed, but you can explicitly
754    /// remove it by setting the this property to `NULL`.
755    pub fn application(self, application: &impl IsA<Application>) -> Self {
756        Self {
757            builder: self
758                .builder
759                .property("application", application.clone().upcast()),
760        }
761    }
762
763    /// The child widget.
764    pub fn child(self, child: &impl IsA<Widget>) -> Self {
765        Self {
766            builder: self.builder.property("child", child.clone().upcast()),
767        }
768    }
769
770    /// Whether the window should have a frame (also known as *decorations*).
771    pub fn decorated(self, decorated: bool) -> Self {
772        Self {
773            builder: self.builder.property("decorated", decorated),
774        }
775    }
776
777    /// The default height of the window.
778    pub fn default_height(self, default_height: i32) -> Self {
779        Self {
780            builder: self.builder.property("default-height", default_height),
781        }
782    }
783
784    /// The default widget.
785    pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
786        Self {
787            builder: self
788                .builder
789                .property("default-widget", default_widget.clone().upcast()),
790        }
791    }
792
793    /// The default width of the window.
794    pub fn default_width(self, default_width: i32) -> Self {
795        Self {
796            builder: self.builder.property("default-width", default_width),
797        }
798    }
799
800    /// Whether the window frame should have a close button.
801    pub fn deletable(self, deletable: bool) -> Self {
802        Self {
803            builder: self.builder.property("deletable", deletable),
804        }
805    }
806
807    /// If this window should be destroyed when the parent is destroyed.
808    pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
809        Self {
810            builder: self
811                .builder
812                .property("destroy-with-parent", destroy_with_parent),
813        }
814    }
815
816    /// The display that will display this window.
817    pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
818        Self {
819            builder: self.builder.property("display", display.clone().upcast()),
820        }
821    }
822
823    /// Whether 'focus rectangles' are currently visible in this window.
824    ///
825    /// This property is maintained by GTK based on user input
826    /// and should not be set by applications.
827    pub fn focus_visible(self, focus_visible: bool) -> Self {
828        Self {
829            builder: self.builder.property("focus-visible", focus_visible),
830        }
831    }
832
833    /// The focus widget.
834    pub fn focus_widget(self, focus_widget: &impl IsA<Widget>) -> Self {
835        Self {
836            builder: self
837                .builder
838                .property("focus-widget", focus_widget.clone().upcast()),
839        }
840    }
841
842    /// Whether the window is fullscreen.
843    ///
844    /// Setting this property is the equivalent of calling
845    /// [`GtkWindowExt::fullscreen()`][crate::prelude::GtkWindowExt::fullscreen()] or [`GtkWindowExt::unfullscreen()`][crate::prelude::GtkWindowExt::unfullscreen()];
846    /// either operation is asynchronous, which means you will need to
847    /// connect to the ::notify signal in order to know whether the
848    /// operation was successful.
849    pub fn fullscreened(self, fullscreened: bool) -> Self {
850        Self {
851            builder: self.builder.property("fullscreened", fullscreened),
852        }
853    }
854
855    /// The gravity to use when resizing the window programmatically.
856    ///
857    /// Gravity describes which point of the window we want to keep
858    /// fixed (meaning that the window will grow in the opposite direction).
859    /// For example, a gravity of `GTK_WINDOW_GRAVITY_TOP_RIGHT` means that we
860    /// want the to fix top right corner of the window.
861    #[cfg(feature = "v4_20")]
862    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
863    pub fn gravity(self, gravity: WindowGravity) -> Self {
864        Self {
865            builder: self.builder.property("gravity", gravity),
866        }
867    }
868
869    /// Whether the window frame should handle <kbd>F10</kbd> for activating
870    /// menubars.
871    #[cfg(feature = "v4_2")]
872    #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
873    pub fn handle_menubar_accel(self, handle_menubar_accel: bool) -> Self {
874        Self {
875            builder: self
876                .builder
877                .property("handle-menubar-accel", handle_menubar_accel),
878        }
879    }
880
881    /// If this window should be hidden instead of destroyed when the user clicks
882    /// the close button.
883    pub fn hide_on_close(self, hide_on_close: bool) -> Self {
884        Self {
885            builder: self.builder.property("hide-on-close", hide_on_close),
886        }
887    }
888
889    /// Specifies the name of the themed icon to use as the window icon.
890    ///
891    /// See [`IconTheme`][crate::IconTheme] for more details.
892    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
893        Self {
894            builder: self.builder.property("icon-name", icon_name.into()),
895        }
896    }
897
898    /// Whether the window is maximized.
899    ///
900    /// Setting this property is the equivalent of calling
901    /// [`GtkWindowExt::maximize()`][crate::prelude::GtkWindowExt::maximize()] or [`GtkWindowExt::unmaximize()`][crate::prelude::GtkWindowExt::unmaximize()];
902    /// either operation is asynchronous, which means you will need to
903    /// connect to the ::notify signal in order to know whether the
904    /// operation was successful.
905    pub fn maximized(self, maximized: bool) -> Self {
906        Self {
907            builder: self.builder.property("maximized", maximized),
908        }
909    }
910
911    /// Whether mnemonics are currently visible in this window.
912    ///
913    /// This property is maintained by GTK based on user input,
914    /// and should not be set by applications.
915    pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
916        Self {
917            builder: self
918                .builder
919                .property("mnemonics-visible", mnemonics_visible),
920        }
921    }
922
923    /// If true, the window is modal.
924    pub fn modal(self, modal: bool) -> Self {
925        Self {
926            builder: self.builder.property("modal", modal),
927        }
928    }
929
930    /// If true, users can resize the window.
931    pub fn resizable(self, resizable: bool) -> Self {
932        Self {
933            builder: self.builder.property("resizable", resizable),
934        }
935    }
936
937    /// A write-only property for setting window's startup notification identifier.
938    pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
939        Self {
940            builder: self.builder.property("startup-id", startup_id.into()),
941        }
942    }
943
944    /// The title of the window.
945    pub fn title(self, title: impl Into<glib::GString>) -> Self {
946        Self {
947            builder: self.builder.property("title", title.into()),
948        }
949    }
950
951    /// The titlebar widget.
952    #[cfg(feature = "v4_6")]
953    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
954    pub fn titlebar(self, titlebar: &impl IsA<Widget>) -> Self {
955        Self {
956            builder: self.builder.property("titlebar", titlebar.clone().upcast()),
957        }
958    }
959
960    /// The transient parent of the window.
961    pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
962        Self {
963            builder: self
964                .builder
965                .property("transient-for", transient_for.clone().upcast()),
966        }
967    }
968
969    /// Whether the widget or any of its descendents can accept
970    /// the input focus.
971    ///
972    /// This property is meant to be set by widget implementations,
973    /// typically in their instance init function.
974    pub fn can_focus(self, can_focus: bool) -> Self {
975        Self {
976            builder: self.builder.property("can-focus", can_focus),
977        }
978    }
979
980    /// Whether the widget can receive pointer events.
981    pub fn can_target(self, can_target: bool) -> Self {
982        Self {
983            builder: self.builder.property("can-target", can_target),
984        }
985    }
986
987    /// A list of css classes applied to this widget.
988    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
989        Self {
990            builder: self.builder.property("css-classes", css_classes.into()),
991        }
992    }
993
994    /// The name of this widget in the CSS tree.
995    ///
996    /// This property is meant to be set by widget implementations,
997    /// typically in their instance init function.
998    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
999        Self {
1000            builder: self.builder.property("css-name", css_name.into()),
1001        }
1002    }
1003
1004    /// The cursor used by @widget.
1005    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1006        Self {
1007            builder: self.builder.property("cursor", cursor.clone()),
1008        }
1009    }
1010
1011    /// Whether the widget should grab focus when it is clicked with the mouse.
1012    ///
1013    /// This property is only relevant for widgets that can take focus.
1014    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1015        Self {
1016            builder: self.builder.property("focus-on-click", focus_on_click),
1017        }
1018    }
1019
1020    /// Whether this widget itself will accept the input focus.
1021    pub fn focusable(self, focusable: bool) -> Self {
1022        Self {
1023            builder: self.builder.property("focusable", focusable),
1024        }
1025    }
1026
1027    /// How to distribute horizontal space if widget gets extra space.
1028    pub fn halign(self, halign: Align) -> Self {
1029        Self {
1030            builder: self.builder.property("halign", halign),
1031        }
1032    }
1033
1034    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1035    /// signal on @widget.
1036    ///
1037    /// A true value indicates that @widget can have a tooltip, in this case
1038    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1039    /// determine whether it will provide a tooltip or not.
1040    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1041        Self {
1042            builder: self.builder.property("has-tooltip", has_tooltip),
1043        }
1044    }
1045
1046    /// Overrides for height request of the widget.
1047    ///
1048    /// If this is -1, the natural request will be used.
1049    pub fn height_request(self, height_request: i32) -> Self {
1050        Self {
1051            builder: self.builder.property("height-request", height_request),
1052        }
1053    }
1054
1055    /// Whether to expand horizontally.
1056    pub fn hexpand(self, hexpand: bool) -> Self {
1057        Self {
1058            builder: self.builder.property("hexpand", hexpand),
1059        }
1060    }
1061
1062    /// Whether to use the `hexpand` property.
1063    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1064        Self {
1065            builder: self.builder.property("hexpand-set", hexpand_set),
1066        }
1067    }
1068
1069    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1070    /// the preferred size of the widget, and allocate its children.
1071    ///
1072    /// This property is meant to be set by widget implementations,
1073    /// typically in their instance init function.
1074    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1075        Self {
1076            builder: self
1077                .builder
1078                .property("layout-manager", layout_manager.clone().upcast()),
1079        }
1080    }
1081
1082    /// Makes this widget act like a modal dialog, with respect to
1083    /// event delivery.
1084    ///
1085    /// Global event controllers will not handle events with targets
1086    /// inside the widget, unless they are set up to ignore propagation
1087    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1088    #[cfg(feature = "v4_18")]
1089    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1090    pub fn limit_events(self, limit_events: bool) -> Self {
1091        Self {
1092            builder: self.builder.property("limit-events", limit_events),
1093        }
1094    }
1095
1096    /// Margin on bottom side of widget.
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_bottom(self, margin_bottom: i32) -> Self {
1102        Self {
1103            builder: self.builder.property("margin-bottom", margin_bottom),
1104        }
1105    }
1106
1107    /// Margin on end of widget, horizontally.
1108    ///
1109    /// This property supports left-to-right and right-to-left text
1110    /// directions.
1111    ///
1112    /// This property adds margin outside of the widget's normal size
1113    /// request, the margin will be added in addition to the size from
1114    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1115    pub fn margin_end(self, margin_end: i32) -> Self {
1116        Self {
1117            builder: self.builder.property("margin-end", margin_end),
1118        }
1119    }
1120
1121    /// Margin on start of widget, horizontally.
1122    ///
1123    /// This property supports left-to-right and right-to-left text
1124    /// directions.
1125    ///
1126    /// This property adds margin outside of the widget's normal size
1127    /// request, the margin will be added in addition to the size from
1128    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1129    pub fn margin_start(self, margin_start: i32) -> Self {
1130        Self {
1131            builder: self.builder.property("margin-start", margin_start),
1132        }
1133    }
1134
1135    /// Margin on top side of widget.
1136    ///
1137    /// This property adds margin outside of the widget's normal size
1138    /// request, the margin will be added in addition to the size from
1139    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1140    pub fn margin_top(self, margin_top: i32) -> Self {
1141        Self {
1142            builder: self.builder.property("margin-top", margin_top),
1143        }
1144    }
1145
1146    /// The name of the widget.
1147    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1148        Self {
1149            builder: self.builder.property("name", name.into()),
1150        }
1151    }
1152
1153    /// The requested opacity of the widget.
1154    pub fn opacity(self, opacity: f64) -> Self {
1155        Self {
1156            builder: self.builder.property("opacity", opacity),
1157        }
1158    }
1159
1160    /// How content outside the widget's content area is treated.
1161    ///
1162    /// This property is meant to be set by widget implementations,
1163    /// typically in their instance init function.
1164    pub fn overflow(self, overflow: Overflow) -> Self {
1165        Self {
1166            builder: self.builder.property("overflow", overflow),
1167        }
1168    }
1169
1170    /// Whether the widget will receive the default action when it is focused.
1171    pub fn receives_default(self, receives_default: bool) -> Self {
1172        Self {
1173            builder: self.builder.property("receives-default", receives_default),
1174        }
1175    }
1176
1177    /// Whether the widget responds to input.
1178    pub fn sensitive(self, sensitive: bool) -> Self {
1179        Self {
1180            builder: self.builder.property("sensitive", sensitive),
1181        }
1182    }
1183
1184    /// Sets the text of tooltip to be the given string, which is marked up
1185    /// with Pango markup.
1186    ///
1187    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1188    ///
1189    /// This is a convenience property which will take care of getting the
1190    /// tooltip shown if the given string is not `NULL`:
1191    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1192    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1193    /// the default signal handler.
1194    ///
1195    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1196    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1197    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1198        Self {
1199            builder: self
1200                .builder
1201                .property("tooltip-markup", tooltip_markup.into()),
1202        }
1203    }
1204
1205    /// Sets the text of tooltip to be the given string.
1206    ///
1207    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1208    ///
1209    /// This is a convenience property which will take care of getting the
1210    /// tooltip shown if the given string is not `NULL`:
1211    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1212    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1213    /// the default signal handler.
1214    ///
1215    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1216    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1217    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1218        Self {
1219            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1220        }
1221    }
1222
1223    /// How to distribute vertical space if widget gets extra space.
1224    pub fn valign(self, valign: Align) -> Self {
1225        Self {
1226            builder: self.builder.property("valign", valign),
1227        }
1228    }
1229
1230    /// Whether to expand vertically.
1231    pub fn vexpand(self, vexpand: bool) -> Self {
1232        Self {
1233            builder: self.builder.property("vexpand", vexpand),
1234        }
1235    }
1236
1237    /// Whether to use the `vexpand` property.
1238    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1239        Self {
1240            builder: self.builder.property("vexpand-set", vexpand_set),
1241        }
1242    }
1243
1244    /// Whether the widget is visible.
1245    pub fn visible(self, visible: bool) -> Self {
1246        Self {
1247            builder: self.builder.property("visible", visible),
1248        }
1249    }
1250
1251    /// Overrides for width request of the widget.
1252    ///
1253    /// If this is -1, the natural request will be used.
1254    pub fn width_request(self, width_request: i32) -> Self {
1255        Self {
1256            builder: self.builder.property("width-request", width_request),
1257        }
1258    }
1259
1260    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1261    ///
1262    /// The accessible role cannot be changed once set.
1263    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1264        Self {
1265            builder: self.builder.property("accessible-role", accessible_role),
1266        }
1267    }
1268
1269    /// The currently selected color, as a [`gdk::RGBA`][crate::gdk::RGBA] struct.
1270    ///
1271    /// The property can be set to change the current selection
1272    /// programmatically.
1273    /// Use [`ColorDialog`][crate::ColorDialog] and [`ColorDialogButton`][crate::ColorDialogButton]
1274    ///   instead of widgets implementing [`ColorChooser`][crate::ColorChooser]
1275    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1276    pub fn rgba(self, rgba: &gdk::RGBA) -> Self {
1277        Self {
1278            builder: self.builder.property("rgba", rgba),
1279        }
1280    }
1281
1282    /// Whether colors may have alpha (translucency).
1283    ///
1284    /// When ::use-alpha is [`false`], the [`gdk::RGBA`][crate::gdk::RGBA] struct obtained
1285    /// via the [`rgba`][struct@crate::ColorChooser#rgba] property will be
1286    /// forced to have alpha == 1.
1287    ///
1288    /// Implementations are expected to show alpha by rendering the color
1289    /// over a non-uniform background (like a checkerboard pattern).
1290    /// Use [`ColorDialog`][crate::ColorDialog] and [`ColorDialogButton`][crate::ColorDialogButton]
1291    ///   instead of widgets implementing [`ColorChooser`][crate::ColorChooser]
1292    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1293    pub fn use_alpha(self, use_alpha: bool) -> Self {
1294        Self {
1295            builder: self.builder.property("use-alpha", use_alpha),
1296        }
1297    }
1298
1299    // rustdoc-stripper-ignore-next
1300    /// Build the [`ColorChooserDialog`].
1301    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1302    pub fn build(self) -> ColorChooserDialog {
1303        assert_initialized_main_thread!();
1304        self.builder.build()
1305    }
1306}