<commit_before>// Copyright 2013-2015, The Rust-GNOME Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>

//! Animations — Animated images.

use std::mem;
use std::ptr;
use glib::{Error, GlibContainer, TimeVal};
use glib::translate::*;
use glib::types::{StaticType, Type};
use object::{Object, Upcast};
use ffi;
use super::Pixbuf;

pub type PixbufAnimationIter = Object<ffi::C_GdkPixbufAnimationIter>;

impl StaticType for PixbufAnimationIter {
    fn static_type() -> Type { unsafe { from_glib(ffi::gdk_pixbuf_animation_iter_get_type()) } }
}

impl PixbufAnimationIter {
    pub fn advance(&self, start_time: &TimeVal) -> bool {
        unsafe {
            from_glib(ffi::gdk_pixbuf_animation_iter_advance(self.to_glib_none().0,
                mem::transmute(start_time)))
        }
    }

    pub fn get_pixbuf(&self) -> Pixbuf {
        unsafe { from_glib_none(ffi::gdk_pixbuf_animation_iter_get_pixbuf(self.to_glib_none().0)) }
    }

    pub fn get_delay_time(&self) -> i32 {
        unsafe { ffi::gdk_pixbuf_animation_iter_get_delay_time(self.to_glib_none().0) }
    }

    pub fn on_currently_loading_frame(&self) -> bool {
        unsafe {
            from_glib(
                ffi::gdk_pixbuf_animation_iter_on_currently_loading_frame(self.to_glib_none().0))
        }
    }
}

pub type PixbufAnimation = Object<ffi::C_GdkPixbufAnimation>;

impl StaticType for PixbufAnimation {
    fn static_type() -> Type { unsafe { from_glib(ffi::gdk_pixbuf_animation_get_type()) } }
}

impl PixbufAnimation {
    pub fn new_from_file(file: &str) -> Result<PixbufAnimation, Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let ptr = ffi::gdk_pixbuf_animation_new_from_file(file.to_glib_none().0, &mut error);
            if error.is_null() {
                Ok(from_glib_full(ptr))
            } else {
                Err(Error::wrap(error))
            }
        }
    }

    pub fn new_from_resource(resource_path: &str) -> Result<PixbufAnimation, Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let ptr = ffi::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(Error::wrap(error))
            }
        }
    }
}

pub trait PixbufAnimationExt {
    fn get_width(&self) -> i32;
    fn get_height(&self) -> i32;<commit_msg>Gate PixbufAnimation::new_from_resource on GDK 3.8<commit_after>// Copyright 2013-2015, The Rust-GNOME Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>

//! Animations — Animated images.

use std::mem;
use std::ptr;
use glib::{Error, GlibContainer, TimeVal};
use glib::translate::*;
use glib::types::{StaticType, Type};
use object::{Object, Upcast};
use ffi;
use super::Pixbuf;

pub type PixbufAnimationIter = Object<ffi::C_GdkPixbufAnimationIter>;

impl StaticType for PixbufAnimationIter {
    fn static_type() -> Type { unsafe { from_glib(ffi::gdk_pixbuf_animation_iter_get_type()) } }
}

impl PixbufAnimationIter {
    pub fn advance(&self, start_time: &TimeVal) -> bool {
        unsafe {
            from_glib(ffi::gdk_pixbuf_animation_iter_advance(self.to_glib_none().0,
                mem::transmute(start_time)))
        }
    }

    pub fn get_pixbuf(&self) -> Pixbuf {
        unsafe { from_glib_none(ffi::gdk_pixbuf_animation_iter_get_pixbuf(self.to_glib_none().0)) }
    }

    pub fn get_delay_time(&self) -> i32 {
        unsafe { ffi::gdk_pixbuf_animation_iter_get_delay_time(self.to_glib_none().0) }
    }

    pub fn on_currently_loading_frame(&self) -> bool {
        unsafe {
            from_glib(
                ffi::gdk_pixbuf_animation_iter_on_currently_loading_frame(self.to_glib_none().0))
        }
    }
}

pub type PixbufAnimation = Object<ffi::C_GdkPixbufAnimation>;

impl StaticType for PixbufAnimation {
    fn static_type() -> Type { unsafe { from_glib(ffi::gdk_pixbuf_animation_get_type()) } }
}

impl PixbufAnimation {
    pub fn new_from_file(file: &str) -> Result<PixbufAnimation, Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let ptr = ffi::gdk_pixbuf_animation_new_from_file(file.to_glib_none().0, &mut error);
            if error.is_null() {
                Ok(from_glib_full(ptr))
            } else {
                Err(Error::wrap(error))
            }
        }
    }

    #[cfg(feature = "gdk_3_8")] // gdk-pixbuf 2.28
    pub fn new_from_resource(resource_path: &str) -> Result<PixbufAnimation, Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let ptr = ffi::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(Error::wrap(error))
            }
        }
    }
}

pub trait PixbufAnimationExt {
    fn get_width(&self) -> i32;
    fn get_height(&self) -> i32;
{'fraction_non_alphanumeric': 0.11617100371747212, 'fraction_numerical': 0.008736059479553903, 'mean_word_length': 2.6114093959731544, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2451855', 'n_tokens_mistral': 1816, 'n_tokens_neox': 1739, 'n_words': 331}