[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[mhc:00238] Re: signal delete_event on Mhc::DayBook
From: Yoshinari NOMURA <nom@xxxxxxxxxxxxxxxxxxx>
Subject: Re: [mhc:00236] Re: signal delete_event on Mhc::DayBook
Date: Fri, 26 Nov 1999 14:23:18 +0900
> ruby-ext に持って行った方がいいかな。
かも、しれませんね。僕は ruby-extも読んでいるので、ねたふりおねがいしま
す(^^;
> On Fri, 26 Nov 1999 07:29:21 +0900,
> Yasushi Shoji <yashi@xxxxxxxxx> said:
>
> > Ruby/Gtk 0.22では、signalを emitする methodすら無いですね(^^;
>
> そうなんですよ。gemcal では、signal 名 -> proc のハッシュを自分
> で持って、むりやり emit 動作をさせています。
signal_emitは作ったんですけど、classに新しい signalを付けるのが難しそう
なんですよ‥‥。Gtkの内部とか良くわかってないもので(汗
[...]
> と書きたいのです。今は container の signal_connect を再定義して、
> そこで場合分けをしていますが、実はもっとうまい方法があるんではな
> いか? と思ったりしているわけです。
う〜ん、C と Rubyでしか Gtkを使ったことがないのでわからないです。
KDEの Qtとかってそういう事ができたりするのでしょうか?
Gtk+の GGAD(かな?)には、signal_emitするのは自分自身に関する signalだけに
しておかないと上手く動かないかもしれない(保証されてない)って書いてあった
様な気がします。
> calendar .day[31] .signal_connect('clicked'){|w| w .open(31)}
>
> と書かずに、Gtk::CList のように
>
> calendar .signal_connect('day-button-clicked'){|w,d| w .open(d)}
これを見て、GtkCalendarに対応してないのを知ったので、作りました(^^;
mailに付けておきますね。patchじゃなくて fileなので extconf.rbとかをいぢ
らないと、compileされません。気を付けてください。
cal = Gtk::Calendar.new
cal.signal_connect('day_selected') do
year, month, day = cal.date
hoge.open(day)
end
かなぁ〜。まだ、だめですね‥‥。
--
yahsi
#include "global.h"
static VALUE
cal_init(self)
VALUE self;
{
set_widget(self, gtk_calendar_new());
return Qnil;
}
static VALUE
cal_select_month(self, month, year)
VALUE self, month, year;
{
gint ret;
ret = gtk_calendar_select_month(GTK_CALENDAR(get_widget(self)),
FIX2INT(month),
FIX2INT(year));
return INT2FIX(ret);
}
static VALUE
cal_select_day(self, day)
VALUE self, day;
{
gtk_calendar_select_day(GTK_CALENDAR(get_widget(self)), FIX2INT(day));
return self;
}
static VALUE
cal_mark_day(self, day)
VALUE self, day;
{
gint ret;
ret = gtk_calendar_mark_day(GTK_CALENDAR(get_widget(self)), FIX2INT(day));
return INT2FIX(ret);
}
static VALUE
cal_unmark_day(self, day)
VALUE self, day;
{
gint ret;
ret = gtk_calendar_unmark_day(GTK_CALENDAR(get_widget(self)), FIX2INT(day));
return INT2FIX(ret);
}
static VALUE
cal_clear_marks(self)
VALUE self;
{
gtk_calendar_clear_marks(GTK_CALENDAR(get_widget(self)));
return self;
}
static VALUE
cal_display_options(self, flags)
VALUE self, flags;
{
gtk_calendar_display_options(GTK_CALENDAR(get_widget(self)),
FIX2INT(flags));
return self;
}
static VALUE
cal_get_date(self)
VALUE self;
{
VALUE ret;
guint year, month, day;
gtk_calendar_get_date(GTK_CALENDAR(get_widget(self)),
&year, &month, &day);
ret = rb_ary_new();
rb_ary_push(ret, INT2FIX(year));
rb_ary_push(ret, INT2FIX(month));
rb_ary_push(ret, INT2FIX(day));
return ret;
}
static VALUE
cal_freeze(self)
VALUE self;
{
gtk_calendar_freeze(GTK_CALENDAR(get_widget(self)));
return self;
}
static VALUE
cal_thaw(self)
VALUE self;
{
gtk_calendar_thaw(GTK_CALENDAR(get_widget(self)));
return self;
}
void Init_gtk_calendar()
{
gCalendar = rb_define_class_under(mGtk, "Calendar", gWidget);
rb_define_const(gCalendar, "SHOW_HEADING",
INT2FIX(GTK_CALENDAR_SHOW_HEADING));
rb_define_const(gCalendar, "SHOW_DAY_NAMES",
INT2FIX(GTK_CALENDAR_SHOW_DAY_NAMES));
rb_define_const(gCalendar, "NO_MONTH_CHANGE",
INT2FIX(GTK_CALENDAR_NO_MONTH_CHANGE));
rb_define_const(gCalendar, "SHOW_WEEK_NUMBERS",
INT2FIX(GTK_CALENDAR_SHOW_WEEK_NUMBERS));
rb_define_const(gCalendar, "WEEK_START_MONDAY",
INT2FIX(GTK_CALENDAR_WEEK_START_MONDAY));
rb_define_const(gCalendar, "SIGNAL_MONTH_CHANGED",
rb_str_new2("month_changed"));
rb_define_const(gCalendar, "SIGNAL_DAY_SELECTED",
rb_str_new2("day_selected"));
rb_define_const(gCalendar, "SIGNAL_DAY_SELECTED_DOUBLE_CLICK",
rb_str_new2("day_selected_double_click"));
rb_define_const(gCalendar, "SIGNAL_PREV_MONTH",
rb_str_new2("prev_month"));
rb_define_const(gCalendar, "SIGNAL_NEXT_MONTH",
rb_str_new2("next_month"));
rb_define_const(gCalendar, "SIGNAL_PREV_YEAR",
rb_str_new2("prev_year"));
rb_define_const(gCalendar, "SIGNAL_NEXT_YEAR",
rb_str_new2("next_year"));
rb_define_method(gCalendar, "initialize", cal_init, 0);
rb_define_method(gCalendar, "select_month", cal_select_month, 2);
rb_define_method(gCalendar, "select_day", cal_select_day, 1);
rb_define_method(gCalendar, "mark_day", cal_mark_day, 1);
rb_define_method(gCalendar, "unmark_day", cal_unmark_day, 1);
rb_define_method(gCalendar, "clear_marks", cal_clear_marks, 0);
rb_define_method(gCalendar, "display_options", cal_display_options, 1);
rb_define_method(gCalendar, "get_date", cal_get_date, 0);
rb_define_method(gCalendar, "freeze", cal_freeze, 0);
rb_define_method(gCalendar, "thaw", cal_thaw, 0);
rb_define_alias(gCalendar, "date", "get_date");
}
/*
* Local Variables:
* c-file-style: "bsd"
* End:
*/
require 'gtk'
cal = Gtk::Calendar.new
w = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
w.add(cal).show_all.signal_connect('delete_event') do
Gtk::main_quit
end
cal.select_month(7, 1974)
cal.select_day(15)
cal.mark_day(20)
cal.clear_marks
#cal.display_options(Gtk::Calendar::SHOW_HEADING |
# Gtk::Calendar::SHOW_DAY_NAMES |
# Gtk::Calendar::NO_MONTH_CHANGE |
# Gtk::Calendar::SHOW_WEEK_NUMBERS |
# Gtk::Calendar::WEEK_START_MONDAY)
year, month, day = cal.get_date
print "this is #{month} #{day}, #{year}\n"
cal.signal_connect('day_selected') do
year, month, day = cal.date
print "selected day: ", day, "\n"
end
cal.signal_connect('month_changed') do
year, month, day = cal.date
print "changed month: ", month, "\n"
end
cal.signal_connect('day_selected_double_click') do
year, month, day = cal.date
print "dclicked day: ", day, "\n"
end
cal.signal_connect('prev_month') do
year, month, day = cal.date
print "prev month: ", month, "\n"
end
cal.signal_connect('next_month') do
year, month, day = cal.date
print "next_month: ", month, "\n"
end
cal.signal_connect('prev_year') do
year, month, day = cal.date
print "prev_year: ", year, "\n"
end
cal.signal_connect('next_year') do
year, month, day = cal.date
print "next year: ", year, "\n"
end
Gtk::main