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; }
if (widget == dp->treeitems[i]) break; if (i < dp->ntreeitems) { if (event->keyval == GDK_Up || event->keyval == GDK_KP_Up) dir = -1; else dir = +1;  while (1) { i += dir; if (i < 0 || i >= dp->ntreeitems) break;	         { GtkWidget *w = dp->treeitems[i]; int vis = TRUE; while (w && GTK_IS_TREE_ITEM(w) || GTK_IS_TREE(w)) { if (!GTK_WIDGET_VISIBLE(w)) { vis = FALSE; break; } w = w->parent; } if (vis) { j = i;	        break; } } } }
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;}