gtk4/auto/color_dialog_button.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6 Accessible, AccessibleRole, Align, Buildable, ColorDialog, ConstraintTarget, LayoutManager,
7 Overflow, Widget, ffi,
8};
9#[cfg(feature = "v4_14")]
10#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
11use glib::object::ObjectType as _;
12use glib::{
13 prelude::*,
14 signal::{SignalHandlerId, connect_raw},
15 translate::*,
16};
17use std::boxed::Box as Box_;
18
19glib::wrapper! {
20 /// 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 unsafe {
609 let f: &F = &*(f as *const F);
610 f(&from_glib_borrow(this))
611 }
612 }
613 unsafe {
614 let f: Box_<F> = Box_::new(f);
615 connect_raw(
616 self.as_ptr() as *mut _,
617 c"activate".as_ptr() as *const _,
618 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
619 activate_trampoline::<F> as *const (),
620 )),
621 Box_::into_raw(f),
622 )
623 }
624 }
625
626 #[cfg(feature = "v4_14")]
627 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
628 pub fn emit_activate(&self) {
629 self.emit_by_name::<()>("activate", &[]);
630 }
631
632 #[cfg(feature = "v4_10")]
633 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
634 #[doc(alias = "dialog")]
635 pub fn connect_dialog_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
636 unsafe extern "C" fn notify_dialog_trampoline<F: Fn(&ColorDialogButton) + 'static>(
637 this: *mut ffi::GtkColorDialogButton,
638 _param_spec: glib::ffi::gpointer,
639 f: glib::ffi::gpointer,
640 ) {
641 unsafe {
642 let f: &F = &*(f as *const F);
643 f(&from_glib_borrow(this))
644 }
645 }
646 unsafe {
647 let f: Box_<F> = Box_::new(f);
648 connect_raw(
649 self.as_ptr() as *mut _,
650 c"notify::dialog".as_ptr() as *const _,
651 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
652 notify_dialog_trampoline::<F> as *const (),
653 )),
654 Box_::into_raw(f),
655 )
656 }
657 }
658
659 #[cfg(feature = "v4_10")]
660 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
661 #[doc(alias = "rgba")]
662 pub fn connect_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
663 unsafe extern "C" fn notify_rgba_trampoline<F: Fn(&ColorDialogButton) + 'static>(
664 this: *mut ffi::GtkColorDialogButton,
665 _param_spec: glib::ffi::gpointer,
666 f: glib::ffi::gpointer,
667 ) {
668 unsafe {
669 let f: &F = &*(f as *const F);
670 f(&from_glib_borrow(this))
671 }
672 }
673 unsafe {
674 let f: Box_<F> = Box_::new(f);
675 connect_raw(
676 self.as_ptr() as *mut _,
677 c"notify::rgba".as_ptr() as *const _,
678 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
679 notify_rgba_trampoline::<F> as *const (),
680 )),
681 Box_::into_raw(f),
682 )
683 }
684 }
685}
686
687#[cfg(feature = "v4_10")]
688#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
689impl Default for ColorDialogButton {
690 fn default() -> Self {
691 glib::object::Object::new::<Self>()
692 }
693}
694
695// rustdoc-stripper-ignore-next
696/// A [builder-pattern] type to construct [`ColorDialogButton`] objects.
697///
698/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
699#[must_use = "The builder must be built to be used"]
700pub struct ColorDialogButtonBuilder {
701 builder: glib::object::ObjectBuilder<'static, ColorDialogButton>,
702}
703
704impl ColorDialogButtonBuilder {
705 fn new() -> Self {
706 Self {
707 builder: glib::object::Object::builder(),
708 }
709 }
710
711 /// The [`ColorDialog`][crate::ColorDialog] that contains parameters for
712 /// the color chooser dialog.
713 #[cfg(feature = "v4_10")]
714 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
715 pub fn dialog(self, dialog: &ColorDialog) -> Self {
716 Self {
717 builder: self.builder.property("dialog", dialog.clone()),
718 }
719 }
720
721 /// The selected color.
722 ///
723 /// This property can be set to give the button its initial
724 /// color, and it will be updated to reflect the users choice
725 /// in the color chooser dialog.
726 ///
727 /// Listen to `notify::rgba` to get informed about changes
728 /// to the buttons color.
729 #[cfg(feature = "v4_10")]
730 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
731 pub fn rgba(self, rgba: &gdk::RGBA) -> Self {
732 Self {
733 builder: self.builder.property("rgba", rgba),
734 }
735 }
736
737 /// Whether the widget or any of its descendents can accept
738 /// the input focus.
739 ///
740 /// This property is meant to be set by widget implementations,
741 /// typically in their instance init function.
742 pub fn can_focus(self, can_focus: bool) -> Self {
743 Self {
744 builder: self.builder.property("can-focus", can_focus),
745 }
746 }
747
748 /// Whether the widget can receive pointer events.
749 pub fn can_target(self, can_target: bool) -> Self {
750 Self {
751 builder: self.builder.property("can-target", can_target),
752 }
753 }
754
755 /// A list of css classes applied to this widget.
756 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
757 Self {
758 builder: self.builder.property("css-classes", css_classes.into()),
759 }
760 }
761
762 /// The name of this widget in the CSS tree.
763 ///
764 /// This property is meant to be set by widget implementations,
765 /// typically in their instance init function.
766 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
767 Self {
768 builder: self.builder.property("css-name", css_name.into()),
769 }
770 }
771
772 /// The cursor used by @widget.
773 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
774 Self {
775 builder: self.builder.property("cursor", cursor.clone()),
776 }
777 }
778
779 /// Whether the widget should grab focus when it is clicked with the mouse.
780 ///
781 /// This property is only relevant for widgets that can take focus.
782 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
783 Self {
784 builder: self.builder.property("focus-on-click", focus_on_click),
785 }
786 }
787
788 /// Whether this widget itself will accept the input focus.
789 pub fn focusable(self, focusable: bool) -> Self {
790 Self {
791 builder: self.builder.property("focusable", focusable),
792 }
793 }
794
795 /// How to distribute horizontal space if widget gets extra space.
796 pub fn halign(self, halign: Align) -> Self {
797 Self {
798 builder: self.builder.property("halign", halign),
799 }
800 }
801
802 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
803 /// signal on @widget.
804 ///
805 /// A true value indicates that @widget can have a tooltip, in this case
806 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
807 /// determine whether it will provide a tooltip or not.
808 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
809 Self {
810 builder: self.builder.property("has-tooltip", has_tooltip),
811 }
812 }
813
814 /// Overrides for height request of the widget.
815 ///
816 /// If this is -1, the natural request will be used.
817 pub fn height_request(self, height_request: i32) -> Self {
818 Self {
819 builder: self.builder.property("height-request", height_request),
820 }
821 }
822
823 /// Whether to expand horizontally.
824 pub fn hexpand(self, hexpand: bool) -> Self {
825 Self {
826 builder: self.builder.property("hexpand", hexpand),
827 }
828 }
829
830 /// Whether to use the `hexpand` property.
831 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
832 Self {
833 builder: self.builder.property("hexpand-set", hexpand_set),
834 }
835 }
836
837 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
838 /// the preferred size of the widget, and allocate its children.
839 ///
840 /// This property is meant to be set by widget implementations,
841 /// typically in their instance init function.
842 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
843 Self {
844 builder: self
845 .builder
846 .property("layout-manager", layout_manager.clone().upcast()),
847 }
848 }
849
850 /// Makes this widget act like a modal dialog, with respect to
851 /// event delivery.
852 ///
853 /// Global event controllers will not handle events with targets
854 /// inside the widget, unless they are set up to ignore propagation
855 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
856 #[cfg(feature = "v4_18")]
857 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
858 pub fn limit_events(self, limit_events: bool) -> Self {
859 Self {
860 builder: self.builder.property("limit-events", limit_events),
861 }
862 }
863
864 /// Margin on bottom side of widget.
865 ///
866 /// This property adds margin outside of the widget's normal size
867 /// request, the margin will be added in addition to the size from
868 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
869 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
870 Self {
871 builder: self.builder.property("margin-bottom", margin_bottom),
872 }
873 }
874
875 /// Margin on end of widget, horizontally.
876 ///
877 /// This property supports left-to-right and right-to-left text
878 /// directions.
879 ///
880 /// This property adds margin outside of the widget's normal size
881 /// request, the margin will be added in addition to the size from
882 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
883 pub fn margin_end(self, margin_end: i32) -> Self {
884 Self {
885 builder: self.builder.property("margin-end", margin_end),
886 }
887 }
888
889 /// Margin on start of widget, horizontally.
890 ///
891 /// This property supports left-to-right and right-to-left text
892 /// directions.
893 ///
894 /// This property adds margin outside of the widget's normal size
895 /// request, the margin will be added in addition to the size from
896 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
897 pub fn margin_start(self, margin_start: i32) -> Self {
898 Self {
899 builder: self.builder.property("margin-start", margin_start),
900 }
901 }
902
903 /// Margin on top side of widget.
904 ///
905 /// This property adds margin outside of the widget's normal size
906 /// request, the margin will be added in addition to the size from
907 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
908 pub fn margin_top(self, margin_top: i32) -> Self {
909 Self {
910 builder: self.builder.property("margin-top", margin_top),
911 }
912 }
913
914 /// The name of the widget.
915 pub fn name(self, name: impl Into<glib::GString>) -> Self {
916 Self {
917 builder: self.builder.property("name", name.into()),
918 }
919 }
920
921 /// The requested opacity of the widget.
922 pub fn opacity(self, opacity: f64) -> Self {
923 Self {
924 builder: self.builder.property("opacity", opacity),
925 }
926 }
927
928 /// How content outside the widget's content area is treated.
929 ///
930 /// This property is meant to be set by widget implementations,
931 /// typically in their instance init function.
932 pub fn overflow(self, overflow: Overflow) -> Self {
933 Self {
934 builder: self.builder.property("overflow", overflow),
935 }
936 }
937
938 /// Whether the widget will receive the default action when it is focused.
939 pub fn receives_default(self, receives_default: bool) -> Self {
940 Self {
941 builder: self.builder.property("receives-default", receives_default),
942 }
943 }
944
945 /// Whether the widget responds to input.
946 pub fn sensitive(self, sensitive: bool) -> Self {
947 Self {
948 builder: self.builder.property("sensitive", sensitive),
949 }
950 }
951
952 /// Sets the text of tooltip to be the given string, which is marked up
953 /// with Pango markup.
954 ///
955 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
956 ///
957 /// This is a convenience property which will take care of getting the
958 /// tooltip shown if the given string is not `NULL`:
959 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
960 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
961 /// the default signal handler.
962 ///
963 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
964 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
965 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
966 Self {
967 builder: self
968 .builder
969 .property("tooltip-markup", tooltip_markup.into()),
970 }
971 }
972
973 /// Sets the text of tooltip to be the given string.
974 ///
975 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
976 ///
977 /// This is a convenience property which will take care of getting the
978 /// tooltip shown if the given string is not `NULL`:
979 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
980 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
981 /// the default signal handler.
982 ///
983 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
984 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
985 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
986 Self {
987 builder: self.builder.property("tooltip-text", tooltip_text.into()),
988 }
989 }
990
991 /// How to distribute vertical space if widget gets extra space.
992 pub fn valign(self, valign: Align) -> Self {
993 Self {
994 builder: self.builder.property("valign", valign),
995 }
996 }
997
998 /// Whether to expand vertically.
999 pub fn vexpand(self, vexpand: bool) -> Self {
1000 Self {
1001 builder: self.builder.property("vexpand", vexpand),
1002 }
1003 }
1004
1005 /// Whether to use the `vexpand` property.
1006 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1007 Self {
1008 builder: self.builder.property("vexpand-set", vexpand_set),
1009 }
1010 }
1011
1012 /// Whether the widget is visible.
1013 pub fn visible(self, visible: bool) -> Self {
1014 Self {
1015 builder: self.builder.property("visible", visible),
1016 }
1017 }
1018
1019 /// Overrides for width request of the widget.
1020 ///
1021 /// If this is -1, the natural request will be used.
1022 pub fn width_request(self, width_request: i32) -> Self {
1023 Self {
1024 builder: self.builder.property("width-request", width_request),
1025 }
1026 }
1027
1028 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1029 ///
1030 /// The accessible role cannot be changed once set.
1031 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1032 Self {
1033 builder: self.builder.property("accessible-role", accessible_role),
1034 }
1035 }
1036
1037 // rustdoc-stripper-ignore-next
1038 /// Build the [`ColorDialogButton`].
1039 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1040 pub fn build(self) -> ColorDialogButton {
1041 assert_initialized_main_thread!();
1042 self.builder.build()
1043 }
1044}