comparison gtk/gtkimhtml.c @ 14338:2ec879353592

[gaim-migrate @ 17035] Fixes SF Bug # 1373116 (and related Debian Bug #341607) Fix the Find functionality in the log viewer. It now properly scrolls to the first occurrence of the search term. Also, clicking the Find button will now jump to the next occurrence of the search term, including wrapping around to the top. Possible Badness: This changes the behavior of all IMHTML searches. Previously, if you kept calling gtk_imhtml_search_find(), it'd clear the highlighting when you went past the last occurrence of the search term. This seems wrong. I believe it should either stop or wrap around to the top. Wrapping around seemed most useful to me, so that's what I implemented. This was inspired by SF Patch #1545488 by Mark Schneider committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sat, 26 Aug 2006 06:25:49 +0000
parents cf8d25072151
children 737a6c286a65
comparison
equal deleted inserted replaced
14337:1a500db56415 14338:2ec879353592
3540 } 3540 }
3541 g_free(imhtml->search_string); 3541 g_free(imhtml->search_string);
3542 imhtml->search_string = g_strdup(text); 3542 imhtml->search_string = g_strdup(text);
3543 3543
3544 if (gtk_source_iter_forward_search(&iter, imhtml->search_string, 3544 if (gtk_source_iter_forward_search(&iter, imhtml->search_string,
3545 GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, 3545 GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE,
3546 &start, &end, NULL)) { 3546 &start, &end, NULL))
3547 3547 {
3548 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0); 3548 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0);
3549 gtk_text_buffer_create_mark(imhtml->text_buffer, "search", &end, FALSE); 3549 gtk_text_buffer_create_mark(imhtml->text_buffer, "search", &end, FALSE);
3550 if (new_search) { 3550 if (new_search)
3551 {
3551 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &iter, &end); 3552 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &iter, &end);
3552 do 3553 do
3553 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "search", &start, &end); 3554 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "search", &start, &end);
3554 while (gtk_source_iter_forward_search(&end, imhtml->search_string, 3555 while (gtk_source_iter_forward_search(&end, imhtml->search_string,
3555 GTK_SOURCE_SEARCH_VISIBLE_ONLY | 3556 GTK_SOURCE_SEARCH_VISIBLE_ONLY |
3556 GTK_SOURCE_SEARCH_CASE_INSENSITIVE, 3557 GTK_SOURCE_SEARCH_CASE_INSENSITIVE,
3557 &start, &end, NULL)); 3558 &start, &end, NULL));
3558 } 3559 }
3559 return TRUE; 3560 return TRUE;
3560 } 3561 }
3561 3562 else if (!new_search)
3562 gtk_imhtml_search_clear(imhtml); 3563 {
3564 /* We hit the end, so start at the beginning again. */
3565 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &iter);
3566
3567 if (gtk_source_iter_forward_search(&iter, imhtml->search_string,
3568 GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE,
3569 &start, &end, NULL))
3570 {
3571 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0);
3572 gtk_text_buffer_create_mark(imhtml->text_buffer, "search", &end, FALSE);
3573
3574 return TRUE;
3575 }
3576
3577 }
3563 3578
3564 return FALSE; 3579 return FALSE;
3565 } 3580 }
3566 3581
3567 void gtk_imhtml_search_clear(GtkIMHtml *imhtml) 3582 void gtk_imhtml_search_clear(GtkIMHtml *imhtml)