diff --git a/Gir.toml b/Gir.toml index 67209458..582ef544 100644 --- a/Gir.toml +++ b/Gir.toml @@ -11,7 +11,6 @@ generate = [ "GdkPixbuf.InterpType", "GdkPixbuf.PixbufAlphaMode", "GdkPixbuf.PixbufError", - "GdkPixbuf.PixbufFormat", "GdkPixbuf.PixbufLoader", "GdkPixbuf.PixbufRotation", "GdkPixbuf.PixbufSimpleAnim", @@ -22,113 +21,78 @@ manual = [ "GdkPixbuf.PixbufAnimationIter", "GLib.Bytes", "GLib.Error", + "Gio.AsyncReadyCallback", "Gio.Cancellable", + "Gio.InputStream", + "Gio.OutputStream", ] [[object]] name = "GdkPixbuf.Pixbuf" status = "generate" - [[object.function]] - name = "add_alpha" - #const self - ignore = true - [[object.function]] - name = "composite" - #const self - ignore = true - [[object.function]] - name = "composite_color" - #const self - ignore = true - [[object.function]] - name = "composite_color_simple" - #const self - ignore = true - [[object.function]] - name = "copy" - #const self - ignore = true - [[object.function]] - name = "copy_area" - #const self - ignore = true - [[object.function]] - name = "flip" - #const self - ignore = true - [[object.function]] - name = "get_bits_per_sample" - #as property: const self - ignore = true - [[object.function]] - name = "get_byte_length" - #const self - ignore = true - [[object.function]] - name = "get_colorspace" - #as property: const self - ignore = true - [[object.function]] - name = "get_has_alpha" - #as property: const self - ignore = true - [[object.function]] - name = "get_height" - #as property: const self - ignore = true - [[object.function]] - name = "get_n_channels" - #as property: const self - ignore = true [[object.function]] name = "get_pixels" - #const self + #manual array without length ignore = true [[object.function]] name = "get_pixels_with_length" - #const self + #manual as get_pixels ignore = true [[object.function]] - name = "get_rowstride" - #as property: const self + name = "read_pixels" + #unimplementable, use get_pixels instead ignore = true [[object.function]] - name = "get_width" - #as property: const self + name = "new_from_file" + #manual is_windows_utf8 ignore = true [[object.function]] - name = "read_pixels" - #const self + name = "new_from_file_at_size" + #manual is_windows_utf8 ignore = true [[object.function]] - name = "read_pixel_bytes" - #const self + name = "new_from_file_at_scale" + #manual is_windows_utf8 ignore = true [[object.function]] - name = "rotate_simple" - #const self + name = "new_from_stream_async" + # wrong async return ignore = true [[object.function]] - name = "saturate_and_pixelate" - #const self + name = "new_from_stream_at_scale_async" + # wrong return and don't generated ignore = true [[object.function]] - name = "scale" - #const self + name = "get_file_info" + # wrong return ignore = true [[object.function]] - name = "scale_simple" - #const self + name = "get_file_info_async" + # wrong async return ignore = true [[object.function]] - name = "new_from_file" - #manual is_windows_utf8 + name = "save_to_bufferv" + # manual complex param ignore = true [[object.function]] - name = "new_from_file_at_size" - #manual is_windows_utf8 + name = "save_to_streamv" + # manual complex param ignore = true [[object.function]] - name = "new_from_file_at_scale" - #manual is_windows_utf8 + name = "savev" + # manual complex param ignore = true + +[[object]] +name = "GdkPixbuf.PixbufFormat" +status = "generate" + [[object.function]] + pattern = "get_.+" + [[object.function.parameter]] + name = "format" + const = true + [[object.function]] + pattern = "is_.+" + [[object.function.parameter]] + name = "format" + const = true diff --git a/gir b/gir index d8a605da..5a68ad02 160000 --- a/gir +++ b/gir @@ -1 +1 @@ -Subproject commit d8a605dac3e852567379aa39a508b58b01aeb458 +Subproject commit 5a68ad0235b09ebc76ae76500d70e4206dde3c23 diff --git a/src/animation.rs b/src/animation.rs index 4ee3e98d..cac0528f 100644 --- a/src/animation.rs +++ b/src/animation.rs @@ -3,6 +3,7 @@ // Licensed under the MIT license, see the LICENSE file or use std::mem; +use std::path::Path; use std::ptr; use glib::{Error, TimeVal}; use glib::object::IsA; @@ -53,7 +54,7 @@ glib_wrapper! { } impl PixbufAnimation { - pub fn new_from_file(file: &str) -> Result { + pub fn new_from_file>(file: T) -> Result { #[cfg(windows)] use ffi::gdk_pixbuf_animation_new_from_file_utf8 as gdk_pixbuf_animation_new_from_file; @@ -62,7 +63,7 @@ impl PixbufAnimation { unsafe { let mut error = ptr::null_mut(); - let ptr = gdk_pixbuf_animation_new_from_file(file.to_glib_none().0, &mut error); + let ptr = gdk_pixbuf_animation_new_from_file(file.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ptr)) } else { diff --git a/src/auto/enums.rs b/src/auto/enums.rs index 43278619..2927d9f7 100644 --- a/src/auto/enums.rs +++ b/src/auto/enums.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (d8a605d) from gir-files (469db10) +// This file was generated by gir (5a68ad0) from gir-files (469db10) // DO NOT EDIT use ffi; diff --git a/src/auto/flags.rs b/src/auto/flags.rs index f768a764..4abfb431 100644 --- a/src/auto/flags.rs +++ b/src/auto/flags.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (d8a605d) from gir-files (469db10) +// This file was generated by gir (5a68ad0) from gir-files (469db10) // DO NOT EDIT use ffi; diff --git a/src/auto/mod.rs b/src/auto/mod.rs index c11a35f2..c5ed961c 100644 --- a/src/auto/mod.rs +++ b/src/auto/mod.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (d8a605d) from gir-files (469db10) +// This file was generated by gir (5a68ad0) from gir-files (469db10) // DO NOT EDIT mod pixbuf; diff --git a/src/auto/pixbuf.rs b/src/auto/pixbuf.rs index e584ec5e..d339ffea 100644 --- a/src/auto/pixbuf.rs +++ b/src/auto/pixbuf.rs @@ -1,13 +1,14 @@ -// This file was generated by gir (d8a605d) from gir-files (469db10) +// This file was generated by gir (5a68ad0) from gir-files (469db10) // DO NOT EDIT use Colorspace; use Error; +use InterpType; use PixbufFormat; +use PixbufRotation; use ffi; -#[cfg(any(feature = "v2_32", feature = "dox"))] use gio; -#[cfg(any(feature = "v2_32", feature = "dox"))] +#[cfg(any(feature = "v2_36", feature = "dox"))] use gio_ffi; use glib; use glib::StaticType; @@ -75,132 +76,123 @@ impl Pixbuf { } } - //pub fn new_from_stream<'a, P: IsA, Q: Into>>(stream: &P, cancellable: Q) -> Result { - // unsafe { TODO: call ffi::gdk_pixbuf_new_from_stream() } - //} - - //pub fn new_from_stream_at_scale<'a, P: IsA, Q: Into>>(stream: &P, width: i32, height: i32, preserve_aspect_ratio: bool, cancellable: Q) -> Result { - // unsafe { TODO: call ffi::gdk_pixbuf_new_from_stream_at_scale() } - //} - - pub fn new_from_xpm_data(data: &[&str]) -> Pixbuf { + pub fn new_from_stream<'a, P: IsA, Q: Into>>(stream: &P, cancellable: Q) -> Result { + let cancellable = cancellable.into(); + let cancellable = cancellable.to_glib_none(); unsafe { - from_glib_full(ffi::gdk_pixbuf_new_from_xpm_data(data.to_glib_none().0)) + let mut error = ptr::null_mut(); + let ret = ffi::gdk_pixbuf_new_from_stream(stream.to_glib_none().0, cancellable.0, &mut error); + if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } - //pub fn from_pixdata(pixdata: /*Ignored*/&Pixdata, copy_pixels: bool) -> Result { - // unsafe { TODO: call ffi::gdk_pixbuf_from_pixdata() } - //} - - pub fn get_file_info(filename: &str) -> (Option, i32, i32) { + pub fn new_from_stream_at_scale<'a, P: IsA, Q: Into>>(stream: &P, width: i32, height: i32, preserve_aspect_ratio: bool, cancellable: Q) -> Result { + let cancellable = cancellable.into(); + let cancellable = cancellable.to_glib_none(); unsafe { - let mut width = mem::uninitialized(); - let mut height = mem::uninitialized(); - let ret = from_glib_none(ffi::gdk_pixbuf_get_file_info(filename.to_glib_none().0, &mut width, &mut height)); - (ret, width, height) + let mut error = ptr::null_mut(); + let ret = ffi::gdk_pixbuf_new_from_stream_at_scale(stream.to_glib_none().0, width, height, preserve_aspect_ratio.to_glib(), cancellable.0, &mut error); + if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } - #[cfg(any(feature = "v2_32", feature = "dox"))] - pub fn get_file_info_async<'a, P: Into>, Q: Fn(Result<(i32, i32), Error>) + Send + Sync + 'static>(filename: &str, cancellable: P, callback: Q) { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - let user_data: Box) + Send + Sync + 'static>> = Box::new(Box::new(callback)); - extern "C" fn get_file_info_async_trampoline(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer) - { - callback_guard!(); - unsafe { - let mut error = ptr::null_mut(); - let mut width = mem::uninitialized(); - let mut height = mem::uninitialized(); - let _ = ffi::gdk_pixbuf_get_file_info_finish(res, &mut width, &mut height, &mut error); - let result = if error.is_null() { Ok((width, height)) } else { Err(from_glib_full(error)) }; - let callback: &&(Fn(Result<(i32, i32), Error>) + Send + Sync + 'static) = transmute(user_data); - callback(result); - } - } - let callback = get_file_info_async_trampoline; + pub fn new_from_xpm_data(data: &[&str]) -> Pixbuf { unsafe { - ffi::gdk_pixbuf_get_file_info_async(filename.to_glib_none().0, cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _); + from_glib_full(ffi::gdk_pixbuf_new_from_xpm_data(data.to_glib_none().0)) } } + //pub fn from_pixdata(pixdata: /*Ignored*/&Pixdata, copy_pixels: bool) -> Result { + // unsafe { TODO: call ffi::gdk_pixbuf_from_pixdata() } + //} + pub fn get_formats() -> Vec { unsafe { FromGlibPtrContainer::from_glib_container(ffi::gdk_pixbuf_get_formats()) } } - - //pub fn new_from_stream_async<'a, P: IsA, Q: Into>, R: Fn(Result<(), Error>) + Send + Sync + 'static>(stream: &P, cancellable: Q, callback: R) { - // unsafe { TODO: call ffi::gdk_pixbuf_new_from_stream_async() } - //} - - //pub fn new_from_stream_at_scale_async<'a, P: IsA, Q: Into>, R: /*Ignored*/gio::AsyncReadyCallback>(stream: &P, width: i32, height: i32, preserve_aspect_ratio: bool, cancellable: Q, callback: R) { - // unsafe { TODO: call ffi::gdk_pixbuf_new_from_stream_at_scale_async() } - //} } pub trait PixbufExt { + fn add_alpha(&self, substitute_color: bool, r: u8, g: u8, b: u8) -> Option; + fn apply_embedded_orientation(&self) -> Option; + fn composite(&self, dest: &Pixbuf, dest_x: i32, dest_y: i32, dest_width: i32, dest_height: i32, offset_x: f64, offset_y: f64, scale_x: f64, scale_y: f64, interp_type: InterpType, overall_alpha: i32); + + fn composite_color(&self, dest: &Pixbuf, dest_x: i32, dest_y: i32, dest_width: i32, dest_height: i32, offset_x: f64, offset_y: f64, scale_x: f64, scale_y: f64, interp_type: InterpType, overall_alpha: i32, check_x: i32, check_y: i32, check_size: i32, color1: u32, color2: u32); + + fn composite_color_simple(&self, dest_width: i32, dest_height: i32, interp_type: InterpType, overall_alpha: i32, check_size: i32, color1: u32, color2: u32) -> Option; + + fn copy(&self) -> Option; + + fn copy_area(&self, src_x: i32, src_y: i32, width: i32, height: i32, dest_pixbuf: &Pixbuf, dest_x: i32, dest_y: i32); + #[cfg(any(feature = "v2_36", feature = "dox"))] fn copy_options(&self, dest_pixbuf: &Pixbuf) -> bool; fn fill(&self, pixel: u32); + fn flip(&self, horizontal: bool) -> Option; + + fn get_bits_per_sample(&self) -> i32; + + fn get_byte_length(&self) -> usize; + + fn get_colorspace(&self) -> Colorspace; + + fn get_has_alpha(&self) -> bool; + + fn get_height(&self) -> i32; + + fn get_n_channels(&self) -> i32; + fn get_option(&self, key: &str) -> Option; //#[cfg(any(feature = "v2_32", feature = "dox"))] //fn get_options(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }; + fn get_rowstride(&self) -> i32; + + fn get_width(&self) -> i32; + fn new_subpixbuf(&self, src_x: i32, src_y: i32, width: i32, height: i32) -> Option; + #[cfg(any(feature = "v2_32", feature = "dox"))] + fn read_pixel_bytes(&self) -> Option; + #[cfg(any(feature = "v2_36", feature = "dox"))] fn remove_option(&self, key: &str) -> bool; + fn rotate_simple(&self, angle: PixbufRotation) -> Option; + + fn saturate_and_pixelate(&self, dest: &Pixbuf, saturation: f32, pixelate: bool); + //fn save<'a, P: Into>>(&self, filename: &str, type_: &str, error: P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool; //fn save_to_buffer<'a, P: Into>>(&self, type_: &str, error: P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option>; - fn save_to_bufferv(&self, type_: &str, option_keys: &[&str], option_values: &[&str]) -> Result, Error>; - //fn save_to_callback<'a, P: Into>, Q: Into>>(&self, save_func: /*Unknown conversion*//*Unimplemented*/PixbufSaveFunc, user_data: P, type_: &str, error: Q, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool; //fn save_to_callbackv>>(&self, save_func: /*Unknown conversion*//*Unimplemented*/PixbufSaveFunc, user_data: P, type_: &str, option_keys: &[&str], option_values: &[&str]) -> Result<(), Error>; - //fn save_to_stream<'a, 'b, P: IsA, Q: Into>, R: Into>>(&self, stream: &P, type_: &str, cancellable: Q, error: R, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool; + //fn save_to_stream<'a, 'b, P: IsA, Q: Into>, R: Into>>(&self, stream: &P, type_: &str, cancellable: Q, error: R, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool; - //fn save_to_stream_async<'a, P: IsA, Q: Into>, R: Fn(Result<(), Error>) + Send + Sync + 'static>(&self, stream: &P, type_: &str, cancellable: Q, callback: R, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); + //fn save_to_stream_async<'a, P: IsA, Q: Into>, R: FnOnce(Result<(), Error>) + Send + 'static>(&self, stream: &P, type_: &str, cancellable: Q, callback: R, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); //#[cfg(any(feature = "v2_36", feature = "dox"))] - //fn save_to_streamv<'a, P: IsA, Q: Into>>(&self, stream: &P, type_: &str, option_keys: &[&str], option_values: &[&str], cancellable: Q) -> Result<(), Error>; + //fn save_to_streamv_async<'a, P: IsA, Q: Into>, R: /*Unimplemented*/gio::AsyncReadyCallback>(&self, stream: &P, type_: &str, option_keys: &[&str], option_values: &[&str], cancellable: Q, callback: R); - //#[cfg(any(feature = "v2_36", feature = "dox"))] - //fn save_to_streamv_async<'a, P: IsA, Q: Into>, R: /*Ignored*/gio::AsyncReadyCallback>(&self, stream: &P, type_: &str, option_keys: &[&str], option_values: &[&str], cancellable: Q, callback: R); + fn scale(&self, dest: &Pixbuf, dest_x: i32, dest_y: i32, dest_width: i32, dest_height: i32, offset_x: f64, offset_y: f64, scale_x: f64, scale_y: f64, interp_type: InterpType); - fn savev(&self, filename: &str, type_: &str, option_keys: &[&str], option_values: &[&str]) -> Result<(), Error>; + fn scale_simple(&self, dest_width: i32, dest_height: i32, interp_type: InterpType) -> Option; fn set_option(&self, key: &str, value: &str) -> bool; - fn get_property_bits_per_sample(&self) -> i32; - - fn get_property_colorspace(&self) -> Colorspace; - - fn get_property_has_alpha(&self) -> bool; - - fn get_property_height(&self) -> i32; - - fn get_property_n_channels(&self) -> i32; - fn get_property_pixel_bytes(&self) -> Option; //fn get_property_pixels(&self) -> /*Unimplemented*/Fundamental: Pointer; - fn get_property_rowstride(&self) -> i32; - - fn get_property_width(&self) -> i32; - fn connect_property_bits_per_sample_notify(&self, f: F) -> SignalHandlerId; fn connect_property_colorspace_notify(&self, f: F) -> SignalHandlerId; @@ -221,12 +213,48 @@ pub trait PixbufExt { } impl + IsA> PixbufExt for O { + fn add_alpha(&self, substitute_color: bool, r: u8, g: u8, b: u8) -> Option { + unsafe { + from_glib_full(ffi::gdk_pixbuf_add_alpha(const_override(self.to_glib_none().0), substitute_color.to_glib(), r, g, b)) + } + } + fn apply_embedded_orientation(&self) -> Option { unsafe { from_glib_full(ffi::gdk_pixbuf_apply_embedded_orientation(self.to_glib_none().0)) } } + fn composite(&self, dest: &Pixbuf, dest_x: i32, dest_y: i32, dest_width: i32, dest_height: i32, offset_x: f64, offset_y: f64, scale_x: f64, scale_y: f64, interp_type: InterpType, overall_alpha: i32) { + unsafe { + ffi::gdk_pixbuf_composite(const_override(self.to_glib_none().0), dest.to_glib_none().0, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type.to_glib(), overall_alpha); + } + } + + fn composite_color(&self, dest: &Pixbuf, dest_x: i32, dest_y: i32, dest_width: i32, dest_height: i32, offset_x: f64, offset_y: f64, scale_x: f64, scale_y: f64, interp_type: InterpType, overall_alpha: i32, check_x: i32, check_y: i32, check_size: i32, color1: u32, color2: u32) { + unsafe { + ffi::gdk_pixbuf_composite_color(const_override(self.to_glib_none().0), dest.to_glib_none().0, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type.to_glib(), overall_alpha, check_x, check_y, check_size, color1, color2); + } + } + + fn composite_color_simple(&self, dest_width: i32, dest_height: i32, interp_type: InterpType, overall_alpha: i32, check_size: i32, color1: u32, color2: u32) -> Option { + unsafe { + from_glib_full(ffi::gdk_pixbuf_composite_color_simple(const_override(self.to_glib_none().0), dest_width, dest_height, interp_type.to_glib(), overall_alpha, check_size, color1, color2)) + } + } + + fn copy(&self) -> Option { + unsafe { + from_glib_full(ffi::gdk_pixbuf_copy(const_override(self.to_glib_none().0))) + } + } + + fn copy_area(&self, src_x: i32, src_y: i32, width: i32, height: i32, dest_pixbuf: &Pixbuf, dest_x: i32, dest_y: i32) { + unsafe { + ffi::gdk_pixbuf_copy_area(const_override(self.to_glib_none().0), src_x, src_y, width, height, dest_pixbuf.to_glib_none().0, dest_x, dest_y); + } + } + #[cfg(any(feature = "v2_36", feature = "dox"))] fn copy_options(&self, dest_pixbuf: &Pixbuf) -> bool { unsafe { @@ -240,6 +268,48 @@ impl + IsA> PixbufExt for O { } } + fn flip(&self, horizontal: bool) -> Option { + unsafe { + from_glib_full(ffi::gdk_pixbuf_flip(const_override(self.to_glib_none().0), horizontal.to_glib())) + } + } + + fn get_bits_per_sample(&self) -> i32 { + unsafe { + ffi::gdk_pixbuf_get_bits_per_sample(const_override(self.to_glib_none().0)) + } + } + + fn get_byte_length(&self) -> usize { + unsafe { + ffi::gdk_pixbuf_get_byte_length(const_override(self.to_glib_none().0)) + } + } + + fn get_colorspace(&self) -> Colorspace { + unsafe { + from_glib(ffi::gdk_pixbuf_get_colorspace(const_override(self.to_glib_none().0))) + } + } + + fn get_has_alpha(&self) -> bool { + unsafe { + from_glib(ffi::gdk_pixbuf_get_has_alpha(const_override(self.to_glib_none().0))) + } + } + + fn get_height(&self) -> i32 { + unsafe { + ffi::gdk_pixbuf_get_height(const_override(self.to_glib_none().0)) + } + } + + fn get_n_channels(&self) -> i32 { + unsafe { + ffi::gdk_pixbuf_get_n_channels(const_override(self.to_glib_none().0)) + } + } + fn get_option(&self, key: &str) -> Option { unsafe { from_glib_none(ffi::gdk_pixbuf_get_option(self.to_glib_none().0, key.to_glib_none().0)) @@ -251,12 +321,31 @@ impl + IsA> PixbufExt for O { // unsafe { TODO: call ffi::gdk_pixbuf_get_options() } //} + fn get_rowstride(&self) -> i32 { + unsafe { + ffi::gdk_pixbuf_get_rowstride(const_override(self.to_glib_none().0)) + } + } + + fn get_width(&self) -> i32 { + unsafe { + ffi::gdk_pixbuf_get_width(const_override(self.to_glib_none().0)) + } + } + fn new_subpixbuf(&self, src_x: i32, src_y: i32, width: i32, height: i32) -> Option { unsafe { from_glib_full(ffi::gdk_pixbuf_new_subpixbuf(self.to_glib_none().0, src_x, src_y, width, height)) } } + #[cfg(any(feature = "v2_32", feature = "dox"))] + fn read_pixel_bytes(&self) -> Option { + unsafe { + from_glib_full(ffi::gdk_pixbuf_read_pixel_bytes(const_override(self.to_glib_none().0))) + } + } + #[cfg(any(feature = "v2_36", feature = "dox"))] fn remove_option(&self, key: &str) -> bool { unsafe { @@ -264,6 +353,18 @@ impl + IsA> PixbufExt for O { } } + fn rotate_simple(&self, angle: PixbufRotation) -> Option { + unsafe { + from_glib_full(ffi::gdk_pixbuf_rotate_simple(const_override(self.to_glib_none().0), angle.to_glib())) + } + } + + fn saturate_and_pixelate(&self, dest: &Pixbuf, saturation: f32, pixelate: bool) { + unsafe { + ffi::gdk_pixbuf_saturate_and_pixelate(const_override(self.to_glib_none().0), dest.to_glib_none().0, saturation, pixelate.to_glib()); + } + } + //fn save<'a, P: Into>>(&self, filename: &str, type_: &str, error: P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { // unsafe { TODO: call ffi::gdk_pixbuf_save() } //} @@ -272,16 +373,6 @@ impl + IsA> PixbufExt for O { // unsafe { TODO: call ffi::gdk_pixbuf_save_to_buffer() } //} - fn save_to_bufferv(&self, type_: &str, option_keys: &[&str], option_values: &[&str]) -> Result, Error> { - unsafe { - let mut buffer = ptr::null_mut(); - let mut buffer_size = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::gdk_pixbuf_save_to_bufferv(self.to_glib_none().0, &mut buffer, &mut buffer_size, type_.to_glib_none().0, option_keys.to_glib_none().0, option_values.to_glib_none().0, &mut error); - if error.is_null() { Ok(FromGlibContainer::from_glib_full_num(buffer, buffer_size as usize)) } else { Err(from_glib_full(error)) } - } - } - //fn save_to_callback<'a, P: Into>, Q: Into>>(&self, save_func: /*Unknown conversion*//*Unimplemented*/PixbufSaveFunc, user_data: P, type_: &str, error: Q, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { // unsafe { TODO: call ffi::gdk_pixbuf_save_to_callback() } //} @@ -290,75 +381,34 @@ impl + IsA> PixbufExt for O { // unsafe { TODO: call ffi::gdk_pixbuf_save_to_callbackv() } //} - //fn save_to_stream<'a, 'b, P: IsA, Q: Into>, R: Into>>(&self, stream: &P, type_: &str, cancellable: Q, error: R, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { + //fn save_to_stream<'a, 'b, P: IsA, Q: Into>, R: Into>>(&self, stream: &P, type_: &str, cancellable: Q, error: R, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { // unsafe { TODO: call ffi::gdk_pixbuf_save_to_stream() } //} - //fn save_to_stream_async<'a, P: IsA, Q: Into>, R: Fn(Result<(), Error>) + Send + Sync + 'static>(&self, stream: &P, type_: &str, cancellable: Q, callback: R, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { + //fn save_to_stream_async<'a, P: IsA, Q: Into>, R: FnOnce(Result<(), Error>) + Send + 'static>(&self, stream: &P, type_: &str, cancellable: Q, callback: R, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call ffi::gdk_pixbuf_save_to_stream_async() } //} //#[cfg(any(feature = "v2_36", feature = "dox"))] - //fn save_to_streamv<'a, P: IsA, Q: Into>>(&self, stream: &P, type_: &str, option_keys: &[&str], option_values: &[&str], cancellable: Q) -> Result<(), Error> { - // unsafe { TODO: call ffi::gdk_pixbuf_save_to_streamv() } - //} - - //#[cfg(any(feature = "v2_36", feature = "dox"))] - //fn save_to_streamv_async<'a, P: IsA, Q: Into>, R: /*Ignored*/gio::AsyncReadyCallback>(&self, stream: &P, type_: &str, option_keys: &[&str], option_values: &[&str], cancellable: Q, callback: R) { + //fn save_to_streamv_async<'a, P: IsA, Q: Into>, R: /*Unimplemented*/gio::AsyncReadyCallback>(&self, stream: &P, type_: &str, option_keys: &[&str], option_values: &[&str], cancellable: Q, callback: R) { // unsafe { TODO: call ffi::gdk_pixbuf_save_to_streamv_async() } //} - fn savev(&self, filename: &str, type_: &str, option_keys: &[&str], option_values: &[&str]) -> Result<(), Error> { - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::gdk_pixbuf_savev(self.to_glib_none().0, filename.to_glib_none().0, type_.to_glib_none().0, option_keys.to_glib_none().0, option_values.to_glib_none().0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn set_option(&self, key: &str, value: &str) -> bool { - unsafe { - from_glib(ffi::gdk_pixbuf_set_option(self.to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0)) - } - } - - fn get_property_bits_per_sample(&self) -> i32 { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_ffi::g_object_get_property(self.to_glib_none().0, "bits-per-sample".to_glib_none().0, value.to_glib_none_mut().0); - value.get().unwrap() - } - } - - fn get_property_colorspace(&self) -> Colorspace { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_ffi::g_object_get_property(self.to_glib_none().0, "colorspace".to_glib_none().0, value.to_glib_none_mut().0); - value.get().unwrap() - } - } - - fn get_property_has_alpha(&self) -> bool { + fn scale(&self, dest: &Pixbuf, dest_x: i32, dest_y: i32, dest_width: i32, dest_height: i32, offset_x: f64, offset_y: f64, scale_x: f64, scale_y: f64, interp_type: InterpType) { unsafe { - let mut value = Value::from_type(::static_type()); - gobject_ffi::g_object_get_property(self.to_glib_none().0, "has-alpha".to_glib_none().0, value.to_glib_none_mut().0); - value.get().unwrap() + ffi::gdk_pixbuf_scale(const_override(self.to_glib_none().0), dest.to_glib_none().0, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type.to_glib()); } } - fn get_property_height(&self) -> i32 { + fn scale_simple(&self, dest_width: i32, dest_height: i32, interp_type: InterpType) -> Option { unsafe { - let mut value = Value::from_type(::static_type()); - gobject_ffi::g_object_get_property(self.to_glib_none().0, "height".to_glib_none().0, value.to_glib_none_mut().0); - value.get().unwrap() + from_glib_full(ffi::gdk_pixbuf_scale_simple(const_override(self.to_glib_none().0), dest_width, dest_height, interp_type.to_glib())) } } - fn get_property_n_channels(&self) -> i32 { + fn set_option(&self, key: &str, value: &str) -> bool { unsafe { - let mut value = Value::from_type(::static_type()); - gobject_ffi::g_object_get_property(self.to_glib_none().0, "n-channels".to_glib_none().0, value.to_glib_none_mut().0); - value.get().unwrap() + from_glib(ffi::gdk_pixbuf_set_option(self.to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0)) } } @@ -378,22 +428,6 @@ impl + IsA> PixbufExt for O { // } //} - fn get_property_rowstride(&self) -> i32 { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_ffi::g_object_get_property(self.to_glib_none().0, "rowstride".to_glib_none().0, value.to_glib_none_mut().0); - value.get().unwrap() - } - } - - fn get_property_width(&self) -> i32 { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_ffi::g_object_get_property(self.to_glib_none().0, "width".to_glib_none().0, value.to_glib_none_mut().0); - value.get().unwrap() - } - } - fn connect_property_bits_per_sample_notify(&self, f: F) -> SignalHandlerId { unsafe { let f: Box_> = Box_::new(Box_::new(f)); diff --git a/src/auto/pixbuf_format.rs b/src/auto/pixbuf_format.rs index 622198ae..09c75549 100644 --- a/src/auto/pixbuf_format.rs +++ b/src/auto/pixbuf_format.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (d8a605d) from gir-files (469db10) +// This file was generated by gir (5a68ad0) from gir-files (469db10) // DO NOT EDIT use ffi; @@ -19,58 +19,58 @@ glib_wrapper! { } impl PixbufFormat { - pub fn get_description(&mut self) -> Option { + pub fn get_description(&self) -> Option { unsafe { - from_glib_full(ffi::gdk_pixbuf_format_get_description(self.to_glib_none_mut().0)) + from_glib_full(ffi::gdk_pixbuf_format_get_description(mut_override(self.to_glib_none().0))) } } - pub fn get_extensions(&mut self) -> Vec { + pub fn get_extensions(&self) -> Vec { unsafe { - FromGlibPtrContainer::from_glib_full(ffi::gdk_pixbuf_format_get_extensions(self.to_glib_none_mut().0)) + FromGlibPtrContainer::from_glib_full(ffi::gdk_pixbuf_format_get_extensions(mut_override(self.to_glib_none().0))) } } - pub fn get_license(&mut self) -> Option { + pub fn get_license(&self) -> Option { unsafe { - from_glib_full(ffi::gdk_pixbuf_format_get_license(self.to_glib_none_mut().0)) + from_glib_full(ffi::gdk_pixbuf_format_get_license(mut_override(self.to_glib_none().0))) } } - pub fn get_mime_types(&mut self) -> Vec { + pub fn get_mime_types(&self) -> Vec { unsafe { - FromGlibPtrContainer::from_glib_full(ffi::gdk_pixbuf_format_get_mime_types(self.to_glib_none_mut().0)) + FromGlibPtrContainer::from_glib_full(ffi::gdk_pixbuf_format_get_mime_types(mut_override(self.to_glib_none().0))) } } - pub fn get_name(&mut self) -> Option { + pub fn get_name(&self) -> Option { unsafe { - from_glib_full(ffi::gdk_pixbuf_format_get_name(self.to_glib_none_mut().0)) + from_glib_full(ffi::gdk_pixbuf_format_get_name(mut_override(self.to_glib_none().0))) } } - pub fn is_disabled(&mut self) -> bool { + pub fn is_disabled(&self) -> bool { unsafe { - from_glib(ffi::gdk_pixbuf_format_is_disabled(self.to_glib_none_mut().0)) + from_glib(ffi::gdk_pixbuf_format_is_disabled(mut_override(self.to_glib_none().0))) } } #[cfg(any(feature = "v2_36", feature = "dox"))] - pub fn is_save_option_supported(&mut self, option_key: &str) -> bool { + pub fn is_save_option_supported(&self, option_key: &str) -> bool { unsafe { - from_glib(ffi::gdk_pixbuf_format_is_save_option_supported(self.to_glib_none_mut().0, option_key.to_glib_none().0)) + from_glib(ffi::gdk_pixbuf_format_is_save_option_supported(mut_override(self.to_glib_none().0), option_key.to_glib_none().0)) } } - pub fn is_scalable(&mut self) -> bool { + pub fn is_scalable(&self) -> bool { unsafe { - from_glib(ffi::gdk_pixbuf_format_is_scalable(self.to_glib_none_mut().0)) + from_glib(ffi::gdk_pixbuf_format_is_scalable(mut_override(self.to_glib_none().0))) } } - pub fn is_writable(&mut self) -> bool { + pub fn is_writable(&self) -> bool { unsafe { - from_glib(ffi::gdk_pixbuf_format_is_writable(self.to_glib_none_mut().0)) + from_glib(ffi::gdk_pixbuf_format_is_writable(mut_override(self.to_glib_none().0))) } } diff --git a/src/auto/pixbuf_loader.rs b/src/auto/pixbuf_loader.rs index f0152885..8f20c2cc 100644 --- a/src/auto/pixbuf_loader.rs +++ b/src/auto/pixbuf_loader.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (d8a605d) from gir-files (469db10) +// This file was generated by gir (5a68ad0) from gir-files (469db10) // DO NOT EDIT use Error; diff --git a/src/auto/pixbuf_simple_anim.rs b/src/auto/pixbuf_simple_anim.rs index 995726f3..27d0530a 100644 --- a/src/auto/pixbuf_simple_anim.rs +++ b/src/auto/pixbuf_simple_anim.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (d8a605d) from gir-files (469db10) +// This file was generated by gir (5a68ad0) from gir-files (469db10) // DO NOT EDIT use Pixbuf; diff --git a/src/pixbuf.rs b/src/pixbuf.rs index 45a4822e..22d783a8 100644 --- a/src/pixbuf.rs +++ b/src/pixbuf.rs @@ -3,17 +3,24 @@ // Licensed under the MIT license, see the LICENSE file or use std::mem; +use std::path::Path; use std::ptr; use std::slice; use libc::{c_void, c_uchar}; +use glib::object::IsA; use glib::translate::*; use glib::Error; +use gio; use ffi; +use glib_ffi; +use gobject_ffi; +use gio_ffi; use { Colorspace, - InterpType, Pixbuf, + PixbufExt, + PixbufFormat, }; impl Pixbuf { @@ -36,7 +43,7 @@ impl Pixbuf { } } - pub fn new_from_file(filename: &str) -> Result { + pub fn new_from_file>(filename: T) -> Result { #[cfg(windows)] use ffi::gdk_pixbuf_new_from_file_utf8 as gdk_pixbuf_new_from_file; #[cfg(not(windows))] @@ -44,7 +51,7 @@ impl Pixbuf { unsafe { let mut error = ptr::null_mut(); - let ptr = gdk_pixbuf_new_from_file(filename.to_glib_none().0, &mut error); + let ptr = gdk_pixbuf_new_from_file(filename.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ptr)) } else { @@ -53,7 +60,7 @@ impl Pixbuf { } } - pub fn new_from_file_at_size(filename: &str, width: i32, height: i32) -> Result { + pub fn new_from_file_at_size>(filename: T, width: i32, height: i32) -> Result { #[cfg(windows)] use ffi::gdk_pixbuf_new_from_file_at_size_utf8 as gdk_pixbuf_new_from_file_at_size; @@ -62,7 +69,7 @@ impl Pixbuf { unsafe { let mut error = ptr::null_mut(); - let ptr = gdk_pixbuf_new_from_file_at_size(filename.to_glib_none().0, width, height, + let ptr = gdk_pixbuf_new_from_file_at_size(filename.as_ref().to_glib_none().0, width, height, &mut error); if error.is_null() { Ok(from_glib_full(ptr)) @@ -72,7 +79,7 @@ impl Pixbuf { } } - pub fn new_from_file_at_scale(filename: &str, width: i32, height: i32, preserve_aspect_ratio: bool) -> Result { + pub fn new_from_file_at_scale>(filename: T, width: i32, height: i32, preserve_aspect_ratio: bool) -> Result { #[cfg(windows)] use ffi::gdk_pixbuf_new_from_file_at_scale_utf8 as gdk_pixbuf_new_from_file_at_scale; @@ -81,7 +88,7 @@ impl Pixbuf { unsafe { let mut error = ptr::null_mut(); - let ptr = gdk_pixbuf_new_from_file_at_scale(filename.to_glib_none().0, width, height, + let ptr = gdk_pixbuf_new_from_file_at_scale(filename.as_ref().to_glib_none().0, width, height, preserve_aspect_ratio.to_glib(), &mut error); if error.is_null() { Ok(from_glib_full(ptr)) @@ -91,20 +98,50 @@ impl Pixbuf { } } - pub fn get_colorspace(&self) -> Colorspace { - unsafe { from_glib(ffi::gdk_pixbuf_get_colorspace(self.to_glib_none().0)) } - } - - pub fn get_n_channels(&self) -> i32 { - unsafe { ffi::gdk_pixbuf_get_n_channels(self.to_glib_none().0) } - } - - pub fn get_has_alpha(&self) -> bool { - unsafe { from_glib(ffi::gdk_pixbuf_get_has_alpha(self.to_glib_none().0)) } + pub fn new_from_stream_async<'a, P: IsA, Q: Into>, R: FnOnce(Result) + Send + 'static>(stream: &P, cancellable: Q, callback: R) { + let cancellable = cancellable.into(); + let cancellable = cancellable.to_glib_none(); + let user_data: Box> = Box::new(Box::new(callback)); + unsafe extern "C" fn new_from_stream_async_trampoline) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer) + { + callback_guard!(); + let mut error = ptr::null_mut(); + let ptr = ffi::gdk_pixbuf_new_from_stream_finish(res, &mut error); + let result = if error.is_null() { + Ok(from_glib_full(ptr)) + } else { + Err(from_glib_full(error)) + }; + let callback: Box> = Box::from_raw(user_data as *mut _); + callback(result); + } + let callback = new_from_stream_async_trampoline::; + unsafe { + ffi::gdk_pixbuf_new_from_stream_async(stream.to_glib_none().0, cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _); + } } - pub fn get_bits_per_sample(&self) -> i32 { - unsafe { ffi::gdk_pixbuf_get_bits_per_sample(self.to_glib_none().0) } + pub fn new_from_stream_at_scale_async<'a, P: IsA, Q: Into>, R: FnOnce(Result) + Send + 'static>(stream: &P, width: i32, height: i32, preserve_aspect_ratio: bool, cancellable: Q, callback: R) { + let cancellable = cancellable.into(); + let cancellable = cancellable.to_glib_none(); + let user_data: Box> = Box::new(Box::new(callback)); + unsafe extern "C" fn new_from_stream_at_scale_async_trampoline) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer) + { + callback_guard!(); + let mut error = ptr::null_mut(); + let ptr = ffi::gdk_pixbuf_new_from_stream_finish(res, &mut error); + let result = if error.is_null() { + Ok(from_glib_full(ptr)) + } else { + Err(from_glib_full(error)) + }; + let callback: Box> = Box::from_raw(user_data as *mut _); + callback(result); + } + let callback = new_from_stream_at_scale_async_trampoline::; + unsafe { + ffi::gdk_pixbuf_new_from_stream_at_scale_async(stream.to_glib_none().0, width, height, preserve_aspect_ratio.to_glib(), cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _); + } } pub unsafe fn get_pixels(&self) -> &mut [u8] { @@ -113,75 +150,93 @@ impl Pixbuf { slice::from_raw_parts_mut(ptr, len as usize) } - pub fn get_width(&self) -> i32 { - unsafe { ffi::gdk_pixbuf_get_width(self.to_glib_none().0) } - } - - pub fn get_height(&self) -> i32 { - unsafe { ffi::gdk_pixbuf_get_height(self.to_glib_none().0) } - } - - pub fn get_rowstride(&self) -> i32 { - unsafe { ffi::gdk_pixbuf_get_rowstride(self.to_glib_none().0) } - } - - pub fn get_byte_length(&self) -> usize { - unsafe { ffi::gdk_pixbuf_get_byte_length(self.to_glib_none().0) as usize } - } - - pub fn scale_simple(&self, dest_width: i32, dest_height: i32, interp_type: InterpType) - -> Result { + pub fn put_pixel(&self, x: i32, y: i32, red: u8, green: u8, blue: u8, alpha: u8) { unsafe { - Option::from_glib_full(ffi::gdk_pixbuf_scale_simple(self.to_glib_none().0, dest_width, - dest_height, interp_type.to_glib())).ok_or(()) + let n_channels = self.get_n_channels(); + let rowstride = self.get_rowstride(); + let pixels = self.get_pixels(); + let pos = (y * rowstride + x * n_channels) as usize; + + pixels[pos] = red; + pixels[pos + 1] = green; + pixels[pos + 2] = blue; + pixels[pos + 3] = alpha; } } - pub fn scale(&self, dest: &Pixbuf, dest_x: i32, dest_y: i32, dest_width: i32, dest_height: i32, - offset_x: f64, offset_y: f64, scale_x: f64, scale_y: f64, - interp_type: InterpType) { + pub fn get_file_info>(filename: T) -> Option<(PixbufFormat, i32, i32)> { unsafe { - ffi::gdk_pixbuf_scale(self.to_glib_none().0, dest.to_glib_none().0, dest_x, dest_y, - dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, - interp_type.to_glib()); + let mut width = mem::uninitialized(); + let mut height = mem::uninitialized(); + let ret = ffi::gdk_pixbuf_get_file_info(filename.as_ref().to_glib_none().0, &mut width, &mut height); + if !ret.is_null() { + Some((from_glib_none(ret), width, height)) + } else { + None + } } } - pub fn composite(&self, dest: &Pixbuf, dest_x: i32, dest_y: i32, dest_width: i32, - dest_height: i32, offset_x: f64, offset_y: f64, scale_x: f64, scale_y: f64, - interp_type: InterpType, overall_alpha: i32) { + #[cfg(any(feature = "v2_32", feature = "dox"))] + pub fn get_file_info_async<'a, P: Into>, Q: FnOnce(Result, Error>) + Send + 'static, T: AsRef>(filename: T, cancellable: P, callback: Q) { + let cancellable = cancellable.into(); + let cancellable = cancellable.to_glib_none(); + let user_data: Box> = Box::new(Box::new(callback)); + unsafe extern "C" fn get_file_info_async_trampoline, Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer) + { + callback_guard!(); + let mut error = ptr::null_mut(); + let mut width = mem::uninitialized(); + let mut height = mem::uninitialized(); + let ret = ffi::gdk_pixbuf_get_file_info_finish(res, &mut width, &mut height, &mut error); + let result = if !error.is_null() { + Err(from_glib_full(error)) + } else if ret.is_null() { + Ok(None) + } else { + Ok(Some((from_glib_none(ret), width, height))) + }; + let callback: Box> = Box::from_raw(user_data as *mut _); + callback(result); + } + let callback = get_file_info_async_trampoline::; unsafe { - ffi::gdk_pixbuf_composite(self.to_glib_none().0, dest.to_glib_none().0, dest_x, dest_y, - dest_width, dest_height, offset_x, offset_y, scale_x, - scale_y, interp_type.to_glib(), overall_alpha); + ffi::gdk_pixbuf_get_file_info_async(filename.as_ref().to_glib_none().0, cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _); } } - pub fn flip(&self, horizontal: bool) -> Result { + pub fn save_to_bufferv(&self, type_: &str, options: &[(&str, &str)]) -> Result, Error> { unsafe { - Option::from_glib_full((ffi::gdk_pixbuf_flip(self.to_glib_none().0, - horizontal.to_glib()))).ok_or(()) + let mut buffer = ptr::null_mut(); + let mut buffer_size = mem::uninitialized(); + let mut error = ptr::null_mut(); + let option_keys: Vec<&str> = options.iter().map(|o| o.0).collect(); + let option_values: Vec<&str> = options.iter().map(|o| o.1).collect(); + let _ = ffi::gdk_pixbuf_save_to_bufferv(self.to_glib_none().0, &mut buffer, &mut buffer_size, type_.to_glib_none().0, option_keys.to_glib_none().0, option_values.to_glib_none().0, &mut error); + if error.is_null() { Ok(FromGlibContainer::from_glib_full_num(buffer, buffer_size as usize)) } else { Err(from_glib_full(error)) } } } - pub fn put_pixel(&self, x: i32, y: i32, red: u8, green: u8, blue: u8, alpha: u8) { + #[cfg(any(feature = "v2_36", feature = "dox"))] + pub fn save_to_streamv<'a, P: IsA, Q: Into>>(&self, stream: &P, type_: &str, options: &[(&str, &str)], cancellable: Q) -> Result<(), Error> { + let cancellable = cancellable.into(); + let cancellable = cancellable.to_glib_none(); unsafe { - let n_channels = self.get_n_channels(); - let rowstride = self.get_rowstride(); - let pixels = self.get_pixels(); - let pos = (y * rowstride + x * n_channels) as usize; - - pixels[pos] = red; - pixels[pos + 1] = green; - pixels[pos + 2] = blue; - pixels[pos + 3] = alpha; + let mut error = ptr::null_mut(); + let option_keys: Vec<&str> = options.iter().map(|o| o.0).collect(); + let option_values: Vec<&str> = options.iter().map(|o| o.1).collect(); + let _ = ffi::gdk_pixbuf_save_to_streamv(self.to_glib_none().0, stream.to_glib_none().0, type_.to_glib_none().0, option_keys.to_glib_none().0, option_values.to_glib_none().0, cancellable.0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } - pub fn copy(&self) -> Pixbuf { + pub fn savev>(&self, filename: T, type_: &str, options: &[(&str, &str)]) -> Result<(), Error> { unsafe { - let copy = ffi::gdk_pixbuf_copy(self.to_glib_none().0); - FromGlibPtrFull::from_glib_full(copy) + let mut error = ptr::null_mut(); + let option_keys: Vec<&str> = options.iter().map(|o| o.0).collect(); + let option_values: Vec<&str> = options.iter().map(|o| o.1).collect(); + let _ = ffi::gdk_pixbuf_savev(self.to_glib_none().0, filename.as_ref().to_glib_none().0, type_.to_glib_none().0, option_keys.to_glib_none().0, option_values.to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } }