is_active = gtk_toggle_action_get_active (toggle);
- /* Show a warning if there is nothing to search: */
- if (is_active && priv->msg_view &&
- modest_msg_view_get_message_is_empty (MODEST_MSG_VIEW (priv->msg_view))) {
- hildon_banner_show_information (GTK_WIDGET (window), NULL, _("mail_ib_nothing_to_find"));
- return;
- }
-
if (is_active) {
gtk_widget_show (priv->find_toolbar);
hildon_find_toolbar_highlight_entry (HILDON_FIND_TOOLBAR (priv->find_toolbar), TRUE);
gchar *current_search;
ModestMsgViewWindowPrivate *priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (obj);
+ if (modest_msg_view_get_message_is_empty (MODEST_MSG_VIEW (priv->msg_view))) {
+ hildon_banner_show_information (NULL, NULL, _("mail_ib_nothing_to_find"));
+ return;
+ }
+
g_object_get (G_OBJECT (widget), "prefix", ¤t_search, NULL);
if ((current_search == NULL) || (strcmp (current_search, "") == 0)) {
priv->headers_window = NULL;
priv->html_window = NULL;
-
gtk_widget_push_composite_child ();
priv->html_scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_composite_name (priv->html_scroll, "contents");
gtk_html_load_from_string (GTK_HTML(priv->gtkhtml),
"", 1);
+
return TRUE;
}
return msg;
}
+static gboolean
+has_contents_receiver (gpointer engine, const gchar *data,
+ size_t len, gboolean *has_contents)
+{
+ if (len > 1 || ((len == 1)&&(data[0]!='\n'))) {
+ *has_contents = TRUE;
+ return FALSE;
+ }
+ return TRUE;
+}
+
gboolean
modest_msg_view_get_message_is_empty (ModestMsgView *self)
{
/* TODO: Find some gtkhtml API to check whether there is any (visible, non markup)
* text in the message:
*/
+ ModestMsgViewPrivate *priv = MODEST_MSG_VIEW_GET_PRIVATE (self);
+ gboolean has_contents = FALSE;
+
+ gtk_html_export (GTK_HTML (priv->gtkhtml), "text/plain",
+ (GtkHTMLSaveReceiverFn) has_contents_receiver, &has_contents);
- return FALSE;
+ return !has_contents;
}