#include "empathy-conf.h"
#include "empathy-ui-utils.h"
#include "empathy-smiley-manager.h"
+#include "empathy-string-parser.h"
#define DEBUG_FLAG EMPATHY_DEBUG_CHAT
#include <libempathy/empathy-debug.h>
static gboolean
chat_text_view_find_previous (EmpathyChatView *view,
const gchar *search_criteria,
- gboolean new_search)
+ gboolean new_search,
+ gboolean match_case)
{
EmpathyChatTextViewPriv *priv;
GtkTextBuffer *buffer;
from_start = TRUE;
}
- if (priv->find_mark_previous) {
+ if (!new_search && priv->find_mark_previous) {
gtk_text_buffer_get_iter_at_mark (buffer,
&iter_at_mark,
priv->find_mark_previous);
priv->find_last_direction = FALSE;
- found = empathy_text_iter_backward_search (&iter_at_mark,
- search_criteria,
- &iter_match_start,
- &iter_match_end,
- NULL);
+ /* Use the standard GTK+ method for case sensitive searches. It can't do
+ * case insensitive searches (see bug #61852), so keep the custom method
+ * around for case insensitive searches. */
+ if (match_case) {
+ found = gtk_text_iter_backward_search (&iter_at_mark,
+ search_criteria,
+ 0, /* no text search flags, we want exact matches */
+ &iter_match_start,
+ &iter_match_end,
+ NULL);
+ } else {
+ found = empathy_text_iter_backward_search (&iter_at_mark,
+ search_criteria,
+ &iter_match_start,
+ &iter_match_end,
+ NULL);
+ }
if (!found) {
gboolean result = FALSE;
priv->find_wrapped = TRUE;
result = chat_text_view_find_previous (view,
search_criteria,
- FALSE);
+ FALSE,
+ match_case);
priv->find_wrapped = FALSE;
}
static gboolean
chat_text_view_find_next (EmpathyChatView *view,
const gchar *search_criteria,
- gboolean new_search)
+ gboolean new_search,
+ gboolean match_case)
{
EmpathyChatTextViewPriv *priv;
GtkTextBuffer *buffer;
from_start = TRUE;
}
- if (priv->find_mark_next) {
+ if (!new_search && priv->find_mark_next) {
gtk_text_buffer_get_iter_at_mark (buffer,
&iter_at_mark,
priv->find_mark_next);
priv->find_last_direction = TRUE;
- found = empathy_text_iter_forward_search (&iter_at_mark,
- search_criteria,
- &iter_match_start,
- &iter_match_end,
- NULL);
+ /* Use the standard GTK+ method for case sensitive searches. It can't do
+ * case insensitive searches (see bug #61852), so keep the custom method
+ * around for case insensitive searches. */
+ if (match_case) {
+ found = gtk_text_iter_forward_search (&iter_at_mark,
+ search_criteria,
+ 0,
+ &iter_match_start,
+ &iter_match_end,
+ NULL);
+ } else {
+ found = empathy_text_iter_forward_search (&iter_at_mark,
+ search_criteria,
+ &iter_match_start,
+ &iter_match_end,
+ NULL);
+ }
if (!found) {
gboolean result = FALSE;
priv->find_wrapped = TRUE;
result = chat_text_view_find_next (view,
search_criteria,
- FALSE);
+ FALSE,
+ match_case);
priv->find_wrapped = FALSE;
}
static void
chat_text_view_find_abilities (EmpathyChatView *view,
const gchar *search_criteria,
+ gboolean match_case,
gboolean *can_do_previous,
gboolean *can_do_next)
{
gtk_text_buffer_get_start_iter (buffer, &iter_at_mark);
}
- *can_do_previous = empathy_text_iter_backward_search (&iter_at_mark,
- search_criteria,
- &iter_match_start,
- &iter_match_end,
- NULL);
+ if (match_case) {
+ *can_do_previous = gtk_text_iter_backward_search (&iter_at_mark,
+ search_criteria,
+ 0,
+ &iter_match_start,
+ &iter_match_end,
+ NULL);
+ } else {
+ *can_do_previous = empathy_text_iter_backward_search (&iter_at_mark,
+ search_criteria,
+ &iter_match_start,
+ &iter_match_end,
+ NULL);
+ }
}
if (can_do_next) {
gtk_text_buffer_get_start_iter (buffer, &iter_at_mark);
}
- *can_do_next = empathy_text_iter_forward_search (&iter_at_mark,
- search_criteria,
- &iter_match_start,
- &iter_match_end,
- NULL);
+ if (match_case) {
+ *can_do_next = gtk_text_iter_forward_search (&iter_at_mark,
+ search_criteria,
+ 0,
+ &iter_match_start,
+ &iter_match_end,
+ NULL);
+ } else {
+ *can_do_next = empathy_text_iter_forward_search (&iter_at_mark,
+ search_criteria,
+ &iter_match_start,
+ &iter_match_end,
+ NULL);
+ }
}
}
static void
chat_text_view_highlight (EmpathyChatView *view,
- const gchar *text)
+ const gchar *text,
+ gboolean match_case)
{
GtkTextBuffer *buffer;
GtkTextIter iter;
}
while (1) {
- found = empathy_text_iter_forward_search (&iter,
- text,
- &iter_match_start,
- &iter_match_end,
- NULL);
-
+ if (match_case) {
+ found = gtk_text_iter_forward_search (&iter,
+ text,
+ 0,
+ &iter_match_start,
+ &iter_match_end,
+ NULL);
+ } else {
+ found = empathy_text_iter_forward_search (&iter,
+ text,
+ &iter_match_start,
+ &iter_match_end,
+ NULL);
+ }
if (!found) {
break;
}
&iter_match_end);
iter = iter_match_end;
- gtk_text_iter_forward_char (&iter);
}
}