<?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-gdkpixbufanimationiter">
  <refnamediv>
    <refname>gtk.gdk.PixbufAnimationIter</refname>
    <refpurpose>an object providing access to the frames of a <link
linkend="class-gdkpixbufanimation"><classname>gtk.gdk.PixbufAnimation</classname></link></refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>gtk.gdk.PixbufAnimationIter</classname></ooclass>
      <ooclass><classname><link
linkend="class-gobject">gobject.GObject</link></classname></ooclass>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkpixbufanimationiter--get-delay-time">get_delay_time</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkpixbufanimationiter--get-pixbuf">get_pixbuf</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkpixbufanimationiter--on-currently-loading-frame">on_currently_loading_frame</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkpixbufanimationiter--advance">advance</link></methodname>
	<methodparam><parameter
		       role="keyword">current_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-gdkpixbufanimationiter">gtk.gdk.PixbufAnimationIter</link>
</synopsis>

  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>A <link
linkend="class-gdkpixbufanimationiter"><classname>gtk.gdk.PixbufAnimationIter</classname></link>
is used to access the frames of a <link
linkend="class-gdkpixbufanimation"><classname>gtk.gdk.PixbufAnimation</classname></link>
at specified times. A <link
linkend="class-gdkpixbufanimationiter"><classname>gtk.gdk.PixbufAnimationIter</classname></link>
object is created using the <link
linkend="method-gdkpixbufanimation--get-iter"><methodname>gtk.gdk.PixbufAnimation.get_iter</methodname>()</link>
method. After creating an iterator, you should immediately display the
pixbuf returned by the <link
linkend="method-gdkpixbufanimationiter--get-pixbuf"><methodname>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>get_delay_time</methodname>()</link>
method. Each time the image is updated, you should reinstall the timeout
with the new, possibly-changed delay time.</para>

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

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-gdkpixbufanimationiter--get-delay-time">
      <title>gtk.gdk.PixbufAnimationIter.get_delay_time</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_delay_time</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the delay time in milliseconds (thousandths of
a second)</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_delay_time</methodname>() method returns the
number of milliseconds the current pixbuf should be displayed, or -1 if the
current pixbuf should be displayed forever. The <link
linkend="function-gobject--timeout-add"><methodname>gobject.timeout_add</methodname>()</link>() 
function conveniently takes a timeout in milliseconds, so you can use a
timeout to schedule the next update.</para>

    </refsect2>

    <refsect2 id="method-gdkpixbufanimationiter--get-pixbuf">
      <title>gtk.gdk.PixbufAnimationIter.get_pixbuf</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_pixbuf</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the current <link
linkend="class-gdkpixbuf"><classname>gtk.gdk.Pixbuf</classname></link> to be
displayed</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_pixbuf</methodname>() method returns the
current <link
linkend="class-gdkpixbuf"><classname>gtk.gdk.Pixbuf</classname></link> that
should be displayed. The pixbuf will be the same size as the animation
itself (see the <link
linkend="method-gdkpixbufanimation--get-width"><methodname>gtk.gdk.PixbufAnimation.get_width</methodname>()</link> 
and <link
linkend="method-gdkpixbufanimation--get-height"><methodname>gtk.gdk.PixbufAnimation.get_height</methodname>()</link> 
methods). The <link
linkend="class-gdkpixbuf"><classname>gtk.gdk.Pixbuf</classname></link>
should be displayed for the number of milliseconds specified by the <link
linkend="method-gdkpixbufanimationiter--get-delay-time"><methodname>get_delay_time</methodname>()</link> 
method.</para>

    </refsect2>

    <refsect2 id="method-gdkpixbufanimationiter--on-currently-loading-frame">
      <title>gtk.gdk.PixbufAnimationIter.on_currently_loading_frame</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>on_currently_loading_frame</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>True</literal> if the frame we're on
is partially loaded, or the last frame</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>on_currently_loading_frame</methodname>() method
returns <literal>True</literal> if the frame currently pointed to by the
iterator is partially loaded or the last frame. This method is used to
determine how to respond to the "area_updated" signal on <link
linkend="class-gdkpixbufloader"><classname>gtk.gdk.PixbufLoader</classname></link> 
when loading an animation. The "area_updated" signal is emitted for an area
of the frame currently streaming in to the loader. So if you're on the
currently loading frame, you need to redraw the screen for the updated
area.</para>

    </refsect2>

    <refsect2 id="method-gdkpixbufanimationiter--advance">
      <title>gtk.gdk.PixbufAnimationIter.advance</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>advance</methodname>
	  <methodparam><parameter role="keyword">current_time</parameter>
	    <initializer>0.0</initializer></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter
role="keyword">current_time</parameter>&nbsp;:</term>
	  <listitem><simpara>the current time as a float or 0.0 to
automatically determine the current time</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>True</literal> if the image may need
updating</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>advance</methodname>() method attempts to
advance an animation to a new frame. The frame is chosen based on the start
time passed to the <link
linkend="method-gdkpixbufanimation--get-iter"><methodname>gtk.gdk.PixbufAnimation.get_iter</methodname>()</link> 
method. <parameter>current_time</parameter> is normally the current time (as
specified by the Python time.time() function) and must be greater than or
equal to the time passed to the <link
linkend="method-gdkpixbufanimation--get-iter"><methodname>gtk.gdk.PixbufAnimation.get_iter</methodname>()</link> 
method, and must increase or remain unchanged each time the <link
linkend="method-gdkpixbufanimationiter--get-pixbuf"><methodname>get_pixbuf</methodname>()</link> 
method is called. That is, you can't go backward in time; animations only
play forward. As a shortcut, pass 0.0 (the default) for the current time and
the current time will automatically be determined an used. So you only need
to explicitly pass <parameter>current_time</parameter> if you're doing
something odd like playing the animation at double speed.</para>

      <para>If this method returns <literal>False</literal>, there's no need
to update the animation display, assuming the display had been rendered
prior to advancing; if <literal>True</literal>, you need to call the <link
linkend="method-gdkpixbufanimationiter--get-pixbuf"><methodname>get_pixbuf</methodname>()</link> 
method and update the display with the new pixbuf.</para>

    </refsect2>

  </refsect1>

</refentry>
