X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-msg-edit-window.c;h=ff4550e40e04cf8f4630ad6294e552b56dfa0897;hb=1728d9b872215ba0b3aadbef96dd3faf9abdb166;hp=d92363a6145f3d7ef6c6f16c1dd96ece17b06040;hpb=7df38f78cb5481006cbd14cb24cc5abb8f0226f9;p=modest diff --git a/src/hildon2/modest-msg-edit-window.c b/src/hildon2/modest-msg-edit-window.c index d92363a..ff4550e 100644 --- a/src/hildon2/modest-msg-edit-window.c +++ b/src/hildon2/modest-msg-edit-window.c @@ -88,6 +88,7 @@ #define SUBJECT_MAX_LENGTH 1000 #define IMAGE_MAX_WIDTH 560 #define DEFAULT_FONT_SCALE 1.5 +#define ATTACHMENT_BUTTON_WIDTH 118 static gboolean is_wp_text_buffer_started = FALSE; @@ -171,6 +172,8 @@ static void on_message_settings (GtkAction *action, ModestMsgEditWindow *window); static void setup_menu (ModestMsgEditWindow *self); +static void from_field_changed (HildonPickerButton *button, + ModestMsgEditWindow *self); static void DEBUG_BUFFER (WPTextBuffer *buffer) { #ifdef DEBUG @@ -230,11 +233,11 @@ enum { typedef struct _ModestMsgEditWindowPrivate ModestMsgEditWindowPrivate; struct _ModestMsgEditWindowPrivate { GtkWidget *msg_body; - GtkWidget *frame; GtkWidget *header_box; ModestPairList *from_field_protos; GtkWidget *from_field; + gchar *last_from_account; gchar *original_account_name; GtkWidget *to_field; @@ -243,6 +246,7 @@ struct _ModestMsgEditWindowPrivate { GtkWidget *subject_field; GtkWidget *attachments_view; GtkWidget *priority_icon; + GtkWidget *subject_box; GtkWidget *add_attachment_button; GtkWidget *cc_caption; @@ -385,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; @@ -507,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); @@ -639,6 +645,8 @@ connect_signals (ModestMsgEditWindow *obj) g_signal_connect (G_OBJECT (priv->add_attachment_button), "clicked", G_CALLBACK (modest_msg_edit_window_add_attachment_clicked), obj); + g_signal_connect (G_OBJECT (priv->from_field), "value-changed", + G_CALLBACK (from_field_changed), obj); g_signal_connect (G_OBJECT (priv->msg_body), "focus-in-event", G_CALLBACK (msg_body_focus), obj); @@ -686,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; @@ -694,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) @@ -771,43 +779,48 @@ 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); - priv->add_attachment_button = gtk_button_new (); + 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_relief (GTK_BUTTON (priv->add_attachment_button), GTK_RELIEF_NONE); gtk_button_set_focus_on_click (GTK_BUTTON (priv->add_attachment_button), FALSE); - gtk_button_set_alignment (GTK_BUTTON (priv->add_attachment_button), 1.0, 0.5); attachment_icon = gtk_image_new_from_icon_name (MODEST_HEADER_ICON_ATTACH, HILDON_ICON_SIZE_FINGER); - gtk_container_add (GTK_CONTAINER (priv->add_attachment_button), attachment_icon); - gtk_box_pack_start (GTK_BOX (subject_box), priv->add_attachment_button, FALSE, FALSE, 0); + hildon_button_set_image (HILDON_BUTTON (priv->add_attachment_button), attachment_icon); + 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); to_caption = modest_maemo_utils_create_captioned_with_size_type (title_size_group, value_size_group, - _("mail_va_to"), priv->to_field, + _("mail_va_to"), FALSE, priv->to_field, HILDON_SIZE_AUTO_HEIGHT | HILDON_SIZE_AUTO_WIDTH); priv->cc_caption = modest_maemo_utils_create_captioned_with_size_type (title_size_group, value_size_group, - _("mail_va_cc"), priv->cc_field, + _("mail_va_cc"), FALSE, priv->cc_field, HILDON_SIZE_AUTO_HEIGHT | HILDON_SIZE_AUTO_WIDTH); priv->bcc_caption = modest_maemo_utils_create_captioned_with_size_type (title_size_group, value_size_group, - _("mail_va_hotfix1"), priv->bcc_field, + _("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"), 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, priv->attachments_view, HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_AUTO_HEIGHT); @@ -853,10 +866,11 @@ 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), + hildon_pannable_area_get_vadjustment (HILDON_PANNABLE_AREA (priv->pannable))); gtk_widget_show_all (GTK_WIDGET(priv->pannable)); window_box = gtk_vbox_new (FALSE, 0); @@ -864,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) { @@ -1332,6 +1344,8 @@ modest_msg_edit_window_setup_toolbar (ModestMsgEditWindow *window) /* Toolbar */ parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar"); + gtk_toolbar_set_show_arrow (GTK_TOOLBAR (parent_priv->toolbar), FALSE); + gtk_toolbar_set_icon_size (GTK_TOOLBAR (parent_priv->toolbar), HILDON_ICON_SIZE_FINGER); hildon_window_add_toolbar (HILDON_WINDOW (window), GTK_TOOLBAR (parent_priv->toolbar)); /* Font color placeholder */ @@ -1341,6 +1355,7 @@ modest_msg_edit_window_setup_toolbar (ModestMsgEditWindow *window) /* font color */ priv->font_color_toolitem = GTK_WIDGET (gtk_tool_item_new ()); priv->font_color_button = hildon_color_button_new (); + gtk_widget_set_size_request (priv->font_color_button, -1, 48); GTK_WIDGET_UNSET_FLAGS (priv->font_color_toolitem, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS (priv->font_color_button, GTK_CAN_FOCUS); gtk_container_add (GTK_CONTAINER (priv->font_color_toolitem), priv->font_color_button); @@ -1358,11 +1373,16 @@ 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 ("", size_text,"", NULL); gtk_label_set_markup (GTK_LABEL (priv->size_tool_button_label), markup); g_free (markup); + hildon_helper_set_logical_font (priv->size_tool_button_label, "LargeSystemFont"); gtk_tool_button_set_label_widget (GTK_TOOL_BUTTON (tool_item), priv->size_tool_button_label); sizes_menu = gtk_menu_new (); priv->size_items_group = NULL; @@ -1391,17 +1411,22 @@ modest_msg_edit_window_setup_toolbar (ModestMsgEditWindow *window) gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (tool_item), sizes_menu); g_signal_connect (G_OBJECT (tool_item), "clicked", G_CALLBACK (menu_tool_button_clicked_popup), NULL); gtk_toolbar_insert (GTK_TOOLBAR (parent_priv->toolbar), GTK_TOOL_ITEM (tool_item), insert_index); - gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), TRUE); - gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), TRUE); + gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), FALSE); + gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), FALSE); menu_tool_button_dont_expand (GTK_MENU_TOOL_BUTTON (tool_item)); priv->font_size_toolitem = tool_item; /* 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 ("Tt", NULL); gtk_label_set_markup (GTK_LABEL (priv->font_tool_button_label), markup); g_free(markup); + hildon_helper_set_logical_font (priv->font_tool_button_label, "LargeSystemFont"); gtk_tool_button_set_label_widget (GTK_TOOL_BUTTON (tool_item), priv->font_tool_button_label); fonts_menu = gtk_menu_new (); priv->font_items_group = NULL; @@ -1434,8 +1459,8 @@ modest_msg_edit_window_setup_toolbar (ModestMsgEditWindow *window) gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (tool_item), fonts_menu); g_signal_connect (G_OBJECT (tool_item), "clicked", G_CALLBACK (menu_tool_button_clicked_popup), NULL); gtk_toolbar_insert (GTK_TOOLBAR (parent_priv->toolbar), GTK_TOOL_ITEM (tool_item), insert_index); - gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), TRUE); - gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), TRUE); + gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), FALSE); + gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), FALSE); menu_tool_button_dont_expand (GTK_MENU_TOOL_BUTTON (tool_item)); priv->font_face_toolitem = tool_item; @@ -1487,6 +1512,7 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre priv->from_field_protos = get_transports (); modest_selector_picker_set_pair_list (MODEST_SELECTOR_PICKER (priv->from_field), priv->from_field_protos); modest_selector_picker_set_active_id (MODEST_SELECTOR_PICKER (priv->from_field), (gpointer) account_name); + priv->last_from_account = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->from_field)); hildon_button_set_title (HILDON_BUTTON (priv->from_field), _("mail_va_from")); hildon_button_set_value (HILDON_BUTTON (priv->from_field), @@ -1530,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)); @@ -2198,31 +2226,32 @@ modest_msg_edit_window_insert_image (ModestMsgEditWindow *window) mime_part = tny_platform_factory_new_mime_part (modest_runtime_get_platform_factory ()); - + TnyStream *stream = create_stream_for_uri (uri); if (stream == NULL) { - modest_platform_information_banner (NULL, NULL, dgettext("hildon-fm", "sfil_ib_opening_not_allowed")); - + modest_platform_information_banner (NULL, NULL, + _FM("sfil_ib_opening_not_allowed")); + g_object_unref (mime_part); gnome_vfs_file_info_unref (info); continue; } tny_mime_part_construct (mime_part, stream, mime_type, "base64"); - + content_id = g_strdup_printf ("%d", priv->next_cid); tny_mime_part_set_content_id (mime_part, content_id); g_free (content_id); priv->next_cid++; - + basename = g_path_get_basename (filename); tny_mime_part_set_filename (mime_part, basename); g_free (basename); pixbuf = pixbuf_from_stream (stream, mime_type, &stream_size); - + if (pixbuf != NULL) { priv->images_size += stream_size; priv->images_count ++; @@ -2374,7 +2403,7 @@ modest_msg_edit_window_attach_file_one (ModestMsgEditWindow *window, size = info->size; if (size > allowed_size) { modest_platform_information_banner (NULL, NULL, - dgettext("hildon-fm", "sfil_ib_opening_not_allowed")); + _FM("sfil_ib_opening_not_allowed")); return 0; } } else @@ -2384,7 +2413,7 @@ modest_msg_edit_window_attach_file_one (ModestMsgEditWindow *window, if (stream == NULL) { - modest_platform_information_banner (NULL, NULL, dgettext("hildon-fm", "sfil_ib_opening_not_allowed")); + modest_platform_information_banner (NULL, NULL, _FM("sfil_ib_opening_not_allowed")); g_object_unref (mime_part); gnome_vfs_file_info_unref (info); @@ -2429,7 +2458,12 @@ modest_msg_edit_window_remove_attachments (ModestMsgEditWindow *window, priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window); if (att_list == NULL) { - att_list = modest_attachments_view_get_selection (MODEST_ATTACHMENTS_VIEW (priv->attachments_view)); + att_list = modest_attachments_view_get_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view)); + if (!modest_maemo_utils_select_attachments (GTK_WINDOW (window), att_list)) { + g_object_unref (att_list); + return; + } + } else { g_object_ref (att_list); } @@ -2731,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"); @@ -2739,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"); @@ -2753,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 @@ -3141,22 +3176,27 @@ modest_msg_edit_window_check_names (ModestMsgEditWindow *window, gboolean add_to return FALSE; } + g_object_ref (window); if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->to_field), add_to_addressbook)) { modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->to_field)); + g_object_unref (window); return FALSE; } if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->cc_field), add_to_addressbook)) { modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->cc_field)); + g_object_unref (window); return FALSE; } if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->bcc_field), add_to_addressbook)) { modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->bcc_field)); + g_object_unref (window); return FALSE; } if (!modest_recpt_editor_has_focus (MODEST_RECPT_EDITOR (priv->cc_field)) && !modest_recpt_editor_has_focus (MODEST_RECPT_EDITOR (priv->bcc_field))) modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->to_field)); + g_object_unref (window); return TRUE; @@ -3309,8 +3349,7 @@ subject_field_insert_text (GtkEditable *editable, if (result_len + old_length > 1000) { hildon_banner_show_information (GTK_WIDGET (window), NULL, - dgettext("hildon-common-strings", - "ckdg_ib_maximum_characters_reached")); + _CS("ckdg_ib_maximum_characters_reached")); } g_string_free (result, TRUE); } @@ -3416,7 +3455,7 @@ modest_msg_edit_window_find_toolbar_search (GtkWidget *widget, g_free (priv->last_search); priv->last_search = NULL; /* Information banner about empty search */ - hildon_banner_show_information (NULL, NULL, dgettext ("hildon-common-strings", "ecdg_ib_find_rep_enter_text")); + hildon_banner_show_information (NULL, NULL, _CS("ecdg_ib_find_rep_enter_text")); return; } @@ -3432,14 +3471,14 @@ modest_msg_edit_window_find_toolbar_search (GtkWidget *widget, result = gtk_text_iter_forward_search_insensitive (&selection_end, current_search, &match_start, &match_end); if (!result) - hildon_banner_show_information (NULL, NULL, dgettext ("hildon-libs", "ckct_ib_find_search_complete")); + hildon_banner_show_information (NULL, NULL, _HL("ckct_ib_find_search_complete")); } else { GtkTextIter buffer_start; gtk_text_buffer_get_start_iter (priv->text_buffer, &buffer_start); result = gtk_text_iter_forward_search_insensitive (&buffer_start, current_search, &match_start, &match_end); if (!result) - hildon_banner_show_information (NULL, NULL, dgettext ("hildon-libs", "ckct_ib_find_no_matches")); + hildon_banner_show_information (NULL, NULL, _HL("ckct_ib_find_no_matches")); } /* Mark as selected the string found in search */ @@ -3620,10 +3659,52 @@ on_account_removed (TnyAccountStore *account_store, } } +static void +from_field_changed (HildonPickerButton *button, + ModestMsgEditWindow *self) +{ + ModestMsgEditWindowPrivate *priv; + 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); + + 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 { ModestMsgEditWindow *window; GSList *priority_group; GSList *format_group; + GtkToggleButton *current_priority; + GtkToggleButton *current_format; } MessageSettingsHelper; static void @@ -3643,12 +3724,7 @@ on_priority_toggle (GtkToggleButton *button, gtk_toggle_button_set_active (node_button, FALSE); } } - if (priv->priority_flags != (TnyHeaderFlags) g_object_get_data (G_OBJECT (button), "priority")) - modest_msg_edit_window_set_priority_flags (helper->window, - (TnyHeaderFlags) - g_object_get_data (G_OBJECT (button), - "priority")); - + helper->current_priority = button; } else { gboolean found = FALSE; /* If no one is active, activate it again */ @@ -3671,10 +3747,8 @@ on_format_toggle (GtkToggleButton *button, { GSList *node; ModestMsgEditWindowPrivate *priv; - ModestMsgEditFormat old_format; priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (helper->window); - old_format = modest_msg_edit_window_get_format (helper->window); if (gtk_toggle_button_get_active (button)) { for (node = helper->format_group; node != NULL; node = g_slist_next (node)) { @@ -3684,11 +3758,7 @@ on_format_toggle (GtkToggleButton *button, gtk_toggle_button_set_active (node_button, FALSE); } } - if (old_format != (ModestMsgEditFormat) g_object_get_data (G_OBJECT (button), "format")) { - modest_msg_edit_window_set_file_format (MODEST_MSG_EDIT_WINDOW (helper->window), - GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "file-format"))); - } - + helper->current_format = button; } else { gboolean found = FALSE; /* If no one is active, activate it again */ @@ -3728,7 +3798,9 @@ modest_msg_edit_window_show_msg_settings_dialog (ModestMsgEditWindow *window) title_sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); value_sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - dialog = gtk_dialog_new (); + dialog = gtk_dialog_new_with_buttons (_("mcen_me_message_settings"), NULL, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + _HL("wdgt_bd_done"), GTK_RESPONSE_ACCEPT, NULL); vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox); gtk_widget_show (vbox); @@ -3752,7 +3824,7 @@ modest_msg_edit_window_show_msg_settings_dialog (ModestMsgEditWindow *window) gtk_box_pack_start (GTK_BOX (priority_hbox), high_toggle, TRUE, TRUE, 0); gtk_widget_show_all (priority_hbox); captioned = modest_maemo_utils_create_captioned (title_sizegroup, value_sizegroup, - _("mcen_me_editor_message_priority"), priority_hbox); + _("mcen_me_editor_message_priority"), FALSE, priority_hbox); gtk_widget_show (captioned); gtk_box_pack_start (GTK_BOX (vbox), captioned, FALSE, FALSE, 0); @@ -3771,36 +3843,38 @@ modest_msg_edit_window_show_msg_settings_dialog (ModestMsgEditWindow *window) gtk_box_pack_start (GTK_BOX (format_hbox), html_toggle, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (format_hbox), text_toggle, TRUE, TRUE, 0); gtk_widget_show_all (format_hbox); - captioned = modest_maemo_utils_create_captioned (title_sizegroup, value_sizegroup, - _("mcen_me_editor_format"), format_hbox); - gtk_widget_show (captioned); - gtk_box_pack_start (GTK_BOX (vbox), captioned, FALSE, FALSE, 0); + gtk_widget_show (format_hbox); + gtk_box_pack_start (GTK_BOX (vbox), format_hbox, FALSE, FALSE, 0); g_object_unref (title_sizegroup); g_object_unref (value_sizegroup); - gtk_window_set_title (GTK_WINDOW (dialog), _("mcen_me_message_settings")); /* Set current values */ switch (priv->priority_flags) { case TNY_HEADER_FLAG_HIGH_PRIORITY: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (high_toggle), TRUE); + helper.current_priority = GTK_TOGGLE_BUTTON (high_toggle); break; case TNY_HEADER_FLAG_LOW_PRIORITY: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (low_toggle), TRUE); + helper.current_priority = GTK_TOGGLE_BUTTON (low_toggle); break; default: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (medium_toggle), TRUE); + helper.current_priority = GTK_TOGGLE_BUTTON (medium_toggle); break; } switch (modest_msg_edit_window_get_format (window)) { case MODEST_MSG_EDIT_FORMAT_TEXT: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text_toggle), TRUE); + helper.current_format = GTK_TOGGLE_BUTTON (text_toggle); break; case MODEST_MSG_EDIT_FORMAT_HTML: default: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (html_toggle), TRUE); + helper.current_format = GTK_TOGGLE_BUTTON (html_toggle); break; } @@ -3810,18 +3884,33 @@ modest_msg_edit_window_show_msg_settings_dialog (ModestMsgEditWindow *window) g_signal_connect (G_OBJECT (low_toggle), "toggled", G_CALLBACK (on_priority_toggle), &helper); g_signal_connect (G_OBJECT (html_toggle), "toggled", G_CALLBACK (on_format_toggle), &helper); g_signal_connect (G_OBJECT (text_toggle), "toggled", G_CALLBACK (on_format_toggle), &helper); - - gtk_dialog_run (GTK_DIALOG (dialog)); - - /* Read new values */ - + + /* Save settings if the user clicked on done */ + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { + TnyHeaderFlags flags; + ModestMsgEditFormat old_format, new_format; + + /* Set priority flags */ + flags = (TnyHeaderFlags) g_object_get_data (G_OBJECT (helper.current_priority), "priority"); + if (priv->priority_flags != flags) + modest_msg_edit_window_set_priority_flags (window, flags); + + /* Set edit format */ + old_format = modest_msg_edit_window_get_format (window); + new_format = (ModestMsgEditFormat) g_object_get_data (G_OBJECT (helper.current_format), "format"); + if (old_format != new_format) { + gint file_format = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (helper.current_format), "file-format")); + modest_msg_edit_window_set_file_format (window, file_format); + } + } + gtk_widget_destroy (dialog); g_slist_free (helper.priority_group); - } -static void on_message_settings (GtkAction *action, - ModestMsgEditWindow *window) +static void +on_message_settings (GtkAction *action, + ModestMsgEditWindow *window) { modest_msg_edit_window_show_msg_settings_dialog (window); }