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 gio_sys;
6use glib::object::ObjectType as ObjectType_;
7use glib::signal::connect_raw;
8use glib::signal::SignalHandlerId;
9use glib::translate::*;
10use glib::GString;
11use glib::StaticType;
12use glib::Value;
13use glib_sys;
14use gobject_sys;
15use std::boxed::Box as Box_;
16use std::fmt;
17use std::mem::transmute;
18use Icon;
19
20glib_wrapper! {
21    pub struct ThemedIcon(Object<gio_sys::GThemedIcon, gio_sys::GThemedIconClass, ThemedIconClass>) @implements Icon;
22
23    match fn {
24        get_type => || gio_sys::g_themed_icon_get_type(),
25    }
26}
27
28impl ThemedIcon {
29    pub fn new(iconname: &str) -> ThemedIcon {
30        unsafe { from_glib_full(gio_sys::g_themed_icon_new(iconname.to_glib_none().0)) }
31    }
32
33    pub fn new_from_names(iconnames: &[&str]) -> ThemedIcon {
34        let len = iconnames.len() as i32;
35        unsafe {
36            from_glib_full(gio_sys::g_themed_icon_new_from_names(
37                iconnames.to_glib_none().0,
38                len,
39            ))
40        }
41    }
42
43    pub fn new_with_default_fallbacks(iconname: &str) -> ThemedIcon {
44        unsafe {
45            from_glib_full(gio_sys::g_themed_icon_new_with_default_fallbacks(
46                iconname.to_glib_none().0,
47            ))
48        }
49    }
50
51    pub fn append_name(&self, iconname: &str) {
52        unsafe {
53            gio_sys::g_themed_icon_append_name(self.to_glib_none().0, iconname.to_glib_none().0);
54        }
55    }
56
57    pub fn get_names(&self) -> Vec<GString> {
58        unsafe {
59            FromGlibPtrContainer::from_glib_none(gio_sys::g_themed_icon_get_names(
60                self.to_glib_none().0,
61            ))
62        }
63    }
64
65    pub fn prepend_name(&self, iconname: &str) {
66        unsafe {
67            gio_sys::g_themed_icon_prepend_name(self.to_glib_none().0, iconname.to_glib_none().0);
68        }
69    }
70
71    pub fn get_property_use_default_fallbacks(&self) -> bool {
72        unsafe {
73            let mut value = Value::from_type(<bool as StaticType>::static_type());
74            gobject_sys::g_object_get_property(
75                self.as_ptr() as *mut gobject_sys::GObject,
76                b"use-default-fallbacks\0".as_ptr() as *const _,
77                value.to_glib_none_mut().0,
78            );
79            value.get().unwrap()
80        }
81    }
82
83    pub fn connect_property_names_notify<F: Fn(&ThemedIcon) + 'static>(
84        &self,
85        f: F,
86    ) -> SignalHandlerId {
87        unsafe extern "C" fn notify_names_trampoline<F: Fn(&ThemedIcon) + 'static>(
88            this: *mut gio_sys::GThemedIcon,
89            _param_spec: glib_sys::gpointer,
90            f: glib_sys::gpointer,
91        ) {
92            let f: &F = &*(f as *const F);
93            f(&from_glib_borrow(this))
94        }
95        unsafe {
96            let f: Box_<F> = Box_::new(f);
97            connect_raw(
98                self.as_ptr() as *mut _,
99                b"notify::names\0".as_ptr() as *const _,
100                Some(transmute(notify_names_trampoline::<F> as usize)),
101                Box_::into_raw(f),
102            )
103        }
104    }
105}
106
107impl fmt::Display for ThemedIcon {
108    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
109        write!(f, "ThemedIcon")
110    }
111}