[empathy] add match_case option to find_abilities



commit ba2326210afd63d1ae622c57b76b3b1f56ab4e9e
Author: Thomas Meire <blackskad gmail com>
Date:   Tue Jan 19 17:25:36 2010 +0100

    add match_case option to find_abilities

 libempathy-gtk/empathy-chat-text-view.c |   49 +++++++++++++++++++++---------
 libempathy-gtk/empathy-chat-view.c      |    2 +
 libempathy-gtk/empathy-chat-view.h      |    2 +
 libempathy-gtk/empathy-log-window.c     |    3 ++
 libempathy-gtk/empathy-search-bar.c     |   11 ++++--
 libempathy-gtk/empathy-theme-adium.c    |    1 +
 6 files changed, 49 insertions(+), 19 deletions(-)
---
diff --git a/libempathy-gtk/empathy-chat-text-view.c b/libempathy-gtk/empathy-chat-text-view.c
index ea8b193..07f8f6c 100644
--- a/libempathy-gtk/empathy-chat-text-view.c
+++ b/libempathy-gtk/empathy-chat-text-view.c
@@ -1096,6 +1096,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)
 {
@@ -1122,11 +1123,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) {
@@ -1138,11 +1148,20 @@ 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);
+		}
 	}
 }
 
@@ -1177,11 +1196,11 @@ chat_text_view_highlight (EmpathyChatView *view,
 	while (1) {
 		if (match_case) {
 			found = gtk_text_iter_forward_search (&iter,
-								  text,
-								  0,
-								  &iter_match_start,
-								  &iter_match_end,
-								  NULL);
+							      text,
+							      0,
+							      &iter_match_start,
+							      &iter_match_end,
+							      NULL);
 		} else {
 			found = empathy_text_iter_forward_search (&iter,
 								  text,
diff --git a/libempathy-gtk/empathy-chat-view.c b/libempathy-gtk/empathy-chat-view.c
index e688396..ada6698 100644
--- a/libempathy-gtk/empathy-chat-view.c
+++ b/libempathy-gtk/empathy-chat-view.c
@@ -164,6 +164,7 @@ empathy_chat_view_find_next (EmpathyChatView *view,
 void
 empathy_chat_view_find_abilities (EmpathyChatView *view,
 				  const gchar    *search_criteria,
+				  gboolean        match_case,
 				  gboolean       *can_do_previous,
 				  gboolean       *can_do_next)
 {
@@ -172,6 +173,7 @@ empathy_chat_view_find_abilities (EmpathyChatView *view,
 	if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_abilities) {
 		EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_abilities (view,
 									 search_criteria,
+									 match_case,
 									 can_do_previous,
 									 can_do_next);
 	}
diff --git a/libempathy-gtk/empathy-chat-view.h b/libempathy-gtk/empathy-chat-view.h
index 11010c4..96365a6 100644
--- a/libempathy-gtk/empathy-chat-view.h
+++ b/libempathy-gtk/empathy-chat-view.h
@@ -61,6 +61,7 @@ struct _EmpathyChatViewIface {
 						  gboolean         match_case);
 	void             (*find_abilities)       (EmpathyChatView *view,
 						  const gchar     *search_criteria,
+						  gboolean         match_case,
 						  gboolean        *can_do_previous,
 						  gboolean        *can_do_next);
 	void             (*highlight)            (EmpathyChatView *view,
@@ -89,6 +90,7 @@ gboolean         empathy_chat_view_find_next            (EmpathyChatView *view,
 							 gboolean         match_case);
 void             empathy_chat_view_find_abilities       (EmpathyChatView *view,
 							 const gchar     *search_criteria,
+							 gboolean         match_case,
 							 gboolean        *can_do_previous,
 							 gboolean        *can_do_next);
 void             empathy_chat_view_highlight            (EmpathyChatView *view,
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c
index dba8877..f12abf3 100644
--- a/libempathy-gtk/empathy-log-window.c
+++ b/libempathy-gtk/empathy-log-window.c
@@ -414,6 +414,7 @@ log_window_find_changed_cb (GtkTreeSelection *selection,
 				    FALSE);
 	empathy_chat_view_find_abilities (window->chatview_find,
 					 window->last_find,
+					 FALSE,
 					 &can_do_previous,
 					 &can_do_next);
 	gtk_widget_set_sensitive (window->button_previous, can_do_previous);
@@ -610,6 +611,7 @@ log_window_button_next_clicked_cb (GtkWidget       *widget,
 					    FALSE);
 		empathy_chat_view_find_abilities (window->chatview_find,
 						 window->last_find,
+						 FALSE,
 						 &can_do_previous,
 						 &can_do_next);
 		gtk_widget_set_sensitive (window->button_previous, can_do_previous);
@@ -631,6 +633,7 @@ log_window_button_previous_clicked_cb (GtkWidget       *widget,
 						FALSE);
 		empathy_chat_view_find_abilities (window->chatview_find,
 						 window->last_find,
+						 FALSE,
 						 &can_do_previous,
 						 &can_do_next);
 		gtk_widget_set_sensitive (window->button_previous, can_do_previous);
diff --git a/libempathy-gtk/empathy-search-bar.c b/libempathy-gtk/empathy-search-bar.c
index dfd680c..8726333 100644
--- a/libempathy-gtk/empathy-search-bar.c
+++ b/libempathy-gtk/empathy-search-bar.c
@@ -103,7 +103,8 @@ empathy_search_bar_size_allocate (GtkWidget *widget,
 
 static void
 empathy_search_bar_update_buttons (EmpathySearchBar *self,
-    gchar *search)
+    gchar *search,
+    gboolean match_case)
 {
   gboolean can_go_forward = FALSE;
   gboolean can_go_backward = FALSE;
@@ -111,7 +112,7 @@ empathy_search_bar_update_buttons (EmpathySearchBar *self,
   EmpathySearchBarPriv* priv = GET_PRIV (self);
 
   /* update previous / next buttons */
-  empathy_chat_view_find_abilities (priv->chat_view, search,
+  empathy_chat_view_find_abilities (priv->chat_view, search, match_case,
       &can_go_backward, &can_go_forward);
 
   gtk_widget_set_sensitive (priv->search_previous,
@@ -124,11 +125,13 @@ void
 empathy_search_bar_show (EmpathySearchBar *self)
 {
   gchar *search;
+  gboolean match_case;
   EmpathySearchBarPriv *priv = GET_PRIV (self);
 
   search = gtk_editable_get_chars (GTK_EDITABLE (priv->search_entry), 0, -1);
+  match_case = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->search_match_case));
   empathy_chat_view_highlight (priv->chat_view, search, TRUE);
-  empathy_search_bar_update_buttons (self, search);
+  empathy_search_bar_update_buttons (self, search, match_case);
 
   /* grab the focus to the search entry */
   gtk_widget_grab_focus (priv->search_entry);
@@ -188,7 +191,7 @@ empathy_search_bar_search (EmpathySearchBar *self,
       !(found || EMP_STR_EMPTY (search)));
 
   /* update the buttons */
-  empathy_search_bar_update_buttons (self, search);
+  empathy_search_bar_update_buttons (self, search, match_case);
 
   g_free (search);
 }
diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c
index f57fe95..62734ff 100644
--- a/libempathy-gtk/empathy-theme-adium.c
+++ b/libempathy-gtk/empathy-theme-adium.c
@@ -730,6 +730,7 @@ theme_adium_find_next (EmpathyChatView *view,
 static void
 theme_adium_find_abilities (EmpathyChatView *view,
 			    const gchar    *search_criteria,
+                            gboolean        match_case,
 			    gboolean       *can_do_previous,
 			    gboolean       *can_do_next)
 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]