<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<refentry id="class-gdkpixbufanimation">
  <refnamediv>
    <refname>gtk.gdk.PixbufAnimation</refname>
    <refpurpose>an object holding an animation</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>gtk.gdk.PixbufAnimation</classname></ooclass>
      <ooclass><classname><link
linkend="class-gobject">gobject.GObject</link></classname></ooclass>
      <constructorsynopsis language="python">
	<methodname><link
linkend="constructor-gdkpixbufanimation">gtk.gdk.PixbufAnimation</link></methodname>
	<methodparam><parameter
		       role="keyword">filename</parameter></methodparam>
      </constructorsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkpixbufanimation--get-width">get_width</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkpixbufanimation--get-height">get_height</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkpixbufanimation--is-static-image">is_static_image</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkpixbufanimation--get-static-image">get_static_image</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkpixbufanimation--get-iter">get_iter</link></methodname>
	<methodparam><parameter role="keyword">start_time</parameter>
	  <initializer>0.0</initializer></methodparam>
      </methodsynopsis>
    </classsynopsis>

  </refsect1>

  <refsect1>
    <title>Ancestry</title>

<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
  +-- <link linkend="class-gdkpixbufanimation">gtk.gdk.PixbufAnimation</link>
</synopsis>

  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>A <link
linkend="class-gdkpixbufanimation"><classname>gtk.gdk.PixbufAnimation</classname></link> 
is an object that holds an animation. An animation is conceptually a series
of frames to be displayed over time. Each frame is the same size. The
animation may not be represented as a series of frames internally; for
example, it may be stored as a sprite and instructions for moving the sprite
around a background. To display an animation you don't need to understand
its representation, you just ask a <link
linkend="class-gdkpixbufanimationiter"><classname>gtk.gdk.PixbufAnimationIter</classname></link> 
for the next frame that should be displayed at a given point in time.</para>

  </refsect1>

  <refsect1 id="constructor-gdkpixbufanimation">
    <title>Constructor</title>

    <programlisting><constructorsynopsis language="python">
	<methodname>gtk.gdk.PixbufAnimation</methodname>
	<methodparam><parameter
		       role="keyword">filename</parameter></methodparam>
      </constructorsynopsis></programlisting>
    <variablelist>
      <varlistentry>
	<term><parameter role="keyword">filename</parameter>&nbsp;:</term>
	<listitem><simpara>the name of the file to
load.</simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	<listitem><simpara>a new <link
	linkend="class-gdkpixbufanimation"><classname>gtk.gdk.PixbufAnimation</classname></link>
	object.</simpara></listitem>
      </varlistentry>
    </variablelist>

    <para>Creates a new <link
linkend="class-gdkpixbufanimation"><classname>gtk.gdk.PixbufAnimation</classname></link> 
by loading it from a file. The file format is detected automatically. If the
file's format does not support multi-frame images, then an animation with a
single frame will be created.</para>

    <para>This constructor raises the GError exception if any of several
error conditions occurred: the file could not be opened, there was no loader
for the file's format, there was not enough memory to allocate the image
buffer, or the image file contained invalid data.</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

  <refsect2 id="method-gdkpixbufanimation--get-width">
      <title>gtk.gdk.PixbufAnimation.get_width</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_width</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the width of the bounding box of the
animation.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_width</methodname>() method returns the
width of the bounding box of a pixbuf animation.</para>

    </refsect2>

    <refsect2 id="method-gdkpixbufanimation--get-height">
      <title>gtk.gdk.PixbufAnimation.get_height</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_height</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the height of the bounding box of the
animation.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_height</methodname>() method returns the
height of the bounding box of a pixbuf animation.</para>

    </refsect2>

    <refsect2 id="method-gdkpixbufanimation--is-static-image">
      <title>gtk.gdk.PixbufAnimation.is_static_image</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>is_static_image</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>True</literal> if the "animation" was
really just an image</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>is_static_image</methodname>() method returns
True if you load a file containing a plain, unanimated image. Use the <link
linkend="method-gdkpixbufanimation--get-static-image"><methodname>get_static_image</methodname>()</link> 
method to retrieve the image.</para>

    </refsect2>

    <refsect2 id="method-gdkpixbufanimation--get-static-image">
      <title>gtk.gdk.PixbufAnimation.get_static_image</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_static_image</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the unanimated image representing the
animation</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_static_image</methodname>() method returns a
<link linkend="class-gdkpixbuf"><classname>gtk.gdk.Pixbuf</classname></link>
that represents a static image of the animation. If the animation is really
just a plain image (has only one frame), this method returns that image. If
the animation is an animation, this method returns a reasonable thing to
display as a static unanimated image, which might be the first frame, or
something more sophisticated. If an animation hasn't loaded any frames yet,
this method will return <literal>None</literal>.</para>

    </refsect2>

    <refsect2 id="method-gdkpixbufanimation--get-iter">
      <title>gtk.gdk.PixbufAnimation.get_iter</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_iter</methodname>
	  <methodparam><parameter role="keyword">start_time</parameter>
	    <initializer>0.0</initializer></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter
role="keyword">start_time</parameter>&nbsp;:</term>
	  <listitem><simpara>the time when the animation starts
playing</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-gdkpixbufanimationiter"><classname>gtk.gdk.PixbufAnimationIter</classname></link> 
object</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_iter</methodname>() method returns a <link
linkend="class-gdkpixbufanimationiter"><classname>gtk.gdk.PixbufAnimationIter</classname></link> 
that is used to access the frames of the animation. The iterator provides
the frames that should be displayed at specific times.
<parameter>start_time</parameter> is the start time specified as a float as
output from the Python time.time() function.
<parameter>start_time</parameter> marks the beginning of the animation
playback. After creating an iterator, you should immediately display the
pixbuf returned by the <link
linkend="method-gdkpixbufanimationiter--get-pixbuf"><methodname>gtk.gdk.PixbufAnimationIter.get_pixbuf</methodname>()</link> 
method. Then, you should install a timeout (with the <link
linkend="function-gobject--timeout-add"><methodname>gobject.timeout_add</methodname>()</link>() 
function) or by some other mechanism ensure that you'll update the image
after the number of  milliseconds specified by the <link
linkend="method-gdkpixbufanimationiter--get-delay-time"><methodname>gtk.gdk.PixbufAnimationIter.get_delay_time</methodname>()</link> 
method. Each time the image is updated, you should reinstall the timeout
with the new, possibly-changed delay time. As a shortcut, if
<parameter>start_time</parameter> is 0.0 (the default), the current time
will be used.</para>

      <para>To update the image (i.e. possibly change the result of the
<link
linkend="method-gdkpixbufanimationiter--get-pixbuf"><methodname>gtk.gdk.PixbufAnimationIter.get_pixbuf</methodname>()</link> 
method to a new frame of the animation), call the <link
linkend="method-gdkpixbufanimationiter--advance"><methodname>gtk.gdk.PixbufAnimationIter.advance</methodname>()</link> 
method.</para>

      <para>If you're using a <link
linkend="class-gdkpixbufloader"><classname>gtk.gdk.PixbufLoader</classname></link>, 
in addition to updating the image after the delay time, you should also
update it whenever you receive the "area_updated" signal and the <link
linkend="method-gdkpixbufanimationiter--on-currently-loading-frame"><methodname>gtk.gdk.PixbufAnimationIter.on_currently_loading_frame</methodname>()</link> 
method returns <literal>True</literal>. In this case, the frame currently
being fed into the loader has received new data, so needs to be refreshed.
The delay time for a frame may also be modified after an "area_updated"
signal, for example if the delay time for a frame is encoded in the data
after the frame itself. So your timeout should be reinstalled after any
area_updated signal. A delay time of -1 is possible, indicating
"infinite."</para>

    </refsect2>

  </refsect1>

</refentry>
