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 
5 use gio_sys;
6 use glib::object::ObjectType as ObjectType_;
7 use glib::signal::connect_raw;
8 use glib::signal::SignalHandlerId;
9 use glib::translate::*;
10 use glib::GString;
11 use glib::StaticType;
12 use glib::Value;
13 use glib_sys;
14 use gobject_sys;
15 use std::boxed::Box as Box_;
16 use std::fmt;
17 use std::mem::transmute;
18 use Icon;
19 
20 glib_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 
28 impl ThemedIcon {
new(iconname: &str) -> ThemedIcon29     pub fn new(iconname: &str) -> ThemedIcon {
30         unsafe { from_glib_full(gio_sys::g_themed_icon_new(iconname.to_glib_none().0)) }
31     }
32 
new_from_names(iconnames: &[&str]) -> ThemedIcon33     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 
new_with_default_fallbacks(iconname: &str) -> ThemedIcon43     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 
append_name(&self, iconname: &str)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 
get_names(&self) -> Vec<GString>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 
prepend_name(&self, iconname: &str)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 
get_property_use_default_fallbacks(&self) -> bool71     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
80                 .get()
81                 .expect("Return Value for property `use-default-fallbacks` getter")
82                 .unwrap()
83         }
84     }
85 
connect_property_names_notify<F: Fn(&ThemedIcon) + 'static>( &self, f: F, ) -> SignalHandlerId86     pub fn connect_property_names_notify<F: Fn(&ThemedIcon) + 'static>(
87         &self,
88         f: F,
89     ) -> SignalHandlerId {
90         unsafe extern "C" fn notify_names_trampoline<F: Fn(&ThemedIcon) + 'static>(
91             this: *mut gio_sys::GThemedIcon,
92             _param_spec: glib_sys::gpointer,
93             f: glib_sys::gpointer,
94         ) {
95             let f: &F = &*(f as *const F);
96             f(&from_glib_borrow(this))
97         }
98         unsafe {
99             let f: Box_<F> = Box_::new(f);
100             connect_raw(
101                 self.as_ptr() as *mut _,
102                 b"notify::names\0".as_ptr() as *const _,
103                 Some(transmute(notify_names_trampoline::<F> as usize)),
104                 Box_::into_raw(f),
105             )
106         }
107     }
108 }
109 
110 impl fmt::Display for ThemedIcon {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result111     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
112         write!(f, "ThemedIcon")
113     }
114 }
115