岡本@姑獲鳥の夏はおもしろかったです。 ちょっと、まとまった時間ができたので Gtk module に Gtk::Statusbar を追加しました。 ついでに、 Gtk::label::get も追加しています。 使い方は、こんな感じです。 statusbar の生成 statusbar = Gtk::Statusbar::new() statusbar の id 確保 id = statusbar.get_context_id("test") data の push mid = statusbar.push(id, text) data の pop statusbar.pop(id) data の削除 statusbar.remove(id, mid) です。詳しいことは gtk のドキュメントを参照してください。 差分は ruby-gtk-0.09 からのものになっています。 Gtk::label::set も含んでいます。 ちょっと長いですが、メールの最後につけてあります。 例のごとく、かなり適当に書いている(^^;;; ので、一応チェックしてもらえますか? > まつもとさん ところで、新しいウィジェットを追加するときに 書く場所ってどこがいいんでしょう? 今回は hbox のサブクラスにしたので、hbox のしたに書きましたが 何かルールはありますか? でわでわ。 -- 岡本和己 E-mail: kazusan / pluto.dti.ne.jp --- gtk.org Wed Jul 22 14:47:49 1998 +++ gtk.c Sun Aug 9 19:54:54 1998 @@ -87,6 +87,7 @@ static VALUE gPreview; static VALUE gProgressBar; static VALUE gScrolledWin; +static VALUE gStatusBar; static VALUE gTable; static VALUE gText; static VALUE gToolbar; @@ -2819,6 +2820,23 @@ } static VALUE +label_get(self) + VALUE self; +{ + gchar** str; + gtk_label_get(GTK_LABEL(get_widget(self)), str); + return str_new2(*str); +} + +static VALUE +label_set(self, str) + VALUE self, str; +{ + gtk_label_set(GTK_LABEL(get_widget(self)), STR2CSTR(str)); + return Qnil; +} + +static VALUE list_initialize(self) VALUE self; { @@ -4931,6 +4949,58 @@ } static VALUE +statusbar_initialize(self) + VALUE self; +{ + set_widget(self, gtk_statusbar_new()); + return Qnil; +} + +static VALUE +statusbar_push(self, id, text) + VALUE self; + VALUE id; + VALUE text; +{ + gint message_id; + message_id = gtk_statusbar_push(GTK_STATUSBAR(get_widget(self)), + NUM2INT(id), STR2CSTR(text)); + return INT2FIX(message_id); +} + +static VALUE +statusbar_pop(self, id) + VALUE self; + VALUE id; +{ + gtk_statusbar_pop(GTK_STATUSBAR(get_widget(self)), NUM2INT(id)); + return Qnil; + +} + +static VALUE +statusbar_get_context_id(self, text) + VALUE self; + VALUE text; +{ + gint context_id; + context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(get_widget(self)), + STR2CSTR(text)); + return INT2FIX(context_id); +} + +static VALUE +statusbar_remove(self, cid, mid) + VALUE self; + VALUE cid; + VALUE mid; +{ + gtk_statusbar_remove(GTK_STATUSBAR(get_widget(self)), + NUM2INT(cid), NUM2INT(mid)); + return Qnil; +} + +static VALUE combo_initialize(self) VALUE self; { @@ -6224,6 +6294,7 @@ gHBBox = rb_define_class_under(mGtk, "HButtonBox", gBBox); gVBBox = rb_define_class_under(mGtk, "VButtonBox", gBBox); gHBox = rb_define_class_under(mGtk, "HBox", gBox); + gStatusBar = rb_define_class_under(mGtk, "Statusbar", gHBox); gCombo = rb_define_class_under(mGtk, "Combo", gHBox); gPaned = rb_define_class_under(mGtk, "Paned", gContainer); gHPaned = rb_define_class_under(mGtk, "HPaned", gPaned); @@ -6644,6 +6715,13 @@ /* HBox */ rb_define_method(gHBox, "initialize", hbox_initialize, -1); + /* Statusbar */ + rb_define_method(gStatusBar, "initialize", statusbar_initialize, 0); + rb_define_method(gStatusBar, "push", statusbar_push, 2); + rb_define_method(gStatusBar, "pop", statusbar_pop, 1); + rb_define_method(gStatusBar, "get_context_id", statusbar_get_context_id, 1); + rb_define_method(gStatusBar, "remove", statusbar_remove, 2); + /* Combo */ rb_define_method(gCombo, "initialize", combo_initialize, 0); rb_define_method(gCombo, "set_value_in_list", combo_val_in_list, 2); @@ -6738,6 +6816,8 @@ /* Label */ rb_define_method(gLabel, "initialize", label_initialize, 1); + rb_define_method(gLabel, "get", label_get, 0); + rb_define_method(gLabel, "set", label_set, 1); /* List */ rb_define_method(gList, "initialize", list_initialize, 0);