Sha256: 694975a4133ba5f470bf6f43cebf008fa87e0da04f2ea49505386d814d84bf64

Contents?: true

Size: 876 Bytes

Versions: 24

Compression:

Stored size: 876 Bytes

Contents

#!/usr/bin/env ruby
=begin
  to_drawable.rb - Gdk::Pixbuf(GDK methods) sample script.

  Copyright (c) 2002-2006 Ruby-GNOME2 Project Team 
  This program is licenced under the same licence as Ruby-GNOME2.

  $Id: to_drawable.rb,v 1.6 2006/06/17 13:18:12 mutoh Exp $
=end

require 'gtk3'

filename = ARGV[0]
unless filename
  puts "ruby #{$0} filename"
  exit(1)
end

pixbuf = Gdk::Pixbuf.new(filename)

w = Gtk::Window.new("Drawable sample")
w.realize
w.signal_connect('delete-event') do
  Gtk.main_quit
end

d = Gtk::DrawingArea.new
gc = Gdk::GC.new(w.window)
d.signal_connect('expose-event') do |w, e|
  unless e.count > 0
    width = w.allocation.width
    height = w.allocation.height
    pixbuf = pixbuf.scale(width, height)
    d.window.draw_pixbuf(gc, pixbuf, 0, 0, 0, 0,
			 width, height, Gdk::RGB::DITHER_NORMAL, 0, 0)
  end
  true
end
w.add(d)
w.show_all

Gtk.main

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
gtk3-2.1.0-x86-mingw32 sample/misc/to_drawable.rb
gtk3-2.1.0 sample/misc/to_drawable.rb
gtk3-2.0.3-x86-mingw32 sample/misc/to_drawable.rb
gtk3-2.0.3 sample/misc/to_drawable.rb
gtk3-2.0.2-x86-mingw32 sample/misc/to_drawable.rb
gtk3-2.0.2 sample/misc/to_drawable.rb
gtk3-2.0.1-x86-mingw32 sample/misc/to_drawable.rb
gtk3-2.0.1 sample/misc/to_drawable.rb
gtk3-2.0.0-x86-mingw32 sample/misc/to_drawable.rb
gtk3-2.0.0 sample/misc/to_drawable.rb
gtk3-1.2.6-x86-mingw32 sample/misc/to_drawable.rb
gtk3-1.2.6 sample/misc/to_drawable.rb
gtk3-1.2.5-x86-mingw32 sample/misc/to_drawable.rb
gtk3-1.2.5 sample/misc/to_drawable.rb
gtk3-1.2.4-x86-mingw32 sample/misc/to_drawable.rb
gtk3-1.2.4 sample/misc/to_drawable.rb
gtk3-1.2.3-x86-mingw32 sample/misc/to_drawable.rb
gtk3-1.2.3 sample/misc/to_drawable.rb
gtk3-1.2.2-x86-mingw32 sample/misc/to_drawable.rb
gtk3-1.2.2 sample/misc/to_drawable.rb