Add licence and installation instructions.
[kaya.git] / lib / ics / example / window.rb
blobc2498a5370750cfe5da25efab4119e14cfd95f4a
1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 class Window < Qt::Widget
9   def initialize(parent = nil)
10     super parent
12     quit = Qt::PushButton.new("Quit", self)
13     connect(quit, SIGNAL(:clicked),
14             self, SLOT(:close))
16     start_button = Qt::PushButton.new("Start", self)
17     start_button.on(:clicked) { start }
19     layout = Qt::VBoxLayout.new
20     layout.add_widget start_button
21     layout.add_widget quit
22     set_layout layout
23     
24     @conn = ICS::Connection.new('freechess.org', 5000)
25     r = lambda do |text, off|
26       puts "received (#{off}): #{text}"
27     end
28     @conn.on(:received_line, &r)
29     @conn.on(:received_text, &r)
30   end
31   
32   def start
33     @conn.start
34   end
35 end