やすしです。

signal_connectするときに signal名を 'delete-event'と書きたい人に(いるの
か?)朗報です。が、ここまでする価値があるのかは、かなり謎です。

しかも '_'を使っていた人には、もうしわけないのですが、少し遅くなるかも‥‥。
趣味の世界の様な気がするので、さっくり捨ててもかまいません(^^;;

# strcmp()って、速いのかなぁ‥‥。
--
         yashi

--- rbgtk.c 1999/11/29 16:45:56 1.3 +++ rbgtk.c 1999/12/01 12:35:47 @@ -491,6 +491,18 @@ return info; } +static gboolean +signal_comp(sig1, sig2, type) + char *sig1; + char *sig2; + guint type; +{ + if (gtk_signal_lookup(sig1, type) == gtk_signal_lookup(sig2, type)) + return TRUE; + else + return FALSE; +} + static void signal_setup_args(obj, sig, argc, params, args) VALUE obj; @@ -504,41 +516,41 @@ char *signame = rb_id2name(sig); if (rb_obj_is_kind_of(obj, gWidget)) { - if (strcmp(signame, "draw") == 0) { + if (signal_comp(signame, "draw", GTK_TYPE_WIDGET)) { rb_ary_push(args, make_gdkrectangle(GTK_VALUE_POINTER(params[0]))); return; } - if (strcmp(signame, "size_request") == 0) { + if (signal_comp(signame, "size_request", GTK_TYPE_WIDGET)) { rb_ary_push(args, make_grequisition(GTK_VALUE_POINTER(params[0]))); return; } - if (strcmp(signame, "size_allocate") == 0) { + if (signal_comp(signame, "size_allocate", GTK_TYPE_WIDGET)) { rb_ary_push(args, make_gallocation(GTK_VALUE_POINTER(params[0]))); return; } } if (rb_obj_is_kind_of(obj, gWindow)) { - if (strcmp(signame, "move_resize") == 0) { + if (signal_comp(signame, "move_resize", GTK_TYPE_WINDOW)) { rb_ary_push(args, INT2NUM(*GTK_RETLOC_INT(params[0]))); rb_ary_push(args, INT2NUM(*GTK_RETLOC_INT(params[1]))); rb_ary_push(args, INT2NUM(GTK_VALUE_INT(params[3]))); rb_ary_push(args, INT2NUM(GTK_VALUE_INT(params[4]))); return; } - if (strcmp(signame, "set_focus") == 0) { + if (signal_comp(signame, "set_focus", GTK_TYPE_WINDOW)) { rb_ary_push(args, get_value_from_gobject(GTK_VALUE_POINTER(params[0]))); return; } } if (rb_obj_is_kind_of(obj, gEntry)) { - if (strcmp(signame, "insert_position") == 0) { + if (signal_comp(signame, "insert_position", GTK_TYPE_ENTRY)) { rb_ary_push(args, INT2NUM(*GTK_RETLOC_INT(params[0]))); return; } } if (rb_obj_is_kind_of(obj, gCList)) { - if (strcmp(signame, "select_row") == 0 || - strcmp(signame, "unselect_row") == 0) { + if (signal_comp(signame, "select_row", GTK_TYPE_CLIST) || + signal_comp(signame, "unselect_row", GTK_TYPE_CLIST)) { rb_ary_push(args, INT2NUM(GTK_VALUE_INT(params[0]))); rb_ary_push(args, INT2NUM(GTK_VALUE_INT(params[1]))); if (GTK_VALUE_POINTER(params[2])) @@ -549,7 +561,7 @@ } } if (rb_obj_is_kind_of(obj, gNotebook)) { - if (strcmp(signame, "switch_page") == 0) { + if (signal_comp(signame, "switch_page", GTK_TYPE_NOTEBOOK)) { rb_ary_push(args, make_notepage((GtkNotebookPage*) GTK_VALUE_OBJECT(params[0]))); rb_ary_push(args, INT2FIX(GTK_VALUE_INT(params[1]))); return; @@ -574,7 +586,7 @@ char *signame = rb_id2name(sig); if (rb_obj_is_kind_of(obj, gWidget)) { - if (strcmp(signame, "size_request") == 0) { + if (signal_comp(signame, "size_request", GTK_TYPE_WIDGET)) { memcpy(GTK_VALUE_POINTER(params[0]), get_grequisition(rb_ary_pop(args)), sizeof(GtkRequisition)); return;