Launch mailboxes window on multimailboxes accounts
[modest] / src / hildon2 / modest-msg-edit-window.c
index 68f179c..690bb80 100644 (file)
@@ -794,6 +794,8 @@ init_window (ModestMsgEditWindow *obj)
        hildon_button_set_image (HILDON_BUTTON (priv->add_attachment_button), attachment_icon);
        gtk_box_pack_start (GTK_BOX (subject_box), priv->add_attachment_button, FALSE, FALSE, 0);
        priv->attachments_view = modest_attachments_view_new (NULL);
+       modest_attachments_view_set_style (MODEST_ATTACHMENTS_VIEW (priv->attachments_view),
+                                          MODEST_ATTACHMENTS_VIEW_STYLE_NO_FOCUS);
        
        priv->header_box = gtk_vbox_new (FALSE, 0);
        
@@ -1369,6 +1371,10 @@ modest_msg_edit_window_setup_toolbar (ModestMsgEditWindow *window)
        /* font_size */
        tool_item = GTK_WIDGET (gtk_menu_tool_button_new (NULL, NULL));
        priv->size_tool_button_label = gtk_label_new (NULL);
+       hildon_helper_set_logical_color (GTK_WIDGET (priv->size_tool_button_label), GTK_RC_TEXT,
+                                        GTK_STATE_INSENSITIVE, "SecondaryTextColor");
+       hildon_helper_set_logical_color (GTK_WIDGET (priv->size_tool_button_label), GTK_RC_FG,
+                                        GTK_STATE_INSENSITIVE, "SecondaryTextColor");
        snprintf(size_text, sizeof(size_text), "%d", wp_font_size[DEFAULT_FONT_SIZE]);
        markup = g_strconcat ("<span font_family='", DEFAULT_SIZE_BUTTON_FONT_FAMILY, "'>",
                              size_text,"</span>", NULL);
@@ -1411,6 +1417,10 @@ modest_msg_edit_window_setup_toolbar (ModestMsgEditWindow *window)
        /* font face */
        tool_item = GTK_WIDGET (gtk_menu_tool_button_new (NULL, NULL));
        priv->font_tool_button_label = gtk_label_new (NULL);
+       hildon_helper_set_logical_color (GTK_WIDGET (priv->font_tool_button_label), GTK_RC_TEXT,
+                                        GTK_STATE_INSENSITIVE, "SecondaryTextColor");
+       hildon_helper_set_logical_color (GTK_WIDGET (priv->font_tool_button_label), GTK_RC_FG,
+                                        GTK_STATE_INSENSITIVE, "SecondaryTextColor");
        markup = g_strconcat ("<span font_family='", wp_get_font_name(DEFAULT_FONT), "'>Tt</span>", NULL);
        gtk_label_set_markup (GTK_LABEL (priv->font_tool_button_label), markup);
        g_free(markup);
@@ -3648,23 +3658,40 @@ static void
 from_field_changed (HildonPickerButton *button,
                    ModestMsgEditWindow *self)
 {
-       gchar *current_text;
        ModestMsgEditWindowPrivate *priv;
-       gboolean old_signature;
+       gboolean has_old_signature, has_new_signature;
+       GtkTextIter iter;
+       GtkTextIter match_start, match_end;
+       ModestAccountMgr *mgr;
+       gchar *signature;
+       gchar *full_signature;
 
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
 
-       g_message ("Current value is %s", hildon_touch_selector_get_current_text (hildon_picker_button_get_selector (button)));
-       current_text = modest_text_utils_text_buffer_get_text (priv->text_buffer);
-       g_message ("Current body is [\n%s\n]", current_text);
-       g_free (current_text);
-       g_message ("Old signature is [\n%s\n]", modest_account_mgr_get_signature (modest_runtime_get_account_mgr (),
-                                                                                 priv->last_from_account,
-                                                                                 &old_signature));
-       g_message ("New signature is [\n%s\n]", modest_account_mgr_get_signature (modest_runtime_get_account_mgr (),
-                                                                                 modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (button)),
-                                                                                 &old_signature));
+       gtk_text_buffer_get_start_iter (priv->text_buffer, &iter);
+       mgr = modest_runtime_get_account_mgr ();
+       signature = modest_account_mgr_get_signature (mgr, priv->last_from_account, &has_old_signature);
+       if (has_old_signature) {
+               full_signature = g_strconcat ("\n--\n", signature, NULL);
+               if (gtk_text_iter_forward_search (&iter, full_signature, 0, &match_start, &match_end, NULL)) {
+                       gtk_text_buffer_delete (priv->text_buffer, &match_start, &match_end);
+                       iter = match_start;
+               } else if (gtk_text_iter_forward_search (&iter, _("mcen_ia_editor_original_message"), 0,
+                                                        &match_start, &match_end, NULL)) {
+                       iter = match_start;
+               }
+               g_free (full_signature);
+       }
+       g_free (signature);
+
        priv->last_from_account = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->from_field));
+       signature = modest_account_mgr_get_signature (mgr, priv->last_from_account, &has_new_signature);
+       if (has_new_signature) {
+               full_signature = g_strconcat ("\n--\n", signature, NULL);
+               gtk_text_buffer_insert (priv->text_buffer, &iter, full_signature, -1);
+               g_free (full_signature);
+       }
+       g_free (signature);
 }
 
 typedef struct _MessageSettingsHelper {