2007-07-16 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Mon, 16 Jul 2007 12:15:00 +0000 (12:15 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Mon, 16 Jul 2007 12:15:00 +0000 (12:15 +0000)
* 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

ChangeLog2
src/maemo/modest-msg-edit-window.c
src/maemo/modest-msg-view-window.c
src/widgets/modest-msg-view.c
src/widgets/modest-msg-view.h

index 4a2acbc..b763726 100644 (file)
@@ -1,3 +1,19 @@
+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):
index 74f4c85..8e2bf7e 100644 (file)
@@ -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);
index 4ae95ca..b4152d2 100644 (file)
@@ -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);
index b26b8fa..d2116ef 100644 (file)
@@ -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;
index 0d73921..067e236 100644 (file)
@@ -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);