]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-chat-text-view.c
Updated Polish translation
[empathy.git] / libempathy-gtk / empathy-chat-text-view.c
index 4f38865f61d92f438a1e84d778a822cf5eface9d..7f16ab9a325a9f4e5693d9e96bf4a0daf5ca0fd0 100644 (file)
@@ -42,6 +42,7 @@
 #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>
@@ -838,7 +839,8 @@ chat_text_view_clear (EmpathyChatView *view)
 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;
@@ -880,7 +882,7 @@ chat_text_view_find_previous (EmpathyChatView *view,
                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);
@@ -891,11 +893,23 @@ chat_text_view_find_previous (EmpathyChatView *view,
 
        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;
@@ -909,7 +923,8 @@ chat_text_view_find_previous (EmpathyChatView *view,
                        priv->find_wrapped = TRUE;
                        result = chat_text_view_find_previous (view,
                                                                 search_criteria,
-                                                                FALSE);
+                                                                FALSE,
+                                                                match_case);
                        priv->find_wrapped = FALSE;
                }
 
@@ -953,7 +968,8 @@ chat_text_view_find_previous (EmpathyChatView *view,
 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;
@@ -995,7 +1011,7 @@ chat_text_view_find_next (EmpathyChatView *view,
                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);
@@ -1006,11 +1022,23 @@ chat_text_view_find_next (EmpathyChatView *view,
 
        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;
@@ -1024,7 +1052,8 @@ chat_text_view_find_next (EmpathyChatView *view,
                        priv->find_wrapped = TRUE;
                        result = chat_text_view_find_next (view,
                                                             search_criteria,
-                                                            FALSE);
+                                                            FALSE,
+                                                            match_case);
                        priv->find_wrapped = FALSE;
                }
 
@@ -1068,6 +1097,7 @@ chat_text_view_find_next (EmpathyChatView *view,
 static void
 chat_text_view_find_abilities (EmpathyChatView *view,
                                 const gchar    *search_criteria,
+                                gboolean        match_case,
                                 gboolean       *can_do_previous,
                                 gboolean       *can_do_next)
 {
@@ -1094,11 +1124,20 @@ chat_text_view_find_abilities (EmpathyChatView *view,
                        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) {
@@ -1110,17 +1149,27 @@ chat_text_view_find_abilities (EmpathyChatView *view,
                        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;
@@ -1146,12 +1195,20 @@ chat_text_view_highlight (EmpathyChatView *view,
        }
 
        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;
                }
@@ -1161,7 +1218,6 @@ chat_text_view_highlight (EmpathyChatView *view,
                                                   &iter_match_end);
 
                iter = iter_match_end;
-               gtk_text_iter_forward_char (&iter);
        }
 }