Skip to main content

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