+
+gchar *
+modest_text_utils_create_colored_signature (const gchar *signature)
+{
+ gchar *gray_color_markup = NULL, *retval;
+ GdkColor color;
+ GtkWidget *widget;
+
+ /* Get color from widgets */
+ widget = (GtkWidget *) modest_window_mgr_get_current_top (modest_runtime_get_window_mgr ());
+ if (widget && gtk_style_lookup_color (gtk_widget_get_style (widget), "SecondaryTextColor", &color))
+ gray_color_markup = modest_text_utils_get_color_string (&color);
+
+ retval = g_strdup_printf ("<br/>\n<font color=\"%s\">%s<br/>\n%s<br/>\n</font>",
+ (gray_color_markup) ? gray_color_markup : "#babababababa",
+ MODEST_TEXT_UTILS_SIGNATURE_MARKER,
+ signature);
+
+ if (gray_color_markup)
+ g_free (gray_color_markup);
+
+ return retval;
+}
+
+gboolean
+modest_text_utils_live_search_find (const gchar *haystack, const gchar *needles)
+{
+ gchar *haystack_fold;
+ gchar *needles_fold;
+ gchar **needle, **current;
+ gboolean match;
+
+ match = FALSE;
+
+ haystack_fold = g_utf8_casefold (haystack, -1);
+ needles_fold = g_utf8_casefold (needles, -1);
+
+ needle = g_strsplit (needles_fold, " ", -1);
+
+ current = needle;
+ while (current && *current != NULL) {
+
+ if (g_strstr_len (haystack_fold, -1, *current) != NULL) {
+ match = TRUE;
+ } else {
+ match = FALSE;
+ break;
+ }
+ current++;
+ }
+
+ g_strfreev (needle);
+ g_free (needles_fold);
+ g_free (haystack_fold);
+
+ return match;
+}