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