libhelium/auto/
tab.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{ffi, Bin};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "HeTab")]
16    pub struct Tab(Object<ffi::HeTab, ffi::HeTabClass>) @extends Bin, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
17
18    match fn {
19        type_ => || ffi::he_tab_get_type(),
20    }
21}
22
23impl Tab {
24    pub const NONE: Option<&'static Tab> = None;
25
26    #[doc(alias = "he_tab_new")]
27    pub fn new(label: Option<&str>, page: Option<&impl IsA<gtk::Widget>>) -> Tab {
28        assert_initialized_main_thread!();
29        unsafe {
30            from_glib_none(ffi::he_tab_new(
31                label.to_glib_none().0,
32                page.map(|p| p.as_ref()).to_glib_none().0,
33            ))
34        }
35    }
36
37    // rustdoc-stripper-ignore-next
38    /// Creates a new builder-pattern struct instance to construct [`Tab`] objects.
39    ///
40    /// This method returns an instance of [`TabBuilder`](crate::builders::TabBuilder) which can be used to create [`Tab`] objects.
41    pub fn builder() -> TabBuilder {
42        TabBuilder::new()
43    }
44}
45
46impl Default for Tab {
47    fn default() -> Self {
48        glib::object::Object::new::<Self>()
49    }
50}
51
52// rustdoc-stripper-ignore-next
53/// A [builder-pattern] type to construct [`Tab`] objects.
54///
55/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
56#[must_use = "The builder must be built to be used"]
57pub struct TabBuilder {
58    builder: glib::object::ObjectBuilder<'static, Tab>,
59}
60
61impl TabBuilder {
62    fn new() -> Self {
63        Self {
64            builder: glib::object::Object::builder(),
65        }
66    }
67
68    pub fn label(self, label: impl Into<glib::GString>) -> Self {
69        Self {
70            builder: self.builder.property("label", label.into()),
71        }
72    }
73
74    pub fn tooltip(self, tooltip: impl Into<glib::GString>) -> Self {
75        Self {
76            builder: self.builder.property("tooltip", tooltip.into()),
77        }
78    }
79
80    pub fn pinned(self, pinned: bool) -> Self {
81        Self {
82            builder: self.builder.property("pinned", pinned),
83        }
84    }
85
86    pub fn can_pin(self, can_pin: bool) -> Self {
87        Self {
88            builder: self.builder.property("can-pin", can_pin),
89        }
90    }
91
92    pub fn can_close(self, can_close: bool) -> Self {
93        Self {
94            builder: self.builder.property("can-close", can_close),
95        }
96    }
97
98    pub fn page(self, page: &impl IsA<gtk::Widget>) -> Self {
99        Self {
100            builder: self.builder.property("page", page.clone().upcast()),
101        }
102    }
103
104    pub fn menu(self, menu: &gio::Menu) -> Self {
105        Self {
106            builder: self.builder.property("menu", menu.clone()),
107        }
108    }
109
110    pub fn actions(self, actions: &impl IsA<gio::SimpleActionGroup>) -> Self {
111        Self {
112            builder: self.builder.property("actions", actions.clone().upcast()),
113        }
114    }
115
116    pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
117        Self {
118            builder: self.builder.property("child", child.clone().upcast()),
119        }
120    }
121
122    pub fn can_focus(self, can_focus: bool) -> Self {
123        Self {
124            builder: self.builder.property("can-focus", can_focus),
125        }
126    }
127
128    pub fn can_target(self, can_target: bool) -> Self {
129        Self {
130            builder: self.builder.property("can-target", can_target),
131        }
132    }
133
134    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
135        Self {
136            builder: self.builder.property("css-classes", css_classes.into()),
137        }
138    }
139
140    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
141        Self {
142            builder: self.builder.property("css-name", css_name.into()),
143        }
144    }
145
146    //pub fn cursor(self, cursor: /*Ignored*/&gdk::Cursor) -> Self {
147    //    Self { builder: self.builder.property("cursor", cursor), }
148    //}
149
150    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
151        Self {
152            builder: self.builder.property("focus-on-click", focus_on_click),
153        }
154    }
155
156    pub fn focusable(self, focusable: bool) -> Self {
157        Self {
158            builder: self.builder.property("focusable", focusable),
159        }
160    }
161
162    pub fn halign(self, halign: gtk::Align) -> Self {
163        Self {
164            builder: self.builder.property("halign", halign),
165        }
166    }
167
168    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
169        Self {
170            builder: self.builder.property("has-tooltip", has_tooltip),
171        }
172    }
173
174    pub fn height_request(self, height_request: i32) -> Self {
175        Self {
176            builder: self.builder.property("height-request", height_request),
177        }
178    }
179
180    pub fn hexpand(self, hexpand: bool) -> Self {
181        Self {
182            builder: self.builder.property("hexpand", hexpand),
183        }
184    }
185
186    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
187        Self {
188            builder: self.builder.property("hexpand-set", hexpand_set),
189        }
190    }
191
192    //pub fn layout_manager(self, layout_manager: &impl IsA</*Ignored*/gtk::LayoutManager>) -> Self {
193    //    Self { builder: self.builder.property("layout-manager", layout_manager.clone().upcast()), }
194    //}
195
196    #[cfg(feature = "gtk_v4_18")]
197    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
198    pub fn limit_events(self, limit_events: bool) -> Self {
199        Self {
200            builder: self.builder.property("limit-events", limit_events),
201        }
202    }
203
204    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
205        Self {
206            builder: self.builder.property("margin-bottom", margin_bottom),
207        }
208    }
209
210    pub fn margin_end(self, margin_end: i32) -> Self {
211        Self {
212            builder: self.builder.property("margin-end", margin_end),
213        }
214    }
215
216    pub fn margin_start(self, margin_start: i32) -> Self {
217        Self {
218            builder: self.builder.property("margin-start", margin_start),
219        }
220    }
221
222    pub fn margin_top(self, margin_top: i32) -> Self {
223        Self {
224            builder: self.builder.property("margin-top", margin_top),
225        }
226    }
227
228    pub fn name(self, name: impl Into<glib::GString>) -> Self {
229        Self {
230            builder: self.builder.property("name", name.into()),
231        }
232    }
233
234    pub fn opacity(self, opacity: f64) -> Self {
235        Self {
236            builder: self.builder.property("opacity", opacity),
237        }
238    }
239
240    //pub fn overflow(self, overflow: /*Ignored*/gtk::Overflow) -> Self {
241    //    Self { builder: self.builder.property("overflow", overflow), }
242    //}
243
244    pub fn receives_default(self, receives_default: bool) -> Self {
245        Self {
246            builder: self.builder.property("receives-default", receives_default),
247        }
248    }
249
250    pub fn sensitive(self, sensitive: bool) -> Self {
251        Self {
252            builder: self.builder.property("sensitive", sensitive),
253        }
254    }
255
256    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
257        Self {
258            builder: self
259                .builder
260                .property("tooltip-markup", tooltip_markup.into()),
261        }
262    }
263
264    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
265        Self {
266            builder: self.builder.property("tooltip-text", tooltip_text.into()),
267        }
268    }
269
270    pub fn valign(self, valign: gtk::Align) -> Self {
271        Self {
272            builder: self.builder.property("valign", valign),
273        }
274    }
275
276    pub fn vexpand(self, vexpand: bool) -> Self {
277        Self {
278            builder: self.builder.property("vexpand", vexpand),
279        }
280    }
281
282    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
283        Self {
284            builder: self.builder.property("vexpand-set", vexpand_set),
285        }
286    }
287
288    pub fn visible(self, visible: bool) -> Self {
289        Self {
290            builder: self.builder.property("visible", visible),
291        }
292    }
293
294    pub fn width_request(self, width_request: i32) -> Self {
295        Self {
296            builder: self.builder.property("width-request", width_request),
297        }
298    }
299
300    //pub fn accessible_role(self, accessible_role: /*Ignored*/gtk::AccessibleRole) -> Self {
301    //    Self { builder: self.builder.property("accessible-role", accessible_role), }
302    //}
303
304    // rustdoc-stripper-ignore-next
305    /// Build the [`Tab`].
306    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
307    pub fn build(self) -> Tab {
308        assert_initialized_main_thread!();
309        self.builder.build()
310    }
311}
312
313pub trait TabExt: IsA<Tab> + 'static {
314    #[doc(alias = "he_tab_get_label")]
315    #[doc(alias = "get_label")]
316    fn label(&self) -> glib::GString {
317        unsafe { from_glib_none(ffi::he_tab_get_label(self.as_ref().to_glib_none().0)) }
318    }
319
320    #[doc(alias = "he_tab_set_label")]
321    fn set_label(&self, value: &str) {
322        unsafe {
323            ffi::he_tab_set_label(self.as_ref().to_glib_none().0, value.to_glib_none().0);
324        }
325    }
326
327    #[doc(alias = "he_tab_set_tooltip")]
328    fn set_tooltip(&self, value: &str) {
329        unsafe {
330            ffi::he_tab_set_tooltip(self.as_ref().to_glib_none().0, value.to_glib_none().0);
331        }
332    }
333
334    #[doc(alias = "he_tab_get_pinned")]
335    #[doc(alias = "get_pinned")]
336    fn is_pinned(&self) -> bool {
337        unsafe { from_glib(ffi::he_tab_get_pinned(self.as_ref().to_glib_none().0)) }
338    }
339
340    #[doc(alias = "he_tab_set_pinned")]
341    fn set_pinned(&self, value: bool) {
342        unsafe {
343            ffi::he_tab_set_pinned(self.as_ref().to_glib_none().0, value.into_glib());
344        }
345    }
346
347    #[doc(alias = "he_tab_get_can_pin")]
348    #[doc(alias = "get_can_pin")]
349    fn can_pin(&self) -> bool {
350        unsafe { from_glib(ffi::he_tab_get_can_pin(self.as_ref().to_glib_none().0)) }
351    }
352
353    #[doc(alias = "he_tab_set_can_pin")]
354    fn set_can_pin(&self, value: bool) {
355        unsafe {
356            ffi::he_tab_set_can_pin(self.as_ref().to_glib_none().0, value.into_glib());
357        }
358    }
359
360    #[doc(alias = "he_tab_get_can_close")]
361    #[doc(alias = "get_can_close")]
362    fn can_close(&self) -> bool {
363        unsafe { from_glib(ffi::he_tab_get_can_close(self.as_ref().to_glib_none().0)) }
364    }
365
366    #[doc(alias = "he_tab_set_can_close")]
367    fn set_can_close(&self, value: bool) {
368        unsafe {
369            ffi::he_tab_set_can_close(self.as_ref().to_glib_none().0, value.into_glib());
370        }
371    }
372
373    #[doc(alias = "he_tab_get_page")]
374    #[doc(alias = "get_page")]
375    fn page(&self) -> gtk::Widget {
376        unsafe { from_glib_none(ffi::he_tab_get_page(self.as_ref().to_glib_none().0)) }
377    }
378
379    #[doc(alias = "he_tab_set_page")]
380    fn set_page(&self, value: &impl IsA<gtk::Widget>) {
381        unsafe {
382            ffi::he_tab_set_page(
383                self.as_ref().to_glib_none().0,
384                value.as_ref().to_glib_none().0,
385            );
386        }
387    }
388
389    #[doc(alias = "he_tab_get_menu")]
390    #[doc(alias = "get_menu")]
391    fn menu(&self) -> gio::Menu {
392        unsafe { from_glib_none(ffi::he_tab_get_menu(self.as_ref().to_glib_none().0)) }
393    }
394
395    #[doc(alias = "he_tab_get_actions")]
396    #[doc(alias = "get_actions")]
397    fn actions(&self) -> gio::SimpleActionGroup {
398        unsafe { from_glib_none(ffi::he_tab_get_actions(self.as_ref().to_glib_none().0)) }
399    }
400
401    fn set_menu(&self, menu: Option<&gio::Menu>) {
402        ObjectExt::set_property(self.as_ref(), "menu", menu)
403    }
404
405    #[doc(alias = "label")]
406    fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
407        unsafe extern "C" fn notify_label_trampoline<P: IsA<Tab>, F: Fn(&P) + 'static>(
408            this: *mut ffi::HeTab,
409            _param_spec: glib::ffi::gpointer,
410            f: glib::ffi::gpointer,
411        ) {
412            let f: &F = &*(f as *const F);
413            f(Tab::from_glib_borrow(this).unsafe_cast_ref())
414        }
415        unsafe {
416            let f: Box_<F> = Box_::new(f);
417            connect_raw(
418                self.as_ptr() as *mut _,
419                c"notify::label".as_ptr() as *const _,
420                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
421                    notify_label_trampoline::<Self, F> as *const (),
422                )),
423                Box_::into_raw(f),
424            )
425        }
426    }
427
428    #[doc(alias = "tooltip")]
429    fn connect_tooltip_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
430        unsafe extern "C" fn notify_tooltip_trampoline<P: IsA<Tab>, F: Fn(&P) + 'static>(
431            this: *mut ffi::HeTab,
432            _param_spec: glib::ffi::gpointer,
433            f: glib::ffi::gpointer,
434        ) {
435            let f: &F = &*(f as *const F);
436            f(Tab::from_glib_borrow(this).unsafe_cast_ref())
437        }
438        unsafe {
439            let f: Box_<F> = Box_::new(f);
440            connect_raw(
441                self.as_ptr() as *mut _,
442                c"notify::tooltip".as_ptr() as *const _,
443                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
444                    notify_tooltip_trampoline::<Self, F> as *const (),
445                )),
446                Box_::into_raw(f),
447            )
448        }
449    }
450
451    #[doc(alias = "pinned")]
452    fn connect_pinned_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
453        unsafe extern "C" fn notify_pinned_trampoline<P: IsA<Tab>, F: Fn(&P) + 'static>(
454            this: *mut ffi::HeTab,
455            _param_spec: glib::ffi::gpointer,
456            f: glib::ffi::gpointer,
457        ) {
458            let f: &F = &*(f as *const F);
459            f(Tab::from_glib_borrow(this).unsafe_cast_ref())
460        }
461        unsafe {
462            let f: Box_<F> = Box_::new(f);
463            connect_raw(
464                self.as_ptr() as *mut _,
465                c"notify::pinned".as_ptr() as *const _,
466                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
467                    notify_pinned_trampoline::<Self, F> as *const (),
468                )),
469                Box_::into_raw(f),
470            )
471        }
472    }
473
474    #[doc(alias = "can-pin")]
475    fn connect_can_pin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
476        unsafe extern "C" fn notify_can_pin_trampoline<P: IsA<Tab>, F: Fn(&P) + 'static>(
477            this: *mut ffi::HeTab,
478            _param_spec: glib::ffi::gpointer,
479            f: glib::ffi::gpointer,
480        ) {
481            let f: &F = &*(f as *const F);
482            f(Tab::from_glib_borrow(this).unsafe_cast_ref())
483        }
484        unsafe {
485            let f: Box_<F> = Box_::new(f);
486            connect_raw(
487                self.as_ptr() as *mut _,
488                c"notify::can-pin".as_ptr() as *const _,
489                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
490                    notify_can_pin_trampoline::<Self, F> as *const (),
491                )),
492                Box_::into_raw(f),
493            )
494        }
495    }
496
497    #[doc(alias = "can-close")]
498    fn connect_can_close_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
499        unsafe extern "C" fn notify_can_close_trampoline<P: IsA<Tab>, F: Fn(&P) + 'static>(
500            this: *mut ffi::HeTab,
501            _param_spec: glib::ffi::gpointer,
502            f: glib::ffi::gpointer,
503        ) {
504            let f: &F = &*(f as *const F);
505            f(Tab::from_glib_borrow(this).unsafe_cast_ref())
506        }
507        unsafe {
508            let f: Box_<F> = Box_::new(f);
509            connect_raw(
510                self.as_ptr() as *mut _,
511                c"notify::can-close".as_ptr() as *const _,
512                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
513                    notify_can_close_trampoline::<Self, F> as *const (),
514                )),
515                Box_::into_raw(f),
516            )
517        }
518    }
519
520    #[doc(alias = "page")]
521    fn connect_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
522        unsafe extern "C" fn notify_page_trampoline<P: IsA<Tab>, F: Fn(&P) + 'static>(
523            this: *mut ffi::HeTab,
524            _param_spec: glib::ffi::gpointer,
525            f: glib::ffi::gpointer,
526        ) {
527            let f: &F = &*(f as *const F);
528            f(Tab::from_glib_borrow(this).unsafe_cast_ref())
529        }
530        unsafe {
531            let f: Box_<F> = Box_::new(f);
532            connect_raw(
533                self.as_ptr() as *mut _,
534                c"notify::page".as_ptr() as *const _,
535                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
536                    notify_page_trampoline::<Self, F> as *const (),
537                )),
538                Box_::into_raw(f),
539            )
540        }
541    }
542
543    #[doc(alias = "menu")]
544    fn connect_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
545        unsafe extern "C" fn notify_menu_trampoline<P: IsA<Tab>, F: Fn(&P) + 'static>(
546            this: *mut ffi::HeTab,
547            _param_spec: glib::ffi::gpointer,
548            f: glib::ffi::gpointer,
549        ) {
550            let f: &F = &*(f as *const F);
551            f(Tab::from_glib_borrow(this).unsafe_cast_ref())
552        }
553        unsafe {
554            let f: Box_<F> = Box_::new(f);
555            connect_raw(
556                self.as_ptr() as *mut _,
557                c"notify::menu".as_ptr() as *const _,
558                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
559                    notify_menu_trampoline::<Self, F> as *const (),
560                )),
561                Box_::into_raw(f),
562            )
563        }
564    }
565}
566
567impl<O: IsA<Tab>> TabExt for O {}