1 // This file was generated by gir (https://github.com/gtk-rs/gir) 2 // from gir-files (https://github.com/gtk-rs/gir-files) 3 // DO NOT EDIT 4 5 use cairo; 6 use gdk; 7 use gdk_pixbuf; 8 use gio; 9 use glib::object::Cast; 10 use glib::object::IsA; 11 use glib::signal::connect_raw; 12 use glib::signal::SignalHandlerId; 13 use glib::translate::*; 14 use glib::value::SetValueOptional; 15 use glib::GString; 16 use glib::StaticType; 17 use glib::ToValue; 18 use glib::Value; 19 use glib_sys; 20 use gobject_sys; 21 use gtk_sys; 22 use std; 23 use std::boxed::Box as Box_; 24 use std::fmt; 25 use std::mem; 26 use std::mem::transmute; 27 use std::ptr; 28 use Align; 29 use Buildable; 30 use Container; 31 use IconSize; 32 use ImageType; 33 use Misc; 34 use Widget; 35 36 glib_wrapper! { 37 pub struct Image(Object<gtk_sys::GtkImage, gtk_sys::GtkImageClass, ImageClass>) @extends Misc, Widget, @implements Buildable; 38 39 match fn { 40 get_type => || gtk_sys::gtk_image_get_type(), 41 } 42 } 43 44 impl Image { new() -> Image45 pub fn new() -> Image { 46 assert_initialized_main_thread!(); 47 unsafe { Widget::from_glib_none(gtk_sys::gtk_image_new()).unsafe_cast() } 48 } 49 new_from_animation<P: IsA<gdk_pixbuf::PixbufAnimation>>(animation: &P) -> Image50 pub fn new_from_animation<P: IsA<gdk_pixbuf::PixbufAnimation>>(animation: &P) -> Image { 51 assert_initialized_main_thread!(); 52 unsafe { 53 Widget::from_glib_none(gtk_sys::gtk_image_new_from_animation( 54 animation.as_ref().to_glib_none().0, 55 )) 56 .unsafe_cast() 57 } 58 } 59 new_from_file<P: AsRef<std::path::Path>>(filename: P) -> Image60 pub fn new_from_file<P: AsRef<std::path::Path>>(filename: P) -> Image { 61 assert_initialized_main_thread!(); 62 unsafe { 63 Widget::from_glib_none(gtk_sys::gtk_image_new_from_file( 64 filename.as_ref().to_glib_none().0, 65 )) 66 .unsafe_cast() 67 } 68 } 69 new_from_gicon<P: IsA<gio::Icon>>(icon: &P, size: IconSize) -> Image70 pub fn new_from_gicon<P: IsA<gio::Icon>>(icon: &P, size: IconSize) -> Image { 71 assert_initialized_main_thread!(); 72 unsafe { 73 Widget::from_glib_none(gtk_sys::gtk_image_new_from_gicon( 74 icon.as_ref().to_glib_none().0, 75 size.to_glib(), 76 )) 77 .unsafe_cast() 78 } 79 } 80 new_from_icon_name(icon_name: Option<&str>, size: IconSize) -> Image81 pub fn new_from_icon_name(icon_name: Option<&str>, size: IconSize) -> Image { 82 assert_initialized_main_thread!(); 83 unsafe { 84 Widget::from_glib_none(gtk_sys::gtk_image_new_from_icon_name( 85 icon_name.to_glib_none().0, 86 size.to_glib(), 87 )) 88 .unsafe_cast() 89 } 90 } 91 new_from_pixbuf(pixbuf: Option<&gdk_pixbuf::Pixbuf>) -> Image92 pub fn new_from_pixbuf(pixbuf: Option<&gdk_pixbuf::Pixbuf>) -> Image { 93 assert_initialized_main_thread!(); 94 unsafe { 95 Widget::from_glib_none(gtk_sys::gtk_image_new_from_pixbuf(pixbuf.to_glib_none().0)) 96 .unsafe_cast() 97 } 98 } 99 new_from_resource(resource_path: &str) -> Image100 pub fn new_from_resource(resource_path: &str) -> Image { 101 assert_initialized_main_thread!(); 102 unsafe { 103 Widget::from_glib_none(gtk_sys::gtk_image_new_from_resource( 104 resource_path.to_glib_none().0, 105 )) 106 .unsafe_cast() 107 } 108 } 109 new_from_surface(surface: Option<&cairo::Surface>) -> Image110 pub fn new_from_surface(surface: Option<&cairo::Surface>) -> Image { 111 assert_initialized_main_thread!(); 112 unsafe { 113 Widget::from_glib_none(gtk_sys::gtk_image_new_from_surface(mut_override( 114 surface.to_glib_none().0, 115 ))) 116 .unsafe_cast() 117 } 118 } 119 } 120 121 impl Default for Image { default() -> Self122 fn default() -> Self { 123 Self::new() 124 } 125 } 126 127 #[derive(Clone, Default)] 128 pub struct ImageBuilder { 129 file: Option<String>, 130 gicon: Option<gio::Icon>, 131 icon_name: Option<String>, 132 icon_size: Option<i32>, 133 pixbuf: Option<gdk_pixbuf::Pixbuf>, 134 pixbuf_animation: Option<gdk_pixbuf::PixbufAnimation>, 135 pixel_size: Option<i32>, 136 resource: Option<String>, 137 use_fallback: Option<bool>, 138 app_paintable: Option<bool>, 139 can_default: Option<bool>, 140 can_focus: Option<bool>, 141 events: Option<gdk::EventMask>, 142 expand: Option<bool>, 143 #[cfg(any(feature = "v3_20", feature = "dox"))] 144 focus_on_click: Option<bool>, 145 halign: Option<Align>, 146 has_default: Option<bool>, 147 has_focus: Option<bool>, 148 has_tooltip: Option<bool>, 149 height_request: Option<i32>, 150 hexpand: Option<bool>, 151 hexpand_set: Option<bool>, 152 is_focus: Option<bool>, 153 margin: Option<i32>, 154 margin_bottom: Option<i32>, 155 margin_end: Option<i32>, 156 margin_start: Option<i32>, 157 margin_top: Option<i32>, 158 name: Option<String>, 159 no_show_all: Option<bool>, 160 opacity: Option<f64>, 161 parent: Option<Container>, 162 receives_default: Option<bool>, 163 sensitive: Option<bool>, 164 tooltip_markup: Option<String>, 165 tooltip_text: Option<String>, 166 valign: Option<Align>, 167 vexpand: Option<bool>, 168 vexpand_set: Option<bool>, 169 visible: Option<bool>, 170 width_request: Option<i32>, 171 } 172 173 impl ImageBuilder { new() -> Self174 pub fn new() -> Self { 175 Self::default() 176 } 177 build(self) -> Image178 pub fn build(self) -> Image { 179 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 180 if let Some(ref file) = self.file { 181 properties.push(("file", file)); 182 } 183 if let Some(ref gicon) = self.gicon { 184 properties.push(("gicon", gicon)); 185 } 186 if let Some(ref icon_name) = self.icon_name { 187 properties.push(("icon-name", icon_name)); 188 } 189 if let Some(ref icon_size) = self.icon_size { 190 properties.push(("icon-size", icon_size)); 191 } 192 if let Some(ref pixbuf) = self.pixbuf { 193 properties.push(("pixbuf", pixbuf)); 194 } 195 if let Some(ref pixbuf_animation) = self.pixbuf_animation { 196 properties.push(("pixbuf-animation", pixbuf_animation)); 197 } 198 if let Some(ref pixel_size) = self.pixel_size { 199 properties.push(("pixel-size", pixel_size)); 200 } 201 if let Some(ref resource) = self.resource { 202 properties.push(("resource", resource)); 203 } 204 if let Some(ref use_fallback) = self.use_fallback { 205 properties.push(("use-fallback", use_fallback)); 206 } 207 if let Some(ref app_paintable) = self.app_paintable { 208 properties.push(("app-paintable", app_paintable)); 209 } 210 if let Some(ref can_default) = self.can_default { 211 properties.push(("can-default", can_default)); 212 } 213 if let Some(ref can_focus) = self.can_focus { 214 properties.push(("can-focus", can_focus)); 215 } 216 if let Some(ref events) = self.events { 217 properties.push(("events", events)); 218 } 219 if let Some(ref expand) = self.expand { 220 properties.push(("expand", expand)); 221 } 222 #[cfg(any(feature = "v3_20", feature = "dox"))] 223 { 224 if let Some(ref focus_on_click) = self.focus_on_click { 225 properties.push(("focus-on-click", focus_on_click)); 226 } 227 } 228 if let Some(ref halign) = self.halign { 229 properties.push(("halign", halign)); 230 } 231 if let Some(ref has_default) = self.has_default { 232 properties.push(("has-default", has_default)); 233 } 234 if let Some(ref has_focus) = self.has_focus { 235 properties.push(("has-focus", has_focus)); 236 } 237 if let Some(ref has_tooltip) = self.has_tooltip { 238 properties.push(("has-tooltip", has_tooltip)); 239 } 240 if let Some(ref height_request) = self.height_request { 241 properties.push(("height-request", height_request)); 242 } 243 if let Some(ref hexpand) = self.hexpand { 244 properties.push(("hexpand", hexpand)); 245 } 246 if let Some(ref hexpand_set) = self.hexpand_set { 247 properties.push(("hexpand-set", hexpand_set)); 248 } 249 if let Some(ref is_focus) = self.is_focus { 250 properties.push(("is-focus", is_focus)); 251 } 252 if let Some(ref margin) = self.margin { 253 properties.push(("margin", margin)); 254 } 255 if let Some(ref margin_bottom) = self.margin_bottom { 256 properties.push(("margin-bottom", margin_bottom)); 257 } 258 if let Some(ref margin_end) = self.margin_end { 259 properties.push(("margin-end", margin_end)); 260 } 261 if let Some(ref margin_start) = self.margin_start { 262 properties.push(("margin-start", margin_start)); 263 } 264 if let Some(ref margin_top) = self.margin_top { 265 properties.push(("margin-top", margin_top)); 266 } 267 if let Some(ref name) = self.name { 268 properties.push(("name", name)); 269 } 270 if let Some(ref no_show_all) = self.no_show_all { 271 properties.push(("no-show-all", no_show_all)); 272 } 273 if let Some(ref opacity) = self.opacity { 274 properties.push(("opacity", opacity)); 275 } 276 if let Some(ref parent) = self.parent { 277 properties.push(("parent", parent)); 278 } 279 if let Some(ref receives_default) = self.receives_default { 280 properties.push(("receives-default", receives_default)); 281 } 282 if let Some(ref sensitive) = self.sensitive { 283 properties.push(("sensitive", sensitive)); 284 } 285 if let Some(ref tooltip_markup) = self.tooltip_markup { 286 properties.push(("tooltip-markup", tooltip_markup)); 287 } 288 if let Some(ref tooltip_text) = self.tooltip_text { 289 properties.push(("tooltip-text", tooltip_text)); 290 } 291 if let Some(ref valign) = self.valign { 292 properties.push(("valign", valign)); 293 } 294 if let Some(ref vexpand) = self.vexpand { 295 properties.push(("vexpand", vexpand)); 296 } 297 if let Some(ref vexpand_set) = self.vexpand_set { 298 properties.push(("vexpand-set", vexpand_set)); 299 } 300 if let Some(ref visible) = self.visible { 301 properties.push(("visible", visible)); 302 } 303 if let Some(ref width_request) = self.width_request { 304 properties.push(("width-request", width_request)); 305 } 306 glib::Object::new(Image::static_type(), &properties) 307 .expect("object new") 308 .downcast() 309 .expect("downcast") 310 } 311 file(mut self, file: &str) -> Self312 pub fn file(mut self, file: &str) -> Self { 313 self.file = Some(file.to_string()); 314 self 315 } 316 gicon<P: IsA<gio::Icon>>(mut self, gicon: &P) -> Self317 pub fn gicon<P: IsA<gio::Icon>>(mut self, gicon: &P) -> Self { 318 self.gicon = Some(gicon.clone().upcast()); 319 self 320 } 321 icon_name(mut self, icon_name: &str) -> Self322 pub fn icon_name(mut self, icon_name: &str) -> Self { 323 self.icon_name = Some(icon_name.to_string()); 324 self 325 } 326 icon_size(mut self, icon_size: i32) -> Self327 pub fn icon_size(mut self, icon_size: i32) -> Self { 328 self.icon_size = Some(icon_size); 329 self 330 } 331 pixbuf(mut self, pixbuf: &gdk_pixbuf::Pixbuf) -> Self332 pub fn pixbuf(mut self, pixbuf: &gdk_pixbuf::Pixbuf) -> Self { 333 self.pixbuf = Some(pixbuf.clone()); 334 self 335 } 336 pixbuf_animation<P: IsA<gdk_pixbuf::PixbufAnimation>>( mut self, pixbuf_animation: &P, ) -> Self337 pub fn pixbuf_animation<P: IsA<gdk_pixbuf::PixbufAnimation>>( 338 mut self, 339 pixbuf_animation: &P, 340 ) -> Self { 341 self.pixbuf_animation = Some(pixbuf_animation.clone().upcast()); 342 self 343 } 344 pixel_size(mut self, pixel_size: i32) -> Self345 pub fn pixel_size(mut self, pixel_size: i32) -> Self { 346 self.pixel_size = Some(pixel_size); 347 self 348 } 349 resource(mut self, resource: &str) -> Self350 pub fn resource(mut self, resource: &str) -> Self { 351 self.resource = Some(resource.to_string()); 352 self 353 } 354 use_fallback(mut self, use_fallback: bool) -> Self355 pub fn use_fallback(mut self, use_fallback: bool) -> Self { 356 self.use_fallback = Some(use_fallback); 357 self 358 } 359 app_paintable(mut self, app_paintable: bool) -> Self360 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 361 self.app_paintable = Some(app_paintable); 362 self 363 } 364 can_default(mut self, can_default: bool) -> Self365 pub fn can_default(mut self, can_default: bool) -> Self { 366 self.can_default = Some(can_default); 367 self 368 } 369 can_focus(mut self, can_focus: bool) -> Self370 pub fn can_focus(mut self, can_focus: bool) -> Self { 371 self.can_focus = Some(can_focus); 372 self 373 } 374 events(mut self, events: gdk::EventMask) -> Self375 pub fn events(mut self, events: gdk::EventMask) -> Self { 376 self.events = Some(events); 377 self 378 } 379 expand(mut self, expand: bool) -> Self380 pub fn expand(mut self, expand: bool) -> Self { 381 self.expand = Some(expand); 382 self 383 } 384 385 #[cfg(any(feature = "v3_20", feature = "dox"))] focus_on_click(mut self, focus_on_click: bool) -> Self386 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 387 self.focus_on_click = Some(focus_on_click); 388 self 389 } 390 halign(mut self, halign: Align) -> Self391 pub fn halign(mut self, halign: Align) -> Self { 392 self.halign = Some(halign); 393 self 394 } 395 has_default(mut self, has_default: bool) -> Self396 pub fn has_default(mut self, has_default: bool) -> Self { 397 self.has_default = Some(has_default); 398 self 399 } 400 has_focus(mut self, has_focus: bool) -> Self401 pub fn has_focus(mut self, has_focus: bool) -> Self { 402 self.has_focus = Some(has_focus); 403 self 404 } 405 has_tooltip(mut self, has_tooltip: bool) -> Self406 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 407 self.has_tooltip = Some(has_tooltip); 408 self 409 } 410 height_request(mut self, height_request: i32) -> Self411 pub fn height_request(mut self, height_request: i32) -> Self { 412 self.height_request = Some(height_request); 413 self 414 } 415 hexpand(mut self, hexpand: bool) -> Self416 pub fn hexpand(mut self, hexpand: bool) -> Self { 417 self.hexpand = Some(hexpand); 418 self 419 } 420 hexpand_set(mut self, hexpand_set: bool) -> Self421 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 422 self.hexpand_set = Some(hexpand_set); 423 self 424 } 425 is_focus(mut self, is_focus: bool) -> Self426 pub fn is_focus(mut self, is_focus: bool) -> Self { 427 self.is_focus = Some(is_focus); 428 self 429 } 430 margin(mut self, margin: i32) -> Self431 pub fn margin(mut self, margin: i32) -> Self { 432 self.margin = Some(margin); 433 self 434 } 435 margin_bottom(mut self, margin_bottom: i32) -> Self436 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 437 self.margin_bottom = Some(margin_bottom); 438 self 439 } 440 margin_end(mut self, margin_end: i32) -> Self441 pub fn margin_end(mut self, margin_end: i32) -> Self { 442 self.margin_end = Some(margin_end); 443 self 444 } 445 margin_start(mut self, margin_start: i32) -> Self446 pub fn margin_start(mut self, margin_start: i32) -> Self { 447 self.margin_start = Some(margin_start); 448 self 449 } 450 margin_top(mut self, margin_top: i32) -> Self451 pub fn margin_top(mut self, margin_top: i32) -> Self { 452 self.margin_top = Some(margin_top); 453 self 454 } 455 name(mut self, name: &str) -> Self456 pub fn name(mut self, name: &str) -> Self { 457 self.name = Some(name.to_string()); 458 self 459 } 460 no_show_all(mut self, no_show_all: bool) -> Self461 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 462 self.no_show_all = Some(no_show_all); 463 self 464 } 465 opacity(mut self, opacity: f64) -> Self466 pub fn opacity(mut self, opacity: f64) -> Self { 467 self.opacity = Some(opacity); 468 self 469 } 470 parent<P: IsA<Container>>(mut self, parent: &P) -> Self471 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 472 self.parent = Some(parent.clone().upcast()); 473 self 474 } 475 receives_default(mut self, receives_default: bool) -> Self476 pub fn receives_default(mut self, receives_default: bool) -> Self { 477 self.receives_default = Some(receives_default); 478 self 479 } 480 sensitive(mut self, sensitive: bool) -> Self481 pub fn sensitive(mut self, sensitive: bool) -> Self { 482 self.sensitive = Some(sensitive); 483 self 484 } 485 tooltip_markup(mut self, tooltip_markup: &str) -> Self486 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 487 self.tooltip_markup = Some(tooltip_markup.to_string()); 488 self 489 } 490 tooltip_text(mut self, tooltip_text: &str) -> Self491 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 492 self.tooltip_text = Some(tooltip_text.to_string()); 493 self 494 } 495 valign(mut self, valign: Align) -> Self496 pub fn valign(mut self, valign: Align) -> Self { 497 self.valign = Some(valign); 498 self 499 } 500 vexpand(mut self, vexpand: bool) -> Self501 pub fn vexpand(mut self, vexpand: bool) -> Self { 502 self.vexpand = Some(vexpand); 503 self 504 } 505 vexpand_set(mut self, vexpand_set: bool) -> Self506 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 507 self.vexpand_set = Some(vexpand_set); 508 self 509 } 510 visible(mut self, visible: bool) -> Self511 pub fn visible(mut self, visible: bool) -> Self { 512 self.visible = Some(visible); 513 self 514 } 515 width_request(mut self, width_request: i32) -> Self516 pub fn width_request(mut self, width_request: i32) -> Self { 517 self.width_request = Some(width_request); 518 self 519 } 520 } 521 522 pub const NONE_IMAGE: Option<&Image> = None; 523 524 pub trait ImageExt: 'static { clear(&self)525 fn clear(&self); 526 get_animation(&self) -> Option<gdk_pixbuf::PixbufAnimation>527 fn get_animation(&self) -> Option<gdk_pixbuf::PixbufAnimation>; 528 get_gicon(&self) -> (gio::Icon, IconSize)529 fn get_gicon(&self) -> (gio::Icon, IconSize); 530 get_pixbuf(&self) -> Option<gdk_pixbuf::Pixbuf>531 fn get_pixbuf(&self) -> Option<gdk_pixbuf::Pixbuf>; 532 get_pixel_size(&self) -> i32533 fn get_pixel_size(&self) -> i32; 534 get_storage_type(&self) -> ImageType535 fn get_storage_type(&self) -> ImageType; 536 set_from_animation<P: IsA<gdk_pixbuf::PixbufAnimation>>(&self, animation: &P)537 fn set_from_animation<P: IsA<gdk_pixbuf::PixbufAnimation>>(&self, animation: &P); 538 set_from_file<P: AsRef<std::path::Path>>(&self, filename: P)539 fn set_from_file<P: AsRef<std::path::Path>>(&self, filename: P); 540 set_from_gicon<P: IsA<gio::Icon>>(&self, icon: &P, size: IconSize)541 fn set_from_gicon<P: IsA<gio::Icon>>(&self, icon: &P, size: IconSize); 542 set_from_icon_name(&self, icon_name: Option<&str>, size: IconSize)543 fn set_from_icon_name(&self, icon_name: Option<&str>, size: IconSize); 544 set_from_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>)545 fn set_from_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>); 546 set_from_resource(&self, resource_path: Option<&str>)547 fn set_from_resource(&self, resource_path: Option<&str>); 548 set_from_surface(&self, surface: Option<&cairo::Surface>)549 fn set_from_surface(&self, surface: Option<&cairo::Surface>); 550 set_pixel_size(&self, pixel_size: i32)551 fn set_pixel_size(&self, pixel_size: i32); 552 get_property_file(&self) -> Option<GString>553 fn get_property_file(&self) -> Option<GString>; 554 set_property_file(&self, file: Option<&str>)555 fn set_property_file(&self, file: Option<&str>); 556 set_property_gicon<P: IsA<gio::Icon> + SetValueOptional>(&self, gicon: Option<&P>)557 fn set_property_gicon<P: IsA<gio::Icon> + SetValueOptional>(&self, gicon: Option<&P>); 558 get_property_icon_name(&self) -> Option<GString>559 fn get_property_icon_name(&self) -> Option<GString>; 560 set_property_icon_name(&self, icon_name: Option<&str>)561 fn set_property_icon_name(&self, icon_name: Option<&str>); 562 get_property_icon_size(&self) -> i32563 fn get_property_icon_size(&self) -> i32; 564 set_property_icon_size(&self, icon_size: i32)565 fn set_property_icon_size(&self, icon_size: i32); 566 set_property_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>)567 fn set_property_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>); 568 get_property_pixbuf_animation(&self) -> Option<gdk_pixbuf::PixbufAnimation>569 fn get_property_pixbuf_animation(&self) -> Option<gdk_pixbuf::PixbufAnimation>; 570 set_property_pixbuf_animation<P: IsA<gdk_pixbuf::PixbufAnimation> + SetValueOptional>( &self, pixbuf_animation: Option<&P>, )571 fn set_property_pixbuf_animation<P: IsA<gdk_pixbuf::PixbufAnimation> + SetValueOptional>( 572 &self, 573 pixbuf_animation: Option<&P>, 574 ); 575 get_property_resource(&self) -> Option<GString>576 fn get_property_resource(&self) -> Option<GString>; 577 set_property_resource(&self, resource: Option<&str>)578 fn set_property_resource(&self, resource: Option<&str>); 579 get_property_use_fallback(&self) -> bool580 fn get_property_use_fallback(&self) -> bool; 581 set_property_use_fallback(&self, use_fallback: bool)582 fn set_property_use_fallback(&self, use_fallback: bool); 583 connect_property_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId584 fn connect_property_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 585 connect_property_gicon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId586 fn connect_property_gicon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 587 connect_property_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId588 fn connect_property_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 589 connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId590 fn connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 591 connect_property_pixbuf_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId592 fn connect_property_pixbuf_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 593 connect_property_pixbuf_animation_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId594 fn connect_property_pixbuf_animation_notify<F: Fn(&Self) + 'static>( 595 &self, 596 f: F, 597 ) -> SignalHandlerId; 598 connect_property_pixel_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId599 fn connect_property_pixel_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 600 connect_property_resource_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId601 fn connect_property_resource_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 602 connect_property_storage_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId603 fn connect_property_storage_type_notify<F: Fn(&Self) + 'static>(&self, f: F) 604 -> SignalHandlerId; 605 connect_property_use_fallback_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId606 fn connect_property_use_fallback_notify<F: Fn(&Self) + 'static>(&self, f: F) 607 -> SignalHandlerId; 608 } 609 610 impl<O: IsA<Image>> ImageExt for O { clear(&self)611 fn clear(&self) { 612 unsafe { 613 gtk_sys::gtk_image_clear(self.as_ref().to_glib_none().0); 614 } 615 } 616 get_animation(&self) -> Option<gdk_pixbuf::PixbufAnimation>617 fn get_animation(&self) -> Option<gdk_pixbuf::PixbufAnimation> { 618 unsafe { 619 from_glib_none(gtk_sys::gtk_image_get_animation( 620 self.as_ref().to_glib_none().0, 621 )) 622 } 623 } 624 get_gicon(&self) -> (gio::Icon, IconSize)625 fn get_gicon(&self) -> (gio::Icon, IconSize) { 626 unsafe { 627 let mut gicon = ptr::null_mut(); 628 let mut size = mem::MaybeUninit::uninit(); 629 gtk_sys::gtk_image_get_gicon( 630 self.as_ref().to_glib_none().0, 631 &mut gicon, 632 size.as_mut_ptr(), 633 ); 634 let size = size.assume_init(); 635 (from_glib_none(gicon), from_glib(size)) 636 } 637 } 638 get_pixbuf(&self) -> Option<gdk_pixbuf::Pixbuf>639 fn get_pixbuf(&self) -> Option<gdk_pixbuf::Pixbuf> { 640 unsafe { 641 from_glib_none(gtk_sys::gtk_image_get_pixbuf( 642 self.as_ref().to_glib_none().0, 643 )) 644 } 645 } 646 get_pixel_size(&self) -> i32647 fn get_pixel_size(&self) -> i32 { 648 unsafe { gtk_sys::gtk_image_get_pixel_size(self.as_ref().to_glib_none().0) } 649 } 650 get_storage_type(&self) -> ImageType651 fn get_storage_type(&self) -> ImageType { 652 unsafe { 653 from_glib(gtk_sys::gtk_image_get_storage_type( 654 self.as_ref().to_glib_none().0, 655 )) 656 } 657 } 658 set_from_animation<P: IsA<gdk_pixbuf::PixbufAnimation>>(&self, animation: &P)659 fn set_from_animation<P: IsA<gdk_pixbuf::PixbufAnimation>>(&self, animation: &P) { 660 unsafe { 661 gtk_sys::gtk_image_set_from_animation( 662 self.as_ref().to_glib_none().0, 663 animation.as_ref().to_glib_none().0, 664 ); 665 } 666 } 667 set_from_file<P: AsRef<std::path::Path>>(&self, filename: P)668 fn set_from_file<P: AsRef<std::path::Path>>(&self, filename: P) { 669 unsafe { 670 gtk_sys::gtk_image_set_from_file( 671 self.as_ref().to_glib_none().0, 672 filename.as_ref().to_glib_none().0, 673 ); 674 } 675 } 676 set_from_gicon<P: IsA<gio::Icon>>(&self, icon: &P, size: IconSize)677 fn set_from_gicon<P: IsA<gio::Icon>>(&self, icon: &P, size: IconSize) { 678 unsafe { 679 gtk_sys::gtk_image_set_from_gicon( 680 self.as_ref().to_glib_none().0, 681 icon.as_ref().to_glib_none().0, 682 size.to_glib(), 683 ); 684 } 685 } 686 set_from_icon_name(&self, icon_name: Option<&str>, size: IconSize)687 fn set_from_icon_name(&self, icon_name: Option<&str>, size: IconSize) { 688 unsafe { 689 gtk_sys::gtk_image_set_from_icon_name( 690 self.as_ref().to_glib_none().0, 691 icon_name.to_glib_none().0, 692 size.to_glib(), 693 ); 694 } 695 } 696 set_from_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>)697 fn set_from_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>) { 698 unsafe { 699 gtk_sys::gtk_image_set_from_pixbuf( 700 self.as_ref().to_glib_none().0, 701 pixbuf.to_glib_none().0, 702 ); 703 } 704 } 705 set_from_resource(&self, resource_path: Option<&str>)706 fn set_from_resource(&self, resource_path: Option<&str>) { 707 unsafe { 708 gtk_sys::gtk_image_set_from_resource( 709 self.as_ref().to_glib_none().0, 710 resource_path.to_glib_none().0, 711 ); 712 } 713 } 714 set_from_surface(&self, surface: Option<&cairo::Surface>)715 fn set_from_surface(&self, surface: Option<&cairo::Surface>) { 716 unsafe { 717 gtk_sys::gtk_image_set_from_surface( 718 self.as_ref().to_glib_none().0, 719 mut_override(surface.to_glib_none().0), 720 ); 721 } 722 } 723 set_pixel_size(&self, pixel_size: i32)724 fn set_pixel_size(&self, pixel_size: i32) { 725 unsafe { 726 gtk_sys::gtk_image_set_pixel_size(self.as_ref().to_glib_none().0, pixel_size); 727 } 728 } 729 get_property_file(&self) -> Option<GString>730 fn get_property_file(&self) -> Option<GString> { 731 unsafe { 732 let mut value = Value::from_type(<GString as StaticType>::static_type()); 733 gobject_sys::g_object_get_property( 734 self.to_glib_none().0 as *mut gobject_sys::GObject, 735 b"file\0".as_ptr() as *const _, 736 value.to_glib_none_mut().0, 737 ); 738 value 739 .get() 740 .expect("Return Value for property `file` getter") 741 } 742 } 743 set_property_file(&self, file: Option<&str>)744 fn set_property_file(&self, file: Option<&str>) { 745 unsafe { 746 gobject_sys::g_object_set_property( 747 self.to_glib_none().0 as *mut gobject_sys::GObject, 748 b"file\0".as_ptr() as *const _, 749 Value::from(file).to_glib_none().0, 750 ); 751 } 752 } 753 set_property_gicon<P: IsA<gio::Icon> + SetValueOptional>(&self, gicon: Option<&P>)754 fn set_property_gicon<P: IsA<gio::Icon> + SetValueOptional>(&self, gicon: Option<&P>) { 755 unsafe { 756 gobject_sys::g_object_set_property( 757 self.to_glib_none().0 as *mut gobject_sys::GObject, 758 b"gicon\0".as_ptr() as *const _, 759 Value::from(gicon).to_glib_none().0, 760 ); 761 } 762 } 763 get_property_icon_name(&self) -> Option<GString>764 fn get_property_icon_name(&self) -> Option<GString> { 765 unsafe { 766 let mut value = Value::from_type(<GString as StaticType>::static_type()); 767 gobject_sys::g_object_get_property( 768 self.to_glib_none().0 as *mut gobject_sys::GObject, 769 b"icon-name\0".as_ptr() as *const _, 770 value.to_glib_none_mut().0, 771 ); 772 value 773 .get() 774 .expect("Return Value for property `icon-name` getter") 775 } 776 } 777 set_property_icon_name(&self, icon_name: Option<&str>)778 fn set_property_icon_name(&self, icon_name: Option<&str>) { 779 unsafe { 780 gobject_sys::g_object_set_property( 781 self.to_glib_none().0 as *mut gobject_sys::GObject, 782 b"icon-name\0".as_ptr() as *const _, 783 Value::from(icon_name).to_glib_none().0, 784 ); 785 } 786 } 787 get_property_icon_size(&self) -> i32788 fn get_property_icon_size(&self) -> i32 { 789 unsafe { 790 let mut value = Value::from_type(<i32 as StaticType>::static_type()); 791 gobject_sys::g_object_get_property( 792 self.to_glib_none().0 as *mut gobject_sys::GObject, 793 b"icon-size\0".as_ptr() as *const _, 794 value.to_glib_none_mut().0, 795 ); 796 value 797 .get() 798 .expect("Return Value for property `icon-size` getter") 799 .unwrap() 800 } 801 } 802 set_property_icon_size(&self, icon_size: i32)803 fn set_property_icon_size(&self, icon_size: i32) { 804 unsafe { 805 gobject_sys::g_object_set_property( 806 self.to_glib_none().0 as *mut gobject_sys::GObject, 807 b"icon-size\0".as_ptr() as *const _, 808 Value::from(&icon_size).to_glib_none().0, 809 ); 810 } 811 } 812 set_property_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>)813 fn set_property_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>) { 814 unsafe { 815 gobject_sys::g_object_set_property( 816 self.to_glib_none().0 as *mut gobject_sys::GObject, 817 b"pixbuf\0".as_ptr() as *const _, 818 Value::from(pixbuf).to_glib_none().0, 819 ); 820 } 821 } 822 get_property_pixbuf_animation(&self) -> Option<gdk_pixbuf::PixbufAnimation>823 fn get_property_pixbuf_animation(&self) -> Option<gdk_pixbuf::PixbufAnimation> { 824 unsafe { 825 let mut value = 826 Value::from_type(<gdk_pixbuf::PixbufAnimation as StaticType>::static_type()); 827 gobject_sys::g_object_get_property( 828 self.to_glib_none().0 as *mut gobject_sys::GObject, 829 b"pixbuf-animation\0".as_ptr() as *const _, 830 value.to_glib_none_mut().0, 831 ); 832 value 833 .get() 834 .expect("Return Value for property `pixbuf-animation` getter") 835 } 836 } 837 set_property_pixbuf_animation<P: IsA<gdk_pixbuf::PixbufAnimation> + SetValueOptional>( &self, pixbuf_animation: Option<&P>, )838 fn set_property_pixbuf_animation<P: IsA<gdk_pixbuf::PixbufAnimation> + SetValueOptional>( 839 &self, 840 pixbuf_animation: Option<&P>, 841 ) { 842 unsafe { 843 gobject_sys::g_object_set_property( 844 self.to_glib_none().0 as *mut gobject_sys::GObject, 845 b"pixbuf-animation\0".as_ptr() as *const _, 846 Value::from(pixbuf_animation).to_glib_none().0, 847 ); 848 } 849 } 850 get_property_resource(&self) -> Option<GString>851 fn get_property_resource(&self) -> Option<GString> { 852 unsafe { 853 let mut value = Value::from_type(<GString as StaticType>::static_type()); 854 gobject_sys::g_object_get_property( 855 self.to_glib_none().0 as *mut gobject_sys::GObject, 856 b"resource\0".as_ptr() as *const _, 857 value.to_glib_none_mut().0, 858 ); 859 value 860 .get() 861 .expect("Return Value for property `resource` getter") 862 } 863 } 864 set_property_resource(&self, resource: Option<&str>)865 fn set_property_resource(&self, resource: Option<&str>) { 866 unsafe { 867 gobject_sys::g_object_set_property( 868 self.to_glib_none().0 as *mut gobject_sys::GObject, 869 b"resource\0".as_ptr() as *const _, 870 Value::from(resource).to_glib_none().0, 871 ); 872 } 873 } 874 get_property_use_fallback(&self) -> bool875 fn get_property_use_fallback(&self) -> bool { 876 unsafe { 877 let mut value = Value::from_type(<bool as StaticType>::static_type()); 878 gobject_sys::g_object_get_property( 879 self.to_glib_none().0 as *mut gobject_sys::GObject, 880 b"use-fallback\0".as_ptr() as *const _, 881 value.to_glib_none_mut().0, 882 ); 883 value 884 .get() 885 .expect("Return Value for property `use-fallback` getter") 886 .unwrap() 887 } 888 } 889 set_property_use_fallback(&self, use_fallback: bool)890 fn set_property_use_fallback(&self, use_fallback: bool) { 891 unsafe { 892 gobject_sys::g_object_set_property( 893 self.to_glib_none().0 as *mut gobject_sys::GObject, 894 b"use-fallback\0".as_ptr() as *const _, 895 Value::from(&use_fallback).to_glib_none().0, 896 ); 897 } 898 } 899 connect_property_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId900 fn connect_property_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 901 unsafe extern "C" fn notify_file_trampoline<P, F: Fn(&P) + 'static>( 902 this: *mut gtk_sys::GtkImage, 903 _param_spec: glib_sys::gpointer, 904 f: glib_sys::gpointer, 905 ) where 906 P: IsA<Image>, 907 { 908 let f: &F = &*(f as *const F); 909 f(&Image::from_glib_borrow(this).unsafe_cast()) 910 } 911 unsafe { 912 let f: Box_<F> = Box_::new(f); 913 connect_raw( 914 self.as_ptr() as *mut _, 915 b"notify::file\0".as_ptr() as *const _, 916 Some(transmute(notify_file_trampoline::<Self, F> as usize)), 917 Box_::into_raw(f), 918 ) 919 } 920 } 921 connect_property_gicon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId922 fn connect_property_gicon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 923 unsafe extern "C" fn notify_gicon_trampoline<P, F: Fn(&P) + 'static>( 924 this: *mut gtk_sys::GtkImage, 925 _param_spec: glib_sys::gpointer, 926 f: glib_sys::gpointer, 927 ) where 928 P: IsA<Image>, 929 { 930 let f: &F = &*(f as *const F); 931 f(&Image::from_glib_borrow(this).unsafe_cast()) 932 } 933 unsafe { 934 let f: Box_<F> = Box_::new(f); 935 connect_raw( 936 self.as_ptr() as *mut _, 937 b"notify::gicon\0".as_ptr() as *const _, 938 Some(transmute(notify_gicon_trampoline::<Self, F> as usize)), 939 Box_::into_raw(f), 940 ) 941 } 942 } 943 connect_property_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId944 fn connect_property_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 945 unsafe extern "C" fn notify_icon_name_trampoline<P, F: Fn(&P) + 'static>( 946 this: *mut gtk_sys::GtkImage, 947 _param_spec: glib_sys::gpointer, 948 f: glib_sys::gpointer, 949 ) where 950 P: IsA<Image>, 951 { 952 let f: &F = &*(f as *const F); 953 f(&Image::from_glib_borrow(this).unsafe_cast()) 954 } 955 unsafe { 956 let f: Box_<F> = Box_::new(f); 957 connect_raw( 958 self.as_ptr() as *mut _, 959 b"notify::icon-name\0".as_ptr() as *const _, 960 Some(transmute(notify_icon_name_trampoline::<Self, F> as usize)), 961 Box_::into_raw(f), 962 ) 963 } 964 } 965 connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId966 fn connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 967 unsafe extern "C" fn notify_icon_size_trampoline<P, F: Fn(&P) + 'static>( 968 this: *mut gtk_sys::GtkImage, 969 _param_spec: glib_sys::gpointer, 970 f: glib_sys::gpointer, 971 ) where 972 P: IsA<Image>, 973 { 974 let f: &F = &*(f as *const F); 975 f(&Image::from_glib_borrow(this).unsafe_cast()) 976 } 977 unsafe { 978 let f: Box_<F> = Box_::new(f); 979 connect_raw( 980 self.as_ptr() as *mut _, 981 b"notify::icon-size\0".as_ptr() as *const _, 982 Some(transmute(notify_icon_size_trampoline::<Self, F> as usize)), 983 Box_::into_raw(f), 984 ) 985 } 986 } 987 connect_property_pixbuf_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId988 fn connect_property_pixbuf_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 989 unsafe extern "C" fn notify_pixbuf_trampoline<P, F: Fn(&P) + 'static>( 990 this: *mut gtk_sys::GtkImage, 991 _param_spec: glib_sys::gpointer, 992 f: glib_sys::gpointer, 993 ) where 994 P: IsA<Image>, 995 { 996 let f: &F = &*(f as *const F); 997 f(&Image::from_glib_borrow(this).unsafe_cast()) 998 } 999 unsafe { 1000 let f: Box_<F> = Box_::new(f); 1001 connect_raw( 1002 self.as_ptr() as *mut _, 1003 b"notify::pixbuf\0".as_ptr() as *const _, 1004 Some(transmute(notify_pixbuf_trampoline::<Self, F> as usize)), 1005 Box_::into_raw(f), 1006 ) 1007 } 1008 } 1009 connect_property_pixbuf_animation_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId1010 fn connect_property_pixbuf_animation_notify<F: Fn(&Self) + 'static>( 1011 &self, 1012 f: F, 1013 ) -> SignalHandlerId { 1014 unsafe extern "C" fn notify_pixbuf_animation_trampoline<P, F: Fn(&P) + 'static>( 1015 this: *mut gtk_sys::GtkImage, 1016 _param_spec: glib_sys::gpointer, 1017 f: glib_sys::gpointer, 1018 ) where 1019 P: IsA<Image>, 1020 { 1021 let f: &F = &*(f as *const F); 1022 f(&Image::from_glib_borrow(this).unsafe_cast()) 1023 } 1024 unsafe { 1025 let f: Box_<F> = Box_::new(f); 1026 connect_raw( 1027 self.as_ptr() as *mut _, 1028 b"notify::pixbuf-animation\0".as_ptr() as *const _, 1029 Some(transmute( 1030 notify_pixbuf_animation_trampoline::<Self, F> as usize, 1031 )), 1032 Box_::into_raw(f), 1033 ) 1034 } 1035 } 1036 connect_property_pixel_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1037 fn connect_property_pixel_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1038 unsafe extern "C" fn notify_pixel_size_trampoline<P, F: Fn(&P) + 'static>( 1039 this: *mut gtk_sys::GtkImage, 1040 _param_spec: glib_sys::gpointer, 1041 f: glib_sys::gpointer, 1042 ) where 1043 P: IsA<Image>, 1044 { 1045 let f: &F = &*(f as *const F); 1046 f(&Image::from_glib_borrow(this).unsafe_cast()) 1047 } 1048 unsafe { 1049 let f: Box_<F> = Box_::new(f); 1050 connect_raw( 1051 self.as_ptr() as *mut _, 1052 b"notify::pixel-size\0".as_ptr() as *const _, 1053 Some(transmute(notify_pixel_size_trampoline::<Self, F> as usize)), 1054 Box_::into_raw(f), 1055 ) 1056 } 1057 } 1058 connect_property_resource_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1059 fn connect_property_resource_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1060 unsafe extern "C" fn notify_resource_trampoline<P, F: Fn(&P) + 'static>( 1061 this: *mut gtk_sys::GtkImage, 1062 _param_spec: glib_sys::gpointer, 1063 f: glib_sys::gpointer, 1064 ) where 1065 P: IsA<Image>, 1066 { 1067 let f: &F = &*(f as *const F); 1068 f(&Image::from_glib_borrow(this).unsafe_cast()) 1069 } 1070 unsafe { 1071 let f: Box_<F> = Box_::new(f); 1072 connect_raw( 1073 self.as_ptr() as *mut _, 1074 b"notify::resource\0".as_ptr() as *const _, 1075 Some(transmute(notify_resource_trampoline::<Self, F> as usize)), 1076 Box_::into_raw(f), 1077 ) 1078 } 1079 } 1080 connect_property_storage_type_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId1081 fn connect_property_storage_type_notify<F: Fn(&Self) + 'static>( 1082 &self, 1083 f: F, 1084 ) -> SignalHandlerId { 1085 unsafe extern "C" fn notify_storage_type_trampoline<P, F: Fn(&P) + 'static>( 1086 this: *mut gtk_sys::GtkImage, 1087 _param_spec: glib_sys::gpointer, 1088 f: glib_sys::gpointer, 1089 ) where 1090 P: IsA<Image>, 1091 { 1092 let f: &F = &*(f as *const F); 1093 f(&Image::from_glib_borrow(this).unsafe_cast()) 1094 } 1095 unsafe { 1096 let f: Box_<F> = Box_::new(f); 1097 connect_raw( 1098 self.as_ptr() as *mut _, 1099 b"notify::storage-type\0".as_ptr() as *const _, 1100 Some(transmute( 1101 notify_storage_type_trampoline::<Self, F> as usize, 1102 )), 1103 Box_::into_raw(f), 1104 ) 1105 } 1106 } 1107 connect_property_use_fallback_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId1108 fn connect_property_use_fallback_notify<F: Fn(&Self) + 'static>( 1109 &self, 1110 f: F, 1111 ) -> SignalHandlerId { 1112 unsafe extern "C" fn notify_use_fallback_trampoline<P, F: Fn(&P) + 'static>( 1113 this: *mut gtk_sys::GtkImage, 1114 _param_spec: glib_sys::gpointer, 1115 f: glib_sys::gpointer, 1116 ) where 1117 P: IsA<Image>, 1118 { 1119 let f: &F = &*(f as *const F); 1120 f(&Image::from_glib_borrow(this).unsafe_cast()) 1121 } 1122 unsafe { 1123 let f: Box_<F> = Box_::new(f); 1124 connect_raw( 1125 self.as_ptr() as *mut _, 1126 b"notify::use-fallback\0".as_ptr() as *const _, 1127 Some(transmute( 1128 notify_use_fallback_trampoline::<Self, F> as usize, 1129 )), 1130 Box_::into_raw(f), 1131 ) 1132 } 1133 } 1134 } 1135 1136 impl fmt::Display for Image { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result1137 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 1138 write!(f, "Image") 1139 } 1140 } 1141