1use crate::{CellRenderer, CellRendererMode};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute};
12
13glib::wrapper! {
14 #[doc(alias = "GtkCellRendererPixbuf")]
156 pub struct CellRendererPixbuf(Object<ffi::GtkCellRendererPixbuf, ffi::GtkCellRendererPixbufClass>) @extends CellRenderer;
157
158 match fn {
159 type_ => || ffi::gtk_cell_renderer_pixbuf_get_type(),
160 }
161}
162
163impl CellRendererPixbuf {
164 pub const NONE: Option<&'static CellRendererPixbuf> = None;
165
166 #[doc(alias = "gtk_cell_renderer_pixbuf_new")]
178 pub fn new() -> CellRendererPixbuf {
179 assert_initialized_main_thread!();
180 unsafe { CellRenderer::from_glib_none(ffi::gtk_cell_renderer_pixbuf_new()).unsafe_cast() }
181 }
182
183 pub fn builder() -> CellRendererPixbufBuilder {
188 CellRendererPixbufBuilder::new()
189 }
190}
191
192impl Default for CellRendererPixbuf {
193 fn default() -> Self {
194 Self::new()
195 }
196}
197
198#[must_use = "The builder must be built to be used"]
203pub struct CellRendererPixbufBuilder {
204 builder: glib::object::ObjectBuilder<'static, CellRendererPixbuf>,
205}
206
207impl CellRendererPixbufBuilder {
208 fn new() -> Self {
209 Self {
210 builder: glib::object::Object::builder(),
211 }
212 }
213
214 pub fn gicon(self, gicon: &impl IsA<gio::Icon>) -> Self {
218 Self {
219 builder: self.builder.property("gicon", gicon.clone().upcast()),
220 }
221 }
222
223 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
227 Self {
228 builder: self.builder.property("icon-name", icon_name.into()),
229 }
230 }
231
232 pub fn pixbuf(self, pixbuf: &gdk_pixbuf::Pixbuf) -> Self {
233 Self {
234 builder: self.builder.property("pixbuf", pixbuf.clone()),
235 }
236 }
237
238 pub fn pixbuf_expander_closed(self, pixbuf_expander_closed: &gdk_pixbuf::Pixbuf) -> Self {
239 Self {
240 builder: self
241 .builder
242 .property("pixbuf-expander-closed", pixbuf_expander_closed.clone()),
243 }
244 }
245
246 pub fn pixbuf_expander_open(self, pixbuf_expander_open: &gdk_pixbuf::Pixbuf) -> Self {
247 Self {
248 builder: self
249 .builder
250 .property("pixbuf-expander-open", pixbuf_expander_open.clone()),
251 }
252 }
253
254 pub fn stock_detail(self, stock_detail: impl Into<glib::GString>) -> Self {
255 Self {
256 builder: self.builder.property("stock-detail", stock_detail.into()),
257 }
258 }
259
260 pub fn stock_size(self, stock_size: u32) -> Self {
262 Self {
263 builder: self.builder.property("stock-size", stock_size),
264 }
265 }
266
267 pub fn surface(self, surface: &cairo::Surface) -> Self {
268 Self {
269 builder: self.builder.property("surface", surface),
270 }
271 }
272
273 pub fn cell_background(self, cell_background: impl Into<glib::GString>) -> Self {
274 Self {
275 builder: self
276 .builder
277 .property("cell-background", cell_background.into()),
278 }
279 }
280
281 pub fn cell_background_rgba(self, cell_background_rgba: &gdk::RGBA) -> Self {
283 Self {
284 builder: self
285 .builder
286 .property("cell-background-rgba", cell_background_rgba),
287 }
288 }
289
290 pub fn cell_background_set(self, cell_background_set: bool) -> Self {
291 Self {
292 builder: self
293 .builder
294 .property("cell-background-set", cell_background_set),
295 }
296 }
297
298 pub fn height(self, height: i32) -> Self {
299 Self {
300 builder: self.builder.property("height", height),
301 }
302 }
303
304 pub fn is_expanded(self, is_expanded: bool) -> Self {
305 Self {
306 builder: self.builder.property("is-expanded", is_expanded),
307 }
308 }
309
310 pub fn is_expander(self, is_expander: bool) -> Self {
311 Self {
312 builder: self.builder.property("is-expander", is_expander),
313 }
314 }
315
316 pub fn mode(self, mode: CellRendererMode) -> Self {
317 Self {
318 builder: self.builder.property("mode", mode),
319 }
320 }
321
322 pub fn sensitive(self, sensitive: bool) -> Self {
323 Self {
324 builder: self.builder.property("sensitive", sensitive),
325 }
326 }
327
328 pub fn visible(self, visible: bool) -> Self {
329 Self {
330 builder: self.builder.property("visible", visible),
331 }
332 }
333
334 pub fn width(self, width: i32) -> Self {
335 Self {
336 builder: self.builder.property("width", width),
337 }
338 }
339
340 pub fn xalign(self, xalign: f32) -> Self {
341 Self {
342 builder: self.builder.property("xalign", xalign),
343 }
344 }
345
346 pub fn xpad(self, xpad: u32) -> Self {
347 Self {
348 builder: self.builder.property("xpad", xpad),
349 }
350 }
351
352 pub fn yalign(self, yalign: f32) -> Self {
353 Self {
354 builder: self.builder.property("yalign", yalign),
355 }
356 }
357
358 pub fn ypad(self, ypad: u32) -> Self {
359 Self {
360 builder: self.builder.property("ypad", ypad),
361 }
362 }
363
364 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
367 pub fn build(self) -> CellRendererPixbuf {
368 self.builder.build()
369 }
370}
371
372mod sealed {
373 pub trait Sealed {}
374 impl<T: super::IsA<super::CellRendererPixbuf>> Sealed for T {}
375}
376
377pub trait CellRendererPixbufExt: IsA<CellRendererPixbuf> + sealed::Sealed + 'static {
383 fn gicon(&self) -> Option<gio::Icon> {
387 ObjectExt::property(self.as_ref(), "gicon")
388 }
389
390 fn set_gicon<P: IsA<gio::Icon>>(&self, gicon: Option<&P>) {
394 ObjectExt::set_property(self.as_ref(), "gicon", gicon)
395 }
396
397 #[doc(alias = "icon-name")]
401 fn icon_name(&self) -> Option<glib::GString> {
402 ObjectExt::property(self.as_ref(), "icon-name")
403 }
404
405 #[doc(alias = "icon-name")]
409 fn set_icon_name(&self, icon_name: Option<&str>) {
410 ObjectExt::set_property(self.as_ref(), "icon-name", icon_name)
411 }
412
413 fn pixbuf(&self) -> Option<gdk_pixbuf::Pixbuf> {
414 ObjectExt::property(self.as_ref(), "pixbuf")
415 }
416
417 fn set_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>) {
418 ObjectExt::set_property(self.as_ref(), "pixbuf", pixbuf)
419 }
420
421 #[doc(alias = "pixbuf-expander-closed")]
422 fn pixbuf_expander_closed(&self) -> Option<gdk_pixbuf::Pixbuf> {
423 ObjectExt::property(self.as_ref(), "pixbuf-expander-closed")
424 }
425
426 #[doc(alias = "pixbuf-expander-closed")]
427 fn set_pixbuf_expander_closed(&self, pixbuf_expander_closed: Option<&gdk_pixbuf::Pixbuf>) {
428 ObjectExt::set_property(
429 self.as_ref(),
430 "pixbuf-expander-closed",
431 pixbuf_expander_closed,
432 )
433 }
434
435 #[doc(alias = "pixbuf-expander-open")]
436 fn pixbuf_expander_open(&self) -> Option<gdk_pixbuf::Pixbuf> {
437 ObjectExt::property(self.as_ref(), "pixbuf-expander-open")
438 }
439
440 #[doc(alias = "pixbuf-expander-open")]
441 fn set_pixbuf_expander_open(&self, pixbuf_expander_open: Option<&gdk_pixbuf::Pixbuf>) {
442 ObjectExt::set_property(self.as_ref(), "pixbuf-expander-open", pixbuf_expander_open)
443 }
444
445 #[doc(alias = "stock-detail")]
446 fn stock_detail(&self) -> Option<glib::GString> {
447 ObjectExt::property(self.as_ref(), "stock-detail")
448 }
449
450 #[doc(alias = "stock-detail")]
451 fn set_stock_detail(&self, stock_detail: Option<&str>) {
452 ObjectExt::set_property(self.as_ref(), "stock-detail", stock_detail)
453 }
454
455 fn surface(&self) -> Option<cairo::Surface> {
456 ObjectExt::property(self.as_ref(), "surface")
457 }
458
459 fn set_surface(&self, surface: Option<&cairo::Surface>) {
460 ObjectExt::set_property(self.as_ref(), "surface", surface)
461 }
462
463 #[doc(alias = "gicon")]
464 fn connect_gicon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
465 unsafe extern "C" fn notify_gicon_trampoline<
466 P: IsA<CellRendererPixbuf>,
467 F: Fn(&P) + 'static,
468 >(
469 this: *mut ffi::GtkCellRendererPixbuf,
470 _param_spec: glib::ffi::gpointer,
471 f: glib::ffi::gpointer,
472 ) {
473 let f: &F = &*(f as *const F);
474 f(CellRendererPixbuf::from_glib_borrow(this).unsafe_cast_ref())
475 }
476 unsafe {
477 let f: Box_<F> = Box_::new(f);
478 connect_raw(
479 self.as_ptr() as *mut _,
480 b"notify::gicon\0".as_ptr() as *const _,
481 Some(transmute::<_, unsafe extern "C" fn()>(
482 notify_gicon_trampoline::<Self, F> as *const (),
483 )),
484 Box_::into_raw(f),
485 )
486 }
487 }
488
489 #[doc(alias = "icon-name")]
490 fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
491 unsafe extern "C" fn notify_icon_name_trampoline<
492 P: IsA<CellRendererPixbuf>,
493 F: Fn(&P) + 'static,
494 >(
495 this: *mut ffi::GtkCellRendererPixbuf,
496 _param_spec: glib::ffi::gpointer,
497 f: glib::ffi::gpointer,
498 ) {
499 let f: &F = &*(f as *const F);
500 f(CellRendererPixbuf::from_glib_borrow(this).unsafe_cast_ref())
501 }
502 unsafe {
503 let f: Box_<F> = Box_::new(f);
504 connect_raw(
505 self.as_ptr() as *mut _,
506 b"notify::icon-name\0".as_ptr() as *const _,
507 Some(transmute::<_, unsafe extern "C" fn()>(
508 notify_icon_name_trampoline::<Self, F> as *const (),
509 )),
510 Box_::into_raw(f),
511 )
512 }
513 }
514
515 #[doc(alias = "pixbuf")]
516 fn connect_pixbuf_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
517 unsafe extern "C" fn notify_pixbuf_trampoline<
518 P: IsA<CellRendererPixbuf>,
519 F: Fn(&P) + 'static,
520 >(
521 this: *mut ffi::GtkCellRendererPixbuf,
522 _param_spec: glib::ffi::gpointer,
523 f: glib::ffi::gpointer,
524 ) {
525 let f: &F = &*(f as *const F);
526 f(CellRendererPixbuf::from_glib_borrow(this).unsafe_cast_ref())
527 }
528 unsafe {
529 let f: Box_<F> = Box_::new(f);
530 connect_raw(
531 self.as_ptr() as *mut _,
532 b"notify::pixbuf\0".as_ptr() as *const _,
533 Some(transmute::<_, unsafe extern "C" fn()>(
534 notify_pixbuf_trampoline::<Self, F> as *const (),
535 )),
536 Box_::into_raw(f),
537 )
538 }
539 }
540
541 #[doc(alias = "pixbuf-expander-closed")]
542 fn connect_pixbuf_expander_closed_notify<F: Fn(&Self) + 'static>(
543 &self,
544 f: F,
545 ) -> SignalHandlerId {
546 unsafe extern "C" fn notify_pixbuf_expander_closed_trampoline<
547 P: IsA<CellRendererPixbuf>,
548 F: Fn(&P) + 'static,
549 >(
550 this: *mut ffi::GtkCellRendererPixbuf,
551 _param_spec: glib::ffi::gpointer,
552 f: glib::ffi::gpointer,
553 ) {
554 let f: &F = &*(f as *const F);
555 f(CellRendererPixbuf::from_glib_borrow(this).unsafe_cast_ref())
556 }
557 unsafe {
558 let f: Box_<F> = Box_::new(f);
559 connect_raw(
560 self.as_ptr() as *mut _,
561 b"notify::pixbuf-expander-closed\0".as_ptr() as *const _,
562 Some(transmute::<_, unsafe extern "C" fn()>(
563 notify_pixbuf_expander_closed_trampoline::<Self, F> as *const (),
564 )),
565 Box_::into_raw(f),
566 )
567 }
568 }
569
570 #[doc(alias = "pixbuf-expander-open")]
571 fn connect_pixbuf_expander_open_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
572 unsafe extern "C" fn notify_pixbuf_expander_open_trampoline<
573 P: IsA<CellRendererPixbuf>,
574 F: Fn(&P) + 'static,
575 >(
576 this: *mut ffi::GtkCellRendererPixbuf,
577 _param_spec: glib::ffi::gpointer,
578 f: glib::ffi::gpointer,
579 ) {
580 let f: &F = &*(f as *const F);
581 f(CellRendererPixbuf::from_glib_borrow(this).unsafe_cast_ref())
582 }
583 unsafe {
584 let f: Box_<F> = Box_::new(f);
585 connect_raw(
586 self.as_ptr() as *mut _,
587 b"notify::pixbuf-expander-open\0".as_ptr() as *const _,
588 Some(transmute::<_, unsafe extern "C" fn()>(
589 notify_pixbuf_expander_open_trampoline::<Self, F> as *const (),
590 )),
591 Box_::into_raw(f),
592 )
593 }
594 }
595
596 #[doc(alias = "stock-detail")]
597 fn connect_stock_detail_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
598 unsafe extern "C" fn notify_stock_detail_trampoline<
599 P: IsA<CellRendererPixbuf>,
600 F: Fn(&P) + 'static,
601 >(
602 this: *mut ffi::GtkCellRendererPixbuf,
603 _param_spec: glib::ffi::gpointer,
604 f: glib::ffi::gpointer,
605 ) {
606 let f: &F = &*(f as *const F);
607 f(CellRendererPixbuf::from_glib_borrow(this).unsafe_cast_ref())
608 }
609 unsafe {
610 let f: Box_<F> = Box_::new(f);
611 connect_raw(
612 self.as_ptr() as *mut _,
613 b"notify::stock-detail\0".as_ptr() as *const _,
614 Some(transmute::<_, unsafe extern "C" fn()>(
615 notify_stock_detail_trampoline::<Self, F> as *const (),
616 )),
617 Box_::into_raw(f),
618 )
619 }
620 }
621
622 #[doc(alias = "stock-size")]
623 fn connect_stock_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
624 unsafe extern "C" fn notify_stock_size_trampoline<
625 P: IsA<CellRendererPixbuf>,
626 F: Fn(&P) + 'static,
627 >(
628 this: *mut ffi::GtkCellRendererPixbuf,
629 _param_spec: glib::ffi::gpointer,
630 f: glib::ffi::gpointer,
631 ) {
632 let f: &F = &*(f as *const F);
633 f(CellRendererPixbuf::from_glib_borrow(this).unsafe_cast_ref())
634 }
635 unsafe {
636 let f: Box_<F> = Box_::new(f);
637 connect_raw(
638 self.as_ptr() as *mut _,
639 b"notify::stock-size\0".as_ptr() as *const _,
640 Some(transmute::<_, unsafe extern "C" fn()>(
641 notify_stock_size_trampoline::<Self, F> as *const (),
642 )),
643 Box_::into_raw(f),
644 )
645 }
646 }
647
648 #[doc(alias = "surface")]
649 fn connect_surface_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
650 unsafe extern "C" fn notify_surface_trampoline<
651 P: IsA<CellRendererPixbuf>,
652 F: Fn(&P) + 'static,
653 >(
654 this: *mut ffi::GtkCellRendererPixbuf,
655 _param_spec: glib::ffi::gpointer,
656 f: glib::ffi::gpointer,
657 ) {
658 let f: &F = &*(f as *const F);
659 f(CellRendererPixbuf::from_glib_borrow(this).unsafe_cast_ref())
660 }
661 unsafe {
662 let f: Box_<F> = Box_::new(f);
663 connect_raw(
664 self.as_ptr() as *mut _,
665 b"notify::surface\0".as_ptr() as *const _,
666 Some(transmute::<_, unsafe extern "C" fn()>(
667 notify_surface_trampoline::<Self, F> as *const (),
668 )),
669 Box_::into_raw(f),
670 )
671 }
672 }
673}
674
675impl<O: IsA<CellRendererPixbuf>> CellRendererPixbufExt for O {}
676
677impl fmt::Display for CellRendererPixbuf {
678 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
679 f.write_str("CellRendererPixbuf")
680 }
681}