Sha256: 6bca7224e948e6df926bf230bc57d474c7205c23215215c3ec4d457fa6e7abfc

Contents?: true

Size: 796 Bytes

Versions: 38

Compression:

Stored size: 796 Bytes

Contents

=begin
  stock.rb - Gtk::Stock sample script.

  Copyright (C) 2001-2006 Masao Mutoh
  This program is licenced under the same licence as Ruby-GNOME2.

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

require 'gtk3'

window = Gtk::Window.new("Gtk::Stock sample")
window.signal_connect("destroy"){Gtk.main_quit}

stocks = Gtk::Stock.constants.sort

image = Gtk::Image.new
label = Gtk::Label.new
button = Gtk::Button.new("Click!")
cnt = 0
button.signal_connect("clicked") do
  stock_name = "Gtk::Stock::#{stocks[cnt]}"
  label.set_text(stock_name)
  image.set(eval(stock_name), Gtk::IconSize::DIALOG)
  if cnt < stocks.size - 1
    cnt += 1
  else
    cnt = 0
  end
end

box = Gtk::VBox.new.add(image).add(label).add(button)
window.add(box).set_default_size(200,200).show_all

Gtk.main

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
gtk3-2.2.5-x64-mingw32 sample/misc/stock.rb
gtk3-2.2.5-x86-mingw32 sample/misc/stock.rb
gtk3-2.2.5 sample/misc/stock.rb
gtk3-2.2.4-x64-mingw32 sample/misc/stock.rb
gtk3-2.2.4-x86-mingw32 sample/misc/stock.rb
gtk3-2.2.4 sample/misc/stock.rb
gtk3-2.2.3-x86-mingw32 sample/misc/stock.rb
gtk3-2.2.3 sample/misc/stock.rb
gtk3-2.2.2-x86-mingw32 sample/misc/stock.rb
gtk3-2.2.2 sample/misc/stock.rb
gtk3-2.2.1-x86-mingw32 sample/misc/stock.rb
gtk3-2.2.1 sample/misc/stock.rb
gtk3-2.2.0-x86-mingw32 sample/misc/stock.rb
gtk3-2.2.0 sample/misc/stock.rb
gtk3-2.1.0-x86-mingw32 sample/misc/stock.rb
gtk3-2.1.0 sample/misc/stock.rb
gtk3-2.0.3-x86-mingw32 sample/misc/stock.rb
gtk3-2.0.3 sample/misc/stock.rb
gtk3-2.0.2-x86-mingw32 sample/misc/stock.rb
gtk3-2.0.2 sample/misc/stock.rb