shell: Don't change casedness when displaying matches

While we do want to match case-insensitively, we don't want to
display the search result in all-lowercase. This patch is probably
not quite utf8-ly correct.

http://bugzilla.gnome.org/show_bug.cgi?id=634923
This commit is contained in:
Matthias Clasen 2010-11-15 12:43:54 -05:00
parent 24b5fb73c1
commit b85950d807

View file

@ -159,27 +159,31 @@ shell_search_renderer_set_layout (ShellSearchRenderer *cell, GtkWidget *widget)
{ {
gchar *start; gchar *start;
gchar *lead, *trail, *leaddot; gchar *lead, *trail, *leaddot;
gchar *match;
gint count; gint count;
#define CONTEXT 10 #define CONTEXT 10
count = strlen (needle); count = strlen (needle);
start = strstr (haystack, needle); start = full_string + (strstr (haystack, needle) - haystack);
lead = MAX (start - CONTEXT, haystack); lead = MAX (start - CONTEXT, full_string);
trail = start + count; trail = start + count;
if (lead == haystack) if (lead == full_string)
leaddot = ""; leaddot = "";
else else
leaddot = "..."; leaddot = "...";
match = g_strndup (start, count);
lead = g_strndup (lead, start - lead); lead = g_strndup (lead, start - lead);
display_string = g_markup_printf_escaped ("%s\n" display_string = g_markup_printf_escaped ("%s\n"
"<small>%s%s<b>%s</b>%s</small>", "<small>%s%s<b>%s</b>%s</small>",
priv->title, leaddot, lead, priv->title, leaddot, lead,
needle, trail); match, trail);
g_free (match);
g_free (lead); g_free (lead);
} }
else else