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