From: Murray Cumming Date: Mon, 16 Jul 2007 12:15:00 +0000 (+0000) Subject: 2007-07-16 Murray Cumming X-Git-Tag: git_migration_finished~2798 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=5b351ebf88b0a4ddc64b6521f8b84c89a8ad36b3 2007-07-16 Murray Cumming * src/widgets/modest-msg-view.h: * src/widgets/modest-msg-view.c: Added modest_msg_view_get_message_is_empty() but this needs to be implemented. * src/maemo/modest-msg-edit-window.c: (message_is_empty): Check if there is any text in the message yet. But this needs to be implemented properly. (modest_msg_edit_window_toggle_find_toolbar): * src/maemo/modest-msg-view-window.c: (modest_msg_view_window_toggle_find_toolbar): Show a banner warning if there is no text to search, when trying to start a search. This partially fixes projects.maemo.org bug NB#62350. pmo-trunk-r2742 --- diff --git a/ChangeLog2 b/ChangeLog2 index 4a2acbc..b763726 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,3 +1,19 @@ +2007-07-16 Murray Cumming + + * src/widgets/modest-msg-view.h: + * src/widgets/modest-msg-view.c: + Added modest_msg_view_get_message_is_empty() but this needs + to be implemented. + * src/maemo/modest-msg-edit-window.c: (message_is_empty): + Check if there is any text in the message yet. + But this needs to be implemented properly. + (modest_msg_edit_window_toggle_find_toolbar): + * src/maemo/modest-msg-view-window.c: + (modest_msg_view_window_toggle_find_toolbar): + Show a banner warning if there is no text to search, when + trying to start a search. This partially fixes + projects.maemo.org bug NB#62350. + 2007-07-13 Murray Cumming * src/modest-mail-operation.c: (update_account_thread): diff --git a/src/maemo/modest-msg-edit-window.c b/src/maemo/modest-msg-edit-window.c index 74f4c85..8e2bf7e 100644 --- a/src/maemo/modest-msg-edit-window.c +++ b/src/maemo/modest-msg-edit-window.c @@ -2709,6 +2709,25 @@ subject_field_changed (GtkEditable *editable, gtk_text_buffer_set_modified (priv->text_buffer, TRUE); } +gboolean +message_is_empty (ModestMsgEditWindow *window) +{ + ModestMsgEditWindowPrivate *priv = NULL; + + g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window), FALSE); + priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window); + + /** TODO: Add wpeditor API to tell us if there is any _visible_ text, + * so we can ignore markup. + */ + GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->msg_body)); + gint count = 0; + if (buf) + count = gtk_text_buffer_get_char_count (buf); + + return count == 0; +} + void modest_msg_edit_window_toggle_find_toolbar (ModestMsgEditWindow *window, gboolean show) @@ -2719,6 +2738,13 @@ modest_msg_edit_window_toggle_find_toolbar (ModestMsgEditWindow *window, priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window); gtk_widget_set_no_show_all (priv->find_toolbar, FALSE); + + /* Show a warning if there is nothing to search: */ + if (show && message_is_empty (window)) { + hildon_banner_show_information (GTK_WIDGET (window), NULL, _("mail_ib_nothing_to_find")); + return; + } + if (show) { gtk_widget_show_all (priv->find_toolbar); hildon_find_toolbar_highlight_entry (HILDON_FIND_TOOLBAR (priv->find_toolbar), TRUE); diff --git a/src/maemo/modest-msg-view-window.c b/src/maemo/modest-msg-view-window.c index 4ae95ca..b4152d2 100644 --- a/src/maemo/modest-msg-view-window.c +++ b/src/maemo/modest-msg-view-window.c @@ -789,6 +789,13 @@ 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); diff --git a/src/widgets/modest-msg-view.c b/src/widgets/modest-msg-view.c index b26b8fa..d2116ef 100644 --- a/src/widgets/modest-msg-view.c +++ b/src/widgets/modest-msg-view.c @@ -1423,6 +1423,17 @@ modest_msg_view_get_message (ModestMsgView *self) } 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: + */ + + return FALSE; +} + + +gboolean modest_msg_view_search (ModestMsgView *self, const gchar *search) { ModestMsgViewPrivate *priv; diff --git a/src/widgets/modest-msg-view.h b/src/widgets/modest-msg-view.h index 0d73921..067e236 100644 --- a/src/widgets/modest-msg-view.h +++ b/src/widgets/modest-msg-view.h @@ -120,6 +120,17 @@ void modest_msg_view_set_message (ModestMsgView *self, TnyMsg *tny_msg) */ TnyMsg* modest_msg_view_get_message (ModestMsgView *self); +/** + * modest_msg_view_get_message_is_empty + * @self: a ModestMsgView instance + * + * Returns whether the message contains any visbible (searchable) text. + * For instance, this will return FALSE if the message contains only markup. + * + * Returns: TRUE if the message contains visible text. + */ +gboolean modest_msg_view_get_message_is_empty (ModestMsgView *self); + GtkAdjustment *modest_msg_view_get_vadjustment (ModestMsgView *self); GtkAdjustment *modest_msg_view_get_hadjustment (ModestMsgView *self); void modest_msg_view_set_vadjustment (ModestMsgView *self, GtkAdjustment *vadj);