gtk4/auto/
app_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#![allow(deprecated)]
5
6use crate::{
7    ffi, Accessible, AccessibleRole, Align, AppChooser, Buildable, ConstraintTarget, LayoutManager,
8    Overflow, Widget,
9};
10use glib::{
11    object::ObjectType as _,
12    prelude::*,
13    signal::{connect_raw, SignalHandlerId},
14    translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19    #[doc(alias = "GtkAppChooserWidget")]
20    pub struct AppChooserWidget(Object<ffi::GtkAppChooserWidget>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AppChooser;
21
22    match fn {
23        type_ => || ffi::gtk_app_chooser_widget_get_type(),
24    }
25}
26
27impl AppChooserWidget {
28    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
29    #[allow(deprecated)]
30    #[doc(alias = "gtk_app_chooser_widget_new")]
31    pub fn new(content_type: &str) -> AppChooserWidget {
32        assert_initialized_main_thread!();
33        unsafe {
34            Widget::from_glib_none(ffi::gtk_app_chooser_widget_new(
35                content_type.to_glib_none().0,
36            ))
37            .unsafe_cast()
38        }
39    }
40
41    // rustdoc-stripper-ignore-next
42    /// Creates a new builder-pattern struct instance to construct [`AppChooserWidget`] objects.
43    ///
44    /// This method returns an instance of [`AppChooserWidgetBuilder`](crate::builders::AppChooserWidgetBuilder) which can be used to create [`AppChooserWidget`] objects.
45    pub fn builder() -> AppChooserWidgetBuilder {
46        AppChooserWidgetBuilder::new()
47    }
48
49    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
50    #[allow(deprecated)]
51    #[doc(alias = "gtk_app_chooser_widget_get_default_text")]
52    #[doc(alias = "get_default_text")]
53    #[doc(alias = "default-text")]
54    pub fn default_text(&self) -> Option<glib::GString> {
55        unsafe {
56            from_glib_none(ffi::gtk_app_chooser_widget_get_default_text(
57                self.to_glib_none().0,
58            ))
59        }
60    }
61
62    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
63    #[allow(deprecated)]
64    #[doc(alias = "gtk_app_chooser_widget_get_show_all")]
65    #[doc(alias = "get_show_all")]
66    #[doc(alias = "show-all")]
67    pub fn shows_all(&self) -> bool {
68        unsafe {
69            from_glib(ffi::gtk_app_chooser_widget_get_show_all(
70                self.to_glib_none().0,
71            ))
72        }
73    }
74
75    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
76    #[allow(deprecated)]
77    #[doc(alias = "gtk_app_chooser_widget_get_show_default")]
78    #[doc(alias = "get_show_default")]
79    #[doc(alias = "show-default")]
80    pub fn shows_default(&self) -> bool {
81        unsafe {
82            from_glib(ffi::gtk_app_chooser_widget_get_show_default(
83                self.to_glib_none().0,
84            ))
85        }
86    }
87
88    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
89    #[allow(deprecated)]
90    #[doc(alias = "gtk_app_chooser_widget_get_show_fallback")]
91    #[doc(alias = "get_show_fallback")]
92    #[doc(alias = "show-fallback")]
93    pub fn shows_fallback(&self) -> bool {
94        unsafe {
95            from_glib(ffi::gtk_app_chooser_widget_get_show_fallback(
96                self.to_glib_none().0,
97            ))
98        }
99    }
100
101    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
102    #[allow(deprecated)]
103    #[doc(alias = "gtk_app_chooser_widget_get_show_other")]
104    #[doc(alias = "get_show_other")]
105    #[doc(alias = "show-other")]
106    pub fn shows_other(&self) -> bool {
107        unsafe {
108            from_glib(ffi::gtk_app_chooser_widget_get_show_other(
109                self.to_glib_none().0,
110            ))
111        }
112    }
113
114    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
115    #[allow(deprecated)]
116    #[doc(alias = "gtk_app_chooser_widget_get_show_recommended")]
117    #[doc(alias = "get_show_recommended")]
118    #[doc(alias = "show-recommended")]
119    pub fn shows_recommended(&self) -> bool {
120        unsafe {
121            from_glib(ffi::gtk_app_chooser_widget_get_show_recommended(
122                self.to_glib_none().0,
123            ))
124        }
125    }
126
127    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
128    #[allow(deprecated)]
129    #[doc(alias = "gtk_app_chooser_widget_set_default_text")]
130    #[doc(alias = "default-text")]
131    pub fn set_default_text(&self, text: &str) {
132        unsafe {
133            ffi::gtk_app_chooser_widget_set_default_text(
134                self.to_glib_none().0,
135                text.to_glib_none().0,
136            );
137        }
138    }
139
140    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
141    #[allow(deprecated)]
142    #[doc(alias = "gtk_app_chooser_widget_set_show_all")]
143    #[doc(alias = "show-all")]
144    pub fn set_show_all(&self, setting: bool) {
145        unsafe {
146            ffi::gtk_app_chooser_widget_set_show_all(self.to_glib_none().0, setting.into_glib());
147        }
148    }
149
150    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
151    #[allow(deprecated)]
152    #[doc(alias = "gtk_app_chooser_widget_set_show_default")]
153    #[doc(alias = "show-default")]
154    pub fn set_show_default(&self, setting: bool) {
155        unsafe {
156            ffi::gtk_app_chooser_widget_set_show_default(
157                self.to_glib_none().0,
158                setting.into_glib(),
159            );
160        }
161    }
162
163    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
164    #[allow(deprecated)]
165    #[doc(alias = "gtk_app_chooser_widget_set_show_fallback")]
166    #[doc(alias = "show-fallback")]
167    pub fn set_show_fallback(&self, setting: bool) {
168        unsafe {
169            ffi::gtk_app_chooser_widget_set_show_fallback(
170                self.to_glib_none().0,
171                setting.into_glib(),
172            );
173        }
174    }
175
176    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
177    #[allow(deprecated)]
178    #[doc(alias = "gtk_app_chooser_widget_set_show_other")]
179    #[doc(alias = "show-other")]
180    pub fn set_show_other(&self, setting: bool) {
181        unsafe {
182            ffi::gtk_app_chooser_widget_set_show_other(self.to_glib_none().0, setting.into_glib());
183        }
184    }
185
186    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
187    #[allow(deprecated)]
188    #[doc(alias = "gtk_app_chooser_widget_set_show_recommended")]
189    #[doc(alias = "show-recommended")]
190    pub fn set_show_recommended(&self, setting: bool) {
191        unsafe {
192            ffi::gtk_app_chooser_widget_set_show_recommended(
193                self.to_glib_none().0,
194                setting.into_glib(),
195            );
196        }
197    }
198
199    #[doc(alias = "application-activated")]
200    pub fn connect_application_activated<F: Fn(&Self, &gio::AppInfo) + 'static>(
201        &self,
202        f: F,
203    ) -> SignalHandlerId {
204        unsafe extern "C" fn application_activated_trampoline<
205            F: Fn(&AppChooserWidget, &gio::AppInfo) + 'static,
206        >(
207            this: *mut ffi::GtkAppChooserWidget,
208            application: *mut gio::ffi::GAppInfo,
209            f: glib::ffi::gpointer,
210        ) {
211            let f: &F = &*(f as *const F);
212            f(&from_glib_borrow(this), &from_glib_borrow(application))
213        }
214        unsafe {
215            let f: Box_<F> = Box_::new(f);
216            connect_raw(
217                self.as_ptr() as *mut _,
218                c"application-activated".as_ptr() as *const _,
219                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
220                    application_activated_trampoline::<F> as *const (),
221                )),
222                Box_::into_raw(f),
223            )
224        }
225    }
226
227    #[doc(alias = "application-selected")]
228    pub fn connect_application_selected<F: Fn(&Self, &gio::AppInfo) + 'static>(
229        &self,
230        f: F,
231    ) -> SignalHandlerId {
232        unsafe extern "C" fn application_selected_trampoline<
233            F: Fn(&AppChooserWidget, &gio::AppInfo) + 'static,
234        >(
235            this: *mut ffi::GtkAppChooserWidget,
236            application: *mut gio::ffi::GAppInfo,
237            f: glib::ffi::gpointer,
238        ) {
239            let f: &F = &*(f as *const F);
240            f(&from_glib_borrow(this), &from_glib_borrow(application))
241        }
242        unsafe {
243            let f: Box_<F> = Box_::new(f);
244            connect_raw(
245                self.as_ptr() as *mut _,
246                c"application-selected".as_ptr() as *const _,
247                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
248                    application_selected_trampoline::<F> as *const (),
249                )),
250                Box_::into_raw(f),
251            )
252        }
253    }
254
255    #[doc(alias = "default-text")]
256    pub fn connect_default_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
257        unsafe extern "C" fn notify_default_text_trampoline<F: Fn(&AppChooserWidget) + 'static>(
258            this: *mut ffi::GtkAppChooserWidget,
259            _param_spec: glib::ffi::gpointer,
260            f: glib::ffi::gpointer,
261        ) {
262            let f: &F = &*(f as *const F);
263            f(&from_glib_borrow(this))
264        }
265        unsafe {
266            let f: Box_<F> = Box_::new(f);
267            connect_raw(
268                self.as_ptr() as *mut _,
269                c"notify::default-text".as_ptr() as *const _,
270                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
271                    notify_default_text_trampoline::<F> as *const (),
272                )),
273                Box_::into_raw(f),
274            )
275        }
276    }
277
278    #[doc(alias = "show-all")]
279    pub fn connect_show_all_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
280        unsafe extern "C" fn notify_show_all_trampoline<F: Fn(&AppChooserWidget) + 'static>(
281            this: *mut ffi::GtkAppChooserWidget,
282            _param_spec: glib::ffi::gpointer,
283            f: glib::ffi::gpointer,
284        ) {
285            let f: &F = &*(f as *const F);
286            f(&from_glib_borrow(this))
287        }
288        unsafe {
289            let f: Box_<F> = Box_::new(f);
290            connect_raw(
291                self.as_ptr() as *mut _,
292                c"notify::show-all".as_ptr() as *const _,
293                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
294                    notify_show_all_trampoline::<F> as *const (),
295                )),
296                Box_::into_raw(f),
297            )
298        }
299    }
300
301    #[doc(alias = "show-default")]
302    pub fn connect_show_default_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
303        unsafe extern "C" fn notify_show_default_trampoline<F: Fn(&AppChooserWidget) + 'static>(
304            this: *mut ffi::GtkAppChooserWidget,
305            _param_spec: glib::ffi::gpointer,
306            f: glib::ffi::gpointer,
307        ) {
308            let f: &F = &*(f as *const F);
309            f(&from_glib_borrow(this))
310        }
311        unsafe {
312            let f: Box_<F> = Box_::new(f);
313            connect_raw(
314                self.as_ptr() as *mut _,
315                c"notify::show-default".as_ptr() as *const _,
316                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
317                    notify_show_default_trampoline::<F> as *const (),
318                )),
319                Box_::into_raw(f),
320            )
321        }
322    }
323
324    #[doc(alias = "show-fallback")]
325    pub fn connect_show_fallback_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
326        unsafe extern "C" fn notify_show_fallback_trampoline<F: Fn(&AppChooserWidget) + 'static>(
327            this: *mut ffi::GtkAppChooserWidget,
328            _param_spec: glib::ffi::gpointer,
329            f: glib::ffi::gpointer,
330        ) {
331            let f: &F = &*(f as *const F);
332            f(&from_glib_borrow(this))
333        }
334        unsafe {
335            let f: Box_<F> = Box_::new(f);
336            connect_raw(
337                self.as_ptr() as *mut _,
338                c"notify::show-fallback".as_ptr() as *const _,
339                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
340                    notify_show_fallback_trampoline::<F> as *const (),
341                )),
342                Box_::into_raw(f),
343            )
344        }
345    }
346
347    #[doc(alias = "show-other")]
348    pub fn connect_show_other_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
349        unsafe extern "C" fn notify_show_other_trampoline<F: Fn(&AppChooserWidget) + 'static>(
350            this: *mut ffi::GtkAppChooserWidget,
351            _param_spec: glib::ffi::gpointer,
352            f: glib::ffi::gpointer,
353        ) {
354            let f: &F = &*(f as *const F);
355            f(&from_glib_borrow(this))
356        }
357        unsafe {
358            let f: Box_<F> = Box_::new(f);
359            connect_raw(
360                self.as_ptr() as *mut _,
361                c"notify::show-other".as_ptr() as *const _,
362                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
363                    notify_show_other_trampoline::<F> as *const (),
364                )),
365                Box_::into_raw(f),
366            )
367        }
368    }
369
370    #[doc(alias = "show-recommended")]
371    pub fn connect_show_recommended_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
372        unsafe extern "C" fn notify_show_recommended_trampoline<
373            F: Fn(&AppChooserWidget) + 'static,
374        >(
375            this: *mut ffi::GtkAppChooserWidget,
376            _param_spec: glib::ffi::gpointer,
377            f: glib::ffi::gpointer,
378        ) {
379            let f: &F = &*(f as *const F);
380            f(&from_glib_borrow(this))
381        }
382        unsafe {
383            let f: Box_<F> = Box_::new(f);
384            connect_raw(
385                self.as_ptr() as *mut _,
386                c"notify::show-recommended".as_ptr() as *const _,
387                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
388                    notify_show_recommended_trampoline::<F> as *const (),
389                )),
390                Box_::into_raw(f),
391            )
392        }
393    }
394}
395
396impl Default for AppChooserWidget {
397    fn default() -> Self {
398        glib::object::Object::new::<Self>()
399    }
400}
401
402// rustdoc-stripper-ignore-next
403/// A [builder-pattern] type to construct [`AppChooserWidget`] objects.
404///
405/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
406#[must_use = "The builder must be built to be used"]
407pub struct AppChooserWidgetBuilder {
408    builder: glib::object::ObjectBuilder<'static, AppChooserWidget>,
409}
410
411impl AppChooserWidgetBuilder {
412    fn new() -> Self {
413        Self {
414            builder: glib::object::Object::builder(),
415        }
416    }
417
418    pub fn default_text(self, default_text: impl Into<glib::GString>) -> Self {
419        Self {
420            builder: self.builder.property("default-text", default_text.into()),
421        }
422    }
423
424    pub fn show_all(self, show_all: bool) -> Self {
425        Self {
426            builder: self.builder.property("show-all", show_all),
427        }
428    }
429
430    pub fn show_default(self, show_default: bool) -> Self {
431        Self {
432            builder: self.builder.property("show-default", show_default),
433        }
434    }
435
436    pub fn show_fallback(self, show_fallback: bool) -> Self {
437        Self {
438            builder: self.builder.property("show-fallback", show_fallback),
439        }
440    }
441
442    pub fn show_other(self, show_other: bool) -> Self {
443        Self {
444            builder: self.builder.property("show-other", show_other),
445        }
446    }
447
448    pub fn show_recommended(self, show_recommended: bool) -> Self {
449        Self {
450            builder: self.builder.property("show-recommended", show_recommended),
451        }
452    }
453
454    pub fn can_focus(self, can_focus: bool) -> Self {
455        Self {
456            builder: self.builder.property("can-focus", can_focus),
457        }
458    }
459
460    pub fn can_target(self, can_target: bool) -> Self {
461        Self {
462            builder: self.builder.property("can-target", can_target),
463        }
464    }
465
466    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
467        Self {
468            builder: self.builder.property("css-classes", css_classes.into()),
469        }
470    }
471
472    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
473        Self {
474            builder: self.builder.property("css-name", css_name.into()),
475        }
476    }
477
478    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
479        Self {
480            builder: self.builder.property("cursor", cursor.clone()),
481        }
482    }
483
484    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
485        Self {
486            builder: self.builder.property("focus-on-click", focus_on_click),
487        }
488    }
489
490    pub fn focusable(self, focusable: bool) -> Self {
491        Self {
492            builder: self.builder.property("focusable", focusable),
493        }
494    }
495
496    pub fn halign(self, halign: Align) -> Self {
497        Self {
498            builder: self.builder.property("halign", halign),
499        }
500    }
501
502    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
503        Self {
504            builder: self.builder.property("has-tooltip", has_tooltip),
505        }
506    }
507
508    pub fn height_request(self, height_request: i32) -> Self {
509        Self {
510            builder: self.builder.property("height-request", height_request),
511        }
512    }
513
514    pub fn hexpand(self, hexpand: bool) -> Self {
515        Self {
516            builder: self.builder.property("hexpand", hexpand),
517        }
518    }
519
520    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
521        Self {
522            builder: self.builder.property("hexpand-set", hexpand_set),
523        }
524    }
525
526    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
527        Self {
528            builder: self
529                .builder
530                .property("layout-manager", layout_manager.clone().upcast()),
531        }
532    }
533
534    #[cfg(feature = "v4_18")]
535    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
536    pub fn limit_events(self, limit_events: bool) -> Self {
537        Self {
538            builder: self.builder.property("limit-events", limit_events),
539        }
540    }
541
542    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
543        Self {
544            builder: self.builder.property("margin-bottom", margin_bottom),
545        }
546    }
547
548    pub fn margin_end(self, margin_end: i32) -> Self {
549        Self {
550            builder: self.builder.property("margin-end", margin_end),
551        }
552    }
553
554    pub fn margin_start(self, margin_start: i32) -> Self {
555        Self {
556            builder: self.builder.property("margin-start", margin_start),
557        }
558    }
559
560    pub fn margin_top(self, margin_top: i32) -> Self {
561        Self {
562            builder: self.builder.property("margin-top", margin_top),
563        }
564    }
565
566    pub fn name(self, name: impl Into<glib::GString>) -> Self {
567        Self {
568            builder: self.builder.property("name", name.into()),
569        }
570    }
571
572    pub fn opacity(self, opacity: f64) -> Self {
573        Self {
574            builder: self.builder.property("opacity", opacity),
575        }
576    }
577
578    pub fn overflow(self, overflow: Overflow) -> Self {
579        Self {
580            builder: self.builder.property("overflow", overflow),
581        }
582    }
583
584    pub fn receives_default(self, receives_default: bool) -> Self {
585        Self {
586            builder: self.builder.property("receives-default", receives_default),
587        }
588    }
589
590    pub fn sensitive(self, sensitive: bool) -> Self {
591        Self {
592            builder: self.builder.property("sensitive", sensitive),
593        }
594    }
595
596    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
597        Self {
598            builder: self
599                .builder
600                .property("tooltip-markup", tooltip_markup.into()),
601        }
602    }
603
604    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
605        Self {
606            builder: self.builder.property("tooltip-text", tooltip_text.into()),
607        }
608    }
609
610    pub fn valign(self, valign: Align) -> Self {
611        Self {
612            builder: self.builder.property("valign", valign),
613        }
614    }
615
616    pub fn vexpand(self, vexpand: bool) -> Self {
617        Self {
618            builder: self.builder.property("vexpand", vexpand),
619        }
620    }
621
622    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
623        Self {
624            builder: self.builder.property("vexpand-set", vexpand_set),
625        }
626    }
627
628    pub fn visible(self, visible: bool) -> Self {
629        Self {
630            builder: self.builder.property("visible", visible),
631        }
632    }
633
634    pub fn width_request(self, width_request: i32) -> Self {
635        Self {
636            builder: self.builder.property("width-request", width_request),
637        }
638    }
639
640    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
641        Self {
642            builder: self.builder.property("accessible-role", accessible_role),
643        }
644    }
645
646    pub fn content_type(self, content_type: impl Into<glib::GString>) -> Self {
647        Self {
648            builder: self.builder.property("content-type", content_type.into()),
649        }
650    }
651
652    // rustdoc-stripper-ignore-next
653    /// Build the [`AppChooserWidget`].
654    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
655    pub fn build(self) -> AppChooserWidget {
656        assert_initialized_main_thread!();
657        self.builder.build()
658    }
659}