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")]
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 let f: &F = &*(f as *const F);
257 f(&from_glib_borrow(this))
258 }
259 unsafe {
260 let f: Box_<F> = Box_::new(f);
261 connect_raw(
262 self.as_ptr() as *mut _,
263 b"notify::gicon\0".as_ptr() as *const _,
264 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
265 notify_gicon_trampoline::<F> as *const (),
266 )),
267 Box_::into_raw(f),
268 )
269 }
270 }
271
272 #[doc(alias = "icon-name")]
273 pub fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
274 unsafe extern "C" fn notify_icon_name_trampoline<F: Fn(&CellRendererPixbuf) + 'static>(
275 this: *mut ffi::GtkCellRendererPixbuf,
276 _param_spec: glib::ffi::gpointer,
277 f: glib::ffi::gpointer,
278 ) {
279 let f: &F = &*(f as *const F);
280 f(&from_glib_borrow(this))
281 }
282 unsafe {
283 let f: Box_<F> = Box_::new(f);
284 connect_raw(
285 self.as_ptr() as *mut _,
286 b"notify::icon-name\0".as_ptr() as *const _,
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 let f: &F = &*(f as *const F);
303 f(&from_glib_borrow(this))
304 }
305 unsafe {
306 let f: Box_<F> = Box_::new(f);
307 connect_raw(
308 self.as_ptr() as *mut _,
309 b"notify::icon-size\0".as_ptr() as *const _,
310 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
311 notify_icon_size_trampoline::<F> as *const (),
312 )),
313 Box_::into_raw(f),
314 )
315 }
316 }
317
318 #[doc(alias = "pixbuf")]
319 pub fn connect_pixbuf_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
320 unsafe extern "C" fn notify_pixbuf_trampoline<F: Fn(&CellRendererPixbuf) + 'static>(
321 this: *mut ffi::GtkCellRendererPixbuf,
322 _param_spec: glib::ffi::gpointer,
323 f: glib::ffi::gpointer,
324 ) {
325 let f: &F = &*(f as *const F);
326 f(&from_glib_borrow(this))
327 }
328 unsafe {
329 let f: Box_<F> = Box_::new(f);
330 connect_raw(
331 self.as_ptr() as *mut _,
332 b"notify::pixbuf\0".as_ptr() as *const _,
333 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
334 notify_pixbuf_trampoline::<F> as *const (),
335 )),
336 Box_::into_raw(f),
337 )
338 }
339 }
340
341 #[doc(alias = "pixbuf-expander-closed")]
342 pub fn connect_pixbuf_expander_closed_notify<F: Fn(&Self) + 'static>(
343 &self,
344 f: F,
345 ) -> SignalHandlerId {
346 unsafe extern "C" fn notify_pixbuf_expander_closed_trampoline<
347 F: Fn(&CellRendererPixbuf) + 'static,
348 >(
349 this: *mut ffi::GtkCellRendererPixbuf,
350 _param_spec: glib::ffi::gpointer,
351 f: glib::ffi::gpointer,
352 ) {
353 let f: &F = &*(f as *const F);
354 f(&from_glib_borrow(this))
355 }
356 unsafe {
357 let f: Box_<F> = Box_::new(f);
358 connect_raw(
359 self.as_ptr() as *mut _,
360 b"notify::pixbuf-expander-closed\0".as_ptr() as *const _,
361 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
362 notify_pixbuf_expander_closed_trampoline::<F> as *const (),
363 )),
364 Box_::into_raw(f),
365 )
366 }
367 }
368
369 #[doc(alias = "pixbuf-expander-open")]
370 pub fn connect_pixbuf_expander_open_notify<F: Fn(&Self) + 'static>(
371 &self,
372 f: F,
373 ) -> SignalHandlerId {
374 unsafe extern "C" fn notify_pixbuf_expander_open_trampoline<
375 F: Fn(&CellRendererPixbuf) + 'static,
376 >(
377 this: *mut ffi::GtkCellRendererPixbuf,
378 _param_spec: glib::ffi::gpointer,
379 f: glib::ffi::gpointer,
380 ) {
381 let f: &F = &*(f as *const F);
382 f(&from_glib_borrow(this))
383 }
384 unsafe {
385 let f: Box_<F> = Box_::new(f);
386 connect_raw(
387 self.as_ptr() as *mut _,
388 b"notify::pixbuf-expander-open\0".as_ptr() as *const _,
389 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
390 notify_pixbuf_expander_open_trampoline::<F> as *const (),
391 )),
392 Box_::into_raw(f),
393 )
394 }
395 }
396
397 #[doc(alias = "texture")]
398 pub fn connect_texture_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
399 unsafe extern "C" fn notify_texture_trampoline<F: Fn(&CellRendererPixbuf) + 'static>(
400 this: *mut ffi::GtkCellRendererPixbuf,
401 _param_spec: glib::ffi::gpointer,
402 f: glib::ffi::gpointer,
403 ) {
404 let f: &F = &*(f as *const F);
405 f(&from_glib_borrow(this))
406 }
407 unsafe {
408 let f: Box_<F> = Box_::new(f);
409 connect_raw(
410 self.as_ptr() as *mut _,
411 b"notify::texture\0".as_ptr() as *const _,
412 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
413 notify_texture_trampoline::<F> as *const (),
414 )),
415 Box_::into_raw(f),
416 )
417 }
418 }
419}
420
421impl Default for CellRendererPixbuf {
422 fn default() -> Self {
423 Self::new()
424 }
425}
426
427#[must_use = "The builder must be built to be used"]
432pub struct CellRendererPixbufBuilder {
433 builder: glib::object::ObjectBuilder<'static, CellRendererPixbuf>,
434}
435
436impl CellRendererPixbufBuilder {
437 fn new() -> Self {
438 Self {
439 builder: glib::object::Object::builder(),
440 }
441 }
442
443 pub fn gicon(self, gicon: &impl IsA<gio::Icon>) -> Self {
447 Self {
448 builder: self.builder.property("gicon", gicon.clone().upcast()),
449 }
450 }
451
452 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
455 Self {
456 builder: self.builder.property("icon-name", icon_name.into()),
457 }
458 }
459
460 pub fn icon_size(self, icon_size: IconSize) -> Self {
462 Self {
463 builder: self.builder.property("icon-size", icon_size),
464 }
465 }
466
467 pub fn pixbuf(self, pixbuf: &gdk_pixbuf::Pixbuf) -> Self {
468 Self {
469 builder: self.builder.property("pixbuf", pixbuf.clone()),
470 }
471 }
472
473 pub fn pixbuf_expander_closed(self, pixbuf_expander_closed: &gdk_pixbuf::Pixbuf) -> Self {
474 Self {
475 builder: self
476 .builder
477 .property("pixbuf-expander-closed", pixbuf_expander_closed.clone()),
478 }
479 }
480
481 pub fn pixbuf_expander_open(self, pixbuf_expander_open: &gdk_pixbuf::Pixbuf) -> Self {
482 Self {
483 builder: self
484 .builder
485 .property("pixbuf-expander-open", pixbuf_expander_open.clone()),
486 }
487 }
488
489 pub fn texture(self, texture: &impl IsA<gdk::Texture>) -> Self {
490 Self {
491 builder: self.builder.property("texture", texture.clone().upcast()),
492 }
493 }
494
495 pub fn cell_background(self, cell_background: impl Into<glib::GString>) -> Self {
496 Self {
497 builder: self
498 .builder
499 .property("cell-background", cell_background.into()),
500 }
501 }
502
503 pub fn cell_background_rgba(self, cell_background_rgba: &gdk::RGBA) -> Self {
505 Self {
506 builder: self
507 .builder
508 .property("cell-background-rgba", cell_background_rgba),
509 }
510 }
511
512 pub fn cell_background_set(self, cell_background_set: bool) -> Self {
513 Self {
514 builder: self
515 .builder
516 .property("cell-background-set", cell_background_set),
517 }
518 }
519
520 pub fn height(self, height: i32) -> Self {
521 Self {
522 builder: self.builder.property("height", height),
523 }
524 }
525
526 pub fn is_expanded(self, is_expanded: bool) -> Self {
527 Self {
528 builder: self.builder.property("is-expanded", is_expanded),
529 }
530 }
531
532 pub fn is_expander(self, is_expander: bool) -> Self {
533 Self {
534 builder: self.builder.property("is-expander", is_expander),
535 }
536 }
537
538 pub fn mode(self, mode: CellRendererMode) -> Self {
539 Self {
540 builder: self.builder.property("mode", mode),
541 }
542 }
543
544 pub fn sensitive(self, sensitive: bool) -> Self {
545 Self {
546 builder: self.builder.property("sensitive", sensitive),
547 }
548 }
549
550 pub fn visible(self, visible: bool) -> Self {
551 Self {
552 builder: self.builder.property("visible", visible),
553 }
554 }
555
556 pub fn width(self, width: i32) -> Self {
557 Self {
558 builder: self.builder.property("width", width),
559 }
560 }
561
562 pub fn xalign(self, xalign: f32) -> Self {
563 Self {
564 builder: self.builder.property("xalign", xalign),
565 }
566 }
567
568 pub fn xpad(self, xpad: u32) -> Self {
569 Self {
570 builder: self.builder.property("xpad", xpad),
571 }
572 }
573
574 pub fn yalign(self, yalign: f32) -> Self {
575 Self {
576 builder: self.builder.property("yalign", yalign),
577 }
578 }
579
580 pub fn ypad(self, ypad: u32) -> Self {
581 Self {
582 builder: self.builder.property("ypad", ypad),
583 }
584 }
585
586 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
589 pub fn build(self) -> CellRendererPixbuf {
590 assert_initialized_main_thread!();
591 self.builder.build()
592 }
593}