gtk4/auto/
color_chooser_widget.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
5use crate::{
6    ffi, Accessible, AccessibleRole, Align, Buildable, ColorChooser, ConstraintTarget,
7    LayoutManager, Overflow, Widget,
8};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    /// Direct use of [`ColorChooserWidget`][crate::ColorChooserWidget] is deprecated.
18    /// The [`ColorChooserWidget`][crate::ColorChooserWidget] widget lets the user select a color.
19    ///
20    /// By default, the chooser presents a predefined palette of colors,
21    /// plus a small number of settable custom colors. It is also possible
22    /// to select a different color with the single-color editor.
23    ///
24    /// To enter the single-color editing mode, use the context menu of any
25    /// color of the palette, or use the '+' button to add a new custom color.
26    ///
27    /// The chooser automatically remembers the last selection, as well
28    /// as custom colors.
29    ///
30    /// To create a [`ColorChooserWidget`][crate::ColorChooserWidget], use [`new()`][Self::new()].
31    ///
32    /// To change the initially selected color, use
33    /// [`ColorChooserExt::set_rgba()`][crate::prelude::ColorChooserExt::set_rgba()]. To get the selected color use
34    /// [`ColorChooserExt::rgba()`][crate::prelude::ColorChooserExt::rgba()].
35    ///
36    /// The [`ColorChooserWidget`][crate::ColorChooserWidget] is used in the [`ColorChooserDialog`][crate::ColorChooserDialog]
37    /// to provide a dialog for selecting colors.
38    ///
39    /// # Actions
40    ///
41    /// [`ColorChooserWidget`][crate::ColorChooserWidget] defines a set of built-in actions:
42    ///
43    /// - `color.customize` activates the color editor for the given color.
44    /// - `color.select` emits the [`color-activated`][struct@crate::ColorChooser#color-activated] signal
45    ///   for the given color.
46    ///
47    /// # CSS names
48    ///
49    /// [`ColorChooserWidget`][crate::ColorChooserWidget] has a single CSS node with name colorchooser.
50    ///
51    /// ## Properties
52    ///
53    ///
54    /// #### `show-editor`
55    ///  [`true`] when the color chooser is showing the single-color editor.
56    ///
57    /// It can be set to switch the color chooser into single-color editing mode.
58    ///
59    /// Readable | Writeable
60    /// <details><summary><h4>Widget</h4></summary>
61    ///
62    ///
63    /// #### `can-focus`
64    ///  Whether the widget or any of its descendents can accept
65    /// the input focus.
66    ///
67    /// This property is meant to be set by widget implementations,
68    /// typically in their instance init function.
69    ///
70    /// Readable | Writeable
71    ///
72    ///
73    /// #### `can-target`
74    ///  Whether the widget can receive pointer events.
75    ///
76    /// Readable | Writeable
77    ///
78    ///
79    /// #### `css-classes`
80    ///  A list of css classes applied to this widget.
81    ///
82    /// Readable | Writeable
83    ///
84    ///
85    /// #### `css-name`
86    ///  The name of this widget in the CSS tree.
87    ///
88    /// This property is meant to be set by widget implementations,
89    /// typically in their instance init function.
90    ///
91    /// Readable | Writeable | Construct Only
92    ///
93    ///
94    /// #### `cursor`
95    ///  The cursor used by @widget.
96    ///
97    /// Readable | Writeable
98    ///
99    ///
100    /// #### `focus-on-click`
101    ///  Whether the widget should grab focus when it is clicked with the mouse.
102    ///
103    /// This property is only relevant for widgets that can take focus.
104    ///
105    /// Readable | Writeable
106    ///
107    ///
108    /// #### `focusable`
109    ///  Whether this widget itself will accept the input focus.
110    ///
111    /// Readable | Writeable
112    ///
113    ///
114    /// #### `halign`
115    ///  How to distribute horizontal space if widget gets extra space.
116    ///
117    /// Readable | Writeable
118    ///
119    ///
120    /// #### `has-default`
121    ///  Whether the widget is the default widget.
122    ///
123    /// Readable
124    ///
125    ///
126    /// #### `has-focus`
127    ///  Whether the widget has the input focus.
128    ///
129    /// Readable
130    ///
131    ///
132    /// #### `has-tooltip`
133    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
134    /// signal on @widget.
135    ///
136    /// A true value indicates that @widget can have a tooltip, in this case
137    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
138    /// determine whether it will provide a tooltip or not.
139    ///
140    /// Readable | Writeable
141    ///
142    ///
143    /// #### `height-request`
144    ///  Overrides for height request of the widget.
145    ///
146    /// If this is -1, the natural request will be used.
147    ///
148    /// Readable | Writeable
149    ///
150    ///
151    /// #### `hexpand`
152    ///  Whether to expand horizontally.
153    ///
154    /// Readable | Writeable
155    ///
156    ///
157    /// #### `hexpand-set`
158    ///  Whether to use the `hexpand` property.
159    ///
160    /// Readable | Writeable
161    ///
162    ///
163    /// #### `layout-manager`
164    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
165    /// the preferred size of the widget, and allocate its children.
166    ///
167    /// This property is meant to be set by widget implementations,
168    /// typically in their instance init function.
169    ///
170    /// Readable | Writeable
171    ///
172    ///
173    /// #### `limit-events`
174    ///  Makes this widget act like a modal dialog, with respect to
175    /// event delivery.
176    ///
177    /// Global event controllers will not handle events with targets
178    /// inside the widget, unless they are set up to ignore propagation
179    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
180    ///
181    /// Readable | Writeable
182    ///
183    ///
184    /// #### `margin-bottom`
185    ///  Margin on bottom side of widget.
186    ///
187    /// This property adds margin outside of the widget's normal size
188    /// request, the margin will be added in addition to the size from
189    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
190    ///
191    /// Readable | Writeable
192    ///
193    ///
194    /// #### `margin-end`
195    ///  Margin on end of widget, horizontally.
196    ///
197    /// This property supports left-to-right and right-to-left text
198    /// directions.
199    ///
200    /// This property adds margin outside of the widget's normal size
201    /// request, the margin will be added in addition to the size from
202    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
203    ///
204    /// Readable | Writeable
205    ///
206    ///
207    /// #### `margin-start`
208    ///  Margin on start of widget, horizontally.
209    ///
210    /// This property supports left-to-right and right-to-left text
211    /// directions.
212    ///
213    /// This property adds margin outside of the widget's normal size
214    /// request, the margin will be added in addition to the size from
215    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
216    ///
217    /// Readable | Writeable
218    ///
219    ///
220    /// #### `margin-top`
221    ///  Margin on top side of widget.
222    ///
223    /// This property adds margin outside of the widget's normal size
224    /// request, the margin will be added in addition to the size from
225    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
226    ///
227    /// Readable | Writeable
228    ///
229    ///
230    /// #### `name`
231    ///  The name of the widget.
232    ///
233    /// Readable | Writeable
234    ///
235    ///
236    /// #### `opacity`
237    ///  The requested opacity of the widget.
238    ///
239    /// Readable | Writeable
240    ///
241    ///
242    /// #### `overflow`
243    ///  How content outside the widget's content area is treated.
244    ///
245    /// This property is meant to be set by widget implementations,
246    /// typically in their instance init function.
247    ///
248    /// Readable | Writeable
249    ///
250    ///
251    /// #### `parent`
252    ///  The parent widget of this widget.
253    ///
254    /// Readable
255    ///
256    ///
257    /// #### `receives-default`
258    ///  Whether the widget will receive the default action when it is focused.
259    ///
260    /// Readable | Writeable
261    ///
262    ///
263    /// #### `root`
264    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
265    ///
266    /// This will be `NULL` if the widget is not contained in a root widget.
267    ///
268    /// Readable
269    ///
270    ///
271    /// #### `scale-factor`
272    ///  The scale factor of the widget.
273    ///
274    /// Readable
275    ///
276    ///
277    /// #### `sensitive`
278    ///  Whether the widget responds to input.
279    ///
280    /// Readable | Writeable
281    ///
282    ///
283    /// #### `tooltip-markup`
284    ///  Sets the text of tooltip to be the given string, which is marked up
285    /// with Pango markup.
286    ///
287    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
288    ///
289    /// This is a convenience property which will take care of getting the
290    /// tooltip shown if the given string is not `NULL`:
291    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
292    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
293    /// the default signal handler.
294    ///
295    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
296    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
297    ///
298    /// Readable | Writeable
299    ///
300    ///
301    /// #### `tooltip-text`
302    ///  Sets the text of tooltip to be the given string.
303    ///
304    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
305    ///
306    /// This is a convenience property which will take care of getting the
307    /// tooltip shown if the given string is not `NULL`:
308    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
309    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
310    /// the default signal handler.
311    ///
312    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
313    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
314    ///
315    /// Readable | Writeable
316    ///
317    ///
318    /// #### `valign`
319    ///  How to distribute vertical space if widget gets extra space.
320    ///
321    /// Readable | Writeable
322    ///
323    ///
324    /// #### `vexpand`
325    ///  Whether to expand vertically.
326    ///
327    /// Readable | Writeable
328    ///
329    ///
330    /// #### `vexpand-set`
331    ///  Whether to use the `vexpand` property.
332    ///
333    /// Readable | Writeable
334    ///
335    ///
336    /// #### `visible`
337    ///  Whether the widget is visible.
338    ///
339    /// Readable | Writeable
340    ///
341    ///
342    /// #### `width-request`
343    ///  Overrides for width request of the widget.
344    ///
345    /// If this is -1, the natural request will be used.
346    ///
347    /// Readable | Writeable
348    /// </details>
349    /// <details><summary><h4>Accessible</h4></summary>
350    ///
351    ///
352    /// #### `accessible-role`
353    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
354    ///
355    /// The accessible role cannot be changed once set.
356    ///
357    /// Readable | Writeable
358    /// </details>
359    /// <details><summary><h4>ColorChooser</h4></summary>
360    ///
361    ///
362    /// #### `rgba`
363    ///  The currently selected color, as a [`gdk::RGBA`][crate::gdk::RGBA] struct.
364    ///
365    /// The property can be set to change the current selection
366    /// programmatically.
367    ///
368    /// Readable | Writeable
369    ///
370    ///
371    /// #### `use-alpha`
372    ///  Whether colors may have alpha (translucency).
373    ///
374    /// When ::use-alpha is [`false`], the [`gdk::RGBA`][crate::gdk::RGBA] struct obtained
375    /// via the [`rgba`][struct@crate::ColorChooser#rgba] property will be
376    /// forced to have alpha == 1.
377    ///
378    /// Implementations are expected to show alpha by rendering the color
379    /// over a non-uniform background (like a checkerboard pattern).
380    ///
381    /// Readable | Writeable
382    /// </details>
383    ///
384    /// # Implements
385    ///
386    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`ColorChooserExt`][trait@crate::prelude::ColorChooserExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual], [`ColorChooserExtManual`][trait@crate::prelude::ColorChooserExtManual]
387    #[doc(alias = "GtkColorChooserWidget")]
388    pub struct ColorChooserWidget(Object<ffi::GtkColorChooserWidget>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, ColorChooser;
389
390    match fn {
391        type_ => || ffi::gtk_color_chooser_widget_get_type(),
392    }
393}
394
395impl ColorChooserWidget {
396    /// Creates a new [`ColorChooserWidget`][crate::ColorChooserWidget].
397    ///
398    /// # Returns
399    ///
400    /// a new [`ColorChooserWidget`][crate::ColorChooserWidget]
401    #[doc(alias = "gtk_color_chooser_widget_new")]
402    pub fn new() -> ColorChooserWidget {
403        assert_initialized_main_thread!();
404        unsafe { Widget::from_glib_none(ffi::gtk_color_chooser_widget_new()).unsafe_cast() }
405    }
406
407    // rustdoc-stripper-ignore-next
408    /// Creates a new builder-pattern struct instance to construct [`ColorChooserWidget`] objects.
409    ///
410    /// This method returns an instance of [`ColorChooserWidgetBuilder`](crate::builders::ColorChooserWidgetBuilder) which can be used to create [`ColorChooserWidget`] objects.
411    pub fn builder() -> ColorChooserWidgetBuilder {
412        ColorChooserWidgetBuilder::new()
413    }
414
415    /// [`true`] when the color chooser is showing the single-color editor.
416    ///
417    /// It can be set to switch the color chooser into single-color editing mode.
418    #[doc(alias = "show-editor")]
419    pub fn shows_editor(&self) -> bool {
420        ObjectExt::property(self, "show-editor")
421    }
422
423    /// [`true`] when the color chooser is showing the single-color editor.
424    ///
425    /// It can be set to switch the color chooser into single-color editing mode.
426    #[doc(alias = "show-editor")]
427    pub fn set_show_editor(&self, show_editor: bool) {
428        ObjectExt::set_property(self, "show-editor", show_editor)
429    }
430
431    #[doc(alias = "show-editor")]
432    pub fn connect_show_editor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
433        unsafe extern "C" fn notify_show_editor_trampoline<F: Fn(&ColorChooserWidget) + 'static>(
434            this: *mut ffi::GtkColorChooserWidget,
435            _param_spec: glib::ffi::gpointer,
436            f: glib::ffi::gpointer,
437        ) {
438            let f: &F = &*(f as *const F);
439            f(&from_glib_borrow(this))
440        }
441        unsafe {
442            let f: Box_<F> = Box_::new(f);
443            connect_raw(
444                self.as_ptr() as *mut _,
445                c"notify::show-editor".as_ptr() as *const _,
446                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
447                    notify_show_editor_trampoline::<F> as *const (),
448                )),
449                Box_::into_raw(f),
450            )
451        }
452    }
453}
454
455impl Default for ColorChooserWidget {
456    fn default() -> Self {
457        Self::new()
458    }
459}
460
461// rustdoc-stripper-ignore-next
462/// A [builder-pattern] type to construct [`ColorChooserWidget`] objects.
463///
464/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
465#[must_use = "The builder must be built to be used"]
466pub struct ColorChooserWidgetBuilder {
467    builder: glib::object::ObjectBuilder<'static, ColorChooserWidget>,
468}
469
470impl ColorChooserWidgetBuilder {
471    fn new() -> Self {
472        Self {
473            builder: glib::object::Object::builder(),
474        }
475    }
476
477    /// [`true`] when the color chooser is showing the single-color editor.
478    ///
479    /// It can be set to switch the color chooser into single-color editing mode.
480    pub fn show_editor(self, show_editor: bool) -> Self {
481        Self {
482            builder: self.builder.property("show-editor", show_editor),
483        }
484    }
485
486    /// Whether the widget or any of its descendents can accept
487    /// the input focus.
488    ///
489    /// This property is meant to be set by widget implementations,
490    /// typically in their instance init function.
491    pub fn can_focus(self, can_focus: bool) -> Self {
492        Self {
493            builder: self.builder.property("can-focus", can_focus),
494        }
495    }
496
497    /// Whether the widget can receive pointer events.
498    pub fn can_target(self, can_target: bool) -> Self {
499        Self {
500            builder: self.builder.property("can-target", can_target),
501        }
502    }
503
504    /// A list of css classes applied to this widget.
505    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
506        Self {
507            builder: self.builder.property("css-classes", css_classes.into()),
508        }
509    }
510
511    /// The name of this widget in the CSS tree.
512    ///
513    /// This property is meant to be set by widget implementations,
514    /// typically in their instance init function.
515    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
516        Self {
517            builder: self.builder.property("css-name", css_name.into()),
518        }
519    }
520
521    /// The cursor used by @widget.
522    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
523        Self {
524            builder: self.builder.property("cursor", cursor.clone()),
525        }
526    }
527
528    /// Whether the widget should grab focus when it is clicked with the mouse.
529    ///
530    /// This property is only relevant for widgets that can take focus.
531    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
532        Self {
533            builder: self.builder.property("focus-on-click", focus_on_click),
534        }
535    }
536
537    /// Whether this widget itself will accept the input focus.
538    pub fn focusable(self, focusable: bool) -> Self {
539        Self {
540            builder: self.builder.property("focusable", focusable),
541        }
542    }
543
544    /// How to distribute horizontal space if widget gets extra space.
545    pub fn halign(self, halign: Align) -> Self {
546        Self {
547            builder: self.builder.property("halign", halign),
548        }
549    }
550
551    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
552    /// signal on @widget.
553    ///
554    /// A true value indicates that @widget can have a tooltip, in this case
555    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
556    /// determine whether it will provide a tooltip or not.
557    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
558        Self {
559            builder: self.builder.property("has-tooltip", has_tooltip),
560        }
561    }
562
563    /// Overrides for height request of the widget.
564    ///
565    /// If this is -1, the natural request will be used.
566    pub fn height_request(self, height_request: i32) -> Self {
567        Self {
568            builder: self.builder.property("height-request", height_request),
569        }
570    }
571
572    /// Whether to expand horizontally.
573    pub fn hexpand(self, hexpand: bool) -> Self {
574        Self {
575            builder: self.builder.property("hexpand", hexpand),
576        }
577    }
578
579    /// Whether to use the `hexpand` property.
580    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
581        Self {
582            builder: self.builder.property("hexpand-set", hexpand_set),
583        }
584    }
585
586    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
587    /// the preferred size of the widget, and allocate its children.
588    ///
589    /// This property is meant to be set by widget implementations,
590    /// typically in their instance init function.
591    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
592        Self {
593            builder: self
594                .builder
595                .property("layout-manager", layout_manager.clone().upcast()),
596        }
597    }
598
599    /// Makes this widget act like a modal dialog, with respect to
600    /// event delivery.
601    ///
602    /// Global event controllers will not handle events with targets
603    /// inside the widget, unless they are set up to ignore propagation
604    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
605    #[cfg(feature = "v4_18")]
606    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
607    pub fn limit_events(self, limit_events: bool) -> Self {
608        Self {
609            builder: self.builder.property("limit-events", limit_events),
610        }
611    }
612
613    /// Margin on bottom side of widget.
614    ///
615    /// This property adds margin outside of the widget's normal size
616    /// request, the margin will be added in addition to the size from
617    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
618    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
619        Self {
620            builder: self.builder.property("margin-bottom", margin_bottom),
621        }
622    }
623
624    /// Margin on end of widget, horizontally.
625    ///
626    /// This property supports left-to-right and right-to-left text
627    /// directions.
628    ///
629    /// This property adds margin outside of the widget's normal size
630    /// request, the margin will be added in addition to the size from
631    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
632    pub fn margin_end(self, margin_end: i32) -> Self {
633        Self {
634            builder: self.builder.property("margin-end", margin_end),
635        }
636    }
637
638    /// Margin on start of widget, horizontally.
639    ///
640    /// This property supports left-to-right and right-to-left text
641    /// directions.
642    ///
643    /// This property adds margin outside of the widget's normal size
644    /// request, the margin will be added in addition to the size from
645    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
646    pub fn margin_start(self, margin_start: i32) -> Self {
647        Self {
648            builder: self.builder.property("margin-start", margin_start),
649        }
650    }
651
652    /// Margin on top side of widget.
653    ///
654    /// This property adds margin outside of the widget's normal size
655    /// request, the margin will be added in addition to the size from
656    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
657    pub fn margin_top(self, margin_top: i32) -> Self {
658        Self {
659            builder: self.builder.property("margin-top", margin_top),
660        }
661    }
662
663    /// The name of the widget.
664    pub fn name(self, name: impl Into<glib::GString>) -> Self {
665        Self {
666            builder: self.builder.property("name", name.into()),
667        }
668    }
669
670    /// The requested opacity of the widget.
671    pub fn opacity(self, opacity: f64) -> Self {
672        Self {
673            builder: self.builder.property("opacity", opacity),
674        }
675    }
676
677    /// How content outside the widget's content area is treated.
678    ///
679    /// This property is meant to be set by widget implementations,
680    /// typically in their instance init function.
681    pub fn overflow(self, overflow: Overflow) -> Self {
682        Self {
683            builder: self.builder.property("overflow", overflow),
684        }
685    }
686
687    /// Whether the widget will receive the default action when it is focused.
688    pub fn receives_default(self, receives_default: bool) -> Self {
689        Self {
690            builder: self.builder.property("receives-default", receives_default),
691        }
692    }
693
694    /// Whether the widget responds to input.
695    pub fn sensitive(self, sensitive: bool) -> Self {
696        Self {
697            builder: self.builder.property("sensitive", sensitive),
698        }
699    }
700
701    /// Sets the text of tooltip to be the given string, which is marked up
702    /// with Pango markup.
703    ///
704    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
705    ///
706    /// This is a convenience property which will take care of getting the
707    /// tooltip shown if the given string is not `NULL`:
708    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
709    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
710    /// the default signal handler.
711    ///
712    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
713    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
714    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
715        Self {
716            builder: self
717                .builder
718                .property("tooltip-markup", tooltip_markup.into()),
719        }
720    }
721
722    /// Sets the text of tooltip to be the given string.
723    ///
724    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
725    ///
726    /// This is a convenience property which will take care of getting the
727    /// tooltip shown if the given string is not `NULL`:
728    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
729    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
730    /// the default signal handler.
731    ///
732    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
733    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
734    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
735        Self {
736            builder: self.builder.property("tooltip-text", tooltip_text.into()),
737        }
738    }
739
740    /// How to distribute vertical space if widget gets extra space.
741    pub fn valign(self, valign: Align) -> Self {
742        Self {
743            builder: self.builder.property("valign", valign),
744        }
745    }
746
747    /// Whether to expand vertically.
748    pub fn vexpand(self, vexpand: bool) -> Self {
749        Self {
750            builder: self.builder.property("vexpand", vexpand),
751        }
752    }
753
754    /// Whether to use the `vexpand` property.
755    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
756        Self {
757            builder: self.builder.property("vexpand-set", vexpand_set),
758        }
759    }
760
761    /// Whether the widget is visible.
762    pub fn visible(self, visible: bool) -> Self {
763        Self {
764            builder: self.builder.property("visible", visible),
765        }
766    }
767
768    /// Overrides for width request of the widget.
769    ///
770    /// If this is -1, the natural request will be used.
771    pub fn width_request(self, width_request: i32) -> Self {
772        Self {
773            builder: self.builder.property("width-request", width_request),
774        }
775    }
776
777    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
778    ///
779    /// The accessible role cannot be changed once set.
780    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
781        Self {
782            builder: self.builder.property("accessible-role", accessible_role),
783        }
784    }
785
786    /// The currently selected color, as a [`gdk::RGBA`][crate::gdk::RGBA] struct.
787    ///
788    /// The property can be set to change the current selection
789    /// programmatically.
790    /// Use [`ColorDialog`][crate::ColorDialog] and [`ColorDialogButton`][crate::ColorDialogButton]
791    ///   instead of widgets implementing [`ColorChooser`][crate::ColorChooser]
792    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
793    pub fn rgba(self, rgba: &gdk::RGBA) -> Self {
794        Self {
795            builder: self.builder.property("rgba", rgba),
796        }
797    }
798
799    /// Whether colors may have alpha (translucency).
800    ///
801    /// When ::use-alpha is [`false`], the [`gdk::RGBA`][crate::gdk::RGBA] struct obtained
802    /// via the [`rgba`][struct@crate::ColorChooser#rgba] property will be
803    /// forced to have alpha == 1.
804    ///
805    /// Implementations are expected to show alpha by rendering the color
806    /// over a non-uniform background (like a checkerboard pattern).
807    /// Use [`ColorDialog`][crate::ColorDialog] and [`ColorDialogButton`][crate::ColorDialogButton]
808    ///   instead of widgets implementing [`ColorChooser`][crate::ColorChooser]
809    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
810    pub fn use_alpha(self, use_alpha: bool) -> Self {
811        Self {
812            builder: self.builder.property("use-alpha", use_alpha),
813        }
814    }
815
816    // rustdoc-stripper-ignore-next
817    /// Build the [`ColorChooserWidget`].
818    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
819    pub fn build(self) -> ColorChooserWidget {
820        assert_initialized_main_thread!();
821        self.builder.build()
822    }
823}