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