#define IMAGE_MAX_WIDTH 560
#define DEFAULT_FONT_SCALE 1.5
#define ATTACHMENT_BUTTON_WIDTH 118
+#define MAX_FROM_VALUE 48
+#define MAX_BODY_LENGTH 4096
static gboolean is_wp_text_buffer_started = FALSE;
GtkTextIter *start, GtkTextIter *end,
gpointer userdata);
static void text_buffer_delete_images_by_id (GtkTextBuffer *buffer, const gchar * image_id);
+static void body_insert_text (GtkTextBuffer *buffer,
+ GtkTextIter *location,
+ gchar *text,
+ gint len,
+ ModestMsgEditWindow *window);
static void subject_field_changed (GtkEditable *editable, ModestMsgEditWindow *window);
static void subject_field_insert_text (GtkEditable *editable,
gchar *new_text,
ModestMsgEditWindow *window);
static void font_face_clicked (GtkToolButton *button,
ModestMsgEditWindow *window);
+static void update_signature (ModestMsgEditWindow *self,
+ const gchar *old_account,
+ const gchar *new_account);
static void DEBUG_BUFFER (WPTextBuffer *buffer)
{
#ifdef DEBUG
HILDON_WINDOW(obj));
}
-static gboolean account_is_multimailbox (const gchar *account_name, ModestProtocol **mmb_protocol)
-{
- gchar *transport_account;
- gboolean result = FALSE;
-
- if (mmb_protocol)
- *mmb_protocol = NULL;
-
- transport_account = modest_account_mgr_get_server_account_name (modest_runtime_get_account_mgr (),
- account_name,
- TNY_ACCOUNT_TYPE_TRANSPORT);
- if (transport_account) {
- gchar *proto;
- ModestProtocolRegistry *registry;
-
- registry = modest_runtime_get_protocol_registry ();
-
- proto = modest_account_mgr_get_string (modest_runtime_get_account_mgr (), transport_account,
- MODEST_ACCOUNT_PROTO, TRUE);
- if (proto != NULL) {
- ModestProtocol *protocol =
- modest_protocol_registry_get_protocol_by_name (registry,
- MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS,
- proto);
- if (protocol &&
- modest_protocol_registry_protocol_type_has_tag
- (registry,
- modest_protocol_get_type_id (protocol),
- MODEST_PROTOCOL_REGISTRY_MULTI_MAILBOX_PROVIDER_PROTOCOLS)) {
- if (mmb_protocol)
- *mmb_protocol = protocol;
- result = TRUE;
- }
-
- }
- }
-
- return result;
-}
-
static gchar *
multimailbox_get_default_mailbox (const gchar *account_name)
{
gboolean multi_mailbox = FALSE;
ModestProtocol *protocol = NULL;
- if (account_is_multimailbox (account_name, &protocol)) {
+ if (modest_account_mgr_account_is_multimailbox (account_mgr, account_name, &protocol)) {
transport_account = modest_account_mgr_get_server_account_name
(modest_runtime_get_account_mgr (),
G_CALLBACK (text_buffer_can_redo), obj);
g_signal_connect (G_OBJECT (priv->text_buffer), "changed",
G_CALLBACK (body_changed), obj);
+ g_signal_connect (G_OBJECT (priv->text_buffer), "insert-text",
+ G_CALLBACK (body_insert_text), obj);
g_signal_connect (G_OBJECT (priv->text_buffer), "modified-changed",
G_CALLBACK (body_changed), obj);
g_signal_connect (G_OBJECT (priv->text_buffer), "end-user-action",
priv->from_field = modest_selector_picker_new (MODEST_EDITABLE_SIZE,
HILDON_BUTTON_ARRANGEMENT_HORIZONTAL,
NULL, g_str_equal);
+ modest_selector_picker_set_value_max_chars (MODEST_SELECTOR_PICKER (priv->from_field), MAX_FROM_VALUE);
modest_maemo_utils_set_hbutton_layout (title_size_group, value_size_group,
_("mail_va_from"), priv->from_field);
/* g_signal_connect (G_OBJECT (obj), "key_pressed", G_CALLBACK (on_key_pressed), NULL) */
priv->pannable = hildon_pannable_area_new ();
+
+ g_object_set (G_OBJECT (priv->pannable), "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
main_vbox = gtk_vbox_new (FALSE, DEFAULT_MAIN_VBOX_SPACING);
window_align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
priv->from_field_protos = get_transports ();
priv->original_mailbox = NULL;
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));
if (mailbox && modest_pair_list_find_by_first_as_string (priv->from_field_protos, mailbox)) {
modest_selector_picker_set_active_id (MODEST_SELECTOR_PICKER (priv->from_field), (gpointer) mailbox);
priv->original_mailbox = g_strdup (mailbox);
- } else if (account_is_multimailbox (account_name, NULL)) {
+ } else if (modest_account_mgr_account_is_multimailbox (modest_runtime_get_account_mgr (), account_name, NULL)) {
/* We set the first mailbox as the active mailbox */
priv->original_mailbox = multimailbox_get_default_mailbox (account_name);
- modest_selector_picker_set_active_id (MODEST_SELECTOR_PICKER (priv->from_field),
- (gpointer) priv->original_mailbox);
+ if (priv->original_mailbox != NULL)
+ modest_selector_picker_set_active_id (MODEST_SELECTOR_PICKER (priv->from_field),
+ (gpointer) priv->original_mailbox);
+ else
+ modest_selector_picker_set_active_id (MODEST_SELECTOR_PICKER (priv->from_field),
+ (gpointer) account_name);
} else {
modest_selector_picker_set_active_id (MODEST_SELECTOR_PICKER (priv->from_field), (gpointer) account_name);
}
selector = hildon_touch_selector_new ();
renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer), "alignment", PANGO_ALIGN_CENTER, "xalign", 0.5, NULL);
hildon_touch_selector_append_column (HILDON_TOUCH_SELECTOR (selector), priv->faces_model,
renderer, "family", 0, "text", 0, NULL);
hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, priv->current_face_index);
}
+
+static void
+body_insert_text (GtkTextBuffer *buffer,
+ GtkTextIter *location,
+ gchar *text,
+ gint len,
+ ModestMsgEditWindow *window)
+{
+ GtkTextIter end_iter;
+ gint offset;
+
+ gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (buffer), &end_iter);
+
+ offset = gtk_text_iter_get_offset (&end_iter);
+
+ if (offset + len > MAX_BODY_LENGTH) {
+ g_signal_stop_emission_by_name (G_OBJECT (buffer), "insert-text");
+ if (offset < MAX_BODY_LENGTH)
+ {
+ gchar *result;
+
+ /* Prevent endless recursion */
+ result = g_strndup (text, MAX_BODY_LENGTH - offset);
+ g_signal_handlers_block_by_func (G_OBJECT (buffer), G_CALLBACK (body_insert_text), window);
+ g_signal_emit_by_name (G_OBJECT (buffer), "insert-text", location,
+ (gpointer) result, (gpointer) MAX_BODY_LENGTH - offset,
+ (gpointer) window);
+ g_signal_handlers_unblock_by_func (G_OBJECT (buffer), G_CALLBACK (body_insert_text), window);
+ }
+
+ }
+ if (offset + len > MAX_BODY_LENGTH) {
+ hildon_banner_show_information (GTK_WIDGET (window), NULL,
+ _CS("ckdg_ib_maximum_characters_reached"));
+ }
+}
+
static void
subject_field_changed (GtkEditable *editable,
ModestMsgEditWindow *window)
modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (window));
modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (window));
}
-
static void
subject_field_insert_text (GtkEditable *editable,
gchar *new_text,
}
}
-static void
-from_field_changed (HildonPickerButton *button,
- ModestMsgEditWindow *self)
+static void update_signature (ModestMsgEditWindow *self,
+ const gchar *old_account,
+ const gchar *new_account)
{
ModestMsgEditWindowPrivate *priv;
gboolean has_old_signature, has_new_signature;
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
+ gtk_text_buffer_begin_user_action (priv->text_buffer);
+
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;
+
+
+ if (old_account) {
+ signature = modest_account_mgr_get_signature_from_recipient (mgr, old_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 (full_signature);
+ g_free (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);
+ signature = modest_account_mgr_get_signature_from_recipient (mgr, new_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);
+ gtk_text_buffer_end_user_action (priv->text_buffer);
+}
+
+static void
+from_field_changed (HildonPickerButton *button,
+ ModestMsgEditWindow *self)
+{
+ ModestMsgEditWindowPrivate *priv;
+ gchar *old_account, *new_account;
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
+
+ old_account = priv->last_from_account;
+ priv->last_from_account = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->from_field));
+ new_account = priv->last_from_account;
+
+ update_signature (self, old_account, new_account);
+
}
typedef struct _MessageSettingsHelper {
NULL);
g_signal_connect (G_OBJECT (priv->cc_button), "toggled",
G_CALLBACK (on_cc_button_toggled), (gpointer) self);
+ gtk_button_set_alignment (GTK_BUTTON (priv->cc_button), 0.5, 0.5);
+ gtk_button_set_alignment (GTK_BUTTON (priv->cc_button), 0.5, 0.5);
+
priv->bcc_button = hildon_check_button_new (0);
gtk_button_set_label (GTK_BUTTON (priv->bcc_button), _("mcen_me_editor_showbcc"));
hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->bcc_button),
NULL);
g_signal_connect (G_OBJECT (priv->bcc_button), "toggled",
G_CALLBACK (on_bcc_button_toggled), (gpointer) self);
+ gtk_button_set_alignment (GTK_BUTTON (priv->bcc_button), 0.5, 0.5);
+ gtk_button_set_alignment (GTK_BUTTON (priv->bcc_button), 0.5, 0.5);
modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_editor_attach_inlineimage"), NULL,
APP_MENU_CALLBACK (modest_ui_actions_on_insert_image),