gtk/auto/
frame.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::GString;
12use glib::StaticType;
13use glib::ToValue;
14use glib::Value;
15use glib_sys;
16use gobject_sys;
17use gtk_sys;
18use std::boxed::Box as Box_;
19use std::fmt;
20use std::mem;
21use std::mem::transmute;
22use Align;
23use Bin;
24use Buildable;
25use Container;
26use ResizeMode;
27use ShadowType;
28use Widget;
29
30glib_wrapper! {
31    pub struct Frame(Object<gtk_sys::GtkFrame, gtk_sys::GtkFrameClass, FrameClass>) @extends Bin, Container, Widget, @implements Buildable;
32
33    match fn {
34        get_type => || gtk_sys::gtk_frame_get_type(),
35    }
36}
37
38impl Frame {
39    pub fn new(label: Option<&str>) -> Frame {
40        assert_initialized_main_thread!();
41        unsafe {
42            Widget::from_glib_none(gtk_sys::gtk_frame_new(label.to_glib_none().0)).unsafe_cast()
43        }
44    }
45}
46
47pub struct FrameBuilder {
48    label: Option<String>,
49    label_widget: Option<Widget>,
50    label_xalign: Option<f32>,
51    label_yalign: Option<f32>,
52    shadow_type: Option<ShadowType>,
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 FrameBuilder {
93    pub fn new() -> Self {
94        Self {
95            label: None,
96            label_widget: None,
97            label_xalign: None,
98            label_yalign: None,
99            shadow_type: None,
100            border_width: None,
101            child: None,
102            resize_mode: None,
103            app_paintable: None,
104            can_default: None,
105            can_focus: None,
106            events: None,
107            expand: None,
108            #[cfg(any(feature = "v3_20", feature = "dox"))]
109            focus_on_click: None,
110            halign: None,
111            has_default: None,
112            has_focus: None,
113            has_tooltip: None,
114            height_request: None,
115            hexpand: None,
116            hexpand_set: None,
117            is_focus: None,
118            margin: None,
119            margin_bottom: None,
120            margin_end: None,
121            margin_start: None,
122            margin_top: None,
123            name: None,
124            no_show_all: None,
125            opacity: None,
126            parent: None,
127            receives_default: None,
128            sensitive: None,
129            tooltip_markup: None,
130            tooltip_text: None,
131            valign: None,
132            vexpand: None,
133            vexpand_set: None,
134            visible: None,
135            width_request: None,
136        }
137    }
138
139    pub fn build(self) -> Frame {
140        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
141        if let Some(ref label) = self.label {
142            properties.push(("label", label));
143        }
144        if let Some(ref label_widget) = self.label_widget {
145            properties.push(("label-widget", label_widget));
146        }
147        if let Some(ref label_xalign) = self.label_xalign {
148            properties.push(("label-xalign", label_xalign));
149        }
150        if let Some(ref label_yalign) = self.label_yalign {
151            properties.push(("label-yalign", label_yalign));
152        }
153        if let Some(ref shadow_type) = self.shadow_type {
154            properties.push(("shadow-type", shadow_type));
155        }
156        if let Some(ref border_width) = self.border_width {
157            properties.push(("border-width", border_width));
158        }
159        if let Some(ref child) = self.child {
160            properties.push(("child", child));
161        }
162        if let Some(ref resize_mode) = self.resize_mode {
163            properties.push(("resize-mode", resize_mode));
164        }
165        if let Some(ref app_paintable) = self.app_paintable {
166            properties.push(("app-paintable", app_paintable));
167        }
168        if let Some(ref can_default) = self.can_default {
169            properties.push(("can-default", can_default));
170        }
171        if let Some(ref can_focus) = self.can_focus {
172            properties.push(("can-focus", can_focus));
173        }
174        if let Some(ref events) = self.events {
175            properties.push(("events", events));
176        }
177        if let Some(ref expand) = self.expand {
178            properties.push(("expand", expand));
179        }
180        #[cfg(any(feature = "v3_20", feature = "dox"))]
181        {
182            if let Some(ref focus_on_click) = self.focus_on_click {
183                properties.push(("focus-on-click", focus_on_click));
184            }
185        }
186        if let Some(ref halign) = self.halign {
187            properties.push(("halign", halign));
188        }
189        if let Some(ref has_default) = self.has_default {
190            properties.push(("has-default", has_default));
191        }
192        if let Some(ref has_focus) = self.has_focus {
193            properties.push(("has-focus", has_focus));
194        }
195        if let Some(ref has_tooltip) = self.has_tooltip {
196            properties.push(("has-tooltip", has_tooltip));
197        }
198        if let Some(ref height_request) = self.height_request {
199            properties.push(("height-request", height_request));
200        }
201        if let Some(ref hexpand) = self.hexpand {
202            properties.push(("hexpand", hexpand));
203        }
204        if let Some(ref hexpand_set) = self.hexpand_set {
205            properties.push(("hexpand-set", hexpand_set));
206        }
207        if let Some(ref is_focus) = self.is_focus {
208            properties.push(("is-focus", is_focus));
209        }
210        if let Some(ref margin) = self.margin {
211            properties.push(("margin", margin));
212        }
213        if let Some(ref margin_bottom) = self.margin_bottom {
214            properties.push(("margin-bottom", margin_bottom));
215        }
216        if let Some(ref margin_end) = self.margin_end {
217            properties.push(("margin-end", margin_end));
218        }
219        if let Some(ref margin_start) = self.margin_start {
220            properties.push(("margin-start", margin_start));
221        }
222        if let Some(ref margin_top) = self.margin_top {
223            properties.push(("margin-top", margin_top));
224        }
225        if let Some(ref name) = self.name {
226            properties.push(("name", name));
227        }
228        if let Some(ref no_show_all) = self.no_show_all {
229            properties.push(("no-show-all", no_show_all));
230        }
231        if let Some(ref opacity) = self.opacity {
232            properties.push(("opacity", opacity));
233        }
234        if let Some(ref parent) = self.parent {
235            properties.push(("parent", parent));
236        }
237        if let Some(ref receives_default) = self.receives_default {
238            properties.push(("receives-default", receives_default));
239        }
240        if let Some(ref sensitive) = self.sensitive {
241            properties.push(("sensitive", sensitive));
242        }
243        if let Some(ref tooltip_markup) = self.tooltip_markup {
244            properties.push(("tooltip-markup", tooltip_markup));
245        }
246        if let Some(ref tooltip_text) = self.tooltip_text {
247            properties.push(("tooltip-text", tooltip_text));
248        }
249        if let Some(ref valign) = self.valign {
250            properties.push(("valign", valign));
251        }
252        if let Some(ref vexpand) = self.vexpand {
253            properties.push(("vexpand", vexpand));
254        }
255        if let Some(ref vexpand_set) = self.vexpand_set {
256            properties.push(("vexpand-set", vexpand_set));
257        }
258        if let Some(ref visible) = self.visible {
259            properties.push(("visible", visible));
260        }
261        if let Some(ref width_request) = self.width_request {
262            properties.push(("width-request", width_request));
263        }
264        glib::Object::new(Frame::static_type(), &properties)
265            .expect("object new")
266            .downcast()
267            .expect("downcast")
268    }
269
270    pub fn label(mut self, label: &str) -> Self {
271        self.label = Some(label.to_string());
272        self
273    }
274
275    pub fn label_widget(mut self, label_widget: &Widget) -> Self {
276        self.label_widget = Some(label_widget.clone());
277        self
278    }
279
280    pub fn label_xalign(mut self, label_xalign: f32) -> Self {
281        self.label_xalign = Some(label_xalign);
282        self
283    }
284
285    pub fn label_yalign(mut self, label_yalign: f32) -> Self {
286        self.label_yalign = Some(label_yalign);
287        self
288    }
289
290    pub fn shadow_type(mut self, shadow_type: ShadowType) -> Self {
291        self.shadow_type = Some(shadow_type);
292        self
293    }
294
295    pub fn border_width(mut self, border_width: u32) -> Self {
296        self.border_width = Some(border_width);
297        self
298    }
299
300    pub fn child(mut self, child: &Widget) -> Self {
301        self.child = Some(child.clone());
302        self
303    }
304
305    pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
306        self.resize_mode = Some(resize_mode);
307        self
308    }
309
310    pub fn app_paintable(mut self, app_paintable: bool) -> Self {
311        self.app_paintable = Some(app_paintable);
312        self
313    }
314
315    pub fn can_default(mut self, can_default: bool) -> Self {
316        self.can_default = Some(can_default);
317        self
318    }
319
320    pub fn can_focus(mut self, can_focus: bool) -> Self {
321        self.can_focus = Some(can_focus);
322        self
323    }
324
325    pub fn events(mut self, events: gdk::EventMask) -> Self {
326        self.events = Some(events);
327        self
328    }
329
330    pub fn expand(mut self, expand: bool) -> Self {
331        self.expand = Some(expand);
332        self
333    }
334
335    #[cfg(any(feature = "v3_20", feature = "dox"))]
336    pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
337        self.focus_on_click = Some(focus_on_click);
338        self
339    }
340
341    pub fn halign(mut self, halign: Align) -> Self {
342        self.halign = Some(halign);
343        self
344    }
345
346    pub fn has_default(mut self, has_default: bool) -> Self {
347        self.has_default = Some(has_default);
348        self
349    }
350
351    pub fn has_focus(mut self, has_focus: bool) -> Self {
352        self.has_focus = Some(has_focus);
353        self
354    }
355
356    pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
357        self.has_tooltip = Some(has_tooltip);
358        self
359    }
360
361    pub fn height_request(mut self, height_request: i32) -> Self {
362        self.height_request = Some(height_request);
363        self
364    }
365
366    pub fn hexpand(mut self, hexpand: bool) -> Self {
367        self.hexpand = Some(hexpand);
368        self
369    }
370
371    pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
372        self.hexpand_set = Some(hexpand_set);
373        self
374    }
375
376    pub fn is_focus(mut self, is_focus: bool) -> Self {
377        self.is_focus = Some(is_focus);
378        self
379    }
380
381    pub fn margin(mut self, margin: i32) -> Self {
382        self.margin = Some(margin);
383        self
384    }
385
386    pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
387        self.margin_bottom = Some(margin_bottom);
388        self
389    }
390
391    pub fn margin_end(mut self, margin_end: i32) -> Self {
392        self.margin_end = Some(margin_end);
393        self
394    }
395
396    pub fn margin_start(mut self, margin_start: i32) -> Self {
397        self.margin_start = Some(margin_start);
398        self
399    }
400
401    pub fn margin_top(mut self, margin_top: i32) -> Self {
402        self.margin_top = Some(margin_top);
403        self
404    }
405
406    pub fn name(mut self, name: &str) -> Self {
407        self.name = Some(name.to_string());
408        self
409    }
410
411    pub fn no_show_all(mut self, no_show_all: bool) -> Self {
412        self.no_show_all = Some(no_show_all);
413        self
414    }
415
416    pub fn opacity(mut self, opacity: f64) -> Self {
417        self.opacity = Some(opacity);
418        self
419    }
420
421    pub fn parent(mut self, parent: &Container) -> Self {
422        self.parent = Some(parent.clone());
423        self
424    }
425
426    pub fn receives_default(mut self, receives_default: bool) -> Self {
427        self.receives_default = Some(receives_default);
428        self
429    }
430
431    pub fn sensitive(mut self, sensitive: bool) -> Self {
432        self.sensitive = Some(sensitive);
433        self
434    }
435
436    pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
437        self.tooltip_markup = Some(tooltip_markup.to_string());
438        self
439    }
440
441    pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
442        self.tooltip_text = Some(tooltip_text.to_string());
443        self
444    }
445
446    pub fn valign(mut self, valign: Align) -> Self {
447        self.valign = Some(valign);
448        self
449    }
450
451    pub fn vexpand(mut self, vexpand: bool) -> Self {
452        self.vexpand = Some(vexpand);
453        self
454    }
455
456    pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
457        self.vexpand_set = Some(vexpand_set);
458        self
459    }
460
461    pub fn visible(mut self, visible: bool) -> Self {
462        self.visible = Some(visible);
463        self
464    }
465
466    pub fn width_request(mut self, width_request: i32) -> Self {
467        self.width_request = Some(width_request);
468        self
469    }
470}
471
472pub const NONE_FRAME: Option<&Frame> = None;
473
474pub trait FrameExt: 'static {
475    fn get_label(&self) -> Option<GString>;
476
477    fn get_label_align(&self) -> (f32, f32);
478
479    fn get_label_widget(&self) -> Option<Widget>;
480
481    fn get_shadow_type(&self) -> ShadowType;
482
483    fn set_label(&self, label: Option<&str>);
484
485    fn set_label_align(&self, xalign: f32, yalign: f32);
486
487    fn set_label_widget<P: IsA<Widget>>(&self, label_widget: Option<&P>);
488
489    fn set_shadow_type(&self, type_: ShadowType);
490
491    fn get_property_label_xalign(&self) -> f32;
492
493    fn set_property_label_xalign(&self, label_xalign: f32);
494
495    fn get_property_label_yalign(&self) -> f32;
496
497    fn set_property_label_yalign(&self, label_yalign: f32);
498
499    fn connect_property_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
500
501    fn connect_property_label_widget_notify<F: Fn(&Self) + 'static>(&self, f: F)
502        -> SignalHandlerId;
503
504    fn connect_property_label_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F)
505        -> SignalHandlerId;
506
507    fn connect_property_label_yalign_notify<F: Fn(&Self) + 'static>(&self, f: F)
508        -> SignalHandlerId;
509
510    fn connect_property_shadow_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
511}
512
513impl<O: IsA<Frame>> FrameExt for O {
514    fn get_label(&self) -> Option<GString> {
515        unsafe { from_glib_none(gtk_sys::gtk_frame_get_label(self.as_ref().to_glib_none().0)) }
516    }
517
518    fn get_label_align(&self) -> (f32, f32) {
519        unsafe {
520            let mut xalign = mem::uninitialized();
521            let mut yalign = mem::uninitialized();
522            gtk_sys::gtk_frame_get_label_align(
523                self.as_ref().to_glib_none().0,
524                &mut xalign,
525                &mut yalign,
526            );
527            (xalign, yalign)
528        }
529    }
530
531    fn get_label_widget(&self) -> Option<Widget> {
532        unsafe {
533            from_glib_none(gtk_sys::gtk_frame_get_label_widget(
534                self.as_ref().to_glib_none().0,
535            ))
536        }
537    }
538
539    fn get_shadow_type(&self) -> ShadowType {
540        unsafe {
541            from_glib(gtk_sys::gtk_frame_get_shadow_type(
542                self.as_ref().to_glib_none().0,
543            ))
544        }
545    }
546
547    fn set_label(&self, label: Option<&str>) {
548        unsafe {
549            gtk_sys::gtk_frame_set_label(self.as_ref().to_glib_none().0, label.to_glib_none().0);
550        }
551    }
552
553    fn set_label_align(&self, xalign: f32, yalign: f32) {
554        unsafe {
555            gtk_sys::gtk_frame_set_label_align(self.as_ref().to_glib_none().0, xalign, yalign);
556        }
557    }
558
559    fn set_label_widget<P: IsA<Widget>>(&self, label_widget: Option<&P>) {
560        unsafe {
561            gtk_sys::gtk_frame_set_label_widget(
562                self.as_ref().to_glib_none().0,
563                label_widget.map(|p| p.as_ref()).to_glib_none().0,
564            );
565        }
566    }
567
568    fn set_shadow_type(&self, type_: ShadowType) {
569        unsafe {
570            gtk_sys::gtk_frame_set_shadow_type(self.as_ref().to_glib_none().0, type_.to_glib());
571        }
572    }
573
574    fn get_property_label_xalign(&self) -> f32 {
575        unsafe {
576            let mut value = Value::from_type(<f32 as StaticType>::static_type());
577            gobject_sys::g_object_get_property(
578                self.to_glib_none().0 as *mut gobject_sys::GObject,
579                b"label-xalign\0".as_ptr() as *const _,
580                value.to_glib_none_mut().0,
581            );
582            value.get().unwrap()
583        }
584    }
585
586    fn set_property_label_xalign(&self, label_xalign: f32) {
587        unsafe {
588            gobject_sys::g_object_set_property(
589                self.to_glib_none().0 as *mut gobject_sys::GObject,
590                b"label-xalign\0".as_ptr() as *const _,
591                Value::from(&label_xalign).to_glib_none().0,
592            );
593        }
594    }
595
596    fn get_property_label_yalign(&self) -> f32 {
597        unsafe {
598            let mut value = Value::from_type(<f32 as StaticType>::static_type());
599            gobject_sys::g_object_get_property(
600                self.to_glib_none().0 as *mut gobject_sys::GObject,
601                b"label-yalign\0".as_ptr() as *const _,
602                value.to_glib_none_mut().0,
603            );
604            value.get().unwrap()
605        }
606    }
607
608    fn set_property_label_yalign(&self, label_yalign: f32) {
609        unsafe {
610            gobject_sys::g_object_set_property(
611                self.to_glib_none().0 as *mut gobject_sys::GObject,
612                b"label-yalign\0".as_ptr() as *const _,
613                Value::from(&label_yalign).to_glib_none().0,
614            );
615        }
616    }
617
618    fn connect_property_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
619        unsafe extern "C" fn notify_label_trampoline<P, F: Fn(&P) + 'static>(
620            this: *mut gtk_sys::GtkFrame,
621            _param_spec: glib_sys::gpointer,
622            f: glib_sys::gpointer,
623        ) where
624            P: IsA<Frame>,
625        {
626            let f: &F = &*(f as *const F);
627            f(&Frame::from_glib_borrow(this).unsafe_cast())
628        }
629        unsafe {
630            let f: Box_<F> = Box_::new(f);
631            connect_raw(
632                self.as_ptr() as *mut _,
633                b"notify::label\0".as_ptr() as *const _,
634                Some(transmute(notify_label_trampoline::<Self, F> as usize)),
635                Box_::into_raw(f),
636            )
637        }
638    }
639
640    fn connect_property_label_widget_notify<F: Fn(&Self) + 'static>(
641        &self,
642        f: F,
643    ) -> SignalHandlerId {
644        unsafe extern "C" fn notify_label_widget_trampoline<P, F: Fn(&P) + 'static>(
645            this: *mut gtk_sys::GtkFrame,
646            _param_spec: glib_sys::gpointer,
647            f: glib_sys::gpointer,
648        ) where
649            P: IsA<Frame>,
650        {
651            let f: &F = &*(f as *const F);
652            f(&Frame::from_glib_borrow(this).unsafe_cast())
653        }
654        unsafe {
655            let f: Box_<F> = Box_::new(f);
656            connect_raw(
657                self.as_ptr() as *mut _,
658                b"notify::label-widget\0".as_ptr() as *const _,
659                Some(transmute(
660                    notify_label_widget_trampoline::<Self, F> as usize,
661                )),
662                Box_::into_raw(f),
663            )
664        }
665    }
666
667    fn connect_property_label_xalign_notify<F: Fn(&Self) + 'static>(
668        &self,
669        f: F,
670    ) -> SignalHandlerId {
671        unsafe extern "C" fn notify_label_xalign_trampoline<P, F: Fn(&P) + 'static>(
672            this: *mut gtk_sys::GtkFrame,
673            _param_spec: glib_sys::gpointer,
674            f: glib_sys::gpointer,
675        ) where
676            P: IsA<Frame>,
677        {
678            let f: &F = &*(f as *const F);
679            f(&Frame::from_glib_borrow(this).unsafe_cast())
680        }
681        unsafe {
682            let f: Box_<F> = Box_::new(f);
683            connect_raw(
684                self.as_ptr() as *mut _,
685                b"notify::label-xalign\0".as_ptr() as *const _,
686                Some(transmute(
687                    notify_label_xalign_trampoline::<Self, F> as usize,
688                )),
689                Box_::into_raw(f),
690            )
691        }
692    }
693
694    fn connect_property_label_yalign_notify<F: Fn(&Self) + 'static>(
695        &self,
696        f: F,
697    ) -> SignalHandlerId {
698        unsafe extern "C" fn notify_label_yalign_trampoline<P, F: Fn(&P) + 'static>(
699            this: *mut gtk_sys::GtkFrame,
700            _param_spec: glib_sys::gpointer,
701            f: glib_sys::gpointer,
702        ) where
703            P: IsA<Frame>,
704        {
705            let f: &F = &*(f as *const F);
706            f(&Frame::from_glib_borrow(this).unsafe_cast())
707        }
708        unsafe {
709            let f: Box_<F> = Box_::new(f);
710            connect_raw(
711                self.as_ptr() as *mut _,
712                b"notify::label-yalign\0".as_ptr() as *const _,
713                Some(transmute(
714                    notify_label_yalign_trampoline::<Self, F> as usize,
715                )),
716                Box_::into_raw(f),
717            )
718        }
719    }
720
721    fn connect_property_shadow_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
722        unsafe extern "C" fn notify_shadow_type_trampoline<P, F: Fn(&P) + 'static>(
723            this: *mut gtk_sys::GtkFrame,
724            _param_spec: glib_sys::gpointer,
725            f: glib_sys::gpointer,
726        ) where
727            P: IsA<Frame>,
728        {
729            let f: &F = &*(f as *const F);
730            f(&Frame::from_glib_borrow(this).unsafe_cast())
731        }
732        unsafe {
733            let f: Box_<F> = Box_::new(f);
734            connect_raw(
735                self.as_ptr() as *mut _,
736                b"notify::shadow-type\0".as_ptr() as *const _,
737                Some(transmute(notify_shadow_type_trampoline::<Self, F> as usize)),
738                Box_::into_raw(f),
739            )
740        }
741    }
742}
743
744impl fmt::Display for Frame {
745    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
746        write!(f, "Frame")
747    }
748}