gdk-pixbuf-0.7.0/.gitignore010064400007650000024000000000231350341530200137540ustar0000000000000000Cargo.lock target/ gdk-pixbuf-0.7.0/.gitmodules010064400007650000024000000002401350341530200141420ustar0000000000000000[submodule "gir"] path = gir url = https://github.com/gtk-rs/gir.git [submodule "gir-files"] path = gir-files url = https://github.com/gtk-rs/gir-files.git gdk-pixbuf-0.7.0/.travis.yml010064400007650000024000000034041350341657000141130ustar0000000000000000dist: xenial language: rust matrix: include: - os: linux rust: nightly env: GTK=3.14 - os: linux rust: nightly env: GTK=3.24 FEATURES=v2_32 - os: linux rust: beta env: GTK=3.14 - os: linux rust: beta env: GTK=3.24 FEATURES=v2_32 - os: linux rust: 1.34.0 env: GTK=3.14 - os: linux rust: 1.34.0 env: GTK=3.24 FEATURES=v2_32 - os: osx rust: nightly env: GTK=3.14 # - os: osx # rust: nightly # env: GTK=3.24 FEATURES=v2_32 - os: osx rust: beta env: GTK=3.14 # - os: osx # rust: beta # env: GTK=3.24 FEATURES=v2_32 - os: osx rust: stable env: GTK=3.14 # - os: osx # rust: stable # env: GTK=3.24 FEATURES=v2_32 sudo: true addons: apt: packages: - libgtk-3-dev - libmount-dev before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gtk+3 cairo atk; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig; fi script: - rustc --version - if [ "$TRAVIS_RUST_VERSION" == "nightly" ] && [ "$GTK" == "3.14" ]; then rustup component add rustfmt; make regen_check; fi - cargo doc --features "dox,embed-lgpl-docs" - cargo test --features "$FEATURES,embed-lgpl-docs" # catch any sneaked in lgpl docs - cargo build --features "$FEATURES,purge-lgpl-docs" --jobs 1 - git diff -R --exit-code - rustc --version - mkdir .cargo - echo 'paths = ["."]' > .cargo/config - git clone -q --depth 50 -b pending https://github.com/gtk-rs/examples _examples - cd _examples - ./build_travis.sh gdk-pixbuf-0.7.0/appveyor.yml010064400007650000024000000014511350341530200143620ustar0000000000000000environment: matrix: - RUST: stable BITS: 32 - RUST: stable BITS: 64 install: - IF "%BITS%" == "32" SET ARCH=i686 - IF "%BITS%" == "64" SET ARCH=x86_64 - curl -sSf -o rustup-init.exe https://win.rustup.rs - rustup-init.exe --default-host "%ARCH%-pc-windows-gnu" --default-toolchain %RUST% -y - SET PATH=C:\Users\appveyor\.cargo\bin;C:\msys64\mingw%BITS%\bin;%PATH%;C:\msys64\usr\bin - rustc -Vv - cargo -Vv - pacman --noconfirm -S mingw-w64-%ARCH%-gtk3 build_script: - cargo doc --features "dox" - cargo test - cargo test --features v2_36_8 - mkdir .cargo - echo paths = ["."] > .cargo\config - git clone -q --depth 50 -b pending https://github.com/gtk-rs/examples _examples - cd _examples - cargo build - cargo build --features gtk_3_24 test: false gdk-pixbuf-0.7.0/build.rs010064400007650000024000000007731350341657000134550ustar0000000000000000fn main() { manage_docs(); } #[cfg(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs"))] fn manage_docs() { extern crate lgpl_docs; const PATH: &'static str = "src"; const IGNORES: &'static [&'static str] = &["prelude.rs"]; lgpl_docs::purge(PATH, IGNORES); if cfg!(feature = "embed-lgpl-docs") { lgpl_docs::embed(lgpl_docs::Library::GdkPixbuf, PATH, IGNORES); } } #[cfg(not(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs")))] fn manage_docs() {} gdk-pixbuf-0.7.0/Cargo.toml.orig010064400007650000024000000023741350341713700146760ustar0000000000000000[package] name = "gdk-pixbuf" license = "MIT" homepage = "http://gtk-rs.org/" authors = ["The Gtk-rs Project Developers"] keywords = ["gdk-pixbuf", "gtk-rs", "gnome"] readme = "README.md" documentation = "http://gtk-rs.org/docs/gdk_pixbuf/" version = "0.7.0" description = "Rust bindings for the GdkPixbuf library" repository = "https://github.com/gtk-rs/gdk-pixbuf" build = "build.rs" exclude = [ "gir-files/*", ] [badges] appveyor = { repository = "GuillaumeGomez/gdk-pixbuf", service = "github" } travis-ci = { repository = "gtk-rs/gdk-pixbuf" } [lib] name = "gdk_pixbuf" [features] v2_32 = ["gdk-pixbuf-sys/v2_32"] v2_36 = ["v2_32", "gdk-pixbuf-sys/v2_36"] v2_36_8 = ["v2_36", "gdk-pixbuf-sys/v2_36_8"] dox = ["glib/dox", "gdk-pixbuf-sys/dox"] purge-lgpl-docs = ["gtk-rs-lgpl-docs"] embed-lgpl-docs = ["gtk-rs-lgpl-docs"] futures = ["futures-preview", "fragile", "glib/futures", "gio/futures"] [build-dependencies.gtk-rs-lgpl-docs] version = "0.1.3" optional = true [dependencies] libc = "0.2" fragile = { version = "0.3", optional = true } futures-preview = { version = "0.3.0-alpha", optional = true } gdk-pixbuf-sys = "0.9.0" glib = "0.8.0" glib-sys = "0.9.0" gobject-sys = "0.9.0" gio-sys = "0.9.0" gio = "0.7.0" [dev-dependencies] gir-format-check = "^0.1" gdk-pixbuf-0.7.0/Cargo.toml0000644000000036550000000000000111460ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] name = "gdk-pixbuf" version = "0.7.0" authors = ["The Gtk-rs Project Developers"] build = "build.rs" exclude = ["gir-files/*"] description = "Rust bindings for the GdkPixbuf library" homepage = "http://gtk-rs.org/" documentation = "http://gtk-rs.org/docs/gdk_pixbuf/" readme = "README.md" keywords = ["gdk-pixbuf", "gtk-rs", "gnome"] license = "MIT" repository = "https://github.com/gtk-rs/gdk-pixbuf" [lib] name = "gdk_pixbuf" [dependencies.fragile] version = "0.3" optional = true [dependencies.futures-preview] version = "0.3.0-alpha" optional = true [dependencies.gdk-pixbuf-sys] version = "0.9.0" [dependencies.gio] version = "0.7.0" [dependencies.gio-sys] version = "0.9.0" [dependencies.glib] version = "0.8.0" [dependencies.glib-sys] version = "0.9.0" [dependencies.gobject-sys] version = "0.9.0" [dependencies.libc] version = "0.2" [dev-dependencies.gir-format-check] version = "^0.1" [build-dependencies.gtk-rs-lgpl-docs] version = "0.1.3" optional = true [features] dox = ["glib/dox", "gdk-pixbuf-sys/dox"] embed-lgpl-docs = ["gtk-rs-lgpl-docs"] futures = ["futures-preview", "fragile", "glib/futures", "gio/futures"] purge-lgpl-docs = ["gtk-rs-lgpl-docs"] v2_32 = ["gdk-pixbuf-sys/v2_32"] v2_36 = ["v2_32", "gdk-pixbuf-sys/v2_36"] v2_36_8 = ["v2_36", "gdk-pixbuf-sys/v2_36_8"] [badges.appveyor] repository = "GuillaumeGomez/gdk-pixbuf" service = "github" [badges.travis-ci] repository = "gtk-rs/gdk-pixbuf" gdk-pixbuf-0.7.0/COPYRIGHT010064400007650000024000000050021350341530200132610ustar0000000000000000The Gtk-rs Project is copyright 2013-2016, The Gtk-rs Project Developers: Adam Crume Adolfo Ochagavía Andre Bogus Anton Konjahin Arne Dussin Boden Garman Brian Kropf Bryant Mairs Chris Greenaway Chris Palmer Corey Farwell Daniel Zalevskiy David Li Edward Shaw Edward Yang Esption Evgenii Pashkin Geoffrey French Gleb Kozyrev Glenn Watson Google Inc. Guillaume Gomez Gulshan Singh Jakob Gillich James Shepherdson Jeremy Letang John Vrbanac kennytm Laurence Tratt Lionel Flandrin Lucas Werkmeister Lukas Diekmann Mathijs Henquet Maxwell Koo mitaa Nick Herman Nicolas Koch Oliver Schneider Ömer Sinan Ağacan Ralph Giles Paul Dennis Paul Hendry Philipp Brüschweiler Raphael Nestler Robertas Romain Gauthier S.J.R. van Schaik Sebastian Schulze Silvio Fricke Simon Sapin Steve Klabnik Tobias Bales trolleyman Umur Gedik UrKr Vojtech Kral Zach Oakes Zach Ploskey The Gtk-rs Project is licensed under the MIT license, see the LICENSE file or . This project provides interoperability with various GNOME libraries but doesn't distribute any parts of them. Distributing compiled libraries and executables that link to those libraries may be subject to terms of the GNU LGPL, see the LGPL file. gdk-pixbuf-0.7.0/Gir.toml010064400007650000024000000050351350341530200134120ustar0000000000000000[options] girs_dir = "gir-files" library = "GdkPixbuf" version = "2.0" min_cfg_version = "2.30" target_path = "." work_mode = "normal" single_version_file = true deprecate_by_min_version = true generate = [ "GdkPixbuf.Colorspace", "GdkPixbuf.InterpType", "GdkPixbuf.PixbufAlphaMode", "GdkPixbuf.PixbufError", "GdkPixbuf.PixbufLoader", "GdkPixbuf.PixbufRotation", "GdkPixbuf.PixbufSimpleAnim", ] manual = [ "GdkPixbuf.PixbufAnimation", "GdkPixbuf.PixbufAnimationIter", "Gio.AsyncReadyCallback", "Gio.Cancellable", "Gio.Icon", "Gio.InputStream", "Gio.LoadableIcon", "Gio.OutputStream", "GLib.Bytes", "GLib.Error", ] [[object]] name = "GdkPixbuf.Pixbuf" status = "generate" [[object.function]] name = "get_pixels" #manual array without length ignore = true [[object.function]] name = "get_pixels_with_length" #manual as get_pixels ignore = true [[object.function]] name = "read_pixels" #unimplementable, use get_pixels instead ignore = true [[object.function]] name = "new_from_file" #manual is_windows_utf8 ignore = true [[object.function]] name = "new" [object.function.return] nullable = true [[object.function]] name = "new_from_file_at_size" #manual is_windows_utf8 ignore = true [[object.function]] name = "new_from_file_at_scale" #manual is_windows_utf8 ignore = true [[object.function]] name = "new_from_stream_async" # wrong async return ignore = true [[object.function]] name = "new_from_stream_at_scale_async" # wrong return and don't generated ignore = true [[object.function]] name = "get_file_info" # wrong return ignore = true [[object.function]] name = "get_file_info_async" # wrong async return ignore = true [[object.function]] name = "save_to_bufferv" # manual complex param ignore = true [[object.function]] name = "save_to_streamv" # manual complex param ignore = true [[object.function]] name = "savev" # manual complex param ignore = true [[object.function]] name = "save_to_streamv_async" # 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 gdk-pixbuf-0.7.0/LICENSE010064400007650000024000000020531350341530200127760ustar0000000000000000The MIT License (MIT) Copyright (c) 2016 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. gdk-pixbuf-0.7.0/Makefile010064400007650000024000000012561350341657000134450ustar0000000000000000GIR = gir/target/bin/gir GIR_SRC = gir/Cargo.toml gir/Cargo.lock gir/build.rs $(shell find gir/src -name '*.rs') GIR_FILES = gir-files/Gtk-3.0.gir # Run `gir` generating the bindings gir : src/auto/mod.rs cargo fmt doc: $(GIR) $(GIR_FILES) $(GIR) -m doc -c Gir.toml not_bound: $(GIR) $(GIR_FILES) $(GIR) -m not_bound -c Gir.toml regen_check: $(GIR) $(GIR_FILES) rm src/auto/* $(GIR) -c Gir.toml cargo fmt git diff -R --exit-code src/auto/mod.rs : Gir.toml $(GIR) $(GIR_FILES) $(GIR) -c Gir.toml $(GIR) : $(GIR_SRC) rm -f gir/target/bin/gir cargo install --path gir --root gir/target rm -f gir/target/.crates.toml $(GIR_SRC) $(GIR_FILES) : git submodule update --init gdk-pixbuf-0.7.0/README.md010064400007650000024000000011601350341530200132460ustar0000000000000000# gdk-pixbuf [![Build Status](https://travis-ci.org/gtk-rs/gdk-pixbuf.png?branch=master)](https://travis-ci.org/gtk-rs/gdk-pixbuf) [![Build status](https://ci.appveyor.com/api/projects/status/5gcteolq1p274tue?svg=true)](https://ci.appveyor.com/project/GuillaumeGomez/gdk-pixbuf) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gtk-rs/gtk) Gdk-Pixbuf bindings for Rust. - [Gtk-rs project site](http://gtk-rs.org/) - [Online documentation](http://gtk-rs.org/docs/) - [Readme](https://github.com/gtk-rs/gtk/blob/master/README.md) in our [main repo](https://github.com/gtk-rs/gtk) ## License MIT gdk-pixbuf-0.7.0/src/animation.rs010064400007650000024000000101751350341657000151210ustar0000000000000000// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use super::Pixbuf; use gdk_pixbuf_sys; use glib::object::IsA; use glib::translate::*; use glib::{Error, TimeVal}; use std::path::Path; use std::ptr; glib_wrapper! { pub struct PixbufAnimationIter(Object); match fn { get_type => || gdk_pixbuf_sys::gdk_pixbuf_animation_iter_get_type(), } } impl PixbufAnimationIter { pub fn advance(&self, start_time: TimeVal) -> bool { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_animation_iter_advance( self.to_glib_none().0, &start_time as *const _, )) } } pub fn get_pixbuf(&self) -> Pixbuf { unsafe { from_glib_none(gdk_pixbuf_sys::gdk_pixbuf_animation_iter_get_pixbuf( self.to_glib_none().0, )) } } pub fn get_delay_time(&self) -> i32 { unsafe { gdk_pixbuf_sys::gdk_pixbuf_animation_iter_get_delay_time(self.to_glib_none().0) } } pub fn on_currently_loading_frame(&self) -> bool { unsafe { from_glib( gdk_pixbuf_sys::gdk_pixbuf_animation_iter_on_currently_loading_frame( self.to_glib_none().0, ), ) } } } glib_wrapper! { pub struct PixbufAnimation(Object); match fn { get_type => || gdk_pixbuf_sys::gdk_pixbuf_animation_get_type(), } } impl PixbufAnimation { pub fn new_from_file>(file: T) -> Result { #[cfg(not(windows))] use gdk_pixbuf_sys::gdk_pixbuf_animation_new_from_file; #[cfg(windows)] use gdk_pixbuf_sys::gdk_pixbuf_animation_new_from_file_utf8 as gdk_pixbuf_animation_new_from_file; unsafe { let mut error = ptr::null_mut(); 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 { Err(from_glib_full(error)) } } } pub fn new_from_resource(resource_path: &str) -> Result { unsafe { let mut error = ptr::null_mut(); let ptr = gdk_pixbuf_sys::gdk_pixbuf_animation_new_from_resource( resource_path.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ptr)) } else { Err(from_glib_full(error)) } } } } pub trait PixbufAnimationExt { fn get_width(&self) -> i32; fn get_height(&self) -> i32; fn get_iter(&self, start_time: TimeVal) -> PixbufAnimationIter; fn is_static_image(&self) -> bool; fn get_static_image(&self) -> Option; } impl> PixbufAnimationExt for T { fn get_width(&self) -> i32 { unsafe { gdk_pixbuf_sys::gdk_pixbuf_animation_get_width(self.as_ref().to_glib_none().0) } } fn get_height(&self) -> i32 { unsafe { gdk_pixbuf_sys::gdk_pixbuf_animation_get_height(self.as_ref().to_glib_none().0) } } fn get_iter(&self, start_time: TimeVal) -> PixbufAnimationIter { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_animation_get_iter( self.as_ref().to_glib_none().0, &start_time as *const _, )) } } fn is_static_image(&self) -> bool { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_animation_is_static_image( self.as_ref().to_glib_none().0, )) } } fn get_static_image(&self) -> Option { unsafe { from_glib_none(gdk_pixbuf_sys::gdk_pixbuf_animation_get_static_image( self.as_ref().to_glib_none().0, )) } } } gdk-pixbuf-0.7.0/src/auto/enums.rs010064400007650000024000000303261350341657000152410ustar0000000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use gdk_pixbuf_sys; use glib::error::ErrorDomain; use glib::translate::*; use glib::value::FromValue; use glib::value::FromValueOptional; use glib::value::SetValue; use glib::value::Value; use glib::Quark; use glib::StaticType; use glib::Type; use gobject_sys; use std::fmt; #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum Colorspace { Rgb, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for Colorspace { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "Colorspace::{}", match *self { Colorspace::Rgb => "Rgb", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for Colorspace { type GlibType = gdk_pixbuf_sys::GdkColorspace; fn to_glib(&self) -> gdk_pixbuf_sys::GdkColorspace { match *self { Colorspace::Rgb => gdk_pixbuf_sys::GDK_COLORSPACE_RGB, Colorspace::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for Colorspace { fn from_glib(value: gdk_pixbuf_sys::GdkColorspace) -> Self { match value { 0 => Colorspace::Rgb, value => Colorspace::__Unknown(value), } } } impl StaticType for Colorspace { fn static_type() -> Type { unsafe { from_glib(gdk_pixbuf_sys::gdk_colorspace_get_type()) } } } impl<'a> FromValueOptional<'a> for Colorspace { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for Colorspace { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for Colorspace { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum InterpType { Nearest, Tiles, Bilinear, Hyper, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for InterpType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "InterpType::{}", match *self { InterpType::Nearest => "Nearest", InterpType::Tiles => "Tiles", InterpType::Bilinear => "Bilinear", InterpType::Hyper => "Hyper", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for InterpType { type GlibType = gdk_pixbuf_sys::GdkInterpType; fn to_glib(&self) -> gdk_pixbuf_sys::GdkInterpType { match *self { InterpType::Nearest => gdk_pixbuf_sys::GDK_INTERP_NEAREST, InterpType::Tiles => gdk_pixbuf_sys::GDK_INTERP_TILES, InterpType::Bilinear => gdk_pixbuf_sys::GDK_INTERP_BILINEAR, InterpType::Hyper => gdk_pixbuf_sys::GDK_INTERP_HYPER, InterpType::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for InterpType { fn from_glib(value: gdk_pixbuf_sys::GdkInterpType) -> Self { match value { 0 => InterpType::Nearest, 1 => InterpType::Tiles, 2 => InterpType::Bilinear, 3 => InterpType::Hyper, value => InterpType::__Unknown(value), } } } impl StaticType for InterpType { fn static_type() -> Type { unsafe { from_glib(gdk_pixbuf_sys::gdk_interp_type_get_type()) } } } impl<'a> FromValueOptional<'a> for InterpType { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for InterpType { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for InterpType { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum PixbufAlphaMode { Bilevel, Full, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for PixbufAlphaMode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "PixbufAlphaMode::{}", match *self { PixbufAlphaMode::Bilevel => "Bilevel", PixbufAlphaMode::Full => "Full", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for PixbufAlphaMode { type GlibType = gdk_pixbuf_sys::GdkPixbufAlphaMode; fn to_glib(&self) -> gdk_pixbuf_sys::GdkPixbufAlphaMode { match *self { PixbufAlphaMode::Bilevel => gdk_pixbuf_sys::GDK_PIXBUF_ALPHA_BILEVEL, PixbufAlphaMode::Full => gdk_pixbuf_sys::GDK_PIXBUF_ALPHA_FULL, PixbufAlphaMode::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for PixbufAlphaMode { fn from_glib(value: gdk_pixbuf_sys::GdkPixbufAlphaMode) -> Self { match value { 0 => PixbufAlphaMode::Bilevel, 1 => PixbufAlphaMode::Full, value => PixbufAlphaMode::__Unknown(value), } } } impl StaticType for PixbufAlphaMode { fn static_type() -> Type { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_alpha_mode_get_type()) } } } impl<'a> FromValueOptional<'a> for PixbufAlphaMode { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for PixbufAlphaMode { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for PixbufAlphaMode { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum PixbufError { CorruptImage, InsufficientMemory, BadOption, UnknownType, UnsupportedOperation, Failed, IncompleteAnimation, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for PixbufError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "PixbufError::{}", match *self { PixbufError::CorruptImage => "CorruptImage", PixbufError::InsufficientMemory => "InsufficientMemory", PixbufError::BadOption => "BadOption", PixbufError::UnknownType => "UnknownType", PixbufError::UnsupportedOperation => "UnsupportedOperation", PixbufError::Failed => "Failed", PixbufError::IncompleteAnimation => "IncompleteAnimation", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for PixbufError { type GlibType = gdk_pixbuf_sys::GdkPixbufError; fn to_glib(&self) -> gdk_pixbuf_sys::GdkPixbufError { match *self { PixbufError::CorruptImage => gdk_pixbuf_sys::GDK_PIXBUF_ERROR_CORRUPT_IMAGE, PixbufError::InsufficientMemory => gdk_pixbuf_sys::GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, PixbufError::BadOption => gdk_pixbuf_sys::GDK_PIXBUF_ERROR_BAD_OPTION, PixbufError::UnknownType => gdk_pixbuf_sys::GDK_PIXBUF_ERROR_UNKNOWN_TYPE, PixbufError::UnsupportedOperation => { gdk_pixbuf_sys::GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION } PixbufError::Failed => gdk_pixbuf_sys::GDK_PIXBUF_ERROR_FAILED, PixbufError::IncompleteAnimation => { gdk_pixbuf_sys::GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION } PixbufError::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for PixbufError { fn from_glib(value: gdk_pixbuf_sys::GdkPixbufError) -> Self { match value { 0 => PixbufError::CorruptImage, 1 => PixbufError::InsufficientMemory, 2 => PixbufError::BadOption, 3 => PixbufError::UnknownType, 4 => PixbufError::UnsupportedOperation, 5 => PixbufError::Failed, 6 => PixbufError::IncompleteAnimation, value => PixbufError::__Unknown(value), } } } impl ErrorDomain for PixbufError { fn domain() -> Quark { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_error_quark()) } } fn code(self) -> i32 { self.to_glib() } fn from(code: i32) -> Option { match code { 0 => Some(PixbufError::CorruptImage), 1 => Some(PixbufError::InsufficientMemory), 2 => Some(PixbufError::BadOption), 3 => Some(PixbufError::UnknownType), 4 => Some(PixbufError::UnsupportedOperation), 5 => Some(PixbufError::Failed), 6 => Some(PixbufError::IncompleteAnimation), _ => Some(PixbufError::Failed), } } } impl StaticType for PixbufError { fn static_type() -> Type { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_error_get_type()) } } } impl<'a> FromValueOptional<'a> for PixbufError { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for PixbufError { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for PixbufError { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum PixbufRotation { None, Counterclockwise, Upsidedown, Clockwise, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for PixbufRotation { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "PixbufRotation::{}", match *self { PixbufRotation::None => "None", PixbufRotation::Counterclockwise => "Counterclockwise", PixbufRotation::Upsidedown => "Upsidedown", PixbufRotation::Clockwise => "Clockwise", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for PixbufRotation { type GlibType = gdk_pixbuf_sys::GdkPixbufRotation; fn to_glib(&self) -> gdk_pixbuf_sys::GdkPixbufRotation { match *self { PixbufRotation::None => gdk_pixbuf_sys::GDK_PIXBUF_ROTATE_NONE, PixbufRotation::Counterclockwise => gdk_pixbuf_sys::GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE, PixbufRotation::Upsidedown => gdk_pixbuf_sys::GDK_PIXBUF_ROTATE_UPSIDEDOWN, PixbufRotation::Clockwise => gdk_pixbuf_sys::GDK_PIXBUF_ROTATE_CLOCKWISE, PixbufRotation::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for PixbufRotation { fn from_glib(value: gdk_pixbuf_sys::GdkPixbufRotation) -> Self { match value { 0 => PixbufRotation::None, 90 => PixbufRotation::Counterclockwise, 180 => PixbufRotation::Upsidedown, 270 => PixbufRotation::Clockwise, value => PixbufRotation::__Unknown(value), } } } impl StaticType for PixbufRotation { fn static_type() -> Type { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_rotation_get_type()) } } } impl<'a> FromValueOptional<'a> for PixbufRotation { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for PixbufRotation { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for PixbufRotation { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } gdk-pixbuf-0.7.0/src/auto/mod.rs010064400007650000024000000014001350341657000146600ustar0000000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT mod pixbuf; pub use self::pixbuf::{Pixbuf, PixbufClass}; mod pixbuf_loader; pub use self::pixbuf_loader::PixbufLoaderExt; pub use self::pixbuf_loader::{PixbufLoader, PixbufLoaderClass, NONE_PIXBUF_LOADER}; mod pixbuf_simple_anim; pub use self::pixbuf_simple_anim::{PixbufSimpleAnim, PixbufSimpleAnimClass}; mod pixbuf_format; pub use self::pixbuf_format::PixbufFormat; mod enums; pub use self::enums::Colorspace; pub use self::enums::InterpType; pub use self::enums::PixbufAlphaMode; pub use self::enums::PixbufError; pub use self::enums::PixbufRotation; #[doc(hidden)] pub mod traits { pub use super::PixbufLoaderExt; } gdk-pixbuf-0.7.0/src/auto/pixbuf.rs010064400007650000024000000443441350341657000154140ustar0000000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use gdk_pixbuf_sys; use gio; use glib; use glib::object::IsA; use glib::object::ObjectType as ObjectType_; use glib::translate::*; use glib::GString; use glib::StaticType; use glib::Value; use gobject_sys; use std::fmt; use std::ptr; use Colorspace; use Error; use InterpType; use PixbufFormat; use PixbufRotation; glib_wrapper! { pub struct Pixbuf(Object) @implements gio::Icon, gio::LoadableIcon; match fn { get_type => || gdk_pixbuf_sys::gdk_pixbuf_get_type(), } } impl Pixbuf { pub fn new( colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, ) -> Option { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_new( colorspace.to_glib(), has_alpha.to_glib(), bits_per_sample, width, height, )) } } #[cfg(any(feature = "v2_32", feature = "dox"))] pub fn new_from_bytes( data: &glib::Bytes, colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, rowstride: i32, ) -> Pixbuf { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_new_from_bytes( data.to_glib_none().0, colorspace.to_glib(), has_alpha.to_glib(), bits_per_sample, width, height, rowstride, )) } } //pub fn new_from_data(data: &[u8], colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, rowstride: i32, destroy_fn: Option) + 'static>>) -> Pixbuf { // unsafe { TODO: call gdk_pixbuf_sys:gdk_pixbuf_new_from_data() } //} #[cfg_attr(feature = "v2_32", deprecated)] pub fn new_from_inline(data: &[u8], copy_pixels: bool) -> Result { let data_length = data.len() as i32; unsafe { let mut error = ptr::null_mut(); let ret = gdk_pixbuf_sys::gdk_pixbuf_new_from_inline( data_length, data.to_glib_none().0, copy_pixels.to_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn new_from_resource(resource_path: &str) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gdk_pixbuf_sys::gdk_pixbuf_new_from_resource( resource_path.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn new_from_resource_at_scale( resource_path: &str, width: i32, height: i32, preserve_aspect_ratio: bool, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gdk_pixbuf_sys::gdk_pixbuf_new_from_resource_at_scale( resource_path.to_glib_none().0, width, height, preserve_aspect_ratio.to_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn new_from_stream, Q: IsA>( stream: &P, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gdk_pixbuf_sys::gdk_pixbuf_new_from_stream( stream.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn new_from_stream_at_scale, Q: IsA>( stream: &P, width: i32, height: i32, preserve_aspect_ratio: bool, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gdk_pixbuf_sys::gdk_pixbuf_new_from_stream_at_scale( stream.as_ref().to_glib_none().0, width, height, preserve_aspect_ratio.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn new_from_xpm_data(data: &[&str]) -> Pixbuf { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_new_from_xpm_data( data.to_glib_none().0, )) } } pub fn add_alpha(&self, substitute_color: bool, r: u8, g: u8, b: u8) -> Option { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_add_alpha( self.to_glib_none().0, substitute_color.to_glib(), r, g, b, )) } } pub fn apply_embedded_orientation(&self) -> Option { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_apply_embedded_orientation( self.to_glib_none().0, )) } } 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, ) { unsafe { gdk_pixbuf_sys::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, ); } } pub 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 { gdk_pixbuf_sys::gdk_pixbuf_composite_color( 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, ); } } pub 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(gdk_pixbuf_sys::gdk_pixbuf_composite_color_simple( self.to_glib_none().0, dest_width, dest_height, interp_type.to_glib(), overall_alpha, check_size, color1, color2, )) } } pub fn copy(&self) -> Option { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_copy(self.to_glib_none().0)) } } pub fn copy_area( &self, src_x: i32, src_y: i32, width: i32, height: i32, dest_pixbuf: &Pixbuf, dest_x: i32, dest_y: i32, ) { unsafe { gdk_pixbuf_sys::gdk_pixbuf_copy_area( 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"))] pub fn copy_options(&self, dest_pixbuf: &Pixbuf) -> bool { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_copy_options( self.to_glib_none().0, dest_pixbuf.to_glib_none().0, )) } } pub fn fill(&self, pixel: u32) { unsafe { gdk_pixbuf_sys::gdk_pixbuf_fill(self.to_glib_none().0, pixel); } } pub fn flip(&self, horizontal: bool) -> Option { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_flip( self.to_glib_none().0, horizontal.to_glib(), )) } } pub fn get_bits_per_sample(&self) -> i32 { unsafe { gdk_pixbuf_sys::gdk_pixbuf_get_bits_per_sample(self.to_glib_none().0) } } pub fn get_byte_length(&self) -> usize { unsafe { gdk_pixbuf_sys::gdk_pixbuf_get_byte_length(self.to_glib_none().0) } } pub fn get_colorspace(&self) -> Colorspace { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_get_colorspace( self.to_glib_none().0, )) } } pub fn get_has_alpha(&self) -> bool { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_get_has_alpha( self.to_glib_none().0, )) } } pub fn get_height(&self) -> i32 { unsafe { gdk_pixbuf_sys::gdk_pixbuf_get_height(self.to_glib_none().0) } } pub fn get_n_channels(&self) -> i32 { unsafe { gdk_pixbuf_sys::gdk_pixbuf_get_n_channels(self.to_glib_none().0) } } pub fn get_option(&self, key: &str) -> Option { unsafe { from_glib_none(gdk_pixbuf_sys::gdk_pixbuf_get_option( self.to_glib_none().0, key.to_glib_none().0, )) } } //#[cfg(any(feature = "v2_32", feature = "dox"))] //pub fn get_options(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 } { // unsafe { TODO: call gdk_pixbuf_sys:gdk_pixbuf_get_options() } //} pub fn get_rowstride(&self) -> i32 { unsafe { gdk_pixbuf_sys::gdk_pixbuf_get_rowstride(self.to_glib_none().0) } } pub fn get_width(&self) -> i32 { unsafe { gdk_pixbuf_sys::gdk_pixbuf_get_width(self.to_glib_none().0) } } pub fn new_subpixbuf(&self, src_x: i32, src_y: i32, width: i32, height: i32) -> Option { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_new_subpixbuf( self.to_glib_none().0, src_x, src_y, width, height, )) } } #[cfg(any(feature = "v2_32", feature = "dox"))] pub fn read_pixel_bytes(&self) -> Option { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_read_pixel_bytes( self.to_glib_none().0, )) } } #[cfg(any(feature = "v2_36", feature = "dox"))] pub fn remove_option(&self, key: &str) -> bool { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_remove_option( self.to_glib_none().0, key.to_glib_none().0, )) } } pub fn rotate_simple(&self, angle: PixbufRotation) -> Option { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_rotate_simple( self.to_glib_none().0, angle.to_glib(), )) } } pub fn saturate_and_pixelate(&self, dest: &Pixbuf, saturation: f32, pixelate: bool) { unsafe { gdk_pixbuf_sys::gdk_pixbuf_saturate_and_pixelate( self.to_glib_none().0, dest.to_glib_none().0, saturation, pixelate.to_glib(), ); } } //pub fn save>(&self, filename: P, type_: &str, error: Option<&mut Error>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { // unsafe { TODO: call gdk_pixbuf_sys:gdk_pixbuf_save() } //} //pub fn save_to_buffer(&self, type_: &str, error: Option<&mut Error>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option> { // unsafe { TODO: call gdk_pixbuf_sys:gdk_pixbuf_save_to_buffer() } //} //pub fn save_to_callback, usize, &Error) -> bool>(&self, save_func: P, type_: &str, error: Option<&mut Error>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { // unsafe { TODO: call gdk_pixbuf_sys:gdk_pixbuf_save_to_callback() } //} //pub fn save_to_callbackv, usize, &Error) -> bool>(&self, save_func: P, type_: &str, option_keys: &[&str], option_values: &[&str]) -> Result<(), Error> { // unsafe { TODO: call gdk_pixbuf_sys:gdk_pixbuf_save_to_callbackv() } //} //pub fn save_to_stream, Q: IsA>(&self, stream: &P, type_: &str, cancellable: Option<&Q>, error: Option<&mut Error>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { // unsafe { TODO: call gdk_pixbuf_sys:gdk_pixbuf_save_to_stream() } //} //pub fn save_to_stream_async, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static>(&self, stream: &P, type_: &str, cancellable: Option<&Q>, callback: R, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call gdk_pixbuf_sys:gdk_pixbuf_save_to_stream_async() } //} //#[cfg(feature = "futures")] //pub fn save_to_stream_async_future + Clone + 'static>(&self, stream: &P, type_: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Box_> + std::marker::Unpin> { //use gio::GioFuture; //use fragile::Fragile; //let stream = stream.clone(); //let type_ = String::from(type_); //GioFuture::new(self, move |obj, send| { // let cancellable = gio::Cancellable::new(); // let send = Fragile::new(send); // obj.save_to_stream_async( // &stream, // &type_, // Some(&cancellable), // , // move |res| { // let _ = send.into_inner().send(res); // }, // ); // cancellable //}) //} 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, ) { unsafe { gdk_pixbuf_sys::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(), ); } } pub fn scale_simple( &self, dest_width: i32, dest_height: i32, interp_type: InterpType, ) -> Option { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_scale_simple( self.to_glib_none().0, dest_width, dest_height, interp_type.to_glib(), )) } } pub fn set_option(&self, key: &str, value: &str) -> bool { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_set_option( self.to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0, )) } } pub fn get_property_pixel_bytes(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.as_ptr() as *mut gobject_sys::GObject, b"pixel-bytes\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get() } } //pub fn get_property_pixels(&self) -> /*Unimplemented*/Fundamental: Pointer { // unsafe { // let mut value = Value::from_type(::static_type()); // gobject_sys::g_object_get_property(self.as_ptr() as *mut gobject_sys::GObject, b"pixels\0".as_ptr() as *const _, value.to_glib_none_mut().0); // value.get().unwrap() // } //} #[cfg(any(feature = "v2_36_8", feature = "dox"))] pub fn calculate_rowstride( colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, ) -> i32 { unsafe { gdk_pixbuf_sys::gdk_pixbuf_calculate_rowstride( colorspace.to_glib(), has_alpha.to_glib(), bits_per_sample, width, height, ) } } pub fn get_formats() -> Vec { unsafe { FromGlibPtrContainer::from_glib_container(gdk_pixbuf_sys::gdk_pixbuf_get_formats()) } } } impl fmt::Display for Pixbuf { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Pixbuf") } } gdk-pixbuf-0.7.0/src/auto/pixbuf_format.rs010064400007650000024000000057161350341657000167640ustar0000000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use gdk_pixbuf_sys; use glib::translate::*; use glib::GString; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct PixbufFormat(Boxed); match fn { copy => |ptr| gdk_pixbuf_sys::gdk_pixbuf_format_copy(mut_override(ptr)), free => |ptr| gdk_pixbuf_sys::gdk_pixbuf_format_free(ptr), get_type => || gdk_pixbuf_sys::gdk_pixbuf_format_get_type(), } } impl PixbufFormat { pub fn get_description(&self) -> Option { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_format_get_description( mut_override(self.to_glib_none().0), )) } } pub fn get_extensions(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_format_get_extensions( mut_override(self.to_glib_none().0), )) } } pub fn get_license(&self) -> Option { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_format_get_license(mut_override( self.to_glib_none().0, ))) } } pub fn get_mime_types(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_format_get_mime_types( mut_override(self.to_glib_none().0), )) } } pub fn get_name(&self) -> Option { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_format_get_name(mut_override( self.to_glib_none().0, ))) } } pub fn is_disabled(&self) -> bool { unsafe { from_glib(gdk_pixbuf_sys::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(&self, option_key: &str) -> bool { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_format_is_save_option_supported( mut_override(self.to_glib_none().0), option_key.to_glib_none().0, )) } } pub fn is_scalable(&self) -> bool { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_format_is_scalable(mut_override( self.to_glib_none().0, ))) } } pub fn is_writable(&self) -> bool { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_format_is_writable(mut_override( self.to_glib_none().0, ))) } } pub fn set_disabled(&mut self, disabled: bool) { unsafe { gdk_pixbuf_sys::gdk_pixbuf_format_set_disabled( self.to_glib_none_mut().0, disabled.to_glib(), ); } } } gdk-pixbuf-0.7.0/src/auto/pixbuf_loader.rs010064400007650000024000000210201350341657000167240ustar0000000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use gdk_pixbuf_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use libc; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Error; use Pixbuf; use PixbufAnimation; use PixbufFormat; glib_wrapper! { pub struct PixbufLoader(Object); match fn { get_type => || gdk_pixbuf_sys::gdk_pixbuf_loader_get_type(), } } impl PixbufLoader { pub fn new() -> PixbufLoader { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_loader_new()) } } pub fn new_with_mime_type(mime_type: &str) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gdk_pixbuf_sys::gdk_pixbuf_loader_new_with_mime_type( mime_type.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn new_with_type(image_type: &str) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gdk_pixbuf_sys::gdk_pixbuf_loader_new_with_type( image_type.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } impl Default for PixbufLoader { fn default() -> Self { Self::new() } } pub const NONE_PIXBUF_LOADER: Option<&PixbufLoader> = None; pub trait PixbufLoaderExt: 'static { fn close(&self) -> Result<(), Error>; fn get_animation(&self) -> Option; fn get_format(&self) -> Option; fn get_pixbuf(&self) -> Option; fn set_size(&self, width: i32, height: i32); fn write(&self, buf: &[u8]) -> Result<(), Error>; fn write_bytes(&self, buffer: &glib::Bytes) -> Result<(), Error>; fn connect_area_prepared(&self, f: F) -> SignalHandlerId; fn connect_area_updated( &self, f: F, ) -> SignalHandlerId; fn connect_closed(&self, f: F) -> SignalHandlerId; fn connect_size_prepared(&self, f: F) -> SignalHandlerId; } impl> PixbufLoaderExt for O { fn close(&self) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gdk_pixbuf_sys::gdk_pixbuf_loader_close(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn get_animation(&self) -> Option { unsafe { from_glib_none(gdk_pixbuf_sys::gdk_pixbuf_loader_get_animation( self.as_ref().to_glib_none().0, )) } } fn get_format(&self) -> Option { unsafe { from_glib_none(gdk_pixbuf_sys::gdk_pixbuf_loader_get_format( self.as_ref().to_glib_none().0, )) } } fn get_pixbuf(&self) -> Option { unsafe { from_glib_none(gdk_pixbuf_sys::gdk_pixbuf_loader_get_pixbuf( self.as_ref().to_glib_none().0, )) } } fn set_size(&self, width: i32, height: i32) { unsafe { gdk_pixbuf_sys::gdk_pixbuf_loader_set_size( self.as_ref().to_glib_none().0, width, height, ); } } fn write(&self, buf: &[u8]) -> Result<(), Error> { let count = buf.len() as usize; unsafe { let mut error = ptr::null_mut(); let _ = gdk_pixbuf_sys::gdk_pixbuf_loader_write( self.as_ref().to_glib_none().0, buf.to_glib_none().0, count, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn write_bytes(&self, buffer: &glib::Bytes) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gdk_pixbuf_sys::gdk_pixbuf_loader_write_bytes( self.as_ref().to_glib_none().0, buffer.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn connect_area_prepared(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn area_prepared_trampoline( this: *mut gdk_pixbuf_sys::GdkPixbufLoader, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&PixbufLoader::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"area-prepared\0".as_ptr() as *const _, Some(transmute(area_prepared_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_area_updated( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn area_updated_trampoline( this: *mut gdk_pixbuf_sys::GdkPixbufLoader, x: libc::c_int, y: libc::c_int, width: libc::c_int, height: libc::c_int, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &PixbufLoader::from_glib_borrow(this).unsafe_cast(), x, y, width, height, ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"area-updated\0".as_ptr() as *const _, Some(transmute(area_updated_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_closed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn closed_trampoline( this: *mut gdk_pixbuf_sys::GdkPixbufLoader, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&PixbufLoader::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"closed\0".as_ptr() as *const _, Some(transmute(closed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_size_prepared(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn size_prepared_trampoline( this: *mut gdk_pixbuf_sys::GdkPixbufLoader, width: libc::c_int, height: libc::c_int, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &PixbufLoader::from_glib_borrow(this).unsafe_cast(), width, height, ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"size-prepared\0".as_ptr() as *const _, Some(transmute(size_prepared_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for PixbufLoader { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "PixbufLoader") } } gdk-pixbuf-0.7.0/src/auto/pixbuf_simple_anim.rs010064400007650000024000000046721350341657000177710ustar0000000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use gdk_pixbuf_sys; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use Pixbuf; use PixbufAnimation; glib_wrapper! { pub struct PixbufSimpleAnim(Object) @extends PixbufAnimation; match fn { get_type => || gdk_pixbuf_sys::gdk_pixbuf_simple_anim_get_type(), } } impl PixbufSimpleAnim { pub fn new(width: i32, height: i32, rate: f32) -> PixbufSimpleAnim { unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_simple_anim_new( width, height, rate, )) } } pub fn add_frame(&self, pixbuf: &Pixbuf) { unsafe { gdk_pixbuf_sys::gdk_pixbuf_simple_anim_add_frame( self.to_glib_none().0, pixbuf.to_glib_none().0, ); } } pub fn get_loop(&self) -> bool { unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_simple_anim_get_loop( self.to_glib_none().0, )) } } pub fn set_loop(&self, loop_: bool) { unsafe { gdk_pixbuf_sys::gdk_pixbuf_simple_anim_set_loop(self.to_glib_none().0, loop_.to_glib()); } } pub fn connect_property_loop_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_loop_trampoline( this: *mut gdk_pixbuf_sys::GdkPixbufSimpleAnim, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::loop\0".as_ptr() as *const _, Some(transmute(notify_loop_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for PixbufSimpleAnim { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "PixbufSimpleAnim") } } gdk-pixbuf-0.7.0/src/auto/versions.txt010064400007650000024000000001721350341657000161510ustar0000000000000000Generated by gir (https://github.com/gtk-rs/gir @ 1dbb0ee) from gir-files (https://github.com/gtk-rs/gir-files @ 617a344) gdk-pixbuf-0.7.0/src/lib.rs010064400007650000024000000016721350341657000137120ustar0000000000000000// Copyright 2013-2016, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or #![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] #![cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] #![cfg_attr(feature = "cargo-clippy", allow(type_complexity))] extern crate gdk_pixbuf_sys; extern crate gio_sys; extern crate glib_sys; extern crate gobject_sys; #[macro_use] extern crate glib; extern crate gio; extern crate libc; #[cfg(feature = "futures")] extern crate fragile; #[cfg(feature = "futures")] extern crate futures; pub use glib::{Cast, Continue, Error, IsA, Object, StaticType, ToValue, Type, TypedValue, Value}; mod auto; mod animation; mod pixbuf; pub mod prelude; pub use auto::*; pub use self::animation::{PixbufAnimation, PixbufAnimationExt, PixbufAnimationIter}; gdk-pixbuf-0.7.0/src/pixbuf.rs010064400007650000024000000446231350341657000144440ustar0000000000000000// Copyright 2013-2016, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use gdk_pixbuf_sys; use gio; use gio_sys; use glib::object::IsA; use glib::translate::*; use glib::Error; use glib_sys; use gobject_sys; use libc::{c_uchar, c_void}; use std::mem; use std::path::Path; use std::ptr; use std::slice; #[cfg(feature = "futures")] use futures::future::Future; use {Colorspace, Pixbuf, PixbufFormat}; impl Pixbuf { pub fn new_from_mut_slice>( data: T, colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, row_stride: i32, ) -> Pixbuf { unsafe extern "C" fn destroy>(_: *mut c_uchar, data: *mut c_void) { let _data: Box = Box::from_raw(data as *mut T); // the data will be destroyed now } assert!(bits_per_sample == 8); let n_channels = if has_alpha { 4 } else { 3 }; let last_row_len = width * ((n_channels * bits_per_sample + 7) / 8); let mut data: Box = Box::new(data); let ptr = { let data: &mut [u8] = (*data).as_mut(); assert!(data.len() == ((height - 1) * row_stride + last_row_len) as usize); data.as_mut_ptr() }; unsafe { from_glib_full(gdk_pixbuf_sys::gdk_pixbuf_new_from_data( ptr, colorspace.to_glib(), has_alpha.to_glib(), bits_per_sample, width, height, row_stride, Some(destroy::), Box::into_raw(data) as *mut _, )) } } pub fn new_from_file>(filename: T) -> Result { #[cfg(not(windows))] use gdk_pixbuf_sys::gdk_pixbuf_new_from_file; #[cfg(windows)] use gdk_pixbuf_sys::gdk_pixbuf_new_from_file_utf8 as gdk_pixbuf_new_from_file; unsafe { let mut error = ptr::null_mut(); 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 { Err(from_glib_full(error)) } } } pub fn new_from_file_at_size>( filename: T, width: i32, height: i32, ) -> Result { #[cfg(not(windows))] use gdk_pixbuf_sys::gdk_pixbuf_new_from_file_at_size; #[cfg(windows)] use gdk_pixbuf_sys::gdk_pixbuf_new_from_file_at_size_utf8 as gdk_pixbuf_new_from_file_at_size; unsafe { let mut error = ptr::null_mut(); 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)) } else { Err(from_glib_full(error)) } } } pub fn new_from_file_at_scale>( filename: T, width: i32, height: i32, preserve_aspect_ratio: bool, ) -> Result { #[cfg(not(windows))] use gdk_pixbuf_sys::gdk_pixbuf_new_from_file_at_scale; #[cfg(windows)] use gdk_pixbuf_sys::gdk_pixbuf_new_from_file_at_scale_utf8 as gdk_pixbuf_new_from_file_at_scale; unsafe { let mut error = ptr::null_mut(); 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)) } else { Err(from_glib_full(error)) } } } pub fn new_from_stream_async< 'a, P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( stream: &P, cancellable: Option<&Q>, callback: R, ) { let cancellable = cancellable.map(|p| p.as_ref()); let user_data: Box = Box::new(callback); unsafe extern "C" fn new_from_stream_async_trampoline< R: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ptr = gdk_pixbuf_sys::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 { gdk_pixbuf_sys::gdk_pixbuf_new_from_stream_async( stream.as_ref().to_glib_none().0, cancellable.to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] pub fn new_from_stream_async_future + Clone + 'static>( stream: &P, ) -> Box> + std::marker::Unpin> { use gio::GioFuture; let stream = stream.clone(); GioFuture::new(&(), move |_obj, send| { use fragile::Fragile; let cancellable = gio::Cancellable::new(); let send = Fragile::new(send); Self::new_from_stream_async(&stream, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } pub fn new_from_stream_at_scale_async< 'a, P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( stream: &P, width: i32, height: i32, preserve_aspect_ratio: bool, cancellable: Option<&Q>, callback: R, ) { let cancellable = cancellable.map(|p| p.as_ref()); let user_data: Box = Box::new(callback); unsafe extern "C" fn new_from_stream_at_scale_async_trampoline< R: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ptr = gdk_pixbuf_sys::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 { gdk_pixbuf_sys::gdk_pixbuf_new_from_stream_at_scale_async( stream.as_ref().to_glib_none().0, width, height, preserve_aspect_ratio.to_glib(), cancellable.to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] pub fn new_from_stream_at_scale_async_future + Clone + 'static>( stream: &P, width: i32, height: i32, preserve_aspect_ratio: bool, ) -> Box> + std::marker::Unpin> { use gio::GioFuture; let stream = stream.clone(); GioFuture::new(&(), move |_obj, send| { use fragile::Fragile; let cancellable = gio::Cancellable::new(); let send = Fragile::new(send); Self::new_from_stream_at_scale_async( &stream, width, height, preserve_aspect_ratio, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } #[cfg_attr(feature = "cargo-clippy", allow(mut_from_ref))] pub unsafe fn get_pixels(&self) -> &mut [u8] { let mut len = 0; let ptr = gdk_pixbuf_sys::gdk_pixbuf_get_pixels_with_length(self.to_glib_none().0, &mut len); slice::from_raw_parts_mut(ptr, len as usize) } pub fn put_pixel(&self, x: i32, y: i32, red: u8, green: u8, blue: u8, alpha: u8) { unsafe { let n_channels = self.get_n_channels(); assert!(n_channels == 3 || n_channels == 4); 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; if n_channels == 4 { pixels[pos + 3] = alpha; } } } pub fn get_file_info>(filename: T) -> Option<(PixbufFormat, i32, i32)> { unsafe { let mut width = mem::uninitialized(); let mut height = mem::uninitialized(); let ret = gdk_pixbuf_sys::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 } } } #[cfg(any(feature = "v2_32", feature = "dox"))] pub fn get_file_info_async< P: IsA, Q: FnOnce(Result, Error>) + Send + 'static, T: AsRef, >( filename: T, cancellable: Option<&P>, callback: Q, ) { let cancellable = cancellable.map(|p| p.as_ref()); let user_data: Box = Box::new(callback); unsafe extern "C" fn get_file_info_async_trampoline< Q: FnOnce(Result, Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let mut width = mem::uninitialized(); let mut height = mem::uninitialized(); let ret = gdk_pixbuf_sys::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 { gdk_pixbuf_sys::gdk_pixbuf_get_file_info_async( filename.as_ref().to_glib_none().0, cancellable.to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] #[cfg(any(feature = "v2_32", feature = "dox"))] pub fn get_file_info_async_future + Clone + 'static>( filename: T, ) -> Box< dyn Future, Error>> + std::marker::Unpin, > { use gio::GioFuture; GioFuture::new(&(), move |_obj, send| { use fragile::Fragile; let cancellable = gio::Cancellable::new(); let send = Fragile::new(send); Self::get_file_info_async(filename, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } pub fn save_to_bufferv(&self, type_: &str, options: &[(&str, &str)]) -> Result, Error> { unsafe { 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 _ = gdk_pixbuf_sys::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)) } } } #[cfg(any(feature = "v2_36", feature = "dox"))] pub fn save_to_streamv<'a, P: IsA, Q: IsA>( &self, stream: &P, type_: &str, options: &[(&str, &str)], cancellable: Option<&Q>, ) -> Result<(), Error> { let cancellable = cancellable.map(|p| p.as_ref()); unsafe { 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 _ = gdk_pixbuf_sys::gdk_pixbuf_save_to_streamv( self.to_glib_none().0, stream.as_ref().to_glib_none().0, type_.to_glib_none().0, option_keys.to_glib_none().0, option_values.to_glib_none().0, cancellable.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2_36", feature = "dox"))] pub fn save_to_streamv_async< 'a, P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, stream: &P, type_: &str, options: &[(&str, &str)], cancellable: Option<&Q>, callback: R, ) { let cancellable = cancellable.map(|p| p.as_ref()); let user_data: Box = Box::new(callback); unsafe extern "C" fn save_to_streamv_async_trampoline< R: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gdk_pixbuf_sys::gdk_pixbuf_save_to_stream_finish(res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = save_to_streamv_async_trampoline::; unsafe { let option_keys: Vec<&str> = options.iter().map(|o| o.0).collect(); let option_values: Vec<&str> = options.iter().map(|o| o.1).collect(); gdk_pixbuf_sys::gdk_pixbuf_save_to_streamv_async( self.to_glib_none().0, stream.as_ref().to_glib_none().0, type_.to_glib_none().0, option_keys.to_glib_none().0, option_values.to_glib_none().0, cancellable.to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] #[cfg(any(feature = "v2_36", feature = "dox"))] pub fn save_to_streamv_async_future + Clone + 'static>( &self, stream: &P, type_: &str, options: &[(&str, &str)], ) -> Box> + std::marker::Unpin> { use fragile::Fragile; use gio::GioFuture; let stream = stream.clone(); let type_ = String::from(type_); let options = options .iter() .map(|&(k, v)| (String::from(k), String::from(v))) .collect::>(); GioFuture::new(self, move |obj, send| { let cancellable = gio::Cancellable::new(); let send = Fragile::new(send); let options = options .iter() .map(|&(ref k, ref v)| (k.as_str(), v.as_str())) .collect::>(); obj.save_to_streamv_async( &stream, &type_, options.as_slice(), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } pub fn savev>( &self, filename: T, type_: &str, options: &[(&str, &str)], ) -> Result<(), Error> { unsafe { 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 _ = gdk_pixbuf_sys::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)) } } } } gdk-pixbuf-0.7.0/src/prelude.rs010064400007650000024000000001371350341530200145670ustar0000000000000000//! Traits inteded for blanket imports. pub use auto::traits::*; pub use PixbufAnimationExt; gdk-pixbuf-0.7.0/tests/check_gir.rs010064400007650000024000000006461350341530200154250ustar0000000000000000// Copyright 2013-2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or extern crate gir_format_check; #[test] fn check_gir_file() { let res = gir_format_check::check_gir_file("Gir.toml"); println!("{}", res.to_string()); assert_eq!(res.nb_errors, 0); } gdk-pixbuf-0.7.0/.cargo_vcs_info.json0000644000000001120000000000000131310ustar00{ "git": { "sha1": "691ef737493c08ffb44c4e65b35eb5ac0b88c619" } }