Skip to main content

gtk4/auto/
color_dialog_button.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    Accessible, AccessibleRole, Align, Buildable, ColorDialog, ConstraintTarget, LayoutManager,
7    Overflow, Widget, ffi,
8};
9#[cfg(feature = "v4_14")]
10#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
11use glib::object::ObjectType as _;
12use glib::{
13    prelude::*,
14    signal::{SignalHandlerId, connect_raw},
15    translate::*,
16};
17use std::boxed::Box as Box_;
18
19glib::wrapper! {
20    ///  [content]
21    /// ```text
22    ///
23    /// [`ColorDialogButton`][crate::ColorDialogButton] has a single CSS node with name colorbutton which
24    /// contains a button node. To differentiate it from a plain [`Button`][crate::Button],
25    /// it gets the .color style class.
26    ///
27    /// ## Properties
28    ///
29    ///
30    /// #### `dialog`
31    ///  The [`ColorDialog`][crate::ColorDialog] that contains parameters for
32    /// the color chooser dialog.
33    ///
34    /// Readable | Writable
35    ///
36    ///
37    /// #### `rgba`
38    ///  The selected color.
39    ///
40    /// This property can be set to give the button its initial
41    /// color, and it will be updated to reflect the users choice
42    /// in the color chooser dialog.
43    ///
44    /// Listen to `notify::rgba` to get informed about changes
45    /// to the buttons color.
46    ///
47    /// Readable | Writable
48    /// <details><summary><h4>Widget</h4></summary>
49    ///
50    ///
51    /// #### `can-focus`
52    ///  Whether the widget or any of its descendents can accept
53    /// the input focus.
54    ///
55    /// This property is meant to be set by widget implementations,
56    /// typically in their instance init function.
57    ///
58    /// Readable | Writable
59    ///
60    ///
61    /// #### `can-target`
62    ///  Whether the widget can receive pointer events.
63    ///
64    /// Readable | Writable
65    ///
66    ///
67    /// #### `css-classes`
68    ///  A list of css classes applied to this widget.
69    ///
70    /// Readable | Writable
71    ///
72    ///
73    /// #### `css-name`
74    ///  The name of this widget in the CSS tree.
75    ///
76    /// This property is meant to be set by widget implementations,
77    /// typically in their instance init function.
78    ///
79    /// Readable | Writable | Construct Only
80    ///
81    ///
82    /// #### `cursor`
83    ///  The cursor used by @widget.
84    ///
85    /// Readable | Writable
86    ///
87    ///
88    /// #### `focus-on-click`
89    ///  Whether the widget should grab focus when it is clicked with the mouse.
90    ///
91    /// This property is only relevant for widgets that can take focus.
92    ///
93    /// Readable | Writable
94    ///
95    ///
96    /// #### `focusable`
97    ///  Whether this widget itself will accept the input focus.
98    ///
99    /// Readable | Writable
100    ///
101    ///
102    /// #### `halign`
103    ///  How to distribute horizontal space if widget gets extra space.
104    ///
105    /// Readable | Writable
106    ///
107    ///
108    /// #### `has-default`
109    ///  Whether the widget is the default widget.
110    ///
111    /// Readable
112    ///
113    ///
114    /// #### `has-focus`
115    ///  Whether the widget has the input focus.
116    ///
117    /// Readable
118    ///
119    ///
120    /// #### `has-tooltip`
121    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
122    /// signal on @widget.
123    ///
124    /// A true value indicates that @widget can have a tooltip, in this case
125    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
126    /// determine whether it will provide a tooltip or not.
127    ///
128    /// Readable | Writable
129    ///
130    ///
131    /// #### `height-request`
132    ///  Overrides for height request of the widget.
133    ///
134    /// If this is -1, the natural request will be used.
135    ///
136    /// Readable | Writable
137    ///
138    ///
139    /// #### `hexpand`
140    ///  Whether to expand horizontally.
141    ///
142    /// Readable | Writable
143    ///
144    ///
145    /// #### `hexpand-set`
146    ///  Whether to use the `hexpand` property.
147    ///
148    /// Readable | Writable
149    ///
150    ///
151    /// #### `layout-manager`
152    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
153    /// the preferred size of the widget, and allocate its children.
154    ///
155    /// This property is meant to be set by widget implementations,
156    /// typically in their instance init function.
157    ///
158    /// Readable | Writable
159    ///
160    ///
161    /// #### `limit-events`
162    ///  Makes this widget act like a modal dialog, with respect to
163    /// event delivery.
164    ///
165    /// Global event controllers will not handle events with targets
166    /// inside the widget, unless they are set up to ignore propagation
167    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
168    ///
169    /// Readable | Writable
170    ///
171    ///
172    /// #### `margin-bottom`
173    ///  Margin on bottom side of widget.
174    ///
175    /// This property adds margin outside of the widget's normal size
176    /// request, the margin will be added in addition to the size from
177    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
178    ///
179    /// Readable | Writable
180    ///
181    ///
182    /// #### `margin-end`
183    ///  Margin on end of widget, horizontally.
184    ///
185    /// This property supports left-to-right and right-to-left text
186    /// directions.
187    ///
188    /// This property adds margin outside of the widget's normal size
189    /// request, the margin will be added in addition to the size from
190    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
191    ///
192    /// Readable | Writable
193    ///
194    ///
195    /// #### `margin-start`
196    ///  Margin on start of widget, horizontally.
197    ///
198    /// This property supports left-to-right and right-to-left text
199    /// directions.
200    ///
201    /// This property adds margin outside of the widget's normal size
202    /// request, the margin will be added in addition to the size from
203    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
204    ///
205    /// Readable | Writable
206    ///
207    ///
208    /// #### `margin-top`
209    ///  Margin on top side of widget.
210    ///
211    /// This property adds margin outside of the widget's normal size
212    /// request, the margin will be added in addition to the size from
213    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
214    ///
215    /// Readable | Writable
216    ///
217    ///
218    /// #### `name`
219    ///  The name of the widget.
220    ///
221    /// Readable | Writable
222    ///
223    ///
224    /// #### `opacity`
225    ///  The requested opacity of the widget.
226    ///
227    /// Readable | Writable
228    ///
229    ///
230    /// #### `overflow`
231    ///  How content outside the widget's content area is treated.
232    ///
233    /// This property is meant to be set by widget implementations,
234    /// typically in their instance init function.
235    ///
236    /// Readable | Writable
237    ///
238    ///
239    /// #### `parent`
240    ///  The parent widget of this widget.
241    ///
242    /// Readable
243    ///
244    ///
245    /// #### `receives-default`
246    ///  Whether the widget will receive the default action when it is focused.
247    ///
248    /// Readable | Writable
249    ///
250    ///
251    /// #### `root`
252    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
253    ///
254    /// This will be `NULL` if the widget is not contained in a root widget.
255    ///
256    /// Readable
257    ///
258    ///
259    /// #### `scale-factor`
260    ///  The scale factor of the widget.
261    ///
262    /// Readable
263    ///
264    ///
265    /// #### `sensitive`
266    ///  Whether the widget responds to input.
267    ///
268    /// Readable | Writable
269    ///
270    ///
271    /// #### `tooltip-markup`
272    ///  Sets the text of tooltip to be the given string, which is marked up
273    /// with Pango markup.
274    ///
275    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
276    ///
277    /// This is a convenience property which will take care of getting the
278    /// tooltip shown if the given string is not `NULL`:
279    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
280    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
281    /// the default signal handler.
282    ///
283    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
284    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
285    ///
286    /// Readable | Writable
287    ///
288    ///
289    /// #### `tooltip-text`
290    ///  Sets the text of tooltip to be the given string.
291    ///
292    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
293    ///
294    /// This is a convenience property which will take care of getting the
295    /// tooltip shown if the given string is not `NULL`:
296    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
297    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
298    /// the default signal handler.
299    ///
300    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
301    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
302    ///
303    /// Readable | Writable
304    ///
305    ///
306    /// #### `valign`
307    ///  How to distribute vertical space if widget gets extra space.
308    ///
309    /// Readable | Writable
310    ///
311    ///
312    /// #### `vexpand`
313    ///  Whether to expand vertically.
314    ///
315    /// Readable | Writable
316    ///
317    ///
318    /// #### `vexpand-set`
319    ///  Whether to use the `vexpand` property.
320    ///
321    /// Readable | Writable
322    ///
323    ///
324    /// #### `visible`
325    ///  Whether the widget is visible.
326    ///
327    /// Readable | Writable
328    ///
329    ///
330    /// #### `width-request`
331    ///  Overrides for width request of the widget.
332    ///
333    /// If this is -1, the natural request will be used.
334    ///
335    /// Readable | Writable
336    /// </details>
337    /// <details><summary><h4>Accessible</h4></summary>
338    ///
339    ///
340    /// #### `accessible-role`
341    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
342    ///
343    /// The accessible role cannot be changed once set.
344    ///
345    /// Readable | Writable
346    /// </details>
347    ///
348    /// ## Signals
349    ///
350    ///
351    /// #### `activate`
352    ///  Emitted when the color dialog button is activated.
353    ///
354    /// The `::activate` signal on [`ColorDialogButton`][crate::ColorDialogButton] is an action signal
355    /// and emitting it causes the button to pop up its dialog.
356    ///
357    /// Action
358    /// <details><summary><h4>Widget</h4></summary>
359    ///
360    ///
361    /// #### `destroy`
362    ///  Signals that all holders of a reference to the widget should release
363    /// the reference that they hold.
364    ///
365    /// May result in finalization of the widget if all references are released.
366    ///
367    /// This signal is not suitable for saving widget state.
368    ///
369    ///
370    ///
371    ///
372    /// #### `direction-changed`
373    ///  Emitted when the text direction of a widget changes.
374    ///
375    ///
376    ///
377    ///
378    /// #### `hide`
379    ///  Emitted when @widget is hidden.
380    ///
381    ///
382    ///
383    ///
384    /// #### `keynav-failed`
385    ///  Emitted if keyboard navigation fails.
386    ///
387    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
388    ///
389    ///
390    ///
391    ///
392    /// #### `map`
393    ///  Emitted when @widget is going to be mapped.
394    ///
395    /// A widget is mapped when the widget is visible (which is controlled with
396    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
397    /// are also visible.
398    ///
399    /// The `::map` signal can be used to determine whether a widget will be drawn,
400    /// for instance it can resume an animation that was stopped during the
401    /// emission of [`unmap`][struct@crate::Widget#unmap].
402    ///
403    ///
404    ///
405    ///
406    /// #### `mnemonic-activate`
407    ///  Emitted when a widget is activated via a mnemonic.
408    ///
409    /// The default handler for this signal activates @widget if @group_cycling
410    /// is false, or just makes @widget grab focus if @group_cycling is true.
411    ///
412    ///
413    ///
414    ///
415    /// #### `move-focus`
416    ///   to move backward.
417    ///
418    /// Action
419    ///
420    ///
421    /// #### `query-tooltip`
422    ///  s tooltip is about to be shown.
423    ///
424    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
425    /// is true and the hover timeout has expired with the cursor hovering
426    /// above @widget; or emitted when @widget got focus in keyboard mode.
427    ///
428    /// Using the given coordinates, the signal handler should determine
429    /// whether a tooltip should be shown for @widget. If this is the case
430    /// true should be returned, false otherwise. Note that if @keyboard_mode
431    /// is true, the values of @x and @y are undefined and should not be used.
432    ///
433    /// The signal handler is free to manipulate @tooltip with the therefore
434    /// destined function calls.
435    ///
436    ///
437    ///
438    ///
439    /// #### `realize`
440    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
441    ///
442    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
443    /// or the widget has been mapped (that is, it is going to be drawn).
444    ///
445    ///
446    ///
447    ///
448    /// #### `show`
449    ///  Emitted when @widget is shown.
450    ///
451    ///
452    ///
453    ///
454    /// #### `state-flags-changed`
455    ///  Emitted when the widget state changes.
456    ///
457    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
458    ///
459    ///
460    ///
461    ///
462    /// #### `unmap`
463    ///  Emitted when @widget is going to be unmapped.
464    ///
465    /// A widget is unmapped when either it or any of its parents up to the
466    /// toplevel widget have been set as hidden.
467    ///
468    /// As `::unmap` indicates that a widget will not be shown any longer,
469    /// it can be used to, for example, stop an animation on the widget.
470    ///
471    ///
472    ///
473    ///
474    /// #### `unrealize`
475    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
476    ///
477    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
478    /// or the widget has been unmapped (that is, it is going to be hidden).
479    ///
480    ///
481    /// </details>
482    ///
483    /// # Implements
484    ///
485    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
486    #[doc(alias = "GtkColorDialogButton")]
487    pub struct ColorDialogButton(Object<ffi::GtkColorDialogButton, ffi::GtkColorDialogButtonClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
488
489    match fn {
490        type_ => || ffi::gtk_color_dialog_button_get_type(),
491    }
492}
493
494impl ColorDialogButton {
495    /// Creates a new [`ColorDialogButton`][crate::ColorDialogButton] with the
496    /// given [`ColorDialog`][crate::ColorDialog].
497    ///
498    /// You can pass `NULL` to this function and set a [`ColorDialog`][crate::ColorDialog]
499    /// later. The button will be insensitive until that happens.
500    /// ## `dialog`
501    /// the [`ColorDialog`][crate::ColorDialog] to use
502    ///
503    /// # Returns
504    ///
505    /// the new [`ColorDialogButton`][crate::ColorDialogButton]
506    #[doc(alias = "gtk_color_dialog_button_new")]
507    pub fn new(dialog: Option<ColorDialog>) -> ColorDialogButton {
508        assert_initialized_main_thread!();
509        unsafe {
510            Widget::from_glib_none(ffi::gtk_color_dialog_button_new(dialog.into_glib_ptr()))
511                .unsafe_cast()
512        }
513    }
514
515    // rustdoc-stripper-ignore-next
516    /// Creates a new builder-pattern struct instance to construct [`ColorDialogButton`] objects.
517    ///
518    /// This method returns an instance of [`ColorDialogButtonBuilder`](crate::builders::ColorDialogButtonBuilder) which can be used to create [`ColorDialogButton`] objects.
519    pub fn builder() -> ColorDialogButtonBuilder {
520        ColorDialogButtonBuilder::new()
521    }
522
523    /// Returns the [`ColorDialog`][crate::ColorDialog] of @self.
524    ///
525    /// # Returns
526    ///
527    /// the [`ColorDialog`][crate::ColorDialog]
528    #[doc(alias = "gtk_color_dialog_button_get_dialog")]
529    #[doc(alias = "get_dialog")]
530    pub fn dialog(&self) -> Option<ColorDialog> {
531        unsafe {
532            from_glib_none(ffi::gtk_color_dialog_button_get_dialog(
533                self.to_glib_none().0,
534            ))
535        }
536    }
537
538    /// Returns the color of the button.
539    ///
540    /// This function is what should be used to obtain
541    /// the color that was chosen by the user. To get
542    /// informed about changes, listen to "notify::rgba".
543    ///
544    /// # Returns
545    ///
546    /// the color
547    #[doc(alias = "gtk_color_dialog_button_get_rgba")]
548    #[doc(alias = "get_rgba")]
549    pub fn rgba(&self) -> gdk::RGBA {
550        unsafe { from_glib_none(ffi::gtk_color_dialog_button_get_rgba(self.to_glib_none().0)) }
551    }
552
553    /// Sets a [`ColorDialog`][crate::ColorDialog] object to use for
554    /// creating the color chooser dialog that is
555    /// presented when the user clicks the button.
556    /// ## `dialog`
557    /// the new [`ColorDialog`][crate::ColorDialog]
558    #[doc(alias = "gtk_color_dialog_button_set_dialog")]
559    #[doc(alias = "dialog")]
560    pub fn set_dialog(&self, dialog: &ColorDialog) {
561        unsafe {
562            ffi::gtk_color_dialog_button_set_dialog(self.to_glib_none().0, dialog.to_glib_none().0);
563        }
564    }
565
566    /// Sets the color of the button.
567    /// ## `color`
568    /// the new color
569    #[doc(alias = "gtk_color_dialog_button_set_rgba")]
570    #[doc(alias = "rgba")]
571    pub fn set_rgba(&self, color: &gdk::RGBA) {
572        unsafe {
573            ffi::gtk_color_dialog_button_set_rgba(self.to_glib_none().0, color.to_glib_none().0);
574        }
575    }
576
577    /// Emitted when the color dialog button is activated.
578    ///
579    /// The `::activate` signal on [`ColorDialogButton`][crate::ColorDialogButton] is an action signal
580    /// and emitting it causes the button to pop up its dialog.
581    #[cfg(feature = "v4_14")]
582    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
583    #[doc(alias = "activate")]
584    pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
585        unsafe extern "C" fn activate_trampoline<F: Fn(&ColorDialogButton) + 'static>(
586            this: *mut ffi::GtkColorDialogButton,
587            f: glib::ffi::gpointer,
588        ) {
589            unsafe {
590                let f: &F = &*(f as *const F);
591                f(&from_glib_borrow(this))
592            }
593        }
594        unsafe {
595            let f: Box_<F> = Box_::new(f);
596            connect_raw(
597                self.as_ptr() as *mut _,
598                c"activate".as_ptr(),
599                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
600                    activate_trampoline::<F> as *const (),
601                )),
602                Box_::into_raw(f),
603            )
604        }
605    }
606
607    #[cfg(feature = "v4_14")]
608    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
609    pub fn emit_activate(&self) {
610        self.emit_by_name::<()>("activate", &[]);
611    }
612
613    #[cfg(feature = "v4_10")]
614    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
615    #[doc(alias = "dialog")]
616    pub fn connect_dialog_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
617        unsafe extern "C" fn notify_dialog_trampoline<F: Fn(&ColorDialogButton) + 'static>(
618            this: *mut ffi::GtkColorDialogButton,
619            _param_spec: glib::ffi::gpointer,
620            f: glib::ffi::gpointer,
621        ) {
622            unsafe {
623                let f: &F = &*(f as *const F);
624                f(&from_glib_borrow(this))
625            }
626        }
627        unsafe {
628            let f: Box_<F> = Box_::new(f);
629            connect_raw(
630                self.as_ptr() as *mut _,
631                c"notify::dialog".as_ptr(),
632                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
633                    notify_dialog_trampoline::<F> as *const (),
634                )),
635                Box_::into_raw(f),
636            )
637        }
638    }
639
640    #[cfg(feature = "v4_10")]
641    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
642    #[doc(alias = "rgba")]
643    pub fn connect_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
644        unsafe extern "C" fn notify_rgba_trampoline<F: Fn(&ColorDialogButton) + 'static>(
645            this: *mut ffi::GtkColorDialogButton,
646            _param_spec: glib::ffi::gpointer,
647            f: glib::ffi::gpointer,
648        ) {
649            unsafe {
650                let f: &F = &*(f as *const F);
651                f(&from_glib_borrow(this))
652            }
653        }
654        unsafe {
655            let f: Box_<F> = Box_::new(f);
656            connect_raw(
657                self.as_ptr() as *mut _,
658                c"notify::rgba".as_ptr(),
659                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
660                    notify_rgba_trampoline::<F> as *const (),
661                )),
662                Box_::into_raw(f),
663            )
664        }
665    }
666}
667
668#[cfg(feature = "v4_10")]
669#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
670impl Default for ColorDialogButton {
671    fn default() -> Self {
672        glib::object::Object::new::<Self>()
673    }
674}
675
676// rustdoc-stripper-ignore-next
677/// A [builder-pattern] type to construct [`ColorDialogButton`] objects.
678///
679/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
680#[must_use = "The builder must be built to be used"]
681pub struct ColorDialogButtonBuilder {
682    builder: glib::object::ObjectBuilder<'static, ColorDialogButton>,
683}
684
685impl ColorDialogButtonBuilder {
686    fn new() -> Self {
687        Self {
688            builder: glib::object::Object::builder(),
689        }
690    }
691
692    /// The [`ColorDialog`][crate::ColorDialog] that contains parameters for
693    /// the color chooser dialog.
694    #[cfg(feature = "v4_10")]
695    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
696    pub fn dialog(self, dialog: &ColorDialog) -> Self {
697        Self {
698            builder: self.builder.property("dialog", dialog.clone()),
699        }
700    }
701
702    /// The selected color.
703    ///
704    /// This property can be set to give the button its initial
705    /// color, and it will be updated to reflect the users choice
706    /// in the color chooser dialog.
707    ///
708    /// Listen to `notify::rgba` to get informed about changes
709    /// to the buttons color.
710    #[cfg(feature = "v4_10")]
711    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
712    pub fn rgba(self, rgba: &gdk::RGBA) -> Self {
713        Self {
714            builder: self.builder.property("rgba", rgba),
715        }
716    }
717
718    /// Whether the widget or any of its descendents can accept
719    /// the input focus.
720    ///
721    /// This property is meant to be set by widget implementations,
722    /// typically in their instance init function.
723    pub fn can_focus(self, can_focus: bool) -> Self {
724        Self {
725            builder: self.builder.property("can-focus", can_focus),
726        }
727    }
728
729    /// Whether the widget can receive pointer events.
730    pub fn can_target(self, can_target: bool) -> Self {
731        Self {
732            builder: self.builder.property("can-target", can_target),
733        }
734    }
735
736    /// A list of css classes applied to this widget.
737    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
738        Self {
739            builder: self.builder.property("css-classes", css_classes.into()),
740        }
741    }
742
743    /// The name of this widget in the CSS tree.
744    ///
745    /// This property is meant to be set by widget implementations,
746    /// typically in their instance init function.
747    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
748        Self {
749            builder: self.builder.property("css-name", css_name.into()),
750        }
751    }
752
753    /// The cursor used by @widget.
754    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
755        Self {
756            builder: self.builder.property("cursor", cursor.clone()),
757        }
758    }
759
760    /// Whether the widget should grab focus when it is clicked with the mouse.
761    ///
762    /// This property is only relevant for widgets that can take focus.
763    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
764        Self {
765            builder: self.builder.property("focus-on-click", focus_on_click),
766        }
767    }
768
769    /// Whether this widget itself will accept the input focus.
770    pub fn focusable(self, focusable: bool) -> Self {
771        Self {
772            builder: self.builder.property("focusable", focusable),
773        }
774    }
775
776    /// How to distribute horizontal space if widget gets extra space.
777    pub fn halign(self, halign: Align) -> Self {
778        Self {
779            builder: self.builder.property("halign", halign),
780        }
781    }
782
783    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
784    /// signal on @widget.
785    ///
786    /// A true value indicates that @widget can have a tooltip, in this case
787    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
788    /// determine whether it will provide a tooltip or not.
789    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
790        Self {
791            builder: self.builder.property("has-tooltip", has_tooltip),
792        }
793    }
794
795    /// Overrides for height request of the widget.
796    ///
797    /// If this is -1, the natural request will be used.
798    pub fn height_request(self, height_request: i32) -> Self {
799        Self {
800            builder: self.builder.property("height-request", height_request),
801        }
802    }
803
804    /// Whether to expand horizontally.
805    pub fn hexpand(self, hexpand: bool) -> Self {
806        Self {
807            builder: self.builder.property("hexpand", hexpand),
808        }
809    }
810
811    /// Whether to use the `hexpand` property.
812    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
813        Self {
814            builder: self.builder.property("hexpand-set", hexpand_set),
815        }
816    }
817
818    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
819    /// the preferred size of the widget, and allocate its children.
820    ///
821    /// This property is meant to be set by widget implementations,
822    /// typically in their instance init function.
823    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
824        Self {
825            builder: self
826                .builder
827                .property("layout-manager", layout_manager.clone().upcast()),
828        }
829    }
830
831    /// Makes this widget act like a modal dialog, with respect to
832    /// event delivery.
833    ///
834    /// Global event controllers will not handle events with targets
835    /// inside the widget, unless they are set up to ignore propagation
836    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
837    #[cfg(feature = "v4_18")]
838    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
839    pub fn limit_events(self, limit_events: bool) -> Self {
840        Self {
841            builder: self.builder.property("limit-events", limit_events),
842        }
843    }
844
845    /// Margin on bottom side of widget.
846    ///
847    /// This property adds margin outside of the widget's normal size
848    /// request, the margin will be added in addition to the size from
849    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
850    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
851        Self {
852            builder: self.builder.property("margin-bottom", margin_bottom),
853        }
854    }
855
856    /// Margin on end of widget, horizontally.
857    ///
858    /// This property supports left-to-right and right-to-left text
859    /// directions.
860    ///
861    /// This property adds margin outside of the widget's normal size
862    /// request, the margin will be added in addition to the size from
863    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
864    pub fn margin_end(self, margin_end: i32) -> Self {
865        Self {
866            builder: self.builder.property("margin-end", margin_end),
867        }
868    }
869
870    /// Margin on start of widget, horizontally.
871    ///
872    /// This property supports left-to-right and right-to-left text
873    /// directions.
874    ///
875    /// This property adds margin outside of the widget's normal size
876    /// request, the margin will be added in addition to the size from
877    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
878    pub fn margin_start(self, margin_start: i32) -> Self {
879        Self {
880            builder: self.builder.property("margin-start", margin_start),
881        }
882    }
883
884    /// Margin on top side of widget.
885    ///
886    /// This property adds margin outside of the widget's normal size
887    /// request, the margin will be added in addition to the size from
888    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
889    pub fn margin_top(self, margin_top: i32) -> Self {
890        Self {
891            builder: self.builder.property("margin-top", margin_top),
892        }
893    }
894
895    /// The name of the widget.
896    pub fn name(self, name: impl Into<glib::GString>) -> Self {
897        Self {
898            builder: self.builder.property("name", name.into()),
899        }
900    }
901
902    /// The requested opacity of the widget.
903    pub fn opacity(self, opacity: f64) -> Self {
904        Self {
905            builder: self.builder.property("opacity", opacity),
906        }
907    }
908
909    /// How content outside the widget's content area is treated.
910    ///
911    /// This property is meant to be set by widget implementations,
912    /// typically in their instance init function.
913    pub fn overflow(self, overflow: Overflow) -> Self {
914        Self {
915            builder: self.builder.property("overflow", overflow),
916        }
917    }
918
919    /// Whether the widget will receive the default action when it is focused.
920    pub fn receives_default(self, receives_default: bool) -> Self {
921        Self {
922            builder: self.builder.property("receives-default", receives_default),
923        }
924    }
925
926    /// Whether the widget responds to input.
927    pub fn sensitive(self, sensitive: bool) -> Self {
928        Self {
929            builder: self.builder.property("sensitive", sensitive),
930        }
931    }
932
933    /// Sets the text of tooltip to be the given string, which is marked up
934    /// with Pango markup.
935    ///
936    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
937    ///
938    /// This is a convenience property which will take care of getting the
939    /// tooltip shown if the given string is not `NULL`:
940    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
941    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
942    /// the default signal handler.
943    ///
944    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
945    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
946    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
947        Self {
948            builder: self
949                .builder
950                .property("tooltip-markup", tooltip_markup.into()),
951        }
952    }
953
954    /// Sets the text of tooltip to be the given string.
955    ///
956    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
957    ///
958    /// This is a convenience property which will take care of getting the
959    /// tooltip shown if the given string is not `NULL`:
960    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
961    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
962    /// the default signal handler.
963    ///
964    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
965    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
966    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
967        Self {
968            builder: self.builder.property("tooltip-text", tooltip_text.into()),
969        }
970    }
971
972    /// How to distribute vertical space if widget gets extra space.
973    pub fn valign(self, valign: Align) -> Self {
974        Self {
975            builder: self.builder.property("valign", valign),
976        }
977    }
978
979    /// Whether to expand vertically.
980    pub fn vexpand(self, vexpand: bool) -> Self {
981        Self {
982            builder: self.builder.property("vexpand", vexpand),
983        }
984    }
985
986    /// Whether to use the `vexpand` property.
987    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
988        Self {
989            builder: self.builder.property("vexpand-set", vexpand_set),
990        }
991    }
992
993    /// Whether the widget is visible.
994    pub fn visible(self, visible: bool) -> Self {
995        Self {
996            builder: self.builder.property("visible", visible),
997        }
998    }
999
1000    /// Overrides for width request of the widget.
1001    ///
1002    /// If this is -1, the natural request will be used.
1003    pub fn width_request(self, width_request: i32) -> Self {
1004        Self {
1005            builder: self.builder.property("width-request", width_request),
1006        }
1007    }
1008
1009    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1010    ///
1011    /// The accessible role cannot be changed once set.
1012    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1013        Self {
1014            builder: self.builder.property("accessible-role", accessible_role),
1015        }
1016    }
1017
1018    // rustdoc-stripper-ignore-next
1019    /// Build the [`ColorDialogButton`].
1020    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1021    pub fn build(self) -> ColorDialogButton {
1022        assert_initialized_main_thread!();
1023        self.builder.build()
1024    }
1025}