aboutsummaryrefslogtreecommitdiff
path: root/src/gtkutils.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-02-04 08:35:17 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-02-04 08:35:17 +0000
commit6e3390d6104c8de11448741242641d1bcb0a85f5 (patch)
tree26f9724bda324dd17c563afc4df8e1c9e0a0ff2c /src/gtkutils.c
parentf5a3ca3e0ac9785f556ce22fea4f78dd9ab3c7fc (diff)
reimplemented message text search.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@90 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/gtkutils.c')
-rw-r--r--src/gtkutils.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/gtkutils.c b/src/gtkutils.c
index 25fe87c7..81d07b61 100644
--- a/src/gtkutils.c
+++ b/src/gtkutils.c
@@ -530,7 +530,7 @@ gboolean gtkut_text_buffer_match_string(GtkTextBuffer *textbuf, gint pos,
return FALSE;
}
- for (; match_count < len; pos++, match_count++) {
+ for (; match_count < len; match_count++) {
gchar *ptr;
gunichar ch;
@@ -628,6 +628,39 @@ guint gtkut_text_buffer_str_compare(GtkTextBuffer *textbuf,
return result ? len : 0;
}
+gint gtkut_text_buffer_find(GtkTextBuffer *buffer, guint start_pos,
+ const gchar *str, gboolean case_sens)
+{
+ gint pos;
+ gunichar *wcs;
+ gint len;
+ glong items_read = 0, items_written = 0;
+ GError *error = NULL;
+ GtkTextIter iter;
+ gint found_pos = -1;
+
+ wcs = g_utf8_to_ucs4(str, -1, &items_read, &items_written, &error);
+ if (error != NULL) {
+ g_warning("An error occured while converting a string from UTF-8 to UCS-4: %s\n", error->message);
+ g_error_free(error);
+ }
+ if (!wcs || items_written <= 0) return -1;
+ len = (gint)items_written;
+
+ gtk_text_buffer_get_iter_at_offset(buffer, &iter, start_pos);
+ do {
+ pos = gtk_text_iter_get_offset(&iter);
+ if (gtkut_text_buffer_match_string
+ (buffer, pos, wcs, len, case_sens) == TRUE) {
+ found_pos = pos;
+ break;
+ }
+ } while (gtk_text_iter_forward_char(&iter));
+
+ g_free(wcs);
+ return found_pos;
+}
+
gboolean gtkut_text_buffer_is_uri_string(GtkTextBuffer *textbuf,
guint start_pos, guint text_len)
{