gtk4/auto/color_chooser_dialog.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#![allow(deprecated)]
5
6use crate::{
7 ffi, Accessible, AccessibleRole, Align, Application, Buildable, ColorChooser, ConstraintTarget,
8 Dialog, LayoutManager, Native, Overflow, Root, ShortcutManager, Widget, Window,
9};
10use glib::{
11 prelude::*,
12 signal::{connect_raw, SignalHandlerId},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 /// Use [`ColorDialog`][crate::ColorDialog] instead
19 /// A dialog for choosing a color.
20 ///
21 /// 
22 ///
23 /// [`ColorChooserDialog`][crate::ColorChooserDialog] implements the [`ColorChooser`][crate::ColorChooser] interface
24 /// and does not provide much API of its own.
25 ///
26 /// To create a [`ColorChooserDialog`][crate::ColorChooserDialog], use [`new()`][Self::new()].
27 ///
28 /// To change the initially selected color, use
29 /// [`ColorChooserExt::set_rgba()`][crate::prelude::ColorChooserExt::set_rgba()]. To get the selected color use
30 /// [`ColorChooserExt::rgba()`][crate::prelude::ColorChooserExt::rgba()].
31 ///
32 /// [`ColorChooserDialog`][crate::ColorChooserDialog] has been deprecated in favor of [`ColorDialog`][crate::ColorDialog].
33 ///
34 /// ## CSS nodes
35 ///
36 /// [`ColorChooserDialog`][crate::ColorChooserDialog] has a single CSS node with the name `window` and style
37 /// class `.colorchooser`.
38 ///
39 /// ## Properties
40 ///
41 ///
42 /// #### `show-editor`
43 /// Whether the color chooser dialog is showing the single-color editor.
44 ///
45 /// It can be set to switch the color chooser into single-color editing mode.
46 ///
47 /// Readable | Writeable
48 /// <details><summary><h4>Dialog</h4></summary>
49 ///
50 ///
51 /// #### `use-header-bar`
52 /// [`true`] if the dialog uses a headerbar for action buttons
53 /// instead of the action-area.
54 ///
55 /// For technical reasons, this property is declared as an integer
56 /// property, but you should only set it to [`true`] or [`false`].
57 ///
58 /// ## Creating a dialog with headerbar
59 ///
60 /// Builtin [`Dialog`][crate::Dialog] subclasses such as [`ColorChooserDialog`][crate::ColorChooserDialog]
61 /// set this property according to platform conventions (using the
62 /// [`gtk-dialogs-use-header`][struct@crate::Settings#gtk-dialogs-use-header] setting).
63 ///
64 /// Here is how you can achieve the same:
65 ///
66 /// **⚠️ The following code is in c ⚠️**
67 ///
68 /// ```c
69 /// g_object_get (settings, "gtk-dialogs-use-header", &header, NULL);
70 /// dialog = g_object_new (GTK_TYPE_DIALOG, header, TRUE, NULL);
71 /// ```
72 ///
73 /// Readable | Writeable | Construct Only
74 /// </details>
75 /// <details><summary><h4>Window</h4></summary>
76 ///
77 ///
78 /// #### `application`
79 /// The [`Application`][crate::Application] associated with the window.
80 ///
81 /// The application will be kept alive for at least as long as it
82 /// has any windows associated with it (see g_application_hold()
83 /// for a way to keep it alive without windows).
84 ///
85 /// Normally, the connection between the application and the window
86 /// will remain until the window is destroyed, but you can explicitly
87 /// remove it by setting the this property to `NULL`.
88 ///
89 /// Readable | Writeable
90 ///
91 ///
92 /// #### `child`
93 /// The child widget.
94 ///
95 /// Readable | Writeable
96 ///
97 ///
98 /// #### `decorated`
99 /// Whether the window should have a frame (also known as *decorations*).
100 ///
101 /// Readable | Writeable
102 ///
103 ///
104 /// #### `default-height`
105 /// The default height of the window.
106 ///
107 /// Readable | Writeable
108 ///
109 ///
110 /// #### `default-widget`
111 /// The default widget.
112 ///
113 /// Readable | Writeable
114 ///
115 ///
116 /// #### `default-width`
117 /// The default width of the window.
118 ///
119 /// Readable | Writeable
120 ///
121 ///
122 /// #### `deletable`
123 /// Whether the window frame should have a close button.
124 ///
125 /// Readable | Writeable
126 ///
127 ///
128 /// #### `destroy-with-parent`
129 /// If this window should be destroyed when the parent is destroyed.
130 ///
131 /// Readable | Writeable
132 ///
133 ///
134 /// #### `display`
135 /// The display that will display this window.
136 ///
137 /// Readable | Writeable
138 ///
139 ///
140 /// #### `focus-visible`
141 /// Whether 'focus rectangles' are currently visible in this window.
142 ///
143 /// This property is maintained by GTK based on user input
144 /// and should not be set by applications.
145 ///
146 /// Readable | Writeable
147 ///
148 ///
149 /// #### `focus-widget`
150 /// The focus widget.
151 ///
152 /// Readable | Writeable
153 ///
154 ///
155 /// #### `fullscreened`
156 /// Whether the window is fullscreen.
157 ///
158 /// Setting this property is the equivalent of calling
159 /// [`GtkWindowExt::fullscreen()`][crate::prelude::GtkWindowExt::fullscreen()] or [`GtkWindowExt::unfullscreen()`][crate::prelude::GtkWindowExt::unfullscreen()];
160 /// either operation is asynchronous, which means you will need to
161 /// connect to the ::notify signal in order to know whether the
162 /// operation was successful.
163 ///
164 /// Readable | Writeable | Construct
165 ///
166 ///
167 /// #### `handle-menubar-accel`
168 /// Whether the window frame should handle <kbd>F10</kbd> for activating
169 /// menubars.
170 ///
171 /// Readable | Writeable
172 ///
173 ///
174 /// #### `hide-on-close`
175 /// If this window should be hidden when the users clicks the close button.
176 ///
177 /// Readable | Writeable
178 ///
179 ///
180 /// #### `icon-name`
181 /// Specifies the name of the themed icon to use as the window icon.
182 ///
183 /// See [`IconTheme`][crate::IconTheme] for more details.
184 ///
185 /// Readable | Writeable
186 ///
187 ///
188 /// #### `is-active`
189 /// Whether the toplevel is the currently active window.
190 ///
191 /// Readable
192 ///
193 ///
194 /// #### `maximized`
195 /// Whether the window is maximized.
196 ///
197 /// Setting this property is the equivalent of calling
198 /// [`GtkWindowExt::maximize()`][crate::prelude::GtkWindowExt::maximize()] or [`GtkWindowExt::unmaximize()`][crate::prelude::GtkWindowExt::unmaximize()];
199 /// either operation is asynchronous, which means you will need to
200 /// connect to the ::notify signal in order to know whether the
201 /// operation was successful.
202 ///
203 /// Readable | Writeable | Construct
204 ///
205 ///
206 /// #### `mnemonics-visible`
207 /// Whether mnemonics are currently visible in this window.
208 ///
209 /// This property is maintained by GTK based on user input,
210 /// and should not be set by applications.
211 ///
212 /// Readable | Writeable
213 ///
214 ///
215 /// #### `modal`
216 /// If true, the window is modal.
217 ///
218 /// Readable | Writeable
219 ///
220 ///
221 /// #### `resizable`
222 /// If true, users can resize the window.
223 ///
224 /// Readable | Writeable
225 ///
226 ///
227 /// #### `startup-id`
228 /// A write-only property for setting window's startup notification identifier.
229 ///
230 /// Writeable
231 ///
232 ///
233 /// #### `suspended`
234 /// Whether the window is suspended.
235 ///
236 /// See [`GtkWindowExt::is_suspended()`][crate::prelude::GtkWindowExt::is_suspended()] for details about what suspended means.
237 ///
238 /// Readable
239 ///
240 ///
241 /// #### `title`
242 /// The title of the window.
243 ///
244 /// Readable | Writeable
245 ///
246 ///
247 /// #### `titlebar`
248 /// The titlebar widget.
249 ///
250 /// Readable | Writeable
251 ///
252 ///
253 /// #### `transient-for`
254 /// The transient parent of the window.
255 ///
256 /// Readable | Writeable | Construct
257 /// </details>
258 /// <details><summary><h4>Widget</h4></summary>
259 ///
260 ///
261 /// #### `can-focus`
262 /// Whether the widget or any of its descendents can accept
263 /// the input focus.
264 ///
265 /// This property is meant to be set by widget implementations,
266 /// typically in their instance init function.
267 ///
268 /// Readable | Writeable
269 ///
270 ///
271 /// #### `can-target`
272 /// Whether the widget can receive pointer events.
273 ///
274 /// Readable | Writeable
275 ///
276 ///
277 /// #### `css-classes`
278 /// A list of css classes applied to this widget.
279 ///
280 /// Readable | Writeable
281 ///
282 ///
283 /// #### `css-name`
284 /// The name of this widget in the CSS tree.
285 ///
286 /// This property is meant to be set by widget implementations,
287 /// typically in their instance init function.
288 ///
289 /// Readable | Writeable | Construct Only
290 ///
291 ///
292 /// #### `cursor`
293 /// The cursor used by @widget.
294 ///
295 /// Readable | Writeable
296 ///
297 ///
298 /// #### `focus-on-click`
299 /// Whether the widget should grab focus when it is clicked with the mouse.
300 ///
301 /// This property is only relevant for widgets that can take focus.
302 ///
303 /// Readable | Writeable
304 ///
305 ///
306 /// #### `focusable`
307 /// Whether this widget itself will accept the input focus.
308 ///
309 /// Readable | Writeable
310 ///
311 ///
312 /// #### `halign`
313 /// How to distribute horizontal space if widget gets extra space.
314 ///
315 /// Readable | Writeable
316 ///
317 ///
318 /// #### `has-default`
319 /// Whether the widget is the default widget.
320 ///
321 /// Readable
322 ///
323 ///
324 /// #### `has-focus`
325 /// Whether the widget has the input focus.
326 ///
327 /// Readable
328 ///
329 ///
330 /// #### `has-tooltip`
331 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
332 /// signal on @widget.
333 ///
334 /// A true value indicates that @widget can have a tooltip, in this case
335 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
336 /// determine whether it will provide a tooltip or not.
337 ///
338 /// Readable | Writeable
339 ///
340 ///
341 /// #### `height-request`
342 /// Overrides for height request of the widget.
343 ///
344 /// If this is -1, the natural request will be used.
345 ///
346 /// Readable | Writeable
347 ///
348 ///
349 /// #### `hexpand`
350 /// Whether to expand horizontally.
351 ///
352 /// Readable | Writeable
353 ///
354 ///
355 /// #### `hexpand-set`
356 /// Whether to use the `hexpand` property.
357 ///
358 /// Readable | Writeable
359 ///
360 ///
361 /// #### `layout-manager`
362 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
363 /// the preferred size of the widget, and allocate its children.
364 ///
365 /// This property is meant to be set by widget implementations,
366 /// typically in their instance init function.
367 ///
368 /// Readable | Writeable
369 ///
370 ///
371 /// #### `limit-events`
372 /// Makes this widget act like a modal dialog, with respect to
373 /// event delivery.
374 ///
375 /// Global event controllers will not handle events with targets
376 /// inside the widget, unless they are set up to ignore propagation
377 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
378 ///
379 /// Readable | Writeable
380 ///
381 ///
382 /// #### `margin-bottom`
383 /// Margin on bottom side of widget.
384 ///
385 /// This property adds margin outside of the widget's normal size
386 /// request, the margin will be added in addition to the size from
387 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
388 ///
389 /// Readable | Writeable
390 ///
391 ///
392 /// #### `margin-end`
393 /// Margin on end of widget, horizontally.
394 ///
395 /// This property supports left-to-right and right-to-left text
396 /// directions.
397 ///
398 /// This property adds margin outside of the widget's normal size
399 /// request, the margin will be added in addition to the size from
400 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
401 ///
402 /// Readable | Writeable
403 ///
404 ///
405 /// #### `margin-start`
406 /// Margin on start of widget, horizontally.
407 ///
408 /// This property supports left-to-right and right-to-left text
409 /// directions.
410 ///
411 /// This property adds margin outside of the widget's normal size
412 /// request, the margin will be added in addition to the size from
413 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
414 ///
415 /// Readable | Writeable
416 ///
417 ///
418 /// #### `margin-top`
419 /// Margin on top side of widget.
420 ///
421 /// This property adds margin outside of the widget's normal size
422 /// request, the margin will be added in addition to the size from
423 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
424 ///
425 /// Readable | Writeable
426 ///
427 ///
428 /// #### `name`
429 /// The name of the widget.
430 ///
431 /// Readable | Writeable
432 ///
433 ///
434 /// #### `opacity`
435 /// The requested opacity of the widget.
436 ///
437 /// Readable | Writeable
438 ///
439 ///
440 /// #### `overflow`
441 /// How content outside the widget's content area is treated.
442 ///
443 /// This property is meant to be set by widget implementations,
444 /// typically in their instance init function.
445 ///
446 /// Readable | Writeable
447 ///
448 ///
449 /// #### `parent`
450 /// The parent widget of this widget.
451 ///
452 /// Readable
453 ///
454 ///
455 /// #### `receives-default`
456 /// Whether the widget will receive the default action when it is focused.
457 ///
458 /// Readable | Writeable
459 ///
460 ///
461 /// #### `root`
462 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
463 ///
464 /// This will be `NULL` if the widget is not contained in a root widget.
465 ///
466 /// Readable
467 ///
468 ///
469 /// #### `scale-factor`
470 /// The scale factor of the widget.
471 ///
472 /// Readable
473 ///
474 ///
475 /// #### `sensitive`
476 /// Whether the widget responds to input.
477 ///
478 /// Readable | Writeable
479 ///
480 ///
481 /// #### `tooltip-markup`
482 /// Sets the text of tooltip to be the given string, which is marked up
483 /// with Pango markup.
484 ///
485 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
486 ///
487 /// This is a convenience property which will take care of getting the
488 /// tooltip shown if the given string is not `NULL`:
489 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
490 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
491 /// the default signal handler.
492 ///
493 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
494 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
495 ///
496 /// Readable | Writeable
497 ///
498 ///
499 /// #### `tooltip-text`
500 /// Sets the text of tooltip to be the given string.
501 ///
502 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
503 ///
504 /// This is a convenience property which will take care of getting the
505 /// tooltip shown if the given string is not `NULL`:
506 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
507 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
508 /// the default signal handler.
509 ///
510 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
511 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
512 ///
513 /// Readable | Writeable
514 ///
515 ///
516 /// #### `valign`
517 /// How to distribute vertical space if widget gets extra space.
518 ///
519 /// Readable | Writeable
520 ///
521 ///
522 /// #### `vexpand`
523 /// Whether to expand vertically.
524 ///
525 /// Readable | Writeable
526 ///
527 ///
528 /// #### `vexpand-set`
529 /// Whether to use the `vexpand` property.
530 ///
531 /// Readable | Writeable
532 ///
533 ///
534 /// #### `visible`
535 /// Whether the widget is visible.
536 ///
537 /// Readable | Writeable
538 ///
539 ///
540 /// #### `width-request`
541 /// Overrides for width request of the widget.
542 ///
543 /// If this is -1, the natural request will be used.
544 ///
545 /// Readable | Writeable
546 /// </details>
547 /// <details><summary><h4>Accessible</h4></summary>
548 ///
549 ///
550 /// #### `accessible-role`
551 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
552 ///
553 /// The accessible role cannot be changed once set.
554 ///
555 /// Readable | Writeable
556 /// </details>
557 /// <details><summary><h4>ColorChooser</h4></summary>
558 ///
559 ///
560 /// #### `rgba`
561 /// The currently selected color, as a [`gdk::RGBA`][crate::gdk::RGBA] struct.
562 ///
563 /// The property can be set to change the current selection
564 /// programmatically.
565 ///
566 /// Readable | Writeable
567 ///
568 ///
569 /// #### `use-alpha`
570 /// Whether colors may have alpha (translucency).
571 ///
572 /// When ::use-alpha is [`false`], the [`gdk::RGBA`][crate::gdk::RGBA] struct obtained
573 /// via the [`rgba`][struct@crate::ColorChooser#rgba] property will be
574 /// forced to have alpha == 1.
575 ///
576 /// Implementations are expected to show alpha by rendering the color
577 /// over a non-uniform background (like a checkerboard pattern).
578 ///
579 /// Readable | Writeable
580 /// </details>
581 ///
582 /// # Implements
583 ///
584 /// [`DialogExt`][trait@crate::prelude::DialogExt], [`GtkWindowExt`][trait@crate::prelude::GtkWindowExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`NativeExt`][trait@crate::prelude::NativeExt], [`RootExt`][trait@crate::prelude::RootExt], [`ShortcutManagerExt`][trait@crate::prelude::ShortcutManagerExt], [`ColorChooserExt`][trait@crate::prelude::ColorChooserExt], [`DialogExtManual`][trait@crate::prelude::DialogExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual], [`ColorChooserExtManual`][trait@crate::prelude::ColorChooserExtManual]
585 #[doc(alias = "GtkColorChooserDialog")]
586 pub struct ColorChooserDialog(Object<ffi::GtkColorChooserDialog>) @extends Dialog, Window, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager, ColorChooser;
587
588 match fn {
589 type_ => || ffi::gtk_color_chooser_dialog_get_type(),
590 }
591}
592
593impl ColorChooserDialog {
594 /// Creates a new [`ColorChooserDialog`][crate::ColorChooserDialog].
595 ///
596 /// # Deprecated since 4.10
597 ///
598 /// Use [`ColorDialog`][crate::ColorDialog] instead
599 /// ## `title`
600 /// Title of the dialog
601 /// ## `parent`
602 /// Transient parent of the dialog
603 ///
604 /// # Returns
605 ///
606 /// a new [`ColorChooserDialog`][crate::ColorChooserDialog]
607 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
608 #[allow(deprecated)]
609 #[doc(alias = "gtk_color_chooser_dialog_new")]
610 pub fn new(title: Option<&str>, parent: Option<&impl IsA<Window>>) -> ColorChooserDialog {
611 assert_initialized_main_thread!();
612 unsafe {
613 Widget::from_glib_none(ffi::gtk_color_chooser_dialog_new(
614 title.to_glib_none().0,
615 parent.map(|p| p.as_ref()).to_glib_none().0,
616 ))
617 .unsafe_cast()
618 }
619 }
620
621 // rustdoc-stripper-ignore-next
622 /// Creates a new builder-pattern struct instance to construct [`ColorChooserDialog`] objects.
623 ///
624 /// This method returns an instance of [`ColorChooserDialogBuilder`](crate::builders::ColorChooserDialogBuilder) which can be used to create [`ColorChooserDialog`] objects.
625 pub fn builder() -> ColorChooserDialogBuilder {
626 ColorChooserDialogBuilder::new()
627 }
628
629 /// Whether the color chooser dialog is showing the single-color editor.
630 ///
631 /// It can be set to switch the color chooser into single-color editing mode.
632 #[doc(alias = "show-editor")]
633 pub fn shows_editor(&self) -> bool {
634 ObjectExt::property(self, "show-editor")
635 }
636
637 /// Whether the color chooser dialog is showing the single-color editor.
638 ///
639 /// It can be set to switch the color chooser into single-color editing mode.
640 #[doc(alias = "show-editor")]
641 pub fn set_show_editor(&self, show_editor: bool) {
642 ObjectExt::set_property(self, "show-editor", show_editor)
643 }
644
645 #[doc(alias = "show-editor")]
646 pub fn connect_show_editor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
647 unsafe extern "C" fn notify_show_editor_trampoline<F: Fn(&ColorChooserDialog) + 'static>(
648 this: *mut ffi::GtkColorChooserDialog,
649 _param_spec: glib::ffi::gpointer,
650 f: glib::ffi::gpointer,
651 ) {
652 let f: &F = &*(f as *const F);
653 f(&from_glib_borrow(this))
654 }
655 unsafe {
656 let f: Box_<F> = Box_::new(f);
657 connect_raw(
658 self.as_ptr() as *mut _,
659 b"notify::show-editor\0".as_ptr() as *const _,
660 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
661 notify_show_editor_trampoline::<F> as *const (),
662 )),
663 Box_::into_raw(f),
664 )
665 }
666 }
667}
668
669impl Default for ColorChooserDialog {
670 fn default() -> Self {
671 glib::object::Object::new::<Self>()
672 }
673}
674
675// rustdoc-stripper-ignore-next
676/// A [builder-pattern] type to construct [`ColorChooserDialog`] objects.
677///
678/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
679#[must_use = "The builder must be built to be used"]
680pub struct ColorChooserDialogBuilder {
681 builder: glib::object::ObjectBuilder<'static, ColorChooserDialog>,
682}
683
684impl ColorChooserDialogBuilder {
685 fn new() -> Self {
686 Self {
687 builder: glib::object::Object::builder(),
688 }
689 }
690
691 /// Whether the color chooser dialog is showing the single-color editor.
692 ///
693 /// It can be set to switch the color chooser into single-color editing mode.
694 pub fn show_editor(self, show_editor: bool) -> Self {
695 Self {
696 builder: self.builder.property("show-editor", show_editor),
697 }
698 }
699
700 /// [`true`] if the dialog uses a headerbar for action buttons
701 /// instead of the action-area.
702 ///
703 /// For technical reasons, this property is declared as an integer
704 /// property, but you should only set it to [`true`] or [`false`].
705 ///
706 /// ## Creating a dialog with headerbar
707 ///
708 /// Builtin [`Dialog`][crate::Dialog] subclasses such as [`ColorChooserDialog`][crate::ColorChooserDialog]
709 /// set this property according to platform conventions (using the
710 /// [`gtk-dialogs-use-header`][struct@crate::Settings#gtk-dialogs-use-header] setting).
711 ///
712 /// Here is how you can achieve the same:
713 ///
714 /// **⚠️ The following code is in c ⚠️**
715 ///
716 /// ```c
717 /// g_object_get (settings, "gtk-dialogs-use-header", &header, NULL);
718 /// dialog = g_object_new (GTK_TYPE_DIALOG, header, TRUE, NULL);
719 /// ```
720 /// Use [`Window`][crate::Window] instead
721 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
722 pub fn use_header_bar(self, use_header_bar: i32) -> Self {
723 Self {
724 builder: self.builder.property("use-header-bar", use_header_bar),
725 }
726 }
727
728 /// The [`Application`][crate::Application] associated with the window.
729 ///
730 /// The application will be kept alive for at least as long as it
731 /// has any windows associated with it (see g_application_hold()
732 /// for a way to keep it alive without windows).
733 ///
734 /// Normally, the connection between the application and the window
735 /// will remain until the window is destroyed, but you can explicitly
736 /// remove it by setting the this property to `NULL`.
737 pub fn application(self, application: &impl IsA<Application>) -> Self {
738 Self {
739 builder: self
740 .builder
741 .property("application", application.clone().upcast()),
742 }
743 }
744
745 /// The child widget.
746 pub fn child(self, child: &impl IsA<Widget>) -> Self {
747 Self {
748 builder: self.builder.property("child", child.clone().upcast()),
749 }
750 }
751
752 /// Whether the window should have a frame (also known as *decorations*).
753 pub fn decorated(self, decorated: bool) -> Self {
754 Self {
755 builder: self.builder.property("decorated", decorated),
756 }
757 }
758
759 /// The default height of the window.
760 pub fn default_height(self, default_height: i32) -> Self {
761 Self {
762 builder: self.builder.property("default-height", default_height),
763 }
764 }
765
766 /// The default widget.
767 pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
768 Self {
769 builder: self
770 .builder
771 .property("default-widget", default_widget.clone().upcast()),
772 }
773 }
774
775 /// The default width of the window.
776 pub fn default_width(self, default_width: i32) -> Self {
777 Self {
778 builder: self.builder.property("default-width", default_width),
779 }
780 }
781
782 /// Whether the window frame should have a close button.
783 pub fn deletable(self, deletable: bool) -> Self {
784 Self {
785 builder: self.builder.property("deletable", deletable),
786 }
787 }
788
789 /// If this window should be destroyed when the parent is destroyed.
790 pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
791 Self {
792 builder: self
793 .builder
794 .property("destroy-with-parent", destroy_with_parent),
795 }
796 }
797
798 /// The display that will display this window.
799 pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
800 Self {
801 builder: self.builder.property("display", display.clone().upcast()),
802 }
803 }
804
805 /// Whether 'focus rectangles' are currently visible in this window.
806 ///
807 /// This property is maintained by GTK based on user input
808 /// and should not be set by applications.
809 pub fn focus_visible(self, focus_visible: bool) -> Self {
810 Self {
811 builder: self.builder.property("focus-visible", focus_visible),
812 }
813 }
814
815 /// The focus widget.
816 pub fn focus_widget(self, focus_widget: &impl IsA<Widget>) -> Self {
817 Self {
818 builder: self
819 .builder
820 .property("focus-widget", focus_widget.clone().upcast()),
821 }
822 }
823
824 /// Whether the window is fullscreen.
825 ///
826 /// Setting this property is the equivalent of calling
827 /// [`GtkWindowExt::fullscreen()`][crate::prelude::GtkWindowExt::fullscreen()] or [`GtkWindowExt::unfullscreen()`][crate::prelude::GtkWindowExt::unfullscreen()];
828 /// either operation is asynchronous, which means you will need to
829 /// connect to the ::notify signal in order to know whether the
830 /// operation was successful.
831 pub fn fullscreened(self, fullscreened: bool) -> Self {
832 Self {
833 builder: self.builder.property("fullscreened", fullscreened),
834 }
835 }
836
837 /// Whether the window frame should handle <kbd>F10</kbd> for activating
838 /// menubars.
839 #[cfg(feature = "v4_2")]
840 #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
841 pub fn handle_menubar_accel(self, handle_menubar_accel: bool) -> Self {
842 Self {
843 builder: self
844 .builder
845 .property("handle-menubar-accel", handle_menubar_accel),
846 }
847 }
848
849 /// If this window should be hidden when the users clicks the close button.
850 pub fn hide_on_close(self, hide_on_close: bool) -> Self {
851 Self {
852 builder: self.builder.property("hide-on-close", hide_on_close),
853 }
854 }
855
856 /// Specifies the name of the themed icon to use as the window icon.
857 ///
858 /// See [`IconTheme`][crate::IconTheme] for more details.
859 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
860 Self {
861 builder: self.builder.property("icon-name", icon_name.into()),
862 }
863 }
864
865 /// Whether the window is maximized.
866 ///
867 /// Setting this property is the equivalent of calling
868 /// [`GtkWindowExt::maximize()`][crate::prelude::GtkWindowExt::maximize()] or [`GtkWindowExt::unmaximize()`][crate::prelude::GtkWindowExt::unmaximize()];
869 /// either operation is asynchronous, which means you will need to
870 /// connect to the ::notify signal in order to know whether the
871 /// operation was successful.
872 pub fn maximized(self, maximized: bool) -> Self {
873 Self {
874 builder: self.builder.property("maximized", maximized),
875 }
876 }
877
878 /// Whether mnemonics are currently visible in this window.
879 ///
880 /// This property is maintained by GTK based on user input,
881 /// and should not be set by applications.
882 pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
883 Self {
884 builder: self
885 .builder
886 .property("mnemonics-visible", mnemonics_visible),
887 }
888 }
889
890 /// If true, the window is modal.
891 pub fn modal(self, modal: bool) -> Self {
892 Self {
893 builder: self.builder.property("modal", modal),
894 }
895 }
896
897 /// If true, users can resize the window.
898 pub fn resizable(self, resizable: bool) -> Self {
899 Self {
900 builder: self.builder.property("resizable", resizable),
901 }
902 }
903
904 /// A write-only property for setting window's startup notification identifier.
905 pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
906 Self {
907 builder: self.builder.property("startup-id", startup_id.into()),
908 }
909 }
910
911 /// The title of the window.
912 pub fn title(self, title: impl Into<glib::GString>) -> Self {
913 Self {
914 builder: self.builder.property("title", title.into()),
915 }
916 }
917
918 /// The titlebar widget.
919 #[cfg(feature = "v4_6")]
920 #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
921 pub fn titlebar(self, titlebar: &impl IsA<Widget>) -> Self {
922 Self {
923 builder: self.builder.property("titlebar", titlebar.clone().upcast()),
924 }
925 }
926
927 /// The transient parent of the window.
928 pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
929 Self {
930 builder: self
931 .builder
932 .property("transient-for", transient_for.clone().upcast()),
933 }
934 }
935
936 /// Whether the widget or any of its descendents can accept
937 /// the input focus.
938 ///
939 /// This property is meant to be set by widget implementations,
940 /// typically in their instance init function.
941 pub fn can_focus(self, can_focus: bool) -> Self {
942 Self {
943 builder: self.builder.property("can-focus", can_focus),
944 }
945 }
946
947 /// Whether the widget can receive pointer events.
948 pub fn can_target(self, can_target: bool) -> Self {
949 Self {
950 builder: self.builder.property("can-target", can_target),
951 }
952 }
953
954 /// A list of css classes applied to this widget.
955 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
956 Self {
957 builder: self.builder.property("css-classes", css_classes.into()),
958 }
959 }
960
961 /// The name of this widget in the CSS tree.
962 ///
963 /// This property is meant to be set by widget implementations,
964 /// typically in their instance init function.
965 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
966 Self {
967 builder: self.builder.property("css-name", css_name.into()),
968 }
969 }
970
971 /// The cursor used by @widget.
972 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
973 Self {
974 builder: self.builder.property("cursor", cursor.clone()),
975 }
976 }
977
978 /// Whether the widget should grab focus when it is clicked with the mouse.
979 ///
980 /// This property is only relevant for widgets that can take focus.
981 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
982 Self {
983 builder: self.builder.property("focus-on-click", focus_on_click),
984 }
985 }
986
987 /// Whether this widget itself will accept the input focus.
988 pub fn focusable(self, focusable: bool) -> Self {
989 Self {
990 builder: self.builder.property("focusable", focusable),
991 }
992 }
993
994 /// How to distribute horizontal space if widget gets extra space.
995 pub fn halign(self, halign: Align) -> Self {
996 Self {
997 builder: self.builder.property("halign", halign),
998 }
999 }
1000
1001 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1002 /// signal on @widget.
1003 ///
1004 /// A true value indicates that @widget can have a tooltip, in this case
1005 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1006 /// determine whether it will provide a tooltip or not.
1007 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1008 Self {
1009 builder: self.builder.property("has-tooltip", has_tooltip),
1010 }
1011 }
1012
1013 /// Overrides for height request of the widget.
1014 ///
1015 /// If this is -1, the natural request will be used.
1016 pub fn height_request(self, height_request: i32) -> Self {
1017 Self {
1018 builder: self.builder.property("height-request", height_request),
1019 }
1020 }
1021
1022 /// Whether to expand horizontally.
1023 pub fn hexpand(self, hexpand: bool) -> Self {
1024 Self {
1025 builder: self.builder.property("hexpand", hexpand),
1026 }
1027 }
1028
1029 /// Whether to use the `hexpand` property.
1030 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1031 Self {
1032 builder: self.builder.property("hexpand-set", hexpand_set),
1033 }
1034 }
1035
1036 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1037 /// the preferred size of the widget, and allocate its children.
1038 ///
1039 /// This property is meant to be set by widget implementations,
1040 /// typically in their instance init function.
1041 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1042 Self {
1043 builder: self
1044 .builder
1045 .property("layout-manager", layout_manager.clone().upcast()),
1046 }
1047 }
1048
1049 /// Makes this widget act like a modal dialog, with respect to
1050 /// event delivery.
1051 ///
1052 /// Global event controllers will not handle events with targets
1053 /// inside the widget, unless they are set up to ignore propagation
1054 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1055 #[cfg(feature = "v4_18")]
1056 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1057 pub fn limit_events(self, limit_events: bool) -> Self {
1058 Self {
1059 builder: self.builder.property("limit-events", limit_events),
1060 }
1061 }
1062
1063 /// Margin on bottom side of widget.
1064 ///
1065 /// This property adds margin outside of the widget's normal size
1066 /// request, the margin will be added in addition to the size from
1067 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1068 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1069 Self {
1070 builder: self.builder.property("margin-bottom", margin_bottom),
1071 }
1072 }
1073
1074 /// Margin on end of widget, horizontally.
1075 ///
1076 /// This property supports left-to-right and right-to-left text
1077 /// directions.
1078 ///
1079 /// This property adds margin outside of the widget's normal size
1080 /// request, the margin will be added in addition to the size from
1081 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1082 pub fn margin_end(self, margin_end: i32) -> Self {
1083 Self {
1084 builder: self.builder.property("margin-end", margin_end),
1085 }
1086 }
1087
1088 /// Margin on start of widget, horizontally.
1089 ///
1090 /// This property supports left-to-right and right-to-left text
1091 /// directions.
1092 ///
1093 /// This property adds margin outside of the widget's normal size
1094 /// request, the margin will be added in addition to the size from
1095 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1096 pub fn margin_start(self, margin_start: i32) -> Self {
1097 Self {
1098 builder: self.builder.property("margin-start", margin_start),
1099 }
1100 }
1101
1102 /// Margin on top side of widget.
1103 ///
1104 /// This property adds margin outside of the widget's normal size
1105 /// request, the margin will be added in addition to the size from
1106 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1107 pub fn margin_top(self, margin_top: i32) -> Self {
1108 Self {
1109 builder: self.builder.property("margin-top", margin_top),
1110 }
1111 }
1112
1113 /// The name of the widget.
1114 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1115 Self {
1116 builder: self.builder.property("name", name.into()),
1117 }
1118 }
1119
1120 /// The requested opacity of the widget.
1121 pub fn opacity(self, opacity: f64) -> Self {
1122 Self {
1123 builder: self.builder.property("opacity", opacity),
1124 }
1125 }
1126
1127 /// How content outside the widget's content area is treated.
1128 ///
1129 /// This property is meant to be set by widget implementations,
1130 /// typically in their instance init function.
1131 pub fn overflow(self, overflow: Overflow) -> Self {
1132 Self {
1133 builder: self.builder.property("overflow", overflow),
1134 }
1135 }
1136
1137 /// Whether the widget will receive the default action when it is focused.
1138 pub fn receives_default(self, receives_default: bool) -> Self {
1139 Self {
1140 builder: self.builder.property("receives-default", receives_default),
1141 }
1142 }
1143
1144 /// Whether the widget responds to input.
1145 pub fn sensitive(self, sensitive: bool) -> Self {
1146 Self {
1147 builder: self.builder.property("sensitive", sensitive),
1148 }
1149 }
1150
1151 /// Sets the text of tooltip to be the given string, which is marked up
1152 /// with Pango markup.
1153 ///
1154 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1155 ///
1156 /// This is a convenience property which will take care of getting the
1157 /// tooltip shown if the given string is not `NULL`:
1158 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1159 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1160 /// the default signal handler.
1161 ///
1162 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1163 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1164 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1165 Self {
1166 builder: self
1167 .builder
1168 .property("tooltip-markup", tooltip_markup.into()),
1169 }
1170 }
1171
1172 /// Sets the text of tooltip to be the given string.
1173 ///
1174 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1175 ///
1176 /// This is a convenience property which will take care of getting the
1177 /// tooltip shown if the given string is not `NULL`:
1178 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1179 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1180 /// the default signal handler.
1181 ///
1182 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1183 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1184 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1185 Self {
1186 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1187 }
1188 }
1189
1190 /// How to distribute vertical space if widget gets extra space.
1191 pub fn valign(self, valign: Align) -> Self {
1192 Self {
1193 builder: self.builder.property("valign", valign),
1194 }
1195 }
1196
1197 /// Whether to expand vertically.
1198 pub fn vexpand(self, vexpand: bool) -> Self {
1199 Self {
1200 builder: self.builder.property("vexpand", vexpand),
1201 }
1202 }
1203
1204 /// Whether to use the `vexpand` property.
1205 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1206 Self {
1207 builder: self.builder.property("vexpand-set", vexpand_set),
1208 }
1209 }
1210
1211 /// Whether the widget is visible.
1212 pub fn visible(self, visible: bool) -> Self {
1213 Self {
1214 builder: self.builder.property("visible", visible),
1215 }
1216 }
1217
1218 /// Overrides for width request of the widget.
1219 ///
1220 /// If this is -1, the natural request will be used.
1221 pub fn width_request(self, width_request: i32) -> Self {
1222 Self {
1223 builder: self.builder.property("width-request", width_request),
1224 }
1225 }
1226
1227 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1228 ///
1229 /// The accessible role cannot be changed once set.
1230 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1231 Self {
1232 builder: self.builder.property("accessible-role", accessible_role),
1233 }
1234 }
1235
1236 /// The currently selected color, as a [`gdk::RGBA`][crate::gdk::RGBA] struct.
1237 ///
1238 /// The property can be set to change the current selection
1239 /// programmatically.
1240 /// Use [`ColorDialog`][crate::ColorDialog] and [`ColorDialogButton`][crate::ColorDialogButton]
1241 /// instead of widgets implementing [`ColorChooser`][crate::ColorChooser]
1242 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1243 pub fn rgba(self, rgba: &gdk::RGBA) -> Self {
1244 Self {
1245 builder: self.builder.property("rgba", rgba),
1246 }
1247 }
1248
1249 /// Whether colors may have alpha (translucency).
1250 ///
1251 /// When ::use-alpha is [`false`], the [`gdk::RGBA`][crate::gdk::RGBA] struct obtained
1252 /// via the [`rgba`][struct@crate::ColorChooser#rgba] property will be
1253 /// forced to have alpha == 1.
1254 ///
1255 /// Implementations are expected to show alpha by rendering the color
1256 /// over a non-uniform background (like a checkerboard pattern).
1257 /// Use [`ColorDialog`][crate::ColorDialog] and [`ColorDialogButton`][crate::ColorDialogButton]
1258 /// instead of widgets implementing [`ColorChooser`][crate::ColorChooser]
1259 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1260 pub fn use_alpha(self, use_alpha: bool) -> Self {
1261 Self {
1262 builder: self.builder.property("use-alpha", use_alpha),
1263 }
1264 }
1265
1266 // rustdoc-stripper-ignore-next
1267 /// Build the [`ColorChooserDialog`].
1268 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1269 pub fn build(self) -> ColorChooserDialog {
1270 assert_initialized_main_thread!();
1271 self.builder.build()
1272 }
1273}