File: cursor.rb

package info (click to toggle)
ruby-gnome2 0.12.0-2sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,820 kB
  • ctags: 7,421
  • sloc: ansic: 61,387; ruby: 17,307; makefile: 85; xml: 35; sql: 13
file content (34 lines) | stat: -rw-r--r-- 729 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
=begin
  cursor.rb - Gdk::Cursor sample script.

  Copyright (C) 2001-2003 Masao Mutoh<mutoh@highway.ne.jp>
  This program is licenced under the same licence as Ruby-GNOME2.

  $Id: cursor.rb,v 1.6 2003/08/31 15:29:44 mutoh Exp $
=end

require 'gtk2'

Gtk.init

window = Gtk::Window.new
window.realize

button = Gtk::Button.new("Click!")
button.use_underline = false

cursors = Gdk::Cursor::Type.values - [Gdk::Cursor::CURSOR_IS_PIXMAP]

cnt = 0
button.signal_connect('clicked') do
  cursor = cursors[cnt]
p cursor.inspect
  button.set_label(cursor.inspect)
  window.window.set_cursor(Gdk::Cursor.new(cursor))
  cnt += 1
  cnt = 0 if cnt == cursors.size
end
window.add(button)
window.set_default_size(400,100).show_all

Gtk.main