This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

plams

By: a guest on Aug 27th, 2007  |  syntax: Ruby  |  size: 0.72 KB  |  views: 150  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. require 'gtk2'
  2.  
  3. class Foo < Gtk::Container
  4.         type_register
  5.         def initialize
  6.                 super()
  7.                 set_flags Gtk::Widget::NO_WINDOW
  8.         end
  9.         def add child
  10.                 # !! following code generates this warning: "Gtk-WARNING **:GtkContainerClass::add not implemented for `Foo'"
  11.                 child.parent = self
  12.         end
  13.         def size_allocate
  14.                 # this method should be called by gtk subsystem, but it isn't
  15.                 puts "called size_allocate"
  16.         end
  17.         def size_request
  18.                 # this method also should be called by gtk subsystem, but it isn't
  19.                 puts "called size_request"
  20.         end
  21. end
  22.  
  23. class App < Gtk::Window
  24.         def initialize
  25.                 super()
  26.                 foo = Foo.new
  27.  
  28.                 button = Gtk::Button.new("hello")
  29.                 foo.add button
  30.  
  31.                 add foo
  32.         end
  33. end
  34.  
  35. app = App.new
  36. app.show_all
  37. Gtk.main
clone this paste RAW Paste Data