static void update_signature (ModestMsgEditWindow *self,
const gchar *old_account,
const gchar *new_account);
+static void update_branding (ModestMsgEditWindow *self,
+ const gchar *new_account);
static GtkWidget *_create_addressbook_box (GtkSizeGroup *title_size_group, GtkSizeGroup *value_size_group,
const gchar *label, GtkWidget *control);
+static void max_chars_banner_unref (ModestMsgEditWindow *self, GObject *old_ref);
static void DEBUG_BUFFER (WPTextBuffer *buffer)
{
#ifdef DEBUG
GtkTextIter iter;
- g_message ("BEGIN BUFFER OF SIZE %d", gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (buffer)));
+ g_debug ("BEGIN BUFFER OF SIZE %d", gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (buffer)));
gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (buffer), &iter);
while (!gtk_text_iter_is_end (&iter)) {
g_string_append (output, " ");
}
output = g_string_append (output, "]\n");
- g_message ("%s", output->str);
+ g_debug ("%s", output->str);
g_string_free (output, TRUE);
gtk_text_iter_forward_to_tag_toggle (&iter, NULL);
}
- g_message ("END BUFFER");
+ g_debug ("END BUFFER");
#endif
}
GtkWidget *app_menu;
GtkWidget *cc_button;
GtkWidget *bcc_button;
+
+ GtkWidget *max_chars_banner;
+
+ GtkWidget *brand_icon;
+ GtkWidget *brand_label;
+ GtkWidget *brand_container;
};
#define MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
priv->references = NULL;
priv->in_reply_to = NULL;
+ priv->max_chars_banner = NULL;
if (!is_wp_text_buffer_started) {
is_wp_text_buffer_started = TRUE;
g_signal_connect_swapped (G_OBJECT (priv->bcc_field), "open-addressbook",
G_CALLBACK (modest_msg_edit_window_open_addressbook), obj);
+ g_signal_connect (G_OBJECT (priv->send_button), "clicked",
+ G_CALLBACK (modest_ui_actions_on_send), obj);
+
g_signal_connect (G_OBJECT (priv->from_field), "value-changed",
G_CALLBACK (from_field_changed), obj);
GtkWidget *from_send_hbox;
GtkWidget *send_icon;
GtkWidget *attachments_label;
+ GtkWidget *branding_box;
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(obj);
parent_priv = MODEST_WINDOW_GET_PRIVATE (obj);
g_object_unref (title_size_group);
g_object_unref (value_size_group);
+ priv->brand_icon = gtk_image_new ();
+ gtk_misc_set_alignment (GTK_MISC (priv->brand_icon), 0.5, 0.5);
+ priv->brand_label = gtk_label_new (NULL);
+ hildon_helper_set_logical_font (priv->brand_label, "SmallSystemFont");
+ gtk_misc_set_alignment (GTK_MISC (priv->brand_label), 0.0, 0.5);
+ gtk_widget_set_no_show_all (priv->brand_icon, TRUE);
+ gtk_widget_set_no_show_all (priv->brand_label, TRUE);
+
from_send_hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (from_send_hbox), priv->from_field, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (from_send_hbox), priv->send_button, FALSE, FALSE, 0);
+ branding_box = gtk_hbox_new (FALSE, MODEST_MARGIN_DEFAULT);
+ gtk_widget_show (branding_box);
+ gtk_box_pack_start (GTK_BOX (branding_box), priv->brand_label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (branding_box), priv->brand_icon, FALSE, FALSE, 0);
+
+ priv->brand_container = gtk_alignment_new (0.0, 0.5, 0.0, 1.0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (priv->brand_container), 0, 0, MODEST_MARGIN_DOUBLE, 0);
+ gtk_container_add (GTK_CONTAINER (priv->brand_container), branding_box);
+ gtk_widget_set_no_show_all (priv->brand_container, TRUE);
+
+
gtk_box_pack_start (GTK_BOX (priv->header_box), from_send_hbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (priv->header_box), to_caption, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (priv->header_box), priv->cc_caption, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (priv->header_box), priv->bcc_caption, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (priv->header_box), subject_caption, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (priv->header_box), priv->attachments_caption, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->header_box), priv->brand_container, FALSE, FALSE, 0);
gtk_widget_set_no_show_all (priv->attachments_caption, TRUE);
init_wp_text_view_style ();
modest_msg_edit_window_finalize (GObject *obj)
{
ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (obj);
-
+
+ if (priv->max_chars_banner) {
+ g_object_weak_unref (G_OBJECT (priv->max_chars_banner), (GWeakNotify) max_chars_banner_unref, obj);
+ priv->max_chars_banner = FALSE;
+ }
+
/* Sanity check: shouldn't be needed, the window mgr should
call this function before */
modest_msg_edit_window_disconnect_signals (MODEST_WINDOW (obj));
g_free (priv->last_search);
g_free (priv->references);
g_free (priv->in_reply_to);
- g_object_unref (priv->faces_model);
- g_object_unref (priv->sizes_model);
g_object_unref (priv->attachments);
g_object_unref (priv->images);
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));
+ update_branding (MODEST_MSG_EDIT_WINDOW (obj), priv->last_from_account);
hildon_button_set_title (HILDON_BUTTON (priv->from_field),
_("mail_va_from"));
hildon_button_set_value (HILDON_BUTTON (priv->from_field),
modest_msg_edit_window_attach_file_one (window, uri, allowed_size);
if (total_size > allowed_size) {
- g_warning ("%s: total size: %u",
+ g_debug ("%s: total size: %u",
__FUNCTION__, (unsigned int)total_size);
break;
}
info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) {
size = info->size;
if (size > allowed_size) {
- modest_platform_information_banner (NULL, NULL,
- _FM("sfil_ib_opening_not_allowed"));
+ modest_platform_information_banner (NULL, NULL,
+ _("mail_ib_error_attachment_size"));
g_free (filename);
return 0;
}
} else
- g_warning ("%s: could not get attachment size", __FUNCTION__);
+ g_debug ("%s: could not get attachment size", __FUNCTION__);
stream = create_stream_for_uri (uri);
g_object_unref (att_list);
return;
}
-
} else {
g_object_ref (att_list);
}
g_object_unref (att_list);
/* if the last attachment has been removed, focus the Subject: field */
- if (!modest_attachments_view_has_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view)))
+ if (!modest_attachments_view_has_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view)))
gtk_widget_grab_focus (priv->subject_field);
}
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
if (editor == NULL) {
- GtkWidget *view_focus;
+ GtkWidget *view_focus, *parent;
view_focus = gtk_window_get_focus (GTK_WINDOW (window));
/* This code should be kept in sync with ModestRecptEditor. The
hbox recpt editor inherits from, we'll need to go up in the
hierarchy to know if the text view is part of the recpt editor
or if it's a different text entry */
-
- if (gtk_widget_get_parent (view_focus)) {
- GtkWidget *first_parent;
-
- first_parent = gtk_widget_get_parent (view_focus);
- if (gtk_widget_get_parent (first_parent) &&
- MODEST_IS_RECPT_EDITOR (gtk_widget_get_parent (first_parent))) {
- editor = MODEST_RECPT_EDITOR (gtk_widget_get_parent (first_parent));
- }
- }
+ parent = gtk_widget_get_parent (view_focus);
+ if (parent && MODEST_IS_RECPT_EDITOR (parent))
+ editor = MODEST_RECPT_EDITOR (parent);
if (editor == NULL)
editor = MODEST_RECPT_EDITOR (priv->to_field);
-
}
- modest_address_book_select_addresses (editor);
-
+ modest_address_book_select_addresses (editor, GTK_WINDOW (window));
}
void
{
GtkTextIter end_iter;
gint offset;
+ glong utf8_len;
+
+ ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (buffer), &end_iter);
offset = gtk_text_iter_get_offset (&end_iter);
+ utf8_len = g_utf8_strlen (text, len);
- if (offset + len > MAX_BODY_LENGTH) {
+ if (offset + utf8_len > MAX_BODY_LENGTH) {
g_signal_stop_emission_by_name (G_OBJECT (buffer), "insert-text");
if (offset < MAX_BODY_LENGTH)
{
gchar *result;
+ gchar *utf8_end;
+
+ utf8_end = g_utf8_offset_to_pointer (text, MAX_BODY_LENGTH - offset);
/* Prevent endless recursion */
- result = g_strndup (text, MAX_BODY_LENGTH - offset);
+ result = g_strndup (text, utf8_end - text);
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) result, (gpointer) (utf8_end - text),
(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"));
+ if (offset + utf8_len > MAX_BODY_LENGTH) {
+ if (priv->max_chars_banner == NULL) {
+ priv->max_chars_banner = hildon_banner_show_information (GTK_WIDGET (window), NULL,
+ _CS("ckdg_ib_maximum_characters_reached"));
+ g_object_weak_ref (G_OBJECT (priv->max_chars_banner), (GWeakNotify) max_chars_banner_unref, window);
+ }
}
}
result = TRUE;
if (!gtk_text_iter_forward_search (iter, found_text, GTK_TEXT_SEARCH_VISIBLE_ONLY|GTK_TEXT_SEARCH_TEXT_ONLY,
match_start, match_end, NULL)) {
- g_warning ("Matched string with collate, but not matched in model");
+ g_debug ("Matched string with collate, but not matched in model");
}
g_free (found_text);
}
}
}
-static void update_signature (ModestMsgEditWindow *self,
- const gchar *old_account,
- const gchar *new_account)
+static void
+update_signature (ModestMsgEditWindow *self,
+ const gchar *old_account,
+ const gchar *new_account)
{
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);
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)) {
+ GtkTextIter match_start, match_end;
+ /* We cannot use
+ MODEST_TEXT_UTILS_SIGNATURE_MARKER as it
+ seems that the search has some problems
+ with the blank space at the end */
+ if (gtk_text_iter_forward_search (&iter, "--",
+ GTK_TEXT_SEARCH_TEXT_ONLY,
+ &match_start, NULL, NULL)) {
+ gtk_text_buffer_get_end_iter (priv->text_buffer ,&match_end);
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_from_recipient (mgr, new_account, &has_new_signature);
if (has_new_signature) {
- full_signature = g_strconcat ("\n--\n", signature, NULL);
+ gchar *full_signature = g_strconcat (MODEST_TEXT_UTILS_SIGNATURE_MARKER, "\n",
+ signature, NULL);
gtk_text_buffer_insert (priv->text_buffer, &iter, full_signature, -1);
g_free (full_signature);
}
gtk_text_buffer_end_user_action (priv->text_buffer);
}
+static void update_branding (ModestMsgEditWindow *self,
+ const gchar *new_account)
+{
+ ModestMsgEditWindowPrivate *priv;
+ ModestAccountMgr *mgr;
+ const GdkPixbuf *new_icon = NULL;
+ gchar *new_label = NULL;
+ gboolean show = FALSE;
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
+
+ mgr = modest_runtime_get_account_mgr ();
+
+ modest_account_mgr_get_branding_from_recipient (mgr, new_account, &new_label, &new_icon, MODEST_ICON_SIZE_SMALL);
+ if (new_icon) {
+ gtk_image_set_from_pixbuf (GTK_IMAGE (priv->brand_icon), (GdkPixbuf *) new_icon);
+ gtk_widget_show (priv->brand_icon);
+ show = TRUE;
+ } else {
+ gtk_widget_hide (priv->brand_icon);
+ }
+ if (new_label) {
+ gtk_label_set_text (GTK_LABEL (priv->brand_label), new_label);
+ gtk_widget_show (priv->brand_label);
+ g_free (new_label);
+ show = TRUE;
+ } else {
+ gtk_widget_hide (priv->brand_label);
+ }
+
+ if (show)
+ gtk_widget_show (priv->brand_container);
+ else
+ gtk_widget_hide (priv->brand_container);
+}
+
static void
from_field_changed (HildonPickerButton *button,
ModestMsgEditWindow *self)
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;
+ new_account = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->from_field));
+
+ if (!new_account) {
+ g_warning ("%s, could not get the new account", __FUNCTION__);
+ return;
+ }
+
+ /* If the From is the same do nothing */
+ if (old_account && new_account && !strcmp (old_account, new_account))
+ return;
+
+ priv->last_from_account = new_account;
update_signature (self, old_account, new_account);
+ update_branding (self, new_account);
}
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);
+ modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
+ GTK_WINDOW (dialog), GTK_WINDOW (window));
+
/* Save settings if the user clicked on done */
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
TnyHeaderFlags flags;
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),
MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_set_style));
- modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("TODO: add attachment"), NULL,
+ modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_editor_add_attachment"), NULL,
APP_MENU_CALLBACK (modest_msg_edit_window_add_attachment_clicked),
NULL);
modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_remove_attachments"), NULL,
box = gtk_hbox_new (FALSE, 0);
- align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
+ align = gtk_alignment_new (0.0, 0.0, 1.0, 0.0);
gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, 0, MODEST_MARGIN_DEFAULT);
abook_button = hildon_gtk_button_new (HILDON_SIZE_FINGER_HEIGHT);
return box;
}
+
+static void
+max_chars_banner_unref (ModestMsgEditWindow *self, GObject *old_ref)
+{
+ ModestMsgEditWindowPrivate *priv = NULL;
+
+ g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(self));
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
+ priv->max_chars_banner = NULL;
+}