#!/usr/bin/env python
# Australian Landscape Trust
# Video thumbnail window class for the Murray-Darling Basin project
# Written by Andrew Pam <andrew@sericyb.com.au>
# Copyright (c) 2003 Serious Cybernetics
#
# 2003/11/20 ADP Initial implementation

import pygtk
pygtk.require('2.0')
import gtk
import fb

# Thumbnail window should be 256x144 (1/4 size at 16:9 aspect ratio)
THUMBWIDTH = 256
THUMBHEIGHT = 144

class Video_Thumbnail:
  def __init__(self, device = '/dev/fb0'):
    fb.open(device)
    self.area = gtk.DrawingArea()
    self.area.set_size_request(THUMBWIDTH, THUMBHEIGHT)
    self.area.connect("expose-event", self.area_expose)

  def area_expose(self, area, event):
    style = self.area.get_style()
    gc = style.fg_gc[gtk.STATE_NORMAL]
    self.area.window.draw_rgb_image(gc, 0, 0, THUMBWIDTH, THUMBHEIGHT,
      gtk.gdk.RGB_DITHER_NONE, fb.getbuf(), THUMBWIDTH * 3)

# Support command line invocation
if __name__ == "__main__":
  window = gtk.Window(gtk.WINDOW_TOPLEVEL)
  window.connect("destroy", lambda quit: gtk.main_quit())
  thumb = Video_Thumbnail('/dev/fb1')
  window.add(thumb.area)
  window.show_all()
  gtk.main()


