if (event->keyval == GDK_Left || event->keyval == GDK_KP_Left) { gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "key_press_event"); gtk_tree_item_collapse(GTK_TREE_ITEM(widget)); return TRUE; } if (event->keyval == GDK_Right || event->keyval == GDK_KP_Right) { gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "key_press_event"); gtk_tree_item_expand(GTK_TREE_ITEM(widget)); return TRUE; }
int tree_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data){    struct dlgparam *dp = (struct dlgparam *)data;    if (event->keyval == GDK_Up || event->keyval == GDK_KP_Up ||        event->keyval == GDK_Down || event->keyval == GDK_KP_Down) {        int i, j = -1;        for (i = 0; i < dp->ntreeitems; i++)            if (widget == dp->treeitems[i]) {                if (event->keyval == GDK_Up || event->keyval == GDK_KP_Up) {                    if (i > 0)                        j = i-1;                } else {                    if (i < dp->ntreeitems-1)                        j = i+1;                }                break;            }        gtk_signal_emit_stop_by_name(GTK_OBJECT(widget),                                     "key_press_event");        if (j >= 0) {            gint return_val;            gtk_signal_emit_by_name(GTK_OBJECT(dp->treeitems[j]), "toggle");            gtk_widget_grab_focus(dp->treeitems[j]);        }        return TRUE;    }    return FALSE;}