title: Display a sequence of images using gtk in Linux
body: <p>I have written a simple code to display a raw image buffer in a window using gtk:</p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;gtk/gtk.h&gt;
  
  int main (int argc, char *argv[])
  {
      const int Width = 1920, Height = 1080;
      char *buffer = (char*)malloc(3 * Width * Height);
  
      // Read a raw image data from the disk and put it in the buffer.
      // ....
  
      GtkWidget *window;
      GtkWidget* image;
  
      gtk_init (&amp;argc, &amp;argv);
  
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data (buffer, GDK_COLORSPACE_RGB,
          FALSE, 8, Width, Height, Width*3, NULL, NULL);
  
      gtk_window_set_title (GTK_WINDOW (window), "Image Viewer");
  
      g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
  
      image = gtk_image_new_from_pixbuf (pixbuf);
      gtk_container_add(GTK_CONTAINER (window), image);
  
      gtk_widget_show_all (window);
  
      gtk_main ();
  
      free (buffer);
      return 0;
  }
  </code></pre>
  
  <p>How can I change this code to display a sequence of <code>N</code> images like a movie (i.e. continuous playback, not by choosing images manually using an image dialog box)? The main display loop is controlled by <code>gtk_main()</code> which ends when the user closes the window. I think the loop to assign the images to the image gadget should be inside an event handler of the image gadget, but I do not know that event handler.</p>