/* Copyright (C) 1999 Southern Gold Development * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "gview.h" gint matchTimer(gpointer data) { sgview *view; view = (sgview *) data; gtk_timeout_remove(view->matchTimer); view->matchTimer = 0; view->matchDepth = 0; return 0; } void doMatchFile(sgview *view, guint keyval) { gint cnt, pos, res; gchar *elem; if (view->matchTimer != 0) { gtk_timeout_remove(view->matchTimer); view->matchTimer = 0; } if (keyval == GDK_BackSpace) { if (view->matchDepth > 0) { view->matchDepth--; view->matchPath[view->matchDepth] = 0; } } else { if (view->matchDepth < 63) { view->matchPath[view->matchDepth] = (gchar) keyval; view->matchDepth++; view->matchPath[view->matchDepth] = 0; } } pos = -1; for (cnt = 0; cnt < GTK_CLIST (view->clist)->rows; cnt++) { res = gtk_clist_get_text(GTK_CLIST (view->clist), cnt, 0, &elem); if (res == 1) { if (strncmp(view->matchPath, elem, view->matchDepth) == 0) { pos = cnt; break; } } } if (pos != -1) { gtk_clist_freeze(GTK_CLIST (view->clist)); gtk_clist_unselect_row(GTK_CLIST (view->clist), GTK_CLIST (view->clist)->focus_row, 0); GTK_CLIST (view->clist)->focus_row = pos; gtk_clist_moveto(GTK_CLIST (view->clist), pos, 0, 0.5, 0.5); gtk_clist_select_row(GTK_CLIST (view->clist), pos, 0); gtk_clist_thaw(GTK_CLIST (view->clist)); } view->matchTimer = gtk_timeout_add(1500, (GtkFunction) matchTimer, (gpointer) view); }