From 3fedab2025de543912778567251b06b9dfe48a6e Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Thu, 19 Jul 2007 16:39:42 +0000 Subject: [PATCH] * src/widgets/modest-msg-view.c: * Added implementation of get_message_is_empty method. It uses gtk_html_export method to know if the buffer has any text representation and this is empty or not. * src/maemo/modest-msg-view-window.c: * Removed check for empty buffer to show "nothing to find" banner on toggling the toolbar. This should be shown on trying to search in the toolbar, not on trying to show the toolbar. * Added the nothing to find banner on searching empty buffers, using the new implementation. This is a partial fix to NB#62350. pmo-trunk-r2756 --- src/maemo/modest-msg-view-window.c | 12 +++++------- src/widgets/modest-msg-view.c | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/maemo/modest-msg-view-window.c b/src/maemo/modest-msg-view-window.c index b4152d2..e2668ae 100644 --- a/src/maemo/modest-msg-view-window.c +++ b/src/maemo/modest-msg-view-window.c @@ -789,13 +789,6 @@ modest_msg_view_window_toggle_find_toolbar (GtkToggleAction *toggle, 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); @@ -830,6 +823,11 @@ modest_msg_view_window_find_toolbar_search (GtkWidget *widget, 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)) { diff --git a/src/widgets/modest-msg-view.c b/src/widgets/modest-msg-view.c index d2116ef..373f75b 100644 --- a/src/widgets/modest-msg-view.c +++ b/src/widgets/modest-msg-view.c @@ -869,7 +869,6 @@ modest_msg_view_init (ModestMsgView *obj) 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"); @@ -1323,6 +1322,7 @@ set_empty_message (ModestMsgView *self) gtk_html_load_from_string (GTK_HTML(priv->gtkhtml), "", 1); + return TRUE; } @@ -1422,14 +1422,30 @@ modest_msg_view_get_message (ModestMsgView *self) 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; } -- 1.7.9.5