+
+/* Returns TRUE if there is no recipients in the text buffer. Note
+ that strings like " ; , " contain only separators and thus no
+ recipients */
+gboolean
+modest_text_utils_no_recipient (GtkTextBuffer *buffer)
+{
+ gboolean retval = TRUE;
+ gchar *text, *tmp;
+ GtkTextIter start, end;
+
+ if (gtk_text_buffer_get_char_count (buffer) == 0)
+ return TRUE;
+
+ gtk_text_buffer_get_start_iter (buffer, &start);
+ gtk_text_buffer_get_end_iter (buffer, &end);
+
+ text = g_strstrip (gtk_text_buffer_get_text (buffer, &start, &end, FALSE));
+ if (!g_strcmp0 (text, ""))
+ return TRUE;
+
+ tmp = text;
+ while (tmp && *tmp != '\0') {
+ if ((*tmp != ',') && (*tmp != ';') &&
+ (*tmp != '\r') && (*tmp != '\n') &&
+ (*tmp != ' ')) {
+ retval = FALSE;
+ break;
+ } else {
+ tmp++;
+ }
+ }
+ g_free (text);
+
+ return retval;
+}
+
+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;
+}