Skip to main content

gtk/auto/
color_chooser_widget.rs

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