[go: up one dir, main page]

gtk4/auto/
icon_paintable.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::ffi;
7#[cfg(feature = "v4_6")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
9use crate::SymbolicPaintable;
10use glib::{
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17#[cfg(feature = "v4_6")]
18#[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
19glib::wrapper! {
20    #[doc(alias = "GtkIconPaintable")]
21    pub struct IconPaintable(Object<ffi::GtkIconPaintable, ffi::GtkIconPaintableClass>) @implements gdk::Paintable, SymbolicPaintable;
22
23    match fn {
24        type_ => || ffi::gtk_icon_paintable_get_type(),
25    }
26}
27
28#[cfg(not(any(feature = "v4_6")))]
29glib::wrapper! {
30    #[doc(alias = "GtkIconPaintable")]
31    pub struct IconPaintable(Object<ffi::GtkIconPaintable, ffi::GtkIconPaintableClass>) @implements gdk::Paintable;
32
33    match fn {
34        type_ => || ffi::gtk_icon_paintable_get_type(),
35    }
36}
37
38impl IconPaintable {
39    #[doc(alias = "gtk_icon_paintable_new_for_file")]
40    #[doc(alias = "new_for_file")]
41    pub fn for_file(file: &impl IsA<gio::File>, size: i32, scale: i32) -> IconPaintable {
42        assert_initialized_main_thread!();
43        unsafe {
44            from_glib_full(ffi::gtk_icon_paintable_new_for_file(
45                file.as_ref().to_glib_none().0,
46                size,
47                scale,
48            ))
49        }
50    }
51
52    #[doc(alias = "gtk_icon_paintable_get_file")]
53    #[doc(alias = "get_file")]
54    pub fn file(&self) -> Option<gio::File> {
55        unsafe { from_glib_full(ffi::gtk_icon_paintable_get_file(self.to_glib_none().0)) }
56    }
57
58    #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
59    #[allow(deprecated)]
60    #[doc(alias = "gtk_icon_paintable_get_icon_name")]
61    #[doc(alias = "get_icon_name")]
62    #[doc(alias = "icon-name")]
63    pub fn icon_name(&self) -> Option<std::path::PathBuf> {
64        unsafe { from_glib_none(ffi::gtk_icon_paintable_get_icon_name(self.to_glib_none().0)) }
65    }
66
67    #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
68    #[allow(deprecated)]
69    #[doc(alias = "gtk_icon_paintable_is_symbolic")]
70    #[doc(alias = "is-symbolic")]
71    pub fn is_symbolic(&self) -> bool {
72        unsafe { from_glib(ffi::gtk_icon_paintable_is_symbolic(self.to_glib_none().0)) }
73    }
74
75    #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
76    #[doc(alias = "is-symbolic")]
77    pub fn set_is_symbolic(&self, is_symbolic: bool) {
78        ObjectExt::set_property(self, "is-symbolic", is_symbolic)
79    }
80
81    pub fn scale(&self) -> i32 {
82        ObjectExt::property(self, "scale")
83    }
84
85    pub fn set_scale(&self, scale: i32) {
86        ObjectExt::set_property(self, "scale", scale)
87    }
88
89    pub fn size(&self) -> i32 {
90        ObjectExt::property(self, "size")
91    }
92
93    pub fn set_size(&self, size: i32) {
94        ObjectExt::set_property(self, "size", size)
95    }
96
97    #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
98    #[doc(alias = "is-symbolic")]
99    pub fn connect_is_symbolic_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
100        unsafe extern "C" fn notify_is_symbolic_trampoline<F: Fn(&IconPaintable) + 'static>(
101            this: *mut ffi::GtkIconPaintable,
102            _param_spec: glib::ffi::gpointer,
103            f: glib::ffi::gpointer,
104        ) {
105            let f: &F = &*(f as *const F);
106            f(&from_glib_borrow(this))
107        }
108        unsafe {
109            let f: Box_<F> = Box_::new(f);
110            connect_raw(
111                self.as_ptr() as *mut _,
112                c"notify::is-symbolic".as_ptr() as *const _,
113                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
114                    notify_is_symbolic_trampoline::<F> as *const (),
115                )),
116                Box_::into_raw(f),
117            )
118        }
119    }
120
121    #[doc(alias = "scale")]
122    pub fn connect_scale_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
123        unsafe extern "C" fn notify_scale_trampoline<F: Fn(&IconPaintable) + 'static>(
124            this: *mut ffi::GtkIconPaintable,
125            _param_spec: glib::ffi::gpointer,
126            f: glib::ffi::gpointer,
127        ) {
128            let f: &F = &*(f as *const F);
129            f(&from_glib_borrow(this))
130        }
131        unsafe {
132            let f: Box_<F> = Box_::new(f);
133            connect_raw(
134                self.as_ptr() as *mut _,
135                c"notify::scale".as_ptr() as *const _,
136                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
137                    notify_scale_trampoline::<F> as *const (),
138                )),
139                Box_::into_raw(f),
140            )
141        }
142    }
143
144    #[doc(alias = "size")]
145    pub fn connect_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
146        unsafe extern "C" fn notify_size_trampoline<F: Fn(&IconPaintable) + 'static>(
147            this: *mut ffi::GtkIconPaintable,
148            _param_spec: glib::ffi::gpointer,
149            f: glib::ffi::gpointer,
150        ) {
151            let f: &F = &*(f as *const F);
152            f(&from_glib_borrow(this))
153        }
154        unsafe {
155            let f: Box_<F> = Box_::new(f);
156            connect_raw(
157                self.as_ptr() as *mut _,
158                c"notify::size".as_ptr() as *const _,
159                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
160                    notify_size_trampoline::<F> as *const (),
161                )),
162                Box_::into_raw(f),
163            )
164        }
165    }
166}