ruby-****@lists*****
ruby-****@lists*****
2003年 7月 8日 (火) 23:26:04 JST
------------------------- REMOTE_ADDR = 210.249.204.48 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/?tips_signals ------------------------- = Investigate Signal behaviors How do you find signals which you need? Some representative signals are found in many samples, but others can't find anywhere even GTK+ API documents. This is the introduction how I find it. == 1 Try all signals in the widget which I need When I want to know the signals behaviors, I write test scripts as below at first. Try to click the widget, to press the keyboards, move the widget, then you can investigate which/when signals are emitted. require 'gtk2' Gtk.init widget = Gtk::Button.new("click") #(1) Gtk::Button.signals(false).each do |v| #(2) p v widget.signal_connect(v) do p "#{v} is occured." end end Gtk::Window.new.set_default_size(100, 100).add(widget).show_all Gtk.main This example which use Gtk::Button. But also you can investigate other Widget/Signals to change (1) and (2). If you need to know superclass's signals, set true to GLib::MetaInterface.signals(). == 2 Investigate a signal deeply Then, you find some signals to investigate deeply, try the script below. require 'gtk2' Gtk.init v = "clicked" #(1) widget = Gtk::Button.new("click") #(2) widget.signal_connect(v) do p "#{v} is occured." end Gtk::Window.new.set_default_size(100, 100).add(widget).show_all Gtk.main Change (1), (2) as you need. - ((<Masao>)) ------------------------- = Investigate Signal behaviors How do you find signals which you need? Some representative signals are found in many samples, but others can't find anywhere even GTK+ API documents. This is the introduction how I find it. == 1 Try all signals in the widget which I need When I want to know the signals behaviors, I write test scripts as below at first. Try to click the widget, to press the keyboards, move the widget, then you can investigate which/when signals are emitted. require 'gtk2' Gtk.init widget = Gtk::Button.new("click") #(1) Gtk::Button.signals(false).each do |v| #(2) p v widget.signal_connect(v) do p "#{v} is occured." end end Gtk::Window.new.set_default_size(100, 100).add(widget).show_all Gtk.main This is a example which use Gtk::Button. But also you can investigate other Widget/Signals to change (1) and (2). If you need to know superclass's signals, set true to GLib::MetaInterface.signals(). == 2 Investigate a signal deeply Then, you find some signals to investigate deeply, try the script below. require 'gtk2' Gtk.init v = "clicked" #(1) widget = Gtk::Button.new("click") #(2) widget.signal_connect(v) do p "#{v} is occured." end Gtk::Window.new.set_default_size(100, 100).add(widget).show_all Gtk.main Change (1), (2) as you need. - ((<Masao>))