* src/maemo/modest-msg-view-window.c:
[modest] / src / maemo / modest-msg-view-window.c
index 7e39bf7..5328c54 100644 (file)
@@ -420,13 +420,13 @@ init_window (ModestMsgViewWindow *obj, TnyMsg *msg)
        gtk_container_add   (GTK_CONTAINER(obj), main_vbox);
 
        priv->find_toolbar = hildon_find_toolbar_new (NULL);
+       hildon_window_add_toolbar (HILDON_WINDOW (obj), GTK_TOOLBAR (priv->find_toolbar));
        gtk_widget_set_no_show_all (priv->find_toolbar, TRUE);
        g_signal_connect (G_OBJECT (priv->find_toolbar), "close", G_CALLBACK (modest_msg_view_window_find_toolbar_close), obj);
        g_signal_connect (G_OBJECT (priv->find_toolbar), "search", G_CALLBACK (modest_msg_view_window_find_toolbar_search), obj);
        
        priv->clipboard_change_handler = g_signal_connect (G_OBJECT (gtk_clipboard_get (GDK_SELECTION_PRIMARY)), "owner-change", G_CALLBACK (modest_msg_view_window_clipboard_owner_change), obj);
        gtk_widget_show_all (GTK_WIDGET(main_vbox));
-       gtk_box_pack_end (GTK_BOX (main_vbox), priv->find_toolbar, FALSE, FALSE, 0);
 
 }      
 
@@ -513,7 +513,7 @@ select_next_valid_row (GtkTreeModel *model,
 
 ModestWindow *
 modest_msg_view_window_new_with_header_model (TnyMsg *msg, 
-                                             const gchar *account_name,
+                                             const gchar *modest_account_name,
                                              const gchar *msg_uid,
                                              GtkTreeModel *model, 
                                              GtkTreeRowReference *row_reference)
@@ -521,7 +521,7 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg,
        ModestMsgViewWindow *window = NULL;
        ModestMsgViewWindowPrivate *priv = NULL;
 
-       window = MODEST_MSG_VIEW_WINDOW(modest_msg_view_window_new (msg, account_name, msg_uid));
+       window = MODEST_MSG_VIEW_WINDOW(modest_msg_view_window_new (msg, modest_account_name, msg_uid));
        g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), NULL);
 
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
@@ -543,7 +543,7 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg,
 
 ModestWindow *
 modest_msg_view_window_new (TnyMsg *msg, 
-                           const gchar *account_name,
+                           const gchar *modest_account_name,
                            const gchar *msg_uid)
 {
        ModestMsgViewWindow *self = NULL;
@@ -665,7 +665,7 @@ modest_msg_view_window_new (TnyMsg *msg,
                                                       G_CALLBACK (on_queue_changed),
                                                       obj);
 
-       modest_window_set_active_account (MODEST_WINDOW(obj), account_name);
+       modest_window_set_active_account (MODEST_WINDOW(obj), modest_account_name);
 
        priv->last_search = NULL;
 
@@ -823,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", &current_search, NULL);
 
        if ((current_search == NULL) || (strcmp (current_search, "") == 0)) {
@@ -1091,12 +1096,13 @@ static gboolean
 message_reader (ModestMsgViewWindow *window,
                ModestMsgViewWindowPrivate *priv,
                TnyHeader *header,
-               GtkTreeIter iter)
+               GtkTreePath *path)
 {
        ModestMailOperation *mail_op = NULL;
-       GtkTreePath *path = NULL;
        ModestMailOperationTypeOperation op_type;
 
+       g_return_val_if_fail (path != NULL, FALSE);
+
        /* Msg download completed */
        if (tny_header_get_flags (header) & TNY_HEADER_FLAG_CACHED) {
                op_type = MODEST_MAIL_OPERATION_TYPE_OPEN;
@@ -1126,9 +1132,6 @@ message_reader (ModestMsgViewWindow *window,
                }
        }
 
-       /* Get the path, will be freed by the callback */
-       path = gtk_tree_model_get_path (priv->header_model, &iter);
-
        /* New mail operation */
        mail_op = modest_mail_operation_new_with_error_handling (op_type, 
                                                                 G_OBJECT(window),
@@ -1170,12 +1173,13 @@ modest_msg_view_window_select_next_message (ModestMsgViewWindow *window)
                            &header, -1);
        
        /* Read the message & show it */
-       if (!message_reader (window, priv, header, tmp_iter))
+       if (!message_reader (window, priv, header, path)) {
                retval = FALSE;
+               gtk_tree_path_free (path);
+       }
 
        /* Free */
        g_object_unref (header);
-       gtk_tree_path_free (path);
 
        return retval;          
 }
@@ -1186,6 +1190,7 @@ modest_msg_view_window_select_first_message (ModestMsgViewWindow *self)
        ModestMsgViewWindowPrivate *priv = NULL;
        TnyHeader *header = NULL;
        GtkTreeIter iter;
+       GtkTreePath *path;
 
        g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (self), FALSE);
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
@@ -1199,15 +1204,16 @@ modest_msg_view_window_select_first_message (ModestMsgViewWindow *self)
                            &iter, 
                            TNY_GTK_HEADER_LIST_MODEL_INSTANCE_COLUMN,
                            &header, -1);
-       
        g_return_val_if_fail (TNY_IS_HEADER (header), FALSE);
        if (tny_header_get_flags (header) & TNY_HEADER_FLAG_DELETED) {
                g_object_unref (header);
                return modest_msg_view_window_select_next_message (self);
        }
        
+       path = gtk_tree_model_get_path (priv->header_model, &iter);
+       
        /* Read the message & show it */
-       message_reader (self, priv, header, iter);
+       message_reader (self, priv, header, path);
        
        /* Free */
        g_object_unref (header);
@@ -1245,7 +1251,7 @@ modest_msg_view_window_select_previous_message (ModestMsgViewWindow *window)
                }
 
                /* Read the message & show it */
-               if (!message_reader (window, priv, header, iter)) {
+               if (!message_reader (window, priv, header, path)) {
                        g_object_unref (header);
                        break;
                }