libhelium/auto/
content_list.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 = "HeContentList")]
16    pub struct ContentList(Object<ffi::HeContentList, ffi::HeContentListClass>) @extends Bin, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
17
18    match fn {
19        type_ => || ffi::he_content_list_get_type(),
20    }
21}
22
23impl ContentList {
24    pub const NONE: Option<&'static ContentList> = None;
25
26    #[doc(alias = "he_content_list_new")]
27    pub fn new() -> ContentList {
28        assert_initialized_main_thread!();
29        unsafe { from_glib_none(ffi::he_content_list_new()) }
30    }
31
32    // rustdoc-stripper-ignore-next
33    /// Creates a new builder-pattern struct instance to construct [`ContentList`] objects.
34    ///
35    /// This method returns an instance of [`ContentListBuilder`](crate::builders::ContentListBuilder) which can be used to create [`ContentList`] objects.
36    pub fn builder() -> ContentListBuilder {
37        ContentListBuilder::new()
38    }
39}
40
41impl Default for ContentList {
42    fn default() -> Self {
43        Self::new()
44    }
45}
46
47// rustdoc-stripper-ignore-next
48/// A [builder-pattern] type to construct [`ContentList`] objects.
49///
50/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
51#[must_use = "The builder must be built to be used"]
52pub struct ContentListBuilder {
53    builder: glib::object::ObjectBuilder<'static, ContentList>,
54}
55
56impl ContentListBuilder {
57    fn new() -> Self {
58        Self {
59            builder: glib::object::Object::builder(),
60        }
61    }
62
63    pub fn title(self, title: impl Into<glib::GString>) -> Self {
64        Self {
65            builder: self.builder.property("title", title.into()),
66        }
67    }
68
69    pub fn description(self, description: impl Into<glib::GString>) -> Self {
70        Self {
71            builder: self.builder.property("description", description.into()),
72        }
73    }
74
75    pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
76        Self {
77            builder: self.builder.property("child", child.clone().upcast()),
78        }
79    }
80
81    pub fn can_focus(self, can_focus: bool) -> Self {
82        Self {
83            builder: self.builder.property("can-focus", can_focus),
84        }
85    }
86
87    pub fn can_target(self, can_target: bool) -> Self {
88        Self {
89            builder: self.builder.property("can-target", can_target),
90        }
91    }
92
93    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
94        Self {
95            builder: self.builder.property("css-classes", css_classes.into()),
96        }
97    }
98
99    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
100        Self {
101            builder: self.builder.property("css-name", css_name.into()),
102        }
103    }
104
105    //pub fn cursor(self, cursor: /*Ignored*/&gdk::Cursor) -> Self {
106    //    Self { builder: self.builder.property("cursor", cursor), }
107    //}
108
109    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
110        Self {
111            builder: self.builder.property("focus-on-click", focus_on_click),
112        }
113    }
114
115    pub fn focusable(self, focusable: bool) -> Self {
116        Self {
117            builder: self.builder.property("focusable", focusable),
118        }
119    }
120
121    pub fn halign(self, halign: gtk::Align) -> Self {
122        Self {
123            builder: self.builder.property("halign", halign),
124        }
125    }
126
127    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
128        Self {
129            builder: self.builder.property("has-tooltip", has_tooltip),
130        }
131    }
132
133    pub fn height_request(self, height_request: i32) -> Self {
134        Self {
135            builder: self.builder.property("height-request", height_request),
136        }
137    }
138
139    pub fn hexpand(self, hexpand: bool) -> Self {
140        Self {
141            builder: self.builder.property("hexpand", hexpand),
142        }
143    }
144
145    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
146        Self {
147            builder: self.builder.property("hexpand-set", hexpand_set),
148        }
149    }
150
151    //pub fn layout_manager(self, layout_manager: &impl IsA</*Ignored*/gtk::LayoutManager>) -> Self {
152    //    Self { builder: self.builder.property("layout-manager", layout_manager.clone().upcast()), }
153    //}
154
155    #[cfg(feature = "gtk_v4_18")]
156    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
157    pub fn limit_events(self, limit_events: bool) -> Self {
158        Self {
159            builder: self.builder.property("limit-events", limit_events),
160        }
161    }
162
163    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
164        Self {
165            builder: self.builder.property("margin-bottom", margin_bottom),
166        }
167    }
168
169    pub fn margin_end(self, margin_end: i32) -> Self {
170        Self {
171            builder: self.builder.property("margin-end", margin_end),
172        }
173    }
174
175    pub fn margin_start(self, margin_start: i32) -> Self {
176        Self {
177            builder: self.builder.property("margin-start", margin_start),
178        }
179    }
180
181    pub fn margin_top(self, margin_top: i32) -> Self {
182        Self {
183            builder: self.builder.property("margin-top", margin_top),
184        }
185    }
186
187    pub fn name(self, name: impl Into<glib::GString>) -> Self {
188        Self {
189            builder: self.builder.property("name", name.into()),
190        }
191    }
192
193    pub fn opacity(self, opacity: f64) -> Self {
194        Self {
195            builder: self.builder.property("opacity", opacity),
196        }
197    }
198
199    //pub fn overflow(self, overflow: /*Ignored*/gtk::Overflow) -> Self {
200    //    Self { builder: self.builder.property("overflow", overflow), }
201    //}
202
203    pub fn receives_default(self, receives_default: bool) -> Self {
204        Self {
205            builder: self.builder.property("receives-default", receives_default),
206        }
207    }
208
209    pub fn sensitive(self, sensitive: bool) -> Self {
210        Self {
211            builder: self.builder.property("sensitive", sensitive),
212        }
213    }
214
215    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
216        Self {
217            builder: self
218                .builder
219                .property("tooltip-markup", tooltip_markup.into()),
220        }
221    }
222
223    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
224        Self {
225            builder: self.builder.property("tooltip-text", tooltip_text.into()),
226        }
227    }
228
229    pub fn valign(self, valign: gtk::Align) -> Self {
230        Self {
231            builder: self.builder.property("valign", valign),
232        }
233    }
234
235    pub fn vexpand(self, vexpand: bool) -> Self {
236        Self {
237            builder: self.builder.property("vexpand", vexpand),
238        }
239    }
240
241    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
242        Self {
243            builder: self.builder.property("vexpand-set", vexpand_set),
244        }
245    }
246
247    pub fn visible(self, visible: bool) -> Self {
248        Self {
249            builder: self.builder.property("visible", visible),
250        }
251    }
252
253    pub fn width_request(self, width_request: i32) -> Self {
254        Self {
255            builder: self.builder.property("width-request", width_request),
256        }
257    }
258
259    //pub fn accessible_role(self, accessible_role: /*Ignored*/gtk::AccessibleRole) -> Self {
260    //    Self { builder: self.builder.property("accessible-role", accessible_role), }
261    //}
262
263    // rustdoc-stripper-ignore-next
264    /// Build the [`ContentList`].
265    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
266    pub fn build(self) -> ContentList {
267        assert_initialized_main_thread!();
268        self.builder.build()
269    }
270}
271
272pub trait ContentListExt: IsA<ContentList> + 'static {
273    #[doc(alias = "he_content_list_add")]
274    fn add(&self, child: &impl IsA<gtk::Widget>) {
275        unsafe {
276            ffi::he_content_list_add(
277                self.as_ref().to_glib_none().0,
278                child.as_ref().to_glib_none().0,
279            );
280        }
281    }
282
283    #[doc(alias = "he_content_list_remove")]
284    fn remove(&self, child: &impl IsA<gtk::Widget>) {
285        unsafe {
286            ffi::he_content_list_remove(
287                self.as_ref().to_glib_none().0,
288                child.as_ref().to_glib_none().0,
289            );
290        }
291    }
292
293    #[doc(alias = "he_content_list_get_title")]
294    #[doc(alias = "get_title")]
295    fn title(&self) -> Option<glib::GString> {
296        unsafe {
297            from_glib_none(ffi::he_content_list_get_title(
298                self.as_ref().to_glib_none().0,
299            ))
300        }
301    }
302
303    #[doc(alias = "he_content_list_set_title")]
304    fn set_title(&self, value: Option<&str>) {
305        unsafe {
306            ffi::he_content_list_set_title(self.as_ref().to_glib_none().0, value.to_glib_none().0);
307        }
308    }
309
310    #[doc(alias = "he_content_list_get_description")]
311    #[doc(alias = "get_description")]
312    fn description(&self) -> Option<glib::GString> {
313        unsafe {
314            from_glib_none(ffi::he_content_list_get_description(
315                self.as_ref().to_glib_none().0,
316            ))
317        }
318    }
319
320    #[doc(alias = "he_content_list_set_description")]
321    fn set_description(&self, value: Option<&str>) {
322        unsafe {
323            ffi::he_content_list_set_description(
324                self.as_ref().to_glib_none().0,
325                value.to_glib_none().0,
326            );
327        }
328    }
329
330    #[doc(alias = "title")]
331    fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
332        unsafe extern "C" fn notify_title_trampoline<P: IsA<ContentList>, F: Fn(&P) + 'static>(
333            this: *mut ffi::HeContentList,
334            _param_spec: glib::ffi::gpointer,
335            f: glib::ffi::gpointer,
336        ) {
337            let f: &F = &*(f as *const F);
338            f(ContentList::from_glib_borrow(this).unsafe_cast_ref())
339        }
340        unsafe {
341            let f: Box_<F> = Box_::new(f);
342            connect_raw(
343                self.as_ptr() as *mut _,
344                c"notify::title".as_ptr() as *const _,
345                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
346                    notify_title_trampoline::<Self, F> as *const (),
347                )),
348                Box_::into_raw(f),
349            )
350        }
351    }
352
353    #[doc(alias = "description")]
354    fn connect_description_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
355        unsafe extern "C" fn notify_description_trampoline<
356            P: IsA<ContentList>,
357            F: Fn(&P) + 'static,
358        >(
359            this: *mut ffi::HeContentList,
360            _param_spec: glib::ffi::gpointer,
361            f: glib::ffi::gpointer,
362        ) {
363            let f: &F = &*(f as *const F);
364            f(ContentList::from_glib_borrow(this).unsafe_cast_ref())
365        }
366        unsafe {
367            let f: Box_<F> = Box_::new(f);
368            connect_raw(
369                self.as_ptr() as *mut _,
370                c"notify::description".as_ptr() as *const _,
371                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
372                    notify_description_trampoline::<Self, F> as *const (),
373                )),
374                Box_::into_raw(f),
375            )
376        }
377    }
378}
379
380impl<O: IsA<ContentList>> ContentListExt for O {}