Remove body frame in hildon2 editor
[modest] / src / hildon2 / modest-msg-edit-window.c
index a8d9c4f..ff4550e 100644 (file)
@@ -233,7 +233,6 @@ enum {
 typedef struct _ModestMsgEditWindowPrivate ModestMsgEditWindowPrivate;
 struct _ModestMsgEditWindowPrivate {
        GtkWidget   *msg_body;
-       GtkWidget   *frame;
        GtkWidget   *header_box;
        
        ModestPairList *from_field_protos;
@@ -247,6 +246,7 @@ struct _ModestMsgEditWindowPrivate {
        GtkWidget   *subject_field;
        GtkWidget   *attachments_view;
        GtkWidget   *priority_icon;
+       GtkWidget   *subject_box;
        GtkWidget   *add_attachment_button;
 
        GtkWidget   *cc_caption;
@@ -389,7 +389,6 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj)
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(obj);
 
        priv->msg_body      = NULL;
-       priv->frame         = NULL;
        priv->from_field    = NULL;
        priv->to_field      = NULL;
        priv->cc_field      = NULL;
@@ -511,6 +510,9 @@ correct_scroll_without_drag_check_idle (gpointer userdata)
        GtkTextMark *insert;
 
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(w);
+
+       if (!gtk_widget_is_focus (priv->msg_body))
+               return FALSE;
        
        insert = gtk_text_buffer_get_insert (priv->text_buffer);
        gtk_text_buffer_get_iter_at_mark (priv->text_buffer, &iter, insert);
@@ -692,6 +694,7 @@ init_window (ModestMsgEditWindow *obj)
 {
        GtkWidget *to_caption, *subject_caption;
        GtkWidget *main_vbox;
+       GtkWidget *add_attachment_align;
        ModestMsgEditWindowPrivate *priv;
        GtkActionGroup *action_group;
        ModestWindowPrivate *parent_priv;
@@ -700,7 +703,6 @@ init_window (ModestMsgEditWindow *obj)
 
        GtkSizeGroup *title_size_group;
        GtkSizeGroup *value_size_group;
-       GtkWidget *subject_box;
        GtkWidget *attachment_icon;
        GtkWidget *window_box;
 #if (GTK_MINOR_VERSION >= 10)
@@ -777,23 +779,28 @@ init_window (ModestMsgEditWindow *obj)
        priv->to_field      = modest_recpt_editor_new ();
        priv->cc_field      = modest_recpt_editor_new ();
        priv->bcc_field     = modest_recpt_editor_new ();
-       subject_box = gtk_hbox_new (FALSE, 0);
+       priv->subject_box = gtk_hbox_new (FALSE, MODEST_MARGIN_NONE);
        priv->priority_icon = gtk_image_new ();
-       gtk_box_pack_start (GTK_BOX (subject_box), priv->priority_icon, FALSE, FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (priv->subject_box), priv->priority_icon, FALSE, FALSE, 0);
        priv->subject_field = hildon_entry_new (MODEST_EDITABLE_SIZE);
        gtk_entry_set_max_length (GTK_ENTRY (priv->subject_field) ,SUBJECT_MAX_LENGTH);
        g_object_set (G_OBJECT (priv->subject_field), "truncate-multiline", TRUE, NULL);
        hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->subject_field), 
                                         HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
-       gtk_box_pack_start (GTK_BOX (subject_box), priv->subject_field, TRUE, TRUE, 0);
+       gtk_box_pack_start (GTK_BOX (priv->subject_box), priv->subject_field, TRUE, TRUE, 0);
        priv->add_attachment_button = hildon_button_new (MODEST_EDITABLE_SIZE, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
        gtk_widget_set_size_request (priv->add_attachment_button, ATTACHMENT_BUTTON_WIDTH, -1);
        GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (priv->add_attachment_button), GTK_CAN_FOCUS);
        gtk_button_set_focus_on_click (GTK_BUTTON (priv->add_attachment_button), FALSE);
        attachment_icon = gtk_image_new_from_icon_name (MODEST_HEADER_ICON_ATTACH, HILDON_ICON_SIZE_FINGER);
        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);
+       add_attachment_align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
+       gtk_alignment_set_padding (GTK_ALIGNMENT (add_attachment_align), 0, 0, MODEST_MARGIN_DEFAULT, 0);
+       gtk_container_add (GTK_CONTAINER (add_attachment_align), priv->add_attachment_button);
+       gtk_box_pack_start (GTK_BOX (priv->subject_box), add_attachment_align, 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);
        
@@ -810,7 +817,7 @@ init_window (ModestMsgEditWindow *obj)
                 _("mail_va_hotfix1"), FALSE, priv->bcc_field,
                 HILDON_SIZE_AUTO_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
        subject_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
-                                                              _("mail_va_subject"), FALSE, subject_box);
+                                                              _("mail_va_subject"), FALSE, priv->subject_box);
        priv->attachments_caption = modest_maemo_utils_create_captioned_with_size_type (title_size_group, value_size_group,
                                                                                        _("mail_va_attachment"), 
                                                                                        FALSE,
@@ -859,8 +866,7 @@ init_window (ModestMsgEditWindow *obj)
        main_vbox = gtk_vbox_new  (FALSE, DEFAULT_MAIN_VBOX_SPACING);
 
        gtk_box_pack_start (GTK_BOX(main_vbox), priv->header_box, FALSE, FALSE, 0);
-       priv->frame = gtk_frame_new (NULL);
-       gtk_box_pack_start (GTK_BOX(main_vbox), priv->frame, TRUE, TRUE, 0);
+       gtk_box_pack_start (GTK_BOX(main_vbox), priv->msg_body, TRUE, TRUE, 0);
 
        hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (priv->pannable), main_vbox);
        gtk_container_set_focus_vadjustment (GTK_CONTAINER (main_vbox), 
@@ -872,8 +878,6 @@ init_window (ModestMsgEditWindow *obj)
 
        gtk_box_pack_start (GTK_BOX (window_box), priv->pannable, TRUE, TRUE, 0);
 
-       gtk_container_add (GTK_CONTAINER (priv->frame), priv->msg_body);
-
        /* Set window icon */
        window_icon = modest_platform_get_icon (MODEST_APP_MSG_EDIT_ICON, MODEST_ICON_SIZE_BIG); 
        if (window_icon) {
@@ -1369,6 +1373,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 +1419,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);
@@ -1544,6 +1556,8 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre
         /* Checks the dimming rules */
        g_object_unref (toolbar_rules_group);
        g_object_unref (clipboard_rules_group);
+       gtk_widget_hide (priv->priority_icon);
+       gtk_widget_queue_resize (priv->subject_box);
        set_msg (MODEST_MSG_EDIT_WINDOW (obj), msg, preserve_is_rich);
 
        text_buffer_refresh_attributes (WP_TEXT_BUFFER (priv->text_buffer), MODEST_MSG_EDIT_WINDOW (obj));
@@ -2751,7 +2765,7 @@ modest_msg_edit_window_set_priority_flags (ModestMsgEditWindow *window,
                case TNY_HEADER_FLAG_HIGH_PRIORITY:
                        gtk_image_set_from_icon_name (GTK_IMAGE (priv->priority_icon),
                                                      MODEST_HEADER_ICON_HIGH, 
-                                                     HILDON_ICON_SIZE_XSMALL);
+                                                     HILDON_ICON_SIZE_SMALL);
                        gtk_widget_show (priv->priority_icon);
                        priority_action = gtk_ui_manager_get_action (parent_priv->ui_manager,
                                                                     "/MenuBar/ToolsMenu/MessagePriorityMenu/MessagePriorityHighMenu");
@@ -2759,7 +2773,7 @@ modest_msg_edit_window_set_priority_flags (ModestMsgEditWindow *window,
                case TNY_HEADER_FLAG_LOW_PRIORITY:
                        gtk_image_set_from_icon_name (GTK_IMAGE (priv->priority_icon),
                                                      MODEST_HEADER_ICON_LOW,
-                                                     HILDON_ICON_SIZE_XSMALL);
+                                                     HILDON_ICON_SIZE_SMALL);
                        gtk_widget_show (priv->priority_icon);
                        priority_action = gtk_ui_manager_get_action (parent_priv->ui_manager,
                                                                     "/MenuBar/ToolsMenu/MessagePriorityMenu/MessagePriorityLowMenu");
@@ -2773,6 +2787,7 @@ modest_msg_edit_window_set_priority_flags (ModestMsgEditWindow *window,
                gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (priority_action), TRUE);
                gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
        }
+       gtk_widget_queue_resize (priv->subject_box);
 }
 
 void
@@ -3653,28 +3668,35 @@ from_field_changed (HildonPickerButton *button,
        GtkTextIter iter;
        GtkTextIter match_start, match_end;
        ModestAccountMgr *mgr;
-       gchar *old_signature;
-       gchar *new_signature;
+       gchar *signature;
+       gchar *full_signature;
 
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
 
        gtk_text_buffer_get_start_iter (priv->text_buffer, &iter);
        mgr = modest_runtime_get_account_mgr ();
-       old_signature = modest_account_mgr_get_signature (mgr, priv->last_from_account, &has_old_signature);
+       signature = modest_account_mgr_get_signature (mgr, priv->last_from_account, &has_old_signature);
        if (has_old_signature) {
-               if (gtk_text_iter_forward_search (&iter, old_signature, 0, &match_start, &match_end, NULL)) {
+               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 (old_signature);
+       g_free (signature);
 
        priv->last_from_account = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->from_field));
-       new_signature = modest_account_mgr_get_signature (mgr, priv->last_from_account, &has_new_signature);
+       signature = modest_account_mgr_get_signature (mgr, priv->last_from_account, &has_new_signature);
        if (has_new_signature) {
-               gtk_text_buffer_insert (priv->text_buffer, &iter, new_signature, -1);
+               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 (new_signature);
+       g_free (signature);
 }
 
 typedef struct _MessageSettingsHelper {