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