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
6#[cfg(feature = "v4_20")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
8use crate::WindowGravity;
9use crate::{
10    ffi, Accessible, AccessibleRole, Align, Application, Buildable, ColorChooser, ConstraintTarget,
11    Dialog, LayoutManager, Native, Overflow, Root, ShortcutManager, Widget, Window,
12};
13use glib::{
14    prelude::*,
15    signal::{connect_raw, SignalHandlerId},
16    translate::*,
17};
18use std::boxed::Box as Box_;
19
20glib::wrapper! {
21    #[doc(alias = "GtkColorChooserDialog")]
22    pub struct ColorChooserDialog(Object<ffi::GtkColorChooserDialog>) @extends Dialog, Window, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager, ColorChooser;
23
24    match fn {
25        type_ => || ffi::gtk_color_chooser_dialog_get_type(),
26    }
27}
28
29impl ColorChooserDialog {
30    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
31    #[allow(deprecated)]
32    #[doc(alias = "gtk_color_chooser_dialog_new")]
33    pub fn new(title: Option<&str>, parent: Option<&impl IsA<Window>>) -> ColorChooserDialog {
34        assert_initialized_main_thread!();
35        unsafe {
36            Widget::from_glib_none(ffi::gtk_color_chooser_dialog_new(
37                title.to_glib_none().0,
38                parent.map(|p| p.as_ref()).to_glib_none().0,
39            ))
40            .unsafe_cast()
41        }
42    }
43
44    // rustdoc-stripper-ignore-next
45    /// Creates a new builder-pattern struct instance to construct [`ColorChooserDialog`] objects.
46    ///
47    /// This method returns an instance of [`ColorChooserDialogBuilder`](crate::builders::ColorChooserDialogBuilder) which can be used to create [`ColorChooserDialog`] objects.
48    pub fn builder() -> ColorChooserDialogBuilder {
49        ColorChooserDialogBuilder::new()
50    }
51
52    #[doc(alias = "show-editor")]
53    pub fn shows_editor(&self) -> bool {
54        ObjectExt::property(self, "show-editor")
55    }
56
57    #[doc(alias = "show-editor")]
58    pub fn set_show_editor(&self, show_editor: bool) {
59        ObjectExt::set_property(self, "show-editor", show_editor)
60    }
61
62    #[doc(alias = "show-editor")]
63    pub fn connect_show_editor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
64        unsafe extern "C" fn notify_show_editor_trampoline<F: Fn(&ColorChooserDialog) + 'static>(
65            this: *mut ffi::GtkColorChooserDialog,
66            _param_spec: glib::ffi::gpointer,
67            f: glib::ffi::gpointer,
68        ) {
69            let f: &F = &*(f as *const F);
70            f(&from_glib_borrow(this))
71        }
72        unsafe {
73            let f: Box_<F> = Box_::new(f);
74            connect_raw(
75                self.as_ptr() as *mut _,
76                c"notify::show-editor".as_ptr() as *const _,
77                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
78                    notify_show_editor_trampoline::<F> as *const (),
79                )),
80                Box_::into_raw(f),
81            )
82        }
83    }
84}
85
86impl Default for ColorChooserDialog {
87    fn default() -> Self {
88        glib::object::Object::new::<Self>()
89    }
90}
91
92// rustdoc-stripper-ignore-next
93/// A [builder-pattern] type to construct [`ColorChooserDialog`] objects.
94///
95/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
96#[must_use = "The builder must be built to be used"]
97pub struct ColorChooserDialogBuilder {
98    builder: glib::object::ObjectBuilder<'static, ColorChooserDialog>,
99}
100
101impl ColorChooserDialogBuilder {
102    fn new() -> Self {
103        Self {
104            builder: glib::object::Object::builder(),
105        }
106    }
107
108    pub fn show_editor(self, show_editor: bool) -> Self {
109        Self {
110            builder: self.builder.property("show-editor", show_editor),
111        }
112    }
113
114    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
115    pub fn use_header_bar(self, use_header_bar: i32) -> Self {
116        Self {
117            builder: self.builder.property("use-header-bar", use_header_bar),
118        }
119    }
120
121    pub fn application(self, application: &impl IsA<Application>) -> Self {
122        Self {
123            builder: self
124                .builder
125                .property("application", application.clone().upcast()),
126        }
127    }
128
129    pub fn child(self, child: &impl IsA<Widget>) -> Self {
130        Self {
131            builder: self.builder.property("child", child.clone().upcast()),
132        }
133    }
134
135    pub fn decorated(self, decorated: bool) -> Self {
136        Self {
137            builder: self.builder.property("decorated", decorated),
138        }
139    }
140
141    pub fn default_height(self, default_height: i32) -> Self {
142        Self {
143            builder: self.builder.property("default-height", default_height),
144        }
145    }
146
147    pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
148        Self {
149            builder: self
150                .builder
151                .property("default-widget", default_widget.clone().upcast()),
152        }
153    }
154
155    pub fn default_width(self, default_width: i32) -> Self {
156        Self {
157            builder: self.builder.property("default-width", default_width),
158        }
159    }
160
161    pub fn deletable(self, deletable: bool) -> Self {
162        Self {
163            builder: self.builder.property("deletable", deletable),
164        }
165    }
166
167    pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
168        Self {
169            builder: self
170                .builder
171                .property("destroy-with-parent", destroy_with_parent),
172        }
173    }
174
175    pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
176        Self {
177            builder: self.builder.property("display", display.clone().upcast()),
178        }
179    }
180
181    pub fn focus_visible(self, focus_visible: bool) -> Self {
182        Self {
183            builder: self.builder.property("focus-visible", focus_visible),
184        }
185    }
186
187    pub fn focus_widget(self, focus_widget: &impl IsA<Widget>) -> Self {
188        Self {
189            builder: self
190                .builder
191                .property("focus-widget", focus_widget.clone().upcast()),
192        }
193    }
194
195    pub fn fullscreened(self, fullscreened: bool) -> Self {
196        Self {
197            builder: self.builder.property("fullscreened", fullscreened),
198        }
199    }
200
201    #[cfg(feature = "v4_20")]
202    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
203    pub fn gravity(self, gravity: WindowGravity) -> Self {
204        Self {
205            builder: self.builder.property("gravity", gravity),
206        }
207    }
208
209    #[cfg(feature = "v4_2")]
210    #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
211    pub fn handle_menubar_accel(self, handle_menubar_accel: bool) -> Self {
212        Self {
213            builder: self
214                .builder
215                .property("handle-menubar-accel", handle_menubar_accel),
216        }
217    }
218
219    pub fn hide_on_close(self, hide_on_close: bool) -> Self {
220        Self {
221            builder: self.builder.property("hide-on-close", hide_on_close),
222        }
223    }
224
225    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
226        Self {
227            builder: self.builder.property("icon-name", icon_name.into()),
228        }
229    }
230
231    pub fn maximized(self, maximized: bool) -> Self {
232        Self {
233            builder: self.builder.property("maximized", maximized),
234        }
235    }
236
237    pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
238        Self {
239            builder: self
240                .builder
241                .property("mnemonics-visible", mnemonics_visible),
242        }
243    }
244
245    pub fn modal(self, modal: bool) -> Self {
246        Self {
247            builder: self.builder.property("modal", modal),
248        }
249    }
250
251    pub fn resizable(self, resizable: bool) -> Self {
252        Self {
253            builder: self.builder.property("resizable", resizable),
254        }
255    }
256
257    pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
258        Self {
259            builder: self.builder.property("startup-id", startup_id.into()),
260        }
261    }
262
263    pub fn title(self, title: impl Into<glib::GString>) -> Self {
264        Self {
265            builder: self.builder.property("title", title.into()),
266        }
267    }
268
269    #[cfg(feature = "v4_6")]
270    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
271    pub fn titlebar(self, titlebar: &impl IsA<Widget>) -> Self {
272        Self {
273            builder: self.builder.property("titlebar", titlebar.clone().upcast()),
274        }
275    }
276
277    pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
278        Self {
279            builder: self
280                .builder
281                .property("transient-for", transient_for.clone().upcast()),
282        }
283    }
284
285    pub fn can_focus(self, can_focus: bool) -> Self {
286        Self {
287            builder: self.builder.property("can-focus", can_focus),
288        }
289    }
290
291    pub fn can_target(self, can_target: bool) -> Self {
292        Self {
293            builder: self.builder.property("can-target", can_target),
294        }
295    }
296
297    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
298        Self {
299            builder: self.builder.property("css-classes", css_classes.into()),
300        }
301    }
302
303    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
304        Self {
305            builder: self.builder.property("css-name", css_name.into()),
306        }
307    }
308
309    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
310        Self {
311            builder: self.builder.property("cursor", cursor.clone()),
312        }
313    }
314
315    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
316        Self {
317            builder: self.builder.property("focus-on-click", focus_on_click),
318        }
319    }
320
321    pub fn focusable(self, focusable: bool) -> Self {
322        Self {
323            builder: self.builder.property("focusable", focusable),
324        }
325    }
326
327    pub fn halign(self, halign: Align) -> Self {
328        Self {
329            builder: self.builder.property("halign", halign),
330        }
331    }
332
333    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
334        Self {
335            builder: self.builder.property("has-tooltip", has_tooltip),
336        }
337    }
338
339    pub fn height_request(self, height_request: i32) -> Self {
340        Self {
341            builder: self.builder.property("height-request", height_request),
342        }
343    }
344
345    pub fn hexpand(self, hexpand: bool) -> Self {
346        Self {
347            builder: self.builder.property("hexpand", hexpand),
348        }
349    }
350
351    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
352        Self {
353            builder: self.builder.property("hexpand-set", hexpand_set),
354        }
355    }
356
357    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
358        Self {
359            builder: self
360                .builder
361                .property("layout-manager", layout_manager.clone().upcast()),
362        }
363    }
364
365    #[cfg(feature = "v4_18")]
366    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
367    pub fn limit_events(self, limit_events: bool) -> Self {
368        Self {
369            builder: self.builder.property("limit-events", limit_events),
370        }
371    }
372
373    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
374        Self {
375            builder: self.builder.property("margin-bottom", margin_bottom),
376        }
377    }
378
379    pub fn margin_end(self, margin_end: i32) -> Self {
380        Self {
381            builder: self.builder.property("margin-end", margin_end),
382        }
383    }
384
385    pub fn margin_start(self, margin_start: i32) -> Self {
386        Self {
387            builder: self.builder.property("margin-start", margin_start),
388        }
389    }
390
391    pub fn margin_top(self, margin_top: i32) -> Self {
392        Self {
393            builder: self.builder.property("margin-top", margin_top),
394        }
395    }
396
397    pub fn name(self, name: impl Into<glib::GString>) -> Self {
398        Self {
399            builder: self.builder.property("name", name.into()),
400        }
401    }
402
403    pub fn opacity(self, opacity: f64) -> Self {
404        Self {
405            builder: self.builder.property("opacity", opacity),
406        }
407    }
408
409    pub fn overflow(self, overflow: Overflow) -> Self {
410        Self {
411            builder: self.builder.property("overflow", overflow),
412        }
413    }
414
415    pub fn receives_default(self, receives_default: bool) -> Self {
416        Self {
417            builder: self.builder.property("receives-default", receives_default),
418        }
419    }
420
421    pub fn sensitive(self, sensitive: bool) -> Self {
422        Self {
423            builder: self.builder.property("sensitive", sensitive),
424        }
425    }
426
427    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
428        Self {
429            builder: self
430                .builder
431                .property("tooltip-markup", tooltip_markup.into()),
432        }
433    }
434
435    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
436        Self {
437            builder: self.builder.property("tooltip-text", tooltip_text.into()),
438        }
439    }
440
441    pub fn valign(self, valign: Align) -> Self {
442        Self {
443            builder: self.builder.property("valign", valign),
444        }
445    }
446
447    pub fn vexpand(self, vexpand: bool) -> Self {
448        Self {
449            builder: self.builder.property("vexpand", vexpand),
450        }
451    }
452
453    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
454        Self {
455            builder: self.builder.property("vexpand-set", vexpand_set),
456        }
457    }
458
459    pub fn visible(self, visible: bool) -> Self {
460        Self {
461            builder: self.builder.property("visible", visible),
462        }
463    }
464
465    pub fn width_request(self, width_request: i32) -> Self {
466        Self {
467            builder: self.builder.property("width-request", width_request),
468        }
469    }
470
471    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
472        Self {
473            builder: self.builder.property("accessible-role", accessible_role),
474        }
475    }
476
477    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
478    pub fn rgba(self, rgba: &gdk::RGBA) -> Self {
479        Self {
480            builder: self.builder.property("rgba", rgba),
481        }
482    }
483
484    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
485    pub fn use_alpha(self, use_alpha: bool) -> Self {
486        Self {
487            builder: self.builder.property("use-alpha", use_alpha),
488        }
489    }
490
491    // rustdoc-stripper-ignore-next
492    /// Build the [`ColorChooserDialog`].
493    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
494    pub fn build(self) -> ColorChooserDialog {
495        assert_initialized_main_thread!();
496        self.builder.build()
497    }
498}