gio/auto/
themed_icon.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 crate::{ffi, Icon};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GThemedIcon")]
15    pub struct ThemedIcon(Object<ffi::GThemedIcon, ffi::GThemedIconClass>) @implements Icon;
16
17    match fn {
18        type_ => || ffi::g_themed_icon_get_type(),
19    }
20}
21
22impl ThemedIcon {
23    #[doc(alias = "g_themed_icon_new")]
24    pub fn new(iconname: &str) -> ThemedIcon {
25        unsafe { from_glib_full(ffi::g_themed_icon_new(iconname.to_glib_none().0)) }
26    }
27
28    #[doc(alias = "g_themed_icon_new_from_names")]
29    #[doc(alias = "new_from_names")]
30    pub fn from_names(iconnames: &[&str]) -> ThemedIcon {
31        let len = iconnames.len() as _;
32        unsafe {
33            from_glib_full(ffi::g_themed_icon_new_from_names(
34                iconnames.to_glib_none().0,
35                len,
36            ))
37        }
38    }
39
40    #[doc(alias = "g_themed_icon_new_with_default_fallbacks")]
41    #[doc(alias = "new_with_default_fallbacks")]
42    pub fn with_default_fallbacks(iconname: &str) -> ThemedIcon {
43        unsafe {
44            from_glib_full(ffi::g_themed_icon_new_with_default_fallbacks(
45                iconname.to_glib_none().0,
46            ))
47        }
48    }
49
50    #[doc(alias = "g_themed_icon_append_name")]
51    pub fn append_name(&self, iconname: &str) {
52        unsafe {
53            ffi::g_themed_icon_append_name(self.to_glib_none().0, iconname.to_glib_none().0);
54        }
55    }
56
57    #[doc(alias = "g_themed_icon_get_names")]
58    #[doc(alias = "get_names")]
59    pub fn names(&self) -> Vec<glib::GString> {
60        unsafe {
61            FromGlibPtrContainer::from_glib_none(ffi::g_themed_icon_get_names(
62                self.to_glib_none().0,
63            ))
64        }
65    }
66
67    #[doc(alias = "g_themed_icon_prepend_name")]
68    pub fn prepend_name(&self, iconname: &str) {
69        unsafe {
70            ffi::g_themed_icon_prepend_name(self.to_glib_none().0, iconname.to_glib_none().0);
71        }
72    }
73
74    #[doc(alias = "use-default-fallbacks")]
75    pub fn uses_default_fallbacks(&self) -> bool {
76        ObjectExt::property(self, "use-default-fallbacks")
77    }
78
79    #[doc(alias = "names")]
80    pub fn connect_names_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
81        unsafe extern "C" fn notify_names_trampoline<F: Fn(&ThemedIcon) + 'static>(
82            this: *mut ffi::GThemedIcon,
83            _param_spec: glib::ffi::gpointer,
84            f: glib::ffi::gpointer,
85        ) {
86            let f: &F = &*(f as *const F);
87            f(&from_glib_borrow(this))
88        }
89        unsafe {
90            let f: Box_<F> = Box_::new(f);
91            connect_raw(
92                self.as_ptr() as *mut _,
93                c"notify::names".as_ptr() as *const _,
94                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
95                    notify_names_trampoline::<F> as *const (),
96                )),
97                Box_::into_raw(f),
98            )
99        }
100    }
101}