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    ffi, Accessible, AccessibleRole, Align, Buildable, ColorDialog, ConstraintTarget,
7    LayoutManager, Overflow, Widget,
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::{connect_raw, SignalHandlerId},
15    translate::*,
16};
17use std::boxed::Box as Box_;
18
19glib::wrapper! {
20    /// The [`ColorDialogButton`][crate::ColorDialogButton] is a wrapped around a [`ColorDialog`][crate::ColorDialog]
21    /// and allows to open a color chooser dialog to change the color.
22    ///
23    /// ![An example GtkColorDialogButton](color-button.png)
24    ///
25    /// It is suitable widget for selecting a color in a preference dialog.
26    ///
27    /// # CSS nodes
28    ///
29    /// ```text
30    /// colorbutton
31    /// ╰── button.color
32    ///     ╰── [content]
33    /// ```
34    ///
35    /// [`ColorDialogButton`][crate::ColorDialogButton] has a single CSS node with name colorbutton which
36    /// contains a button node. To differentiate it from a plain [`Button`][crate::Button],
37    /// it gets the .color style class.
38    ///
39    /// ## Properties
40    ///
41    ///
42    /// #### `dialog`
43    ///  The [`ColorDialog`][crate::ColorDialog] that contains parameters for
44    /// the color chooser dialog.
45    ///
46    /// Readable | Writeable
47    ///
48    ///
49    /// #### `rgba`
50    ///  The selected color.
51    ///
52    /// This property can be set to give the button its initial
53    /// color, and it will be updated to reflect the users choice
54    /// in the color chooser dialog.
55    ///
56    /// Listen to `notify::rgba` to get informed about changes
57    /// to the buttons color.
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    ///
360    /// ## Signals
361    ///
362    ///
363    /// #### `activate`
364    ///  Emitted when the color dialog button is activated.
365    ///
366    /// The `::activate` signal on [`ColorDialogButton`][crate::ColorDialogButton] is an action signal
367    /// and emitting it causes the button to pop up its dialog.
368    ///
369    /// Action
370    /// <details><summary><h4>Widget</h4></summary>
371    ///
372    ///
373    /// #### `destroy`
374    ///  Signals that all holders of a reference to the widget should release
375    /// the reference that they hold.
376    ///
377    /// May result in finalization of the widget if all references are released.
378    ///
379    /// This signal is not suitable for saving widget state.
380    ///
381    ///
382    ///
383    ///
384    /// #### `direction-changed`
385    ///  Emitted when the text direction of a widget changes.
386    ///
387    ///
388    ///
389    ///
390    /// #### `hide`
391    ///  Emitted when @widget is hidden.
392    ///
393    ///
394    ///
395    ///
396    /// #### `keynav-failed`
397    ///  Emitted if keyboard navigation fails.
398    ///
399    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
400    ///
401    ///
402    ///
403    ///
404    /// #### `map`
405    ///  Emitted when @widget is going to be mapped.
406    ///
407    /// A widget is mapped when the widget is visible (which is controlled with
408    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
409    /// are also visible.
410    ///
411    /// The `::map` signal can be used to determine whether a widget will be drawn,
412    /// for instance it can resume an animation that was stopped during the
413    /// emission of [`unmap`][struct@crate::Widget#unmap].
414    ///
415    ///
416    ///
417    ///
418    /// #### `mnemonic-activate`
419    ///  Emitted when a widget is activated via a mnemonic.
420    ///
421    /// The default handler for this signal activates @widget if @group_cycling
422    /// is false, or just makes @widget grab focus if @group_cycling is true.
423    ///
424    ///
425    ///
426    ///
427    /// #### `move-focus`
428    ///  Emitted when the focus is moved.
429    ///
430    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
431    ///
432    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
433    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
434    ///
435    /// Action
436    ///
437    ///
438    /// #### `query-tooltip`
439    ///  Emitted when the widget’s tooltip is about to be shown.
440    ///
441    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
442    /// is true and the hover timeout has expired with the cursor hovering
443    /// above @widget; or emitted when @widget got focus in keyboard mode.
444    ///
445    /// Using the given coordinates, the signal handler should determine
446    /// whether a tooltip should be shown for @widget. If this is the case
447    /// true should be returned, false otherwise. Note that if @keyboard_mode
448    /// is true, the values of @x and @y are undefined and should not be used.
449    ///
450    /// The signal handler is free to manipulate @tooltip with the therefore
451    /// destined function calls.
452    ///
453    ///
454    ///
455    ///
456    /// #### `realize`
457    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
458    ///
459    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
460    /// or the widget has been mapped (that is, it is going to be drawn).
461    ///
462    ///
463    ///
464    ///
465    /// #### `show`
466    ///  Emitted when @widget is shown.
467    ///
468    ///
469    ///
470    ///
471    /// #### `state-flags-changed`
472    ///  Emitted when the widget state changes.
473    ///
474    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
475    ///
476    ///
477    ///
478    ///
479    /// #### `unmap`
480    ///  Emitted when @widget is going to be unmapped.
481    ///
482    /// A widget is unmapped when either it or any of its parents up to the
483    /// toplevel widget have been set as hidden.
484    ///
485    /// As `::unmap` indicates that a widget will not be shown any longer,
486    /// it can be used to, for example, stop an animation on the widget.
487    ///
488    ///
489    ///
490    ///
491    /// #### `unrealize`
492    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
493    ///
494    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
495    /// or the widget has been unmapped (that is, it is going to be hidden).
496    ///
497    ///
498    /// </details>
499    ///
500    /// # Implements
501    ///
502    /// [`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]
503    #[doc(alias = "GtkColorDialogButton")]
504    pub struct ColorDialogButton(Object<ffi::GtkColorDialogButton, ffi::GtkColorDialogButtonClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
505
506    match fn {
507        type_ => || ffi::gtk_color_dialog_button_get_type(),
508    }
509}
510
511impl ColorDialogButton {
512    /// Creates a new [`ColorDialogButton`][crate::ColorDialogButton] with the
513    /// given [`ColorDialog`][crate::ColorDialog].
514    ///
515    /// You can pass `NULL` to this function and set a [`ColorDialog`][crate::ColorDialog]
516    /// later. The button will be insensitive until that happens.
517    /// ## `dialog`
518    /// the [`ColorDialog`][crate::ColorDialog] to use
519    ///
520    /// # Returns
521    ///
522    /// the new [`ColorDialogButton`][crate::ColorDialogButton]
523    #[doc(alias = "gtk_color_dialog_button_new")]
524    pub fn new(dialog: Option<ColorDialog>) -> ColorDialogButton {
525        assert_initialized_main_thread!();
526        unsafe {
527            Widget::from_glib_none(ffi::gtk_color_dialog_button_new(dialog.into_glib_ptr()))
528                .unsafe_cast()
529        }
530    }
531
532    // rustdoc-stripper-ignore-next
533    /// Creates a new builder-pattern struct instance to construct [`ColorDialogButton`] objects.
534    ///
535    /// This method returns an instance of [`ColorDialogButtonBuilder`](crate::builders::ColorDialogButtonBuilder) which can be used to create [`ColorDialogButton`] objects.
536    pub fn builder() -> ColorDialogButtonBuilder {
537        ColorDialogButtonBuilder::new()
538    }
539
540    /// Returns the [`ColorDialog`][crate::ColorDialog] of @self.
541    ///
542    /// # Returns
543    ///
544    /// the [`ColorDialog`][crate::ColorDialog]
545    #[doc(alias = "gtk_color_dialog_button_get_dialog")]
546    #[doc(alias = "get_dialog")]
547    pub fn dialog(&self) -> Option<ColorDialog> {
548        unsafe {
549            from_glib_none(ffi::gtk_color_dialog_button_get_dialog(
550                self.to_glib_none().0,
551            ))
552        }
553    }
554
555    /// Returns the color of the button.
556    ///
557    /// This function is what should be used to obtain
558    /// the color that was chosen by the user. To get
559    /// informed about changes, listen to "notify::rgba".
560    ///
561    /// # Returns
562    ///
563    /// the color
564    #[doc(alias = "gtk_color_dialog_button_get_rgba")]
565    #[doc(alias = "get_rgba")]
566    pub fn rgba(&self) -> gdk::RGBA {
567        unsafe { from_glib_none(ffi::gtk_color_dialog_button_get_rgba(self.to_glib_none().0)) }
568    }
569
570    /// Sets a [`ColorDialog`][crate::ColorDialog] object to use for
571    /// creating the color chooser dialog that is
572    /// presented when the user clicks the button.
573    /// ## `dialog`
574    /// the new [`ColorDialog`][crate::ColorDialog]
575    #[doc(alias = "gtk_color_dialog_button_set_dialog")]
576    #[doc(alias = "dialog")]
577    pub fn set_dialog(&self, dialog: &ColorDialog) {
578        unsafe {
579            ffi::gtk_color_dialog_button_set_dialog(self.to_glib_none().0, dialog.to_glib_none().0);
580        }
581    }
582
583    /// Sets the color of the button.
584    /// ## `color`
585    /// the new color
586    #[doc(alias = "gtk_color_dialog_button_set_rgba")]
587    #[doc(alias = "rgba")]
588    pub fn set_rgba(&self, color: &gdk::RGBA) {
589        unsafe {
590            ffi::gtk_color_dialog_button_set_rgba(self.to_glib_none().0, color.to_glib_none().0);
591        }
592    }
593
594    /// Emitted when the color dialog button is activated.
595    ///
596    /// The `::activate` signal on [`ColorDialogButton`][crate::ColorDialogButton] is an action signal
597    /// and emitting it causes the button to pop up its dialog.
598    #[cfg(feature = "v4_14")]
599    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
600    #[doc(alias = "activate")]
601    pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
602        unsafe extern "C" fn activate_trampoline<F: Fn(&ColorDialogButton) + 'static>(
603            this: *mut ffi::GtkColorDialogButton,
604            f: glib::ffi::gpointer,
605        ) {
606            let f: &F = &*(f as *const F);
607            f(&from_glib_borrow(this))
608        }
609        unsafe {
610            let f: Box_<F> = Box_::new(f);
611            connect_raw(
612                self.as_ptr() as *mut _,
613                b"activate\0".as_ptr() as *const _,
614                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
615                    activate_trampoline::<F> as *const (),
616                )),
617                Box_::into_raw(f),
618            )
619        }
620    }
621
622    #[cfg(feature = "v4_14")]
623    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
624    pub fn emit_activate(&self) {
625        self.emit_by_name::<()>("activate", &[]);
626    }
627
628    #[cfg(feature = "v4_10")]
629    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
630    #[doc(alias = "dialog")]
631    pub fn connect_dialog_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
632        unsafe extern "C" fn notify_dialog_trampoline<F: Fn(&ColorDialogButton) + 'static>(
633            this: *mut ffi::GtkColorDialogButton,
634            _param_spec: glib::ffi::gpointer,
635            f: glib::ffi::gpointer,
636        ) {
637            let f: &F = &*(f as *const F);
638            f(&from_glib_borrow(this))
639        }
640        unsafe {
641            let f: Box_<F> = Box_::new(f);
642            connect_raw(
643                self.as_ptr() as *mut _,
644                b"notify::dialog\0".as_ptr() as *const _,
645                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
646                    notify_dialog_trampoline::<F> as *const (),
647                )),
648                Box_::into_raw(f),
649            )
650        }
651    }
652
653    #[cfg(feature = "v4_10")]
654    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
655    #[doc(alias = "rgba")]
656    pub fn connect_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
657        unsafe extern "C" fn notify_rgba_trampoline<F: Fn(&ColorDialogButton) + 'static>(
658            this: *mut ffi::GtkColorDialogButton,
659            _param_spec: glib::ffi::gpointer,
660            f: glib::ffi::gpointer,
661        ) {
662            let f: &F = &*(f as *const F);
663            f(&from_glib_borrow(this))
664        }
665        unsafe {
666            let f: Box_<F> = Box_::new(f);
667            connect_raw(
668                self.as_ptr() as *mut _,
669                b"notify::rgba\0".as_ptr() as *const _,
670                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
671                    notify_rgba_trampoline::<F> as *const (),
672                )),
673                Box_::into_raw(f),
674            )
675        }
676    }
677}
678
679#[cfg(feature = "v4_10")]
680#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
681impl Default for ColorDialogButton {
682    fn default() -> Self {
683        glib::object::Object::new::<Self>()
684    }
685}
686
687// rustdoc-stripper-ignore-next
688/// A [builder-pattern] type to construct [`ColorDialogButton`] objects.
689///
690/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
691#[must_use = "The builder must be built to be used"]
692pub struct ColorDialogButtonBuilder {
693    builder: glib::object::ObjectBuilder<'static, ColorDialogButton>,
694}
695
696impl ColorDialogButtonBuilder {
697    fn new() -> Self {
698        Self {
699            builder: glib::object::Object::builder(),
700        }
701    }
702
703    /// The [`ColorDialog`][crate::ColorDialog] that contains parameters for
704    /// the color chooser dialog.
705    #[cfg(feature = "v4_10")]
706    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
707    pub fn dialog(self, dialog: &ColorDialog) -> Self {
708        Self {
709            builder: self.builder.property("dialog", dialog.clone()),
710        }
711    }
712
713    /// The selected color.
714    ///
715    /// This property can be set to give the button its initial
716    /// color, and it will be updated to reflect the users choice
717    /// in the color chooser dialog.
718    ///
719    /// Listen to `notify::rgba` to get informed about changes
720    /// to the buttons color.
721    #[cfg(feature = "v4_10")]
722    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
723    pub fn rgba(self, rgba: &gdk::RGBA) -> Self {
724        Self {
725            builder: self.builder.property("rgba", rgba),
726        }
727    }
728
729    /// Whether the widget or any of its descendents can accept
730    /// the input focus.
731    ///
732    /// This property is meant to be set by widget implementations,
733    /// typically in their instance init function.
734    pub fn can_focus(self, can_focus: bool) -> Self {
735        Self {
736            builder: self.builder.property("can-focus", can_focus),
737        }
738    }
739
740    /// Whether the widget can receive pointer events.
741    pub fn can_target(self, can_target: bool) -> Self {
742        Self {
743            builder: self.builder.property("can-target", can_target),
744        }
745    }
746
747    /// A list of css classes applied to this widget.
748    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
749        Self {
750            builder: self.builder.property("css-classes", css_classes.into()),
751        }
752    }
753
754    /// The name of this widget in the CSS tree.
755    ///
756    /// This property is meant to be set by widget implementations,
757    /// typically in their instance init function.
758    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
759        Self {
760            builder: self.builder.property("css-name", css_name.into()),
761        }
762    }
763
764    /// The cursor used by @widget.
765    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
766        Self {
767            builder: self.builder.property("cursor", cursor.clone()),
768        }
769    }
770
771    /// Whether the widget should grab focus when it is clicked with the mouse.
772    ///
773    /// This property is only relevant for widgets that can take focus.
774    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
775        Self {
776            builder: self.builder.property("focus-on-click", focus_on_click),
777        }
778    }
779
780    /// Whether this widget itself will accept the input focus.
781    pub fn focusable(self, focusable: bool) -> Self {
782        Self {
783            builder: self.builder.property("focusable", focusable),
784        }
785    }
786
787    /// How to distribute horizontal space if widget gets extra space.
788    pub fn halign(self, halign: Align) -> Self {
789        Self {
790            builder: self.builder.property("halign", halign),
791        }
792    }
793
794    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
795    /// signal on @widget.
796    ///
797    /// A true value indicates that @widget can have a tooltip, in this case
798    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
799    /// determine whether it will provide a tooltip or not.
800    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
801        Self {
802            builder: self.builder.property("has-tooltip", has_tooltip),
803        }
804    }
805
806    /// Overrides for height request of the widget.
807    ///
808    /// If this is -1, the natural request will be used.
809    pub fn height_request(self, height_request: i32) -> Self {
810        Self {
811            builder: self.builder.property("height-request", height_request),
812        }
813    }
814
815    /// Whether to expand horizontally.
816    pub fn hexpand(self, hexpand: bool) -> Self {
817        Self {
818            builder: self.builder.property("hexpand", hexpand),
819        }
820    }
821
822    /// Whether to use the `hexpand` property.
823    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
824        Self {
825            builder: self.builder.property("hexpand-set", hexpand_set),
826        }
827    }
828
829    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
830    /// the preferred size of the widget, and allocate its children.
831    ///
832    /// This property is meant to be set by widget implementations,
833    /// typically in their instance init function.
834    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
835        Self {
836            builder: self
837                .builder
838                .property("layout-manager", layout_manager.clone().upcast()),
839        }
840    }
841
842    /// Makes this widget act like a modal dialog, with respect to
843    /// event delivery.
844    ///
845    /// Global event controllers will not handle events with targets
846    /// inside the widget, unless they are set up to ignore propagation
847    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
848    #[cfg(feature = "v4_18")]
849    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
850    pub fn limit_events(self, limit_events: bool) -> Self {
851        Self {
852            builder: self.builder.property("limit-events", limit_events),
853        }
854    }
855
856    /// Margin on bottom side of widget.
857    ///
858    /// This property adds margin outside of the widget's normal size
859    /// request, the margin will be added in addition to the size from
860    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
861    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
862        Self {
863            builder: self.builder.property("margin-bottom", margin_bottom),
864        }
865    }
866
867    /// Margin on end of widget, horizontally.
868    ///
869    /// This property supports left-to-right and right-to-left text
870    /// directions.
871    ///
872    /// This property adds margin outside of the widget's normal size
873    /// request, the margin will be added in addition to the size from
874    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
875    pub fn margin_end(self, margin_end: i32) -> Self {
876        Self {
877            builder: self.builder.property("margin-end", margin_end),
878        }
879    }
880
881    /// Margin on start of widget, horizontally.
882    ///
883    /// This property supports left-to-right and right-to-left text
884    /// directions.
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_start(self, margin_start: i32) -> Self {
890        Self {
891            builder: self.builder.property("margin-start", margin_start),
892        }
893    }
894
895    /// Margin on top side of widget.
896    ///
897    /// This property adds margin outside of the widget's normal size
898    /// request, the margin will be added in addition to the size from
899    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
900    pub fn margin_top(self, margin_top: i32) -> Self {
901        Self {
902            builder: self.builder.property("margin-top", margin_top),
903        }
904    }
905
906    /// The name of the widget.
907    pub fn name(self, name: impl Into<glib::GString>) -> Self {
908        Self {
909            builder: self.builder.property("name", name.into()),
910        }
911    }
912
913    /// The requested opacity of the widget.
914    pub fn opacity(self, opacity: f64) -> Self {
915        Self {
916            builder: self.builder.property("opacity", opacity),
917        }
918    }
919
920    /// How content outside the widget's content area is treated.
921    ///
922    /// This property is meant to be set by widget implementations,
923    /// typically in their instance init function.
924    pub fn overflow(self, overflow: Overflow) -> Self {
925        Self {
926            builder: self.builder.property("overflow", overflow),
927        }
928    }
929
930    /// Whether the widget will receive the default action when it is focused.
931    pub fn receives_default(self, receives_default: bool) -> Self {
932        Self {
933            builder: self.builder.property("receives-default", receives_default),
934        }
935    }
936
937    /// Whether the widget responds to input.
938    pub fn sensitive(self, sensitive: bool) -> Self {
939        Self {
940            builder: self.builder.property("sensitive", sensitive),
941        }
942    }
943
944    /// Sets the text of tooltip to be the given string, which is marked up
945    /// with Pango markup.
946    ///
947    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
948    ///
949    /// This is a convenience property which will take care of getting the
950    /// tooltip shown if the given string is not `NULL`:
951    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
952    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
953    /// the default signal handler.
954    ///
955    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
956    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
957    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
958        Self {
959            builder: self
960                .builder
961                .property("tooltip-markup", tooltip_markup.into()),
962        }
963    }
964
965    /// Sets the text of tooltip to be the given string.
966    ///
967    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
968    ///
969    /// This is a convenience property which will take care of getting the
970    /// tooltip shown if the given string is not `NULL`:
971    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
972    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
973    /// the default signal handler.
974    ///
975    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
976    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
977    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
978        Self {
979            builder: self.builder.property("tooltip-text", tooltip_text.into()),
980        }
981    }
982
983    /// How to distribute vertical space if widget gets extra space.
984    pub fn valign(self, valign: Align) -> Self {
985        Self {
986            builder: self.builder.property("valign", valign),
987        }
988    }
989
990    /// Whether to expand vertically.
991    pub fn vexpand(self, vexpand: bool) -> Self {
992        Self {
993            builder: self.builder.property("vexpand", vexpand),
994        }
995    }
996
997    /// Whether to use the `vexpand` property.
998    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
999        Self {
1000            builder: self.builder.property("vexpand-set", vexpand_set),
1001        }
1002    }
1003
1004    /// Whether the widget is visible.
1005    pub fn visible(self, visible: bool) -> Self {
1006        Self {
1007            builder: self.builder.property("visible", visible),
1008        }
1009    }
1010
1011    /// Overrides for width request of the widget.
1012    ///
1013    /// If this is -1, the natural request will be used.
1014    pub fn width_request(self, width_request: i32) -> Self {
1015        Self {
1016            builder: self.builder.property("width-request", width_request),
1017        }
1018    }
1019
1020    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1021    ///
1022    /// The accessible role cannot be changed once set.
1023    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1024        Self {
1025            builder: self.builder.property("accessible-role", accessible_role),
1026        }
1027    }
1028
1029    // rustdoc-stripper-ignore-next
1030    /// Build the [`ColorDialogButton`].
1031    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1032    pub fn build(self) -> ColorDialogButton {
1033        assert_initialized_main_thread!();
1034        self.builder.build()
1035    }
1036}