gtk/auto/
color_chooser_widget.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 gdk;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::signal::connect_raw;
9use glib::signal::SignalHandlerId;
10use glib::translate::*;
11use glib::StaticType;
12use glib::ToValue;
13use glib::Value;
14use glib_sys;
15use gobject_sys;
16use gtk_sys;
17use std::boxed::Box as Box_;
18use std::fmt;
19use std::mem::transmute;
20use Align;
21use BaselinePosition;
22use Box;
23use Buildable;
24use ColorChooser;
25use Container;
26use Orientable;
27use ResizeMode;
28use Widget;
29
30glib_wrapper! {
31    pub struct ColorChooserWidget(Object<gtk_sys::GtkColorChooserWidget, gtk_sys::GtkColorChooserWidgetClass, ColorChooserWidgetClass>) @extends Box, Container, Widget, @implements Buildable, Orientable, ColorChooser;
32
33    match fn {
34        get_type => || gtk_sys::gtk_color_chooser_widget_get_type(),
35    }
36}
37
38impl ColorChooserWidget {
39    pub fn new() -> ColorChooserWidget {
40        assert_initialized_main_thread!();
41        unsafe { Widget::from_glib_none(gtk_sys::gtk_color_chooser_widget_new()).unsafe_cast() }
42    }
43}
44
45impl Default for ColorChooserWidget {
46    fn default() -> Self {
47        Self::new()
48    }
49}
50
51pub struct ColorChooserWidgetBuilder {
52    show_editor: Option<bool>,
53    baseline_position: Option<BaselinePosition>,
54    homogeneous: Option<bool>,
55    spacing: Option<i32>,
56    border_width: Option<u32>,
57    child: Option<Widget>,
58    resize_mode: Option<ResizeMode>,
59    app_paintable: Option<bool>,
60    can_default: Option<bool>,
61    can_focus: Option<bool>,
62    events: Option<gdk::EventMask>,
63    expand: Option<bool>,
64    #[cfg(any(feature = "v3_20", feature = "dox"))]
65    focus_on_click: Option<bool>,
66    halign: Option<Align>,
67    has_default: Option<bool>,
68    has_focus: Option<bool>,
69    has_tooltip: Option<bool>,
70    height_request: Option<i32>,
71    hexpand: Option<bool>,
72    hexpand_set: Option<bool>,
73    is_focus: Option<bool>,
74    margin: Option<i32>,
75    margin_bottom: Option<i32>,
76    margin_end: Option<i32>,
77    margin_start: Option<i32>,
78    margin_top: Option<i32>,
79    name: Option<String>,
80    no_show_all: Option<bool>,
81    opacity: Option<f64>,
82    parent: Option<Container>,
83    receives_default: Option<bool>,
84    sensitive: Option<bool>,
85    //style: /*Unknown type*/,
86    tooltip_markup: Option<String>,
87    tooltip_text: Option<String>,
88    valign: Option<Align>,
89    vexpand: Option<bool>,
90    vexpand_set: Option<bool>,
91    visible: Option<bool>,
92    width_request: Option<i32>,
93}
94
95impl ColorChooserWidgetBuilder {
96    pub fn new() -> Self {
97        Self {
98            show_editor: None,
99            baseline_position: None,
100            homogeneous: None,
101            spacing: None,
102            border_width: None,
103            child: None,
104            resize_mode: None,
105            app_paintable: None,
106            can_default: None,
107            can_focus: None,
108            events: None,
109            expand: None,
110            #[cfg(any(feature = "v3_20", feature = "dox"))]
111            focus_on_click: None,
112            halign: None,
113            has_default: None,
114            has_focus: None,
115            has_tooltip: None,
116            height_request: None,
117            hexpand: None,
118            hexpand_set: None,
119            is_focus: None,
120            margin: None,
121            margin_bottom: None,
122            margin_end: None,
123            margin_start: None,
124            margin_top: None,
125            name: None,
126            no_show_all: None,
127            opacity: None,
128            parent: None,
129            receives_default: None,
130            sensitive: None,
131            tooltip_markup: None,
132            tooltip_text: None,
133            valign: None,
134            vexpand: None,
135            vexpand_set: None,
136            visible: None,
137            width_request: None,
138        }
139    }
140
141    pub fn build(self) -> ColorChooserWidget {
142        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
143        if let Some(ref show_editor) = self.show_editor {
144            properties.push(("show-editor", show_editor));
145        }
146        if let Some(ref baseline_position) = self.baseline_position {
147            properties.push(("baseline-position", baseline_position));
148        }
149        if let Some(ref homogeneous) = self.homogeneous {
150            properties.push(("homogeneous", homogeneous));
151        }
152        if let Some(ref spacing) = self.spacing {
153            properties.push(("spacing", spacing));
154        }
155        if let Some(ref border_width) = self.border_width {
156            properties.push(("border-width", border_width));
157        }
158        if let Some(ref child) = self.child {
159            properties.push(("child", child));
160        }
161        if let Some(ref resize_mode) = self.resize_mode {
162            properties.push(("resize-mode", resize_mode));
163        }
164        if let Some(ref app_paintable) = self.app_paintable {
165            properties.push(("app-paintable", app_paintable));
166        }
167        if let Some(ref can_default) = self.can_default {
168            properties.push(("can-default", can_default));
169        }
170        if let Some(ref can_focus) = self.can_focus {
171            properties.push(("can-focus", can_focus));
172        }
173        if let Some(ref events) = self.events {
174            properties.push(("events", events));
175        }
176        if let Some(ref expand) = self.expand {
177            properties.push(("expand", expand));
178        }
179        #[cfg(any(feature = "v3_20", feature = "dox"))]
180        {
181            if let Some(ref focus_on_click) = self.focus_on_click {
182                properties.push(("focus-on-click", focus_on_click));
183            }
184        }
185        if let Some(ref halign) = self.halign {
186            properties.push(("halign", halign));
187        }
188        if let Some(ref has_default) = self.has_default {
189            properties.push(("has-default", has_default));
190        }
191        if let Some(ref has_focus) = self.has_focus {
192            properties.push(("has-focus", has_focus));
193        }
194        if let Some(ref has_tooltip) = self.has_tooltip {
195            properties.push(("has-tooltip", has_tooltip));
196        }
197        if let Some(ref height_request) = self.height_request {
198            properties.push(("height-request", height_request));
199        }
200        if let Some(ref hexpand) = self.hexpand {
201            properties.push(("hexpand", hexpand));
202        }
203        if let Some(ref hexpand_set) = self.hexpand_set {
204            properties.push(("hexpand-set", hexpand_set));
205        }
206        if let Some(ref is_focus) = self.is_focus {
207            properties.push(("is-focus", is_focus));
208        }
209        if let Some(ref margin) = self.margin {
210            properties.push(("margin", margin));
211        }
212        if let Some(ref margin_bottom) = self.margin_bottom {
213            properties.push(("margin-bottom", margin_bottom));
214        }
215        if let Some(ref margin_end) = self.margin_end {
216            properties.push(("margin-end", margin_end));
217        }
218        if let Some(ref margin_start) = self.margin_start {
219            properties.push(("margin-start", margin_start));
220        }
221        if let Some(ref margin_top) = self.margin_top {
222            properties.push(("margin-top", margin_top));
223        }
224        if let Some(ref name) = self.name {
225            properties.push(("name", name));
226        }
227        if let Some(ref no_show_all) = self.no_show_all {
228            properties.push(("no-show-all", no_show_all));
229        }
230        if let Some(ref opacity) = self.opacity {
231            properties.push(("opacity", opacity));
232        }
233        if let Some(ref parent) = self.parent {
234            properties.push(("parent", parent));
235        }
236        if let Some(ref receives_default) = self.receives_default {
237            properties.push(("receives-default", receives_default));
238        }
239        if let Some(ref sensitive) = self.sensitive {
240            properties.push(("sensitive", sensitive));
241        }
242        if let Some(ref tooltip_markup) = self.tooltip_markup {
243            properties.push(("tooltip-markup", tooltip_markup));
244        }
245        if let Some(ref tooltip_text) = self.tooltip_text {
246            properties.push(("tooltip-text", tooltip_text));
247        }
248        if let Some(ref valign) = self.valign {
249            properties.push(("valign", valign));
250        }
251        if let Some(ref vexpand) = self.vexpand {
252            properties.push(("vexpand", vexpand));
253        }
254        if let Some(ref vexpand_set) = self.vexpand_set {
255            properties.push(("vexpand-set", vexpand_set));
256        }
257        if let Some(ref visible) = self.visible {
258            properties.push(("visible", visible));
259        }
260        if let Some(ref width_request) = self.width_request {
261            properties.push(("width-request", width_request));
262        }
263        glib::Object::new(ColorChooserWidget::static_type(), &properties)
264            .expect("object new")
265            .downcast()
266            .expect("downcast")
267    }
268
269    pub fn show_editor(mut self, show_editor: bool) -> Self {
270        self.show_editor = Some(show_editor);
271        self
272    }
273
274    pub fn baseline_position(mut self, baseline_position: BaselinePosition) -> Self {
275        self.baseline_position = Some(baseline_position);
276        self
277    }
278
279    pub fn homogeneous(mut self, homogeneous: bool) -> Self {
280        self.homogeneous = Some(homogeneous);
281        self
282    }
283
284    pub fn spacing(mut self, spacing: i32) -> Self {
285        self.spacing = Some(spacing);
286        self
287    }
288
289    pub fn border_width(mut self, border_width: u32) -> Self {
290        self.border_width = Some(border_width);
291        self
292    }
293
294    pub fn child(mut self, child: &Widget) -> Self {
295        self.child = Some(child.clone());
296        self
297    }
298
299    pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
300        self.resize_mode = Some(resize_mode);
301        self
302    }
303
304    pub fn app_paintable(mut self, app_paintable: bool) -> Self {
305        self.app_paintable = Some(app_paintable);
306        self
307    }
308
309    pub fn can_default(mut self, can_default: bool) -> Self {
310        self.can_default = Some(can_default);
311        self
312    }
313
314    pub fn can_focus(mut self, can_focus: bool) -> Self {
315        self.can_focus = Some(can_focus);
316        self
317    }
318
319    pub fn events(mut self, events: gdk::EventMask) -> Self {
320        self.events = Some(events);
321        self
322    }
323
324    pub fn expand(mut self, expand: bool) -> Self {
325        self.expand = Some(expand);
326        self
327    }
328
329    #[cfg(any(feature = "v3_20", feature = "dox"))]
330    pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
331        self.focus_on_click = Some(focus_on_click);
332        self
333    }
334
335    pub fn halign(mut self, halign: Align) -> Self {
336        self.halign = Some(halign);
337        self
338    }
339
340    pub fn has_default(mut self, has_default: bool) -> Self {
341        self.has_default = Some(has_default);
342        self
343    }
344
345    pub fn has_focus(mut self, has_focus: bool) -> Self {
346        self.has_focus = Some(has_focus);
347        self
348    }
349
350    pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
351        self.has_tooltip = Some(has_tooltip);
352        self
353    }
354
355    pub fn height_request(mut self, height_request: i32) -> Self {
356        self.height_request = Some(height_request);
357        self
358    }
359
360    pub fn hexpand(mut self, hexpand: bool) -> Self {
361        self.hexpand = Some(hexpand);
362        self
363    }
364
365    pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
366        self.hexpand_set = Some(hexpand_set);
367        self
368    }
369
370    pub fn is_focus(mut self, is_focus: bool) -> Self {
371        self.is_focus = Some(is_focus);
372        self
373    }
374
375    pub fn margin(mut self, margin: i32) -> Self {
376        self.margin = Some(margin);
377        self
378    }
379
380    pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
381        self.margin_bottom = Some(margin_bottom);
382        self
383    }
384
385    pub fn margin_end(mut self, margin_end: i32) -> Self {
386        self.margin_end = Some(margin_end);
387        self
388    }
389
390    pub fn margin_start(mut self, margin_start: i32) -> Self {
391        self.margin_start = Some(margin_start);
392        self
393    }
394
395    pub fn margin_top(mut self, margin_top: i32) -> Self {
396        self.margin_top = Some(margin_top);
397        self
398    }
399
400    pub fn name(mut self, name: &str) -> Self {
401        self.name = Some(name.to_string());
402        self
403    }
404
405    pub fn no_show_all(mut self, no_show_all: bool) -> Self {
406        self.no_show_all = Some(no_show_all);
407        self
408    }
409
410    pub fn opacity(mut self, opacity: f64) -> Self {
411        self.opacity = Some(opacity);
412        self
413    }
414
415    pub fn parent(mut self, parent: &Container) -> Self {
416        self.parent = Some(parent.clone());
417        self
418    }
419
420    pub fn receives_default(mut self, receives_default: bool) -> Self {
421        self.receives_default = Some(receives_default);
422        self
423    }
424
425    pub fn sensitive(mut self, sensitive: bool) -> Self {
426        self.sensitive = Some(sensitive);
427        self
428    }
429
430    pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
431        self.tooltip_markup = Some(tooltip_markup.to_string());
432        self
433    }
434
435    pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
436        self.tooltip_text = Some(tooltip_text.to_string());
437        self
438    }
439
440    pub fn valign(mut self, valign: Align) -> Self {
441        self.valign = Some(valign);
442        self
443    }
444
445    pub fn vexpand(mut self, vexpand: bool) -> Self {
446        self.vexpand = Some(vexpand);
447        self
448    }
449
450    pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
451        self.vexpand_set = Some(vexpand_set);
452        self
453    }
454
455    pub fn visible(mut self, visible: bool) -> Self {
456        self.visible = Some(visible);
457        self
458    }
459
460    pub fn width_request(mut self, width_request: i32) -> Self {
461        self.width_request = Some(width_request);
462        self
463    }
464}
465
466pub const NONE_COLOR_CHOOSER_WIDGET: Option<&ColorChooserWidget> = None;
467
468pub trait ColorChooserWidgetExt: 'static {
469    fn get_property_show_editor(&self) -> bool;
470
471    fn set_property_show_editor(&self, show_editor: bool);
472
473    fn connect_property_show_editor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
474}
475
476impl<O: IsA<ColorChooserWidget>> ColorChooserWidgetExt for O {
477    fn get_property_show_editor(&self) -> bool {
478        unsafe {
479            let mut value = Value::from_type(<bool as StaticType>::static_type());
480            gobject_sys::g_object_get_property(
481                self.to_glib_none().0 as *mut gobject_sys::GObject,
482                b"show-editor\0".as_ptr() as *const _,
483                value.to_glib_none_mut().0,
484            );
485            value.get().unwrap()
486        }
487    }
488
489    fn set_property_show_editor(&self, show_editor: bool) {
490        unsafe {
491            gobject_sys::g_object_set_property(
492                self.to_glib_none().0 as *mut gobject_sys::GObject,
493                b"show-editor\0".as_ptr() as *const _,
494                Value::from(&show_editor).to_glib_none().0,
495            );
496        }
497    }
498
499    fn connect_property_show_editor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
500        unsafe extern "C" fn notify_show_editor_trampoline<P, F: Fn(&P) + 'static>(
501            this: *mut gtk_sys::GtkColorChooserWidget,
502            _param_spec: glib_sys::gpointer,
503            f: glib_sys::gpointer,
504        ) where
505            P: IsA<ColorChooserWidget>,
506        {
507            let f: &F = &*(f as *const F);
508            f(&ColorChooserWidget::from_glib_borrow(this).unsafe_cast())
509        }
510        unsafe {
511            let f: Box_<F> = Box_::new(f);
512            connect_raw(
513                self.as_ptr() as *mut _,
514                b"notify::show-editor\0".as_ptr() as *const _,
515                Some(transmute(notify_show_editor_trampoline::<Self, F> as usize)),
516                Box_::into_raw(f),
517            )
518        }
519    }
520}
521
522impl fmt::Display for ColorChooserWidget {
523    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
524        write!(f, "ColorChooserWidget")
525    }
526}