[gq-commit] gq/src search.c,1.47,1.48
Status: Beta
Brought to you by:
sur5r
From: <bi...@us...> - 2003-10-13 22:19:18
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv24583/src Modified Files: search.c Log Message: if a searchterm already exists in search history, move it up start with a blank search entry box, not the last query Index: search.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/search.c,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** search.c 12 Oct 2003 06:14:18 -0000 1.47 --- search.c 13 Oct 2003 22:18:31 -0000 1.48 *************** *** 70,87 **** static void search_restore_snapshot(char *state_name, struct tab *tab) { if (config->restore_search_history) { const GList *hist = state_value_get_list(state_name, "history"); if (hist) { const GList *I; for (I = hist ; I ; I = g_list_next(I)) { ! SEARCHTAB(tab)->history = ! g_list_append(SEARCHTAB(tab)->history, ! g_strdup(I->data)); } ! gtk_combo_set_popdown_strings(GTK_COMBO(SEARCHTAB(tab)->search_combo), ! SEARCHTAB(tab)->history); ! } } } --- 70,91 ---- static void search_restore_snapshot(char *state_name, struct tab *tab) { + GList *searchhist; + if (config->restore_search_history) { const GList *hist = state_value_get_list(state_name, "history"); if (hist) { const GList *I; + + searchhist = SEARCHTAB(tab)->history; for (I = hist ; I ; I = g_list_next(I)) { ! searchhist = g_list_append(searchhist, g_strdup(I->data)); } ! searchhist = g_list_insert(searchhist, "", 0); ! gtk_combo_set_popdown_strings(GTK_COMBO(SEARCHTAB(tab)->search_combo), searchhist); ! searchhist = g_list_remove(searchhist, searchhist->data); ! SEARCHTAB(tab)->history = searchhist; } } + } *************** *** 440,444 **** { gchar *searchterm; ! GList *list, *last; list = SEARCHTAB(tab)->history; --- 444,448 ---- { gchar *searchterm; ! GList *list, *last, *item; list = SEARCHTAB(tab)->history; *************** *** 448,451 **** --- 452,462 ---- } else { + /* if this searchterm is already in history, delete it first */ + item = g_list_find_custom(list, searchterm, (GCompareFunc) strcasecmp); + if(item) { + g_free(item->data); + list = g_list_remove(list, item->data); + } + list = g_list_insert(list, searchterm, 0); if(g_list_length(list) > MAX_SEARCH_HISTORY_LENGTH) { |