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