+2007-07-16 Murray Cumming <murrayc@murrayc.com>
+
+ * 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 <murrayc@murrayc.com>
* src/modest-mail-operation.c: (update_account_thread):
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)
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);
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);
}
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;
*/
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);