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