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