ruby-****@sourc*****
ruby-****@sourc*****
2008年 10月 2日 (木) 16:30:26 JST
------------------------- REMOTE_ADDR = 222.225.51.171 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/ja/hiki.cgi?libglade2-tut-about-template ------------------------- @@ -29,55 +29,59 @@ 勝手にHweditGladeという名前のクラスになりました。 - include GetText + include GetText + + attr :glade + + def initialize(path_or_data, root = nil, domain = nil, localedir = nil, flag = GladeXML::FILE) + GetText.bindtextdomain(domain, localedir, nil, "UTF-8") + @glade = GladeXML.new(path_or_data, root, domain, localedir, flag) {|handler| method(handler)} - def initialize(path_or_data, root = nil, domain = nil, localedir = nil, flag = GladeXML::FILE) - GetText.bindtextdomain(domain, localedir, nil, "UTF-8") - @glade = GladeXML.new(path_or_data, root, domain, localedir, flag) {|handler| method(handler)} - - end + end コンストラクタ(HweditGlade.new)実行時、path_or_dataの指定は必須です。Glade XMLファイル(*.glade)を指定するか、Glade XML(*.gladeの内容)を文字列として渡してあげます。ただし、文字列として渡す場合は、flagにGladeXML::BUFFERを渡す必要があります。domainはRuby/Libgladeと((<Ruby-GetText-Package|raa:ruby-gettext>))で用いるドメイン名(言語リソース名:moファイルの検索に用いられる)です。 - def on_save1_activate(widget) - puts "on_save1_activate() is not implemented yet." + def on_open1_activate(widget) + puts "on_open1_activate() is not implemented yet." end - def on_quit1_activate(widget) - puts "on_quit1_activate() is not implemented yet." + def on_paste1_activate(widget) + puts "on_paste1_activate() is not implemented yet." end - def on_cut1_activate(widget) - puts "on_cut1_activate() is not implemented yet." + def on_save_as1_activate(widget) + puts "on_save_as1_activate() is not implemented yet." end def on_about1_activate(widget) puts "on_about1_activate() is not implemented yet." end - def on_open1_activate(widget) - puts "on_open1_activate() is not implemented yet." - end - def on_paste1_activate(widget) - puts "on_paste1_activate() is not implemented yet." + def on_copy1_activate(widget) + puts "on_copy1_activate() is not implemented yet." end def on_closebutton1_clicked(widget) puts "on_closebutton1_clicked() is not implemented yet." end + def on_main_window_delete_event(widget, arg0) + puts "on_main_window_delete_event() is not implemented yet." + end def on_new1_activate(widget) puts "on_new1_activate() is not implemented yet." end - def on_save_as1_activate(widget) - puts "on_save_as1_activate() is not implemented yet." + def on_main_window_destroy(widget) + puts "on_main_window_destroy() is not implemented yet." end - def on_main_window_delete_event(widget, arg0) - puts "on_main_window_delete_event() is not implemented yet." + def on_cut1_activate(widget) + puts "on_cut1_activate() is not implemented yet." + end + def on_save1_activate(widget) + puts "on_save1_activate() is not implemented yet." end - def on_copy1_activate(widget) - puts "on_copy1_activate() is not implemented yet." + def on_quit1_activate(widget) + puts "on_quit1_activate() is not implemented yet." end これらは全てイベントハンドラ(ボタンクリック等のイベントが発生したときに呼び出されるメソッド)です。 デフォルトでは、"xxxx is not implemented yet."と表示されるようになっていますので自分で実装したいところから書き換えて行くイメージです。 end - # Main program if __FILE__ == $0