1#![allow(deprecated)]
5
6use crate::{CellRenderer, CellRendererMode, IconSize, ffi};
7use glib::{
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GtkCellRendererPixbuf")]
139 pub struct CellRendererPixbuf(Object<ffi::GtkCellRendererPixbuf>) @extends CellRenderer;
140
141 match fn {
142 type_ => || ffi::gtk_cell_renderer_pixbuf_get_type(),
143 }
144}
145
146impl CellRendererPixbuf {
147 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
158 #[allow(deprecated)]
159 #[doc(alias = "gtk_cell_renderer_pixbuf_new")]
160 pub fn new() -> CellRendererPixbuf {
161 assert_initialized_main_thread!();
162 unsafe { CellRenderer::from_glib_none(ffi::gtk_cell_renderer_pixbuf_new()).unsafe_cast() }
163 }
164
165 pub fn builder() -> CellRendererPixbufBuilder {
170 CellRendererPixbufBuilder::new()
171 }
172
173 pub fn gicon(&self) -> Option<gio::Icon> {
177 ObjectExt::property(self, "gicon")
178 }
179
180 pub fn set_gicon<P: IsA<gio::Icon>>(&self, gicon: Option<&P>) {
184 ObjectExt::set_property(self, "gicon", gicon)
185 }
186
187 #[doc(alias = "icon-name")]
190 pub fn icon_name(&self) -> Option<glib::GString> {
191 ObjectExt::property(self, "icon-name")
192 }
193
194 #[doc(alias = "icon-name")]
197 pub fn set_icon_name(&self, icon_name: Option<&str>) {
198 ObjectExt::set_property(self, "icon-name", icon_name)
199 }
200
201 #[doc(alias = "icon-size")]
203 pub fn icon_size(&self) -> IconSize {
204 ObjectExt::property(self, "icon-size")
205 }
206
207 #[doc(alias = "icon-size")]
209 pub fn set_icon_size(&self, icon_size: IconSize) {
210 ObjectExt::set_property(self, "icon-size", icon_size)
211 }
212
213 pub fn set_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>) {
214 ObjectExt::set_property(self, "pixbuf", pixbuf)
215 }
216
217 #[doc(alias = "pixbuf-expander-closed")]
218 pub fn pixbuf_expander_closed(&self) -> Option<gdk_pixbuf::Pixbuf> {
219 ObjectExt::property(self, "pixbuf-expander-closed")
220 }
221
222 #[doc(alias = "pixbuf-expander-closed")]
223 pub fn set_pixbuf_expander_closed(&self, pixbuf_expander_closed: Option<&gdk_pixbuf::Pixbuf>) {
224 ObjectExt::set_property(self, "pixbuf-expander-closed", pixbuf_expander_closed)
225 }
226
227 #[doc(alias = "pixbuf-expander-open")]
228 pub fn pixbuf_expander_open(&self) -> Option<gdk_pixbuf::Pixbuf> {
229 ObjectExt::property(self, "pixbuf-expander-open")
230 }
231
232 #[doc(alias = "pixbuf-expander-open")]
233 pub fn set_pixbuf_expander_open(&self, pixbuf_expander_open: Option<&gdk_pixbuf::Pixbuf>) {
234 ObjectExt::set_property(self, "pixbuf-expander-open", pixbuf_expander_open)
235 }
236
237 pub fn texture(&self) -> Option<gdk::Texture> {
238 ObjectExt::property(self, "texture")
239 }
240
241 pub fn set_texture<P: IsA<gdk::Texture>>(&self, texture: Option<&P>) {
242 ObjectExt::set_property(self, "texture", texture)
243 }
244
245 #[doc(alias = "gicon")]
246 pub fn connect_gicon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
247 unsafe extern "C" fn notify_gicon_trampoline<F: Fn(&CellRendererPixbuf) + 'static>(
248 this: *mut ffi::GtkCellRendererPixbuf,
249 _param_spec: glib::ffi::gpointer,
250 f: glib::ffi::gpointer,
251 ) {
252 unsafe {
253 let f: &F = &*(f as *const F);
254 f(&from_glib_borrow(this))
255 }
256 }
257 unsafe {
258 let f: Box_<F> = Box_::new(f);
259 connect_raw(
260 self.as_ptr() as *mut _,
261 c"notify::gicon".as_ptr(),
262 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
263 notify_gicon_trampoline::<F> as *const (),
264 )),
265 Box_::into_raw(f),
266 )
267 }
268 }
269
270 #[doc(alias = "icon-name")]
271 pub fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
272 unsafe extern "C" fn notify_icon_name_trampoline<F: Fn(&CellRendererPixbuf) + 'static>(
273 this: *mut ffi::GtkCellRendererPixbuf,
274 _param_spec: glib::ffi::gpointer,
275 f: glib::ffi::gpointer,
276 ) {
277 unsafe {
278 let f: &F = &*(f as *const F);
279 f(&from_glib_borrow(this))
280 }
281 }
282 unsafe {
283 let f: Box_<F> = Box_::new(f);
284 connect_raw(
285 self.as_ptr() as *mut _,
286 c"notify::icon-name".as_ptr(),
287 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
288 notify_icon_name_trampoline::<F> as *const (),
289 )),
290 Box_::into_raw(f),
291 )
292 }
293 }
294
295 #[doc(alias = "icon-size")]
296 pub fn connect_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
297 unsafe extern "C" fn notify_icon_size_trampoline<F: Fn(&CellRendererPixbuf) + 'static>(
298 this: *mut ffi::GtkCellRendererPixbuf,
299 _param_spec: glib::ffi::gpointer,
300 f: glib::ffi::gpointer,
301 ) {
302 unsafe {
303 let f: &F = &*(f as *const F);
304 f(&from_glib_borrow(this))
305 }
306 }
307 unsafe {
308 let f: Box_<F> = Box_::new(f);
309 connect_raw(
310 self.as_ptr() as *mut _,
311 c"notify::icon-size".as_ptr(),
312 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
313 notify_icon_size_trampoline::<F> as *const (),
314 )),
315 Box_::into_raw(f),
316 )
317 }
318 }
319
320 #[doc(alias = "pixbuf")]
321 pub fn connect_pixbuf_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
322 unsafe extern "C" fn notify_pixbuf_trampoline<F: Fn(&CellRendererPixbuf) + 'static>(
323 this: *mut ffi::GtkCellRendererPixbuf,
324 _param_spec: glib::ffi::gpointer,
325 f: glib::ffi::gpointer,
326 ) {
327 unsafe {
328 let f: &F = &*(f as *const F);
329 f(&from_glib_borrow(this))
330 }
331 }
332 unsafe {
333 let f: Box_<F> = Box_::new(f);
334 connect_raw(
335 self.as_ptr() as *mut _,
336 c"notify::pixbuf".as_ptr(),
337 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
338 notify_pixbuf_trampoline::<F> as *const (),
339 )),
340 Box_::into_raw(f),
341 )
342 }
343 }
344
345 #[doc(alias = "pixbuf-expander-closed")]
346 pub fn connect_pixbuf_expander_closed_notify<F: Fn(&Self) + 'static>(
347 &self,
348 f: F,
349 ) -> SignalHandlerId {
350 unsafe extern "C" fn notify_pixbuf_expander_closed_trampoline<
351 F: Fn(&CellRendererPixbuf) + 'static,
352 >(
353 this: *mut ffi::GtkCellRendererPixbuf,
354 _param_spec: glib::ffi::gpointer,
355 f: glib::ffi::gpointer,
356 ) {
357 unsafe {
358 let f: &F = &*(f as *const F);
359 f(&from_glib_borrow(this))
360 }
361 }
362 unsafe {
363 let f: Box_<F> = Box_::new(f);
364 connect_raw(
365 self.as_ptr() as *mut _,
366 c"notify::pixbuf-expander-closed".as_ptr(),
367 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
368 notify_pixbuf_expander_closed_trampoline::<F> as *const (),
369 )),
370 Box_::into_raw(f),
371 )
372 }
373 }
374
375 #[doc(alias = "pixbuf-expander-open")]
376 pub fn connect_pixbuf_expander_open_notify<F: Fn(&Self) + 'static>(
377 &self,
378 f: F,
379 ) -> SignalHandlerId {
380 unsafe extern "C" fn notify_pixbuf_expander_open_trampoline<
381 F: Fn(&CellRendererPixbuf) + 'static,
382 >(
383 this: *mut ffi::GtkCellRendererPixbuf,
384 _param_spec: glib::ffi::gpointer,
385 f: glib::ffi::gpointer,
386 ) {
387 unsafe {
388 let f: &F = &*(f as *const F);
389 f(&from_glib_borrow(this))
390 }
391 }
392 unsafe {
393 let f: Box_<F> = Box_::new(f);
394 connect_raw(
395 self.as_ptr() as *mut _,
396 c"notify::pixbuf-expander-open".as_ptr(),
397 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
398 notify_pixbuf_expander_open_trampoline::<F> as *const (),
399 )),
400 Box_::into_raw(f),
401 )
402 }
403 }
404
405 #[doc(alias = "texture")]
406 pub fn connect_texture_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
407 unsafe extern "C" fn notify_texture_trampoline<F: Fn(&CellRendererPixbuf) + 'static>(
408 this: *mut ffi::GtkCellRendererPixbuf,
409 _param_spec: glib::ffi::gpointer,
410 f: glib::ffi::gpointer,
411 ) {
412 unsafe {
413 let f: &F = &*(f as *const F);
414 f(&from_glib_borrow(this))
415 }
416 }
417 unsafe {
418 let f: Box_<F> = Box_::new(f);
419 connect_raw(
420 self.as_ptr() as *mut _,
421 c"notify::texture".as_ptr(),
422 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
423 notify_texture_trampoline::<F> as *const (),
424 )),
425 Box_::into_raw(f),
426 )
427 }
428 }
429}
430
431impl Default for CellRendererPixbuf {
432 fn default() -> Self {
433 Self::new()
434 }
435}
436
437#[must_use = "The builder must be built to be used"]
442pub struct CellRendererPixbufBuilder {
443 builder: glib::object::ObjectBuilder<'static, CellRendererPixbuf>,
444}
445
446impl CellRendererPixbufBuilder {
447 fn new() -> Self {
448 Self {
449 builder: glib::object::Object::builder(),
450 }
451 }
452
453 pub fn gicon(self, gicon: &impl IsA<gio::Icon>) -> Self {
457 Self {
458 builder: self.builder.property("gicon", gicon.clone().upcast()),
459 }
460 }
461
462 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
465 Self {
466 builder: self.builder.property("icon-name", icon_name.into()),
467 }
468 }
469
470 pub fn icon_size(self, icon_size: IconSize) -> Self {
472 Self {
473 builder: self.builder.property("icon-size", icon_size),
474 }
475 }
476
477 pub fn pixbuf(self, pixbuf: &gdk_pixbuf::Pixbuf) -> Self {
478 Self {
479 builder: self.builder.property("pixbuf", pixbuf.clone()),
480 }
481 }
482
483 pub fn pixbuf_expander_closed(self, pixbuf_expander_closed: &gdk_pixbuf::Pixbuf) -> Self {
484 Self {
485 builder: self
486 .builder
487 .property("pixbuf-expander-closed", pixbuf_expander_closed.clone()),
488 }
489 }
490
491 pub fn pixbuf_expander_open(self, pixbuf_expander_open: &gdk_pixbuf::Pixbuf) -> Self {
492 Self {
493 builder: self
494 .builder
495 .property("pixbuf-expander-open", pixbuf_expander_open.clone()),
496 }
497 }
498
499 pub fn texture(self, texture: &impl IsA<gdk::Texture>) -> Self {
500 Self {
501 builder: self.builder.property("texture", texture.clone().upcast()),
502 }
503 }
504
505 pub fn cell_background(self, cell_background: impl Into<glib::GString>) -> Self {
506 Self {
507 builder: self
508 .builder
509 .property("cell-background", cell_background.into()),
510 }
511 }
512
513 pub fn cell_background_rgba(self, cell_background_rgba: &gdk::RGBA) -> Self {
515 Self {
516 builder: self
517 .builder
518 .property("cell-background-rgba", cell_background_rgba),
519 }
520 }
521
522 pub fn cell_background_set(self, cell_background_set: bool) -> Self {
523 Self {
524 builder: self
525 .builder
526 .property("cell-background-set", cell_background_set),
527 }
528 }
529
530 pub fn height(self, height: i32) -> Self {
531 Self {
532 builder: self.builder.property("height", height),
533 }
534 }
535
536 pub fn is_expanded(self, is_expanded: bool) -> Self {
537 Self {
538 builder: self.builder.property("is-expanded", is_expanded),
539 }
540 }
541
542 pub fn is_expander(self, is_expander: bool) -> Self {
543 Self {
544 builder: self.builder.property("is-expander", is_expander),
545 }
546 }
547
548 pub fn mode(self, mode: CellRendererMode) -> Self {
549 Self {
550 builder: self.builder.property("mode", mode),
551 }
552 }
553
554 pub fn sensitive(self, sensitive: bool) -> Self {
555 Self {
556 builder: self.builder.property("sensitive", sensitive),
557 }
558 }
559
560 pub fn visible(self, visible: bool) -> Self {
561 Self {
562 builder: self.builder.property("visible", visible),
563 }
564 }
565
566 pub fn width(self, width: i32) -> Self {
567 Self {
568 builder: self.builder.property("width", width),
569 }
570 }
571
572 pub fn xalign(self, xalign: f32) -> Self {
573 Self {
574 builder: self.builder.property("xalign", xalign),
575 }
576 }
577
578 pub fn xpad(self, xpad: u32) -> Self {
579 Self {
580 builder: self.builder.property("xpad", xpad),
581 }
582 }
583
584 pub fn yalign(self, yalign: f32) -> Self {
585 Self {
586 builder: self.builder.property("yalign", yalign),
587 }
588 }
589
590 pub fn ypad(self, ypad: u32) -> Self {
591 Self {
592 builder: self.builder.property("ypad", ypad),
593 }
594 }
595
596 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
599 pub fn build(self) -> CellRendererPixbuf {
600 assert_initialized_main_thread!();
601 self.builder.build()
602 }
603}