[Xfce4-commits] <midori:master> Do smart case for inline search while typing

Christian Dywan noreply at xfce.org
Wed Sep 8 01:36:03 CEST 2010


Updating branch refs/heads/master
         to d8b4eaa566f6d70ca73013f0a8691d2da69c0c03 (commit)
       from 1856912fd1278682376dca90a06c602247105069 (commit)

commit d8b4eaa566f6d70ca73013f0a8691d2da69c0c03
Author: Christian Dywan <christian at twotoasts.de>
Date:   Tue Sep 7 21:30:45 2010 +0200

    Do smart case for inline search while typing

 toolbars/midori-findbar.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/toolbars/midori-findbar.c b/toolbars/midori-findbar.c
index fa72a3a..5b7ca9d 100644
--- a/toolbars/midori-findbar.c
+++ b/toolbars/midori-findbar.c
@@ -83,6 +83,19 @@ midori_findbar_entry_clear_icon_released_cb (GtkIconEntry* entry,
         gtk_entry_set_text (GTK_ENTRY (entry), "");
 }
 
+static gboolean
+midori_findbar_case_sensitive (MidoriFindbar* findbar)
+{
+    /* Smart case while typing: foo or fOO lowercase, Foo or FOO uppercase */
+    if (findbar->find_typing)
+    {
+        const gchar* text = gtk_entry_get_text (GTK_ENTRY (findbar->find_text));
+        return g_unichar_isupper (g_utf8_get_char (text));
+    }
+    return gtk_toggle_tool_button_get_active (
+        GTK_TOGGLE_TOOL_BUTTON (findbar->find_case));
+}
+
 void
 midori_findbar_find (MidoriFindbar* findbar,
                      gboolean       forward)
@@ -96,8 +109,7 @@ midori_findbar_find (MidoriFindbar* findbar,
         return;
 
     text = gtk_entry_get_text (GTK_ENTRY (findbar->find_text));
-    case_sensitive = gtk_toggle_tool_button_get_active (
-        GTK_TOGGLE_TOOL_BUTTON (findbar->find_case));
+    case_sensitive = midori_findbar_case_sensitive (findbar);
     midori_view_search_text (MIDORI_VIEW (view), text, case_sensitive, forward);
 }
 
@@ -315,8 +327,7 @@ midori_findbar_search_text (MidoriFindbar* findbar,
             GTK_ICON_ENTRY_PRIMARY, (found) ? GTK_STOCK_FIND : GTK_STOCK_STOP);
         #endif
         text = gtk_entry_get_text (GTK_ENTRY (findbar->find_text));
-        case_sensitive = gtk_toggle_tool_button_get_active (
-            GTK_TOGGLE_TOOL_BUTTON (findbar->find_case));
+        case_sensitive = midori_findbar_case_sensitive (findbar);
         midori_view_mark_text_matches (MIDORI_VIEW (view), text, case_sensitive);
         highlight = gtk_toggle_tool_button_get_active (
             GTK_TOGGLE_TOOL_BUTTON (findbar->find_highlight));



More information about the Xfce4-commits mailing list