1#![allow(deprecated)]
5
6use crate::{ffi, CellRenderer, CellRendererMode, IconSize};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GtkCellRendererPixbuf")]
16 pub struct CellRendererPixbuf(Object<ffi::GtkCellRendererPixbuf>) @extends CellRenderer;
17
18 match fn {
19 type_ => || ffi::gtk_cell_renderer_pixbuf_get_type(),
20 }
21}
22
23impl CellRendererPixbuf {
24 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
25 #[allow(deprecated)]
26 #[doc(alias = "gtk_cell_renderer_pixbuf_new")]
27 pub fn new() -> CellRendererPixbuf {
28 assert_initialized_main_thread!();
29 unsafe { CellRenderer::from_glib_none(ffi::gtk_cell_renderer_pixbuf_new()).unsafe_cast() }
30 }
31
32 pub fn builder() -> CellRendererPixbufBuilder {
37 CellRendererPixbufBuilder::new()
38 }
39
40 pub fn gicon(&self) -> Option<gio::Icon> {
41 ObjectExt::property(self, "gicon")
42 }
43
44 pub fn set_gicon<P: IsA<gio::Icon>>(&self, gicon: Option<&P>) {
45 ObjectExt::set_property(self, "gicon", gicon)
46 }
47
48 #[doc(alias = "icon-name")]
49 pub fn icon_name(&self) -> Option<glib::GString> {
50 ObjectExt::property(self, "icon-name")
51 }
52
53 #[doc(alias = "icon-name")]
54 pub fn set_icon_name(&self, icon_name: Option<&str>) {
55 ObjectExt::set_property(self, "icon-name", icon_name)
56 }
57
58 #[doc(alias = "icon-size")]
59 pub fn icon_size(&self) -> IconSize {
60 ObjectExt::property(self, "icon-size")
61 }
62
63 #[doc(alias = "icon-size")]
64 pub fn set_icon_size(&self, icon_size: IconSize) {
65 ObjectExt::set_property(self, "icon-size", icon_size)
66 }
67
68 pub fn set_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>) {
69 ObjectExt::set_property(self, "pixbuf", pixbuf)
70 }
71
72 #[doc(alias = "pixbuf-expander-closed")]
73 pub fn pixbuf_expander_closed(&self) -> Option<gdk_pixbuf::Pixbuf> {
74 ObjectExt::property(self, "pixbuf-expander-closed")
75 }
76
77 #[doc(alias = "pixbuf-expander-closed")]
78 pub fn set_pixbuf_expander_closed(&self, pixbuf_expander_closed: Option<&gdk_pixbuf::Pixbuf>) {
79 ObjectExt::set_property(self, "pixbuf-expander-closed", pixbuf_expander_closed)
80 }
81
82 #[doc(alias = "pixbuf-expander-open")]
83 pub fn pixbuf_expander_open(&self) -> Option<gdk_pixbuf::Pixbuf> {
84 ObjectExt::property(self, "pixbuf-expander-open")
85 }
86
87 #[doc(alias = "pixbuf-expander-open")]
88 pub fn set_pixbuf_expander_open(&self, pixbuf_expander_open: Option<&gdk_pixbuf::Pixbuf>) {
89 ObjectExt::set_property(self, "pixbuf-expander-open", pixbuf_expander_open)
90 }
91
92 pub fn texture(&self) -> Option<gdk::Texture> {
93 ObjectExt::property(self, "texture")
94 }
95
96 pub fn set_texture<P: IsA<gdk::Texture>>(&self, texture: Option<&P>) {
97 ObjectExt::set_property(self, "texture", texture)
98 }
99
100 #[doc(alias = "gicon")]
101 pub fn connect_gicon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
102 unsafe extern "C" fn notify_gicon_trampoline<F: Fn(&CellRendererPixbuf) + 'static>(
103 this: *mut ffi::GtkCellRendererPixbuf,
104 _param_spec: glib::ffi::gpointer,
105 f: glib::ffi::gpointer,
106 ) {
107 let f: &F = &*(f as *const F);
108 f(&from_glib_borrow(this))
109 }
110 unsafe {
111 let f: Box_<F> = Box_::new(f);
112 connect_raw(
113 self.as_ptr() as *mut _,
114 b"notify::gicon\0".as_ptr() as *const _,
115 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
116 notify_gicon_trampoline::<F> as *const (),
117 )),
118 Box_::into_raw(f),
119 )
120 }
121 }
122
123 #[doc(alias = "icon-name")]
124 pub fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
125 unsafe extern "C" fn notify_icon_name_trampoline<F: Fn(&CellRendererPixbuf) + 'static>(
126 this: *mut ffi::GtkCellRendererPixbuf,
127 _param_spec: glib::ffi::gpointer,
128 f: glib::ffi::gpointer,
129 ) {
130 let f: &F = &*(f as *const F);
131 f(&from_glib_borrow(this))
132 }
133 unsafe {
134 let f: Box_<F> = Box_::new(f);
135 connect_raw(
136 self.as_ptr() as *mut _,
137 b"notify::icon-name\0".as_ptr() as *const _,
138 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
139 notify_icon_name_trampoline::<F> as *const (),
140 )),
141 Box_::into_raw(f),
142 )
143 }
144 }
145
146 #[doc(alias = "icon-size")]
147 pub fn connect_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
148 unsafe extern "C" fn notify_icon_size_trampoline<F: Fn(&CellRendererPixbuf) + 'static>(
149 this: *mut ffi::GtkCellRendererPixbuf,
150 _param_spec: glib::ffi::gpointer,
151 f: glib::ffi::gpointer,
152 ) {
153 let f: &F = &*(f as *const F);
154 f(&from_glib_borrow(this))
155 }
156 unsafe {
157 let f: Box_<F> = Box_::new(f);
158 connect_raw(
159 self.as_ptr() as *mut _,
160 b"notify::icon-size\0".as_ptr() as *const _,
161 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
162 notify_icon_size_trampoline::<F> as *const (),
163 )),
164 Box_::into_raw(f),
165 )
166 }
167 }
168
169 #[doc(alias = "pixbuf")]
170 pub fn connect_pixbuf_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
171 unsafe extern "C" fn notify_pixbuf_trampoline<F: Fn(&CellRendererPixbuf) + 'static>(
172 this: *mut ffi::GtkCellRendererPixbuf,
173 _param_spec: glib::ffi::gpointer,
174 f: glib::ffi::gpointer,
175 ) {
176 let f: &F = &*(f as *const F);
177 f(&from_glib_borrow(this))
178 }
179 unsafe {
180 let f: Box_<F> = Box_::new(f);
181 connect_raw(
182 self.as_ptr() as *mut _,
183 b"notify::pixbuf\0".as_ptr() as *const _,
184 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
185 notify_pixbuf_trampoline::<F> as *const (),
186 )),
187 Box_::into_raw(f),
188 )
189 }
190 }
191
192 #[doc(alias = "pixbuf-expander-closed")]
193 pub fn connect_pixbuf_expander_closed_notify<F: Fn(&Self) + 'static>(
194 &self,
195 f: F,
196 ) -> SignalHandlerId {
197 unsafe extern "C" fn notify_pixbuf_expander_closed_trampoline<
198 F: Fn(&CellRendererPixbuf) + 'static,
199 >(
200 this: *mut ffi::GtkCellRendererPixbuf,
201 _param_spec: glib::ffi::gpointer,
202 f: glib::ffi::gpointer,
203 ) {
204 let f: &F = &*(f as *const F);
205 f(&from_glib_borrow(this))
206 }
207 unsafe {
208 let f: Box_<F> = Box_::new(f);
209 connect_raw(
210 self.as_ptr() as *mut _,
211 b"notify::pixbuf-expander-closed\0".as_ptr() as *const _,
212 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
213 notify_pixbuf_expander_closed_trampoline::<F> as *const (),
214 )),
215 Box_::into_raw(f),
216 )
217 }
218 }
219
220 #[doc(alias = "pixbuf-expander-open")]
221 pub fn connect_pixbuf_expander_open_notify<F: Fn(&Self) + 'static>(
222 &self,
223 f: F,
224 ) -> SignalHandlerId {
225 unsafe extern "C" fn notify_pixbuf_expander_open_trampoline<
226 F: Fn(&CellRendererPixbuf) + 'static,
227 >(
228 this: *mut ffi::GtkCellRendererPixbuf,
229 _param_spec: glib::ffi::gpointer,
230 f: glib::ffi::gpointer,
231 ) {
232 let f: &F = &*(f as *const F);
233 f(&from_glib_borrow(this))
234 }
235 unsafe {
236 let f: Box_<F> = Box_::new(f);
237 connect_raw(
238 self.as_ptr() as *mut _,
239 b"notify::pixbuf-expander-open\0".as_ptr() as *const _,
240 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
241 notify_pixbuf_expander_open_trampoline::<F> as *const (),
242 )),
243 Box_::into_raw(f),
244 )
245 }
246 }
247
248 #[doc(alias = "texture")]
249 pub fn connect_texture_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
250 unsafe extern "C" fn notify_texture_trampoline<F: Fn(&CellRendererPixbuf) + 'static>(
251 this: *mut ffi::GtkCellRendererPixbuf,
252 _param_spec: glib::ffi::gpointer,
253 f: glib::ffi::gpointer,
254 ) {
255 let f: &F = &*(f as *const F);
256 f(&from_glib_borrow(this))
257 }
258 unsafe {
259 let f: Box_<F> = Box_::new(f);
260 connect_raw(
261 self.as_ptr() as *mut _,
262 b"notify::texture\0".as_ptr() as *const _,
263 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
264 notify_texture_trampoline::<F> as *const (),
265 )),
266 Box_::into_raw(f),
267 )
268 }
269 }
270}
271
272impl Default for CellRendererPixbuf {
273 fn default() -> Self {
274 Self::new()
275 }
276}
277
278#[must_use = "The builder must be built to be used"]
283pub struct CellRendererPixbufBuilder {
284 builder: glib::object::ObjectBuilder<'static, CellRendererPixbuf>,
285}
286
287impl CellRendererPixbufBuilder {
288 fn new() -> Self {
289 Self {
290 builder: glib::object::Object::builder(),
291 }
292 }
293
294 pub fn gicon(self, gicon: &impl IsA<gio::Icon>) -> Self {
295 Self {
296 builder: self.builder.property("gicon", gicon.clone().upcast()),
297 }
298 }
299
300 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
301 Self {
302 builder: self.builder.property("icon-name", icon_name.into()),
303 }
304 }
305
306 pub fn icon_size(self, icon_size: IconSize) -> Self {
307 Self {
308 builder: self.builder.property("icon-size", icon_size),
309 }
310 }
311
312 pub fn pixbuf(self, pixbuf: &gdk_pixbuf::Pixbuf) -> Self {
313 Self {
314 builder: self.builder.property("pixbuf", pixbuf.clone()),
315 }
316 }
317
318 pub fn pixbuf_expander_closed(self, pixbuf_expander_closed: &gdk_pixbuf::Pixbuf) -> Self {
319 Self {
320 builder: self
321 .builder
322 .property("pixbuf-expander-closed", pixbuf_expander_closed.clone()),
323 }
324 }
325
326 pub fn pixbuf_expander_open(self, pixbuf_expander_open: &gdk_pixbuf::Pixbuf) -> Self {
327 Self {
328 builder: self
329 .builder
330 .property("pixbuf-expander-open", pixbuf_expander_open.clone()),
331 }
332 }
333
334 pub fn texture(self, texture: &impl IsA<gdk::Texture>) -> Self {
335 Self {
336 builder: self.builder.property("texture", texture.clone().upcast()),
337 }
338 }
339
340 pub fn cell_background(self, cell_background: impl Into<glib::GString>) -> Self {
341 Self {
342 builder: self
343 .builder
344 .property("cell-background", cell_background.into()),
345 }
346 }
347
348 pub fn cell_background_rgba(self, cell_background_rgba: &gdk::RGBA) -> Self {
349 Self {
350 builder: self
351 .builder
352 .property("cell-background-rgba", cell_background_rgba),
353 }
354 }
355
356 pub fn cell_background_set(self, cell_background_set: bool) -> Self {
357 Self {
358 builder: self
359 .builder
360 .property("cell-background-set", cell_background_set),
361 }
362 }
363
364 pub fn height(self, height: i32) -> Self {
365 Self {
366 builder: self.builder.property("height", height),
367 }
368 }
369
370 pub fn is_expanded(self, is_expanded: bool) -> Self {
371 Self {
372 builder: self.builder.property("is-expanded", is_expanded),
373 }
374 }
375
376 pub fn is_expander(self, is_expander: bool) -> Self {
377 Self {
378 builder: self.builder.property("is-expander", is_expander),
379 }
380 }
381
382 pub fn mode(self, mode: CellRendererMode) -> Self {
383 Self {
384 builder: self.builder.property("mode", mode),
385 }
386 }
387
388 pub fn sensitive(self, sensitive: bool) -> Self {
389 Self {
390 builder: self.builder.property("sensitive", sensitive),
391 }
392 }
393
394 pub fn visible(self, visible: bool) -> Self {
395 Self {
396 builder: self.builder.property("visible", visible),
397 }
398 }
399
400 pub fn width(self, width: i32) -> Self {
401 Self {
402 builder: self.builder.property("width", width),
403 }
404 }
405
406 pub fn xalign(self, xalign: f32) -> Self {
407 Self {
408 builder: self.builder.property("xalign", xalign),
409 }
410 }
411
412 pub fn xpad(self, xpad: u32) -> Self {
413 Self {
414 builder: self.builder.property("xpad", xpad),
415 }
416 }
417
418 pub fn yalign(self, yalign: f32) -> Self {
419 Self {
420 builder: self.builder.property("yalign", yalign),
421 }
422 }
423
424 pub fn ypad(self, ypad: u32) -> Self {
425 Self {
426 builder: self.builder.property("ypad", ypad),
427 }
428 }
429
430 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
433 pub fn build(self) -> CellRendererPixbuf {
434 assert_initialized_main_thread!();
435 self.builder.build()
436 }
437}