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