#include "modest-tny-platform-factory.h"
#include "modest-tny-msg.h"
#include "modest-tny-folder.h"
+#include "modest-tny-account.h"
#include "modest-address-book.h"
#include "modest-text-utils.h"
#include <tny-simple-list.h>
#define IMAGE_MAX_WIDTH 560
#define DEFAULT_FONT_SCALE 1.5
+static gboolean is_wp_text_buffer_started = FALSE;
+
static void modest_msg_edit_window_class_init (ModestMsgEditWindowClass *klass);
static void modest_msg_edit_window_init (ModestMsgEditWindow *obj);
static void modest_msg_edit_window_finalize (GObject *obj);
static gboolean msg_body_focus (GtkWidget *focus, GdkEventFocus *event, gpointer userdata);
static void body_changed (GtkTextBuffer *buffer, ModestMsgEditWindow *editor);
static void recpt_field_changed (GtkTextBuffer *buffer, ModestMsgEditWindow *editor);
-static void reset_modified (ModestMsgEditWindow *editor);
static void text_buffer_refresh_attributes (WPTextBuffer *buffer, ModestMsgEditWindow *window);
static void text_buffer_can_undo (GtkTextBuffer *buffer, gboolean can_undo, ModestMsgEditWindow *window);
/* ModestWindow methods implementation */
static void modest_msg_edit_window_disconnect_signals (ModestWindow *window);
-static void modest_msg_edit_window_set_zoom (ModestWindow *window, gdouble zoom);
-static gdouble modest_msg_edit_window_get_zoom (ModestWindow *window);
-static gboolean modest_msg_edit_window_zoom_minus (ModestWindow *window);
-static gboolean modest_msg_edit_window_zoom_plus (ModestWindow *window);
static void modest_msg_edit_window_show_toolbar (ModestWindow *window,
gboolean show_toolbar);
static void modest_msg_edit_window_clipboard_owner_change (GtkClipboard *clipboard,
const gchar *str,
GtkTextIter *match_start,
GtkTextIter *match_end);
-
+
+static void remove_tags (WPTextBuffer *buffer);
+
+static void on_account_removed (TnyAccountStore *account_store,
+ TnyAccount *account,
+ gpointer user_data);
+
+static gboolean on_zoom_minus_plus_not_implemented (ModestWindow *window);
+
+static void init_window (ModestMsgEditWindow *obj);
+
static void DEBUG_BUFFER (WPTextBuffer *buffer)
{
#ifdef DEBUG
gint last_cid;
GList *attachments;
+ GList *images;
TnyHeaderFlags priority_flags;
-
- gdouble zoom_level;
gboolean can_undo, can_redo;
gulong clipboard_change_handler_id;
gulong default_clipboard_change_handler_id;
+ gulong account_removed_handler_id;
+ gchar *clipboard_text;
TnyMsg *draft_msg;
TnyMsg *outbox_msg;
"ModestMsgEditWindow",
&my_info, 0);
- wp_text_buffer_library_init ();
}
return my_type;
}
static void
restore_settings (ModestMsgEditWindow *self)
{
- modest_widget_memory_restore (modest_runtime_get_conf(),
+ ModestConf *conf = NULL;
+ GtkAction *action;
+ ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (self);
+
+ conf = modest_runtime_get_conf ();
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager,
+ "/MenuBar/ViewMenu/ShowToolbarMenu/ViewShowToolbarNormalScreenMenu");
+ modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ modest_conf_get_bool (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR, NULL));
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager,
+ "/MenuBar/ViewMenu/ShowToolbarMenu/ViewShowToolbarFullScreenMenu");
+ modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ modest_conf_get_bool (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR_FULLSCREEN, NULL));
+
+ /* set initial state of cc and bcc */
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ViewCcFieldMenu");
+ modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ modest_conf_get_bool(modest_runtime_get_conf(), MODEST_CONF_SHOW_CC, NULL));
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ViewBccFieldMenu");
+ modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ modest_conf_get_bool(modest_runtime_get_conf(), MODEST_CONF_SHOW_BCC, NULL));
+
+ /* Dim at start clipboard actions */
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/CutMenu");
+ gtk_action_set_sensitive (action, FALSE);
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/CopyMenu");
+ gtk_action_set_sensitive (action, FALSE);
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/AttachmentsMenu/RemoveAttachmentsMenu");
+ gtk_action_set_sensitive (action, FALSE);
+
+ modest_widget_memory_restore (conf,
G_OBJECT(self), MODEST_CONF_EDIT_WINDOW_KEY);
}
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = modest_msg_edit_window_finalize;
- modest_window_class->set_zoom_func = modest_msg_edit_window_set_zoom;
- modest_window_class->get_zoom_func = modest_msg_edit_window_get_zoom;
- modest_window_class->zoom_plus_func = modest_msg_edit_window_zoom_plus;
- modest_window_class->zoom_minus_func = modest_msg_edit_window_zoom_minus;
+ modest_window_class->zoom_plus_func = on_zoom_minus_plus_not_implemented;
+ modest_window_class->zoom_minus_func = on_zoom_minus_plus_not_implemented;
modest_window_class->show_toolbar_func = modest_msg_edit_window_show_toolbar;
modest_window_class->save_state_func = save_state;
modest_window_class->disconnect_signals_func = modest_msg_edit_window_disconnect_signals;
priv->bcc_field = NULL;
priv->subject_field = NULL;
priv->attachments = NULL;
+ priv->images = NULL;
priv->last_cid = 0;
- priv->zoom_level = 1.0;
priv->cc_caption = NULL;
priv->bcc_caption = NULL;
priv->can_redo = FALSE;
priv->clipboard_change_handler_id = 0;
priv->default_clipboard_change_handler_id = 0;
+ priv->account_removed_handler_id = 0;
+ priv->clipboard_text = NULL;
priv->sent = FALSE;
priv->last_vadj_upper = 0;
+
+ modest_window_mgr_register_help_id (modest_runtime_get_window_mgr(),
+ GTK_WINDOW(obj),"applications_email_editor");
+
+ if (!is_wp_text_buffer_started) {
+ is_wp_text_buffer_started = TRUE;
+ wp_text_buffer_library_init ();
+ }
+
+ init_window (obj);
}
static void
+connect_signals (ModestMsgEditWindow *obj)
+{
+ ModestMsgEditWindowPrivate *priv;
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(obj);
+
+ g_signal_connect (G_OBJECT (priv->text_buffer), "refresh_attributes",
+ G_CALLBACK (text_buffer_refresh_attributes), obj);
+ g_signal_connect (G_OBJECT (priv->text_buffer), "can-undo",
+ G_CALLBACK (text_buffer_can_undo), obj);
+ g_signal_connect (G_OBJECT (priv->text_buffer), "can-redo",
+ 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 (obj), "window-state-event",
+ G_CALLBACK (modest_msg_edit_window_window_state_event),
+ NULL);
+ g_signal_connect_after (G_OBJECT (priv->text_buffer), "apply-tag",
+ G_CALLBACK (text_buffer_apply_tag), obj);
+ g_signal_connect_swapped (G_OBJECT (priv->to_field), "open-addressbook",
+ G_CALLBACK (modest_msg_edit_window_open_addressbook), obj);
+ g_signal_connect_swapped (G_OBJECT (priv->cc_field), "open-addressbook",
+ G_CALLBACK (modest_msg_edit_window_open_addressbook), obj);
+ 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->add_attachment_button), "clicked",
+ G_CALLBACK (modest_msg_edit_window_add_attachment_clicked), obj);
+
+ g_signal_connect (G_OBJECT (priv->msg_body), "focus-in-event",
+ G_CALLBACK (msg_body_focus), obj);
+ g_signal_connect (G_OBJECT (priv->msg_body), "focus-out-event",
+ G_CALLBACK (msg_body_focus), obj);
+ g_signal_connect (G_OBJECT (modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR (priv->to_field))),
+ "changed", G_CALLBACK (recpt_field_changed), obj);
+ g_signal_connect (G_OBJECT (modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR (priv->cc_field))),
+ "changed", G_CALLBACK (recpt_field_changed), obj);
+ g_signal_connect (G_OBJECT (modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR (priv->bcc_field))),
+ "changed", G_CALLBACK (recpt_field_changed), obj);
+ g_signal_connect (G_OBJECT (priv->subject_field), "changed", G_CALLBACK (subject_field_changed), obj);
+ g_signal_connect_after (G_OBJECT (priv->subject_field), "move-cursor", G_CALLBACK (subject_field_move_cursor), obj);
+ g_signal_connect (G_OBJECT (priv->subject_field), "insert-text", G_CALLBACK (subject_field_insert_text), obj);
+
+ g_signal_connect (G_OBJECT (priv->find_toolbar), "close", G_CALLBACK (modest_msg_edit_window_find_toolbar_close), obj);
+ g_signal_connect (G_OBJECT (priv->find_toolbar), "search", G_CALLBACK (modest_msg_edit_window_find_toolbar_search), obj);
+
+ g_signal_connect (G_OBJECT (gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scroll))),
+ "changed",
+ G_CALLBACK (vadj_changed),
+ obj);
+
+ priv->clipboard_change_handler_id =
+ g_signal_connect (G_OBJECT (gtk_clipboard_get (GDK_SELECTION_PRIMARY)), "owner-change",
+ G_CALLBACK (modest_msg_edit_window_clipboard_owner_change), obj);
+ priv->default_clipboard_change_handler_id =
+ g_signal_connect (G_OBJECT (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD)), "owner-change",
+ G_CALLBACK (modest_msg_edit_window_clipboard_owner_change), obj);
+
+}
+
+static GtkWidget *
+menubar_to_menu (GtkUIManager *ui_manager)
+{
+ GtkWidget *main_menu;
+
+ /* Get the menubar from the UI manager */
+ main_menu = gtk_ui_manager_get_widget (ui_manager, "/MenuBar");
+
+ return main_menu;
+}
+
+static void
init_window (ModestMsgEditWindow *obj)
{
GtkWidget *from_caption, *to_caption, *subject_caption;
GtkWidget *main_vbox;
ModestMsgEditWindowPrivate *priv;
+ GtkActionGroup *action_group;
+ ModestWindowPrivate *parent_priv;
+ GdkPixbuf *window_icon = NULL;
+ GError *error = NULL;
GtkSizeGroup *size_group;
GtkWidget *frame;
GdkAtom deserialize_type;
#endif
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(obj);
+ parent_priv = MODEST_WINDOW_GET_PRIVATE (obj);
+
+ parent_priv->ui_manager = gtk_ui_manager_new();
+ action_group = gtk_action_group_new ("ModestMsgEditWindowActions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+
+ /* Add common actions */
+ gtk_action_group_add_actions (action_group,
+ modest_msg_edit_action_entries,
+ G_N_ELEMENTS (modest_msg_edit_action_entries),
+ obj);
+ gtk_action_group_add_toggle_actions (action_group,
+ modest_msg_edit_toggle_action_entries,
+ G_N_ELEMENTS (modest_msg_edit_toggle_action_entries),
+ obj);
+ gtk_action_group_add_radio_actions (action_group,
+ modest_msg_edit_alignment_radio_action_entries,
+ G_N_ELEMENTS (modest_msg_edit_alignment_radio_action_entries),
+ GTK_JUSTIFY_LEFT,
+ G_CALLBACK (modest_ui_actions_on_change_justify),
+ obj);
+ gtk_action_group_add_radio_actions (action_group,
+ modest_msg_edit_priority_action_entries,
+ G_N_ELEMENTS (modest_msg_edit_priority_action_entries),
+ 0,
+ G_CALLBACK (modest_ui_actions_msg_edit_on_change_priority),
+ obj);
+ gtk_action_group_add_radio_actions (action_group,
+ modest_msg_edit_file_format_action_entries,
+ G_N_ELEMENTS (modest_msg_edit_file_format_action_entries),
+ modest_conf_get_bool (modest_runtime_get_conf (), MODEST_CONF_PREFER_FORMATTED_TEXT, NULL),
+ G_CALLBACK (modest_ui_actions_msg_edit_on_change_file_format),
+ obj);
+ gtk_ui_manager_insert_action_group (parent_priv->ui_manager, action_group, 0);
+ g_object_unref (action_group);
+
+ /* Load the UI definition */
+ gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager, MODEST_UIDIR "modest-msg-edit-window-ui.xml",
+ &error);
+ if (error != NULL) {
+ g_warning ("Could not merge modest-msg-edit-window-ui.xml: %s", error->message);
+ g_clear_error (&error);
+ }
+
+ /* Add accelerators */
+ gtk_window_add_accel_group (GTK_WINDOW (obj),
+ gtk_ui_manager_get_accel_group (parent_priv->ui_manager));
+
+ parent_priv->menubar = NULL;
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
/* Note: This ModestPairList* must exist for as long as the combo
* that uses it, because the ModestComboBox uses the ID opaquely,
* so it can't know how to manage its memory. */
- priv->from_field_protos = get_transports ();
-
- priv->from_field = modest_combo_box_new (priv->from_field_protos, g_str_equal);
+ priv->from_field = modest_combo_box_new (NULL, g_str_equal);
priv->to_field = modest_recpt_editor_new ();
priv->cc_field = modest_recpt_editor_new ();
/* g_signal_connect (G_OBJECT (obj), "key_pressed", G_CALLBACK (on_key_pressed), NULL) */
- g_signal_connect (G_OBJECT (priv->text_buffer), "refresh_attributes",
- G_CALLBACK (text_buffer_refresh_attributes), obj);
- g_signal_connect (G_OBJECT (priv->text_buffer), "can-undo",
- G_CALLBACK (text_buffer_can_undo), obj);
- g_signal_connect (G_OBJECT (priv->text_buffer), "can-redo",
- 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 (obj), "window-state-event",
- G_CALLBACK (modest_msg_edit_window_window_state_event),
- NULL);
- g_signal_connect_after (G_OBJECT (priv->text_buffer), "apply-tag",
- G_CALLBACK (text_buffer_apply_tag), obj);
- g_signal_connect_swapped (G_OBJECT (priv->to_field), "open-addressbook",
- G_CALLBACK (modest_msg_edit_window_open_addressbook), obj);
- g_signal_connect_swapped (G_OBJECT (priv->cc_field), "open-addressbook",
- G_CALLBACK (modest_msg_edit_window_open_addressbook), obj);
- 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->add_attachment_button), "clicked",
- G_CALLBACK (modest_msg_edit_window_add_attachment_clicked), obj);
-
- g_signal_connect (G_OBJECT (priv->msg_body), "focus-in-event",
- G_CALLBACK (msg_body_focus), obj);
- g_signal_connect (G_OBJECT (priv->msg_body), "focus-out-event",
- G_CALLBACK (msg_body_focus), obj);
- g_signal_connect (G_OBJECT (modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR (priv->to_field))),
- "changed", G_CALLBACK (recpt_field_changed), obj);
- g_signal_connect (G_OBJECT (modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR (priv->cc_field))),
- "changed", G_CALLBACK (recpt_field_changed), obj);
- g_signal_connect (G_OBJECT (modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR (priv->bcc_field))),
- "changed", G_CALLBACK (recpt_field_changed), obj);
- g_signal_connect (G_OBJECT (priv->subject_field), "changed", G_CALLBACK (subject_field_changed), obj);
- g_signal_connect_after (G_OBJECT (priv->subject_field), "move-cursor", G_CALLBACK (subject_field_move_cursor), obj);
- g_signal_connect (G_OBJECT (priv->subject_field), "insert-text", G_CALLBACK (subject_field_insert_text), obj);
-
- g_signal_connect (G_OBJECT (priv->find_toolbar), "close", G_CALLBACK (modest_msg_edit_window_find_toolbar_close), obj);
- g_signal_connect (G_OBJECT (priv->find_toolbar), "search", G_CALLBACK (modest_msg_edit_window_find_toolbar_search), obj);
-
priv->scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->scroll), GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER(obj), window_box);
priv->scroll_area = modest_scroll_area_new (priv->scroll, priv->msg_body);
gtk_container_add (GTK_CONTAINER (frame), priv->scroll_area);
-
- priv->clipboard_change_handler_id = g_signal_connect (G_OBJECT (gtk_clipboard_get (GDK_SELECTION_PRIMARY)), "owner-change",
- G_CALLBACK (modest_msg_edit_window_clipboard_owner_change), obj);
- priv->default_clipboard_change_handler_id = g_signal_connect (G_OBJECT (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD)), "owner-change",
- G_CALLBACK (modest_msg_edit_window_clipboard_owner_change), obj);
+
+ /* Set window icon */
+ window_icon = modest_platform_get_icon (MODEST_APP_MSG_EDIT_ICON);
+ if (window_icon) {
+ gtk_window_set_icon (GTK_WINDOW (obj), window_icon);
+ g_object_unref (window_icon);
+ }
}
priv->default_clipboard_change_handler_id))
g_signal_handler_disconnect (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD),
priv->default_clipboard_change_handler_id);
+
+ if (priv->account_removed_handler_id &&
+ g_signal_handler_is_connected (modest_runtime_get_account_store (),
+ priv->account_removed_handler_id))
+ g_signal_handler_disconnect(modest_runtime_get_account_store (),
+ priv->account_removed_handler_id);
}
static void
/* Sanity check: shouldn't be needed, the window mgr should
call this function before */
modest_msg_edit_window_disconnect_signals (MODEST_WINDOW (obj));
+
+ if (priv->clipboard_text != NULL) {
+ g_free (priv->clipboard_text);
+ priv->clipboard_text = NULL;
+ }
if (priv->draft_msg != NULL) {
TnyHeader *header = tny_msg_get_header (priv->draft_msg);
g_object_unref (priv->outbox_msg);
priv->outbox_msg = NULL;
}
- if (priv->msg_uid != NULL) {
- g_free (priv->msg_uid);
- priv->msg_uid = NULL;
- }
+ g_free (priv->msg_uid);
+ g_free (priv->last_search);
+ g_slist_free (priv->font_items_group);
+ g_slist_free (priv->size_items_group);
+ g_list_foreach (priv->attachments, (GFunc) g_object_unref, NULL);
+ g_list_free (priv->attachments);
+ g_list_foreach (priv->images, (GFunc) g_object_unref, NULL);
+ g_list_free (priv->images);
/* This had to stay alive for as long as the combobox that used it: */
modest_pair_list_free (priv->from_field_protos);
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
-static GtkWidget *
-menubar_to_menu (GtkUIManager *ui_manager)
-{
- GtkWidget *main_menu;
- GtkWidget *menubar;
- GList *iter;
-
- /* Create new main menu */
- main_menu = gtk_menu_new();
-
- /* Get the menubar from the UI manager */
- menubar = gtk_ui_manager_get_widget (ui_manager, "/MenuBar");
-
- iter = gtk_container_get_children (GTK_CONTAINER (menubar));
- while (iter) {
- GtkWidget *menu;
-
- menu = GTK_WIDGET (iter->data);
- gtk_widget_reparent(menu, main_menu);
-
- iter = g_list_next (iter);
- }
- return main_menu;
-}
-
static GdkPixbuf *
pixbuf_from_stream (TnyStream *stream, const gchar *mime_type)
{
}
static void
-replace_with_attachments (ModestMsgEditWindow *self, GList *attachments)
+replace_with_images (ModestMsgEditWindow *self, GList *attachments)
{
ModestMsgEditWindowPrivate *priv;
GList *node;
g_object_unref (stream);
if (pixbuf != NULL) {
-/* wp_text_buffer_replace_image (WP_TEXT_BUFFER (priv->text_buffer), cid, pixbuf); */
+ wp_text_buffer_replace_image (WP_TEXT_BUFFER (priv->text_buffer), cid, pixbuf);
g_object_unref (pixbuf);
}
}
}
static void
+get_related_images (ModestMsgEditWindow *self, TnyMsg *msg)
+{
+ TnyMimePart *parent = NULL;
+ const gchar *content_type = NULL;
+ ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
+
+ content_type = tny_mime_part_get_content_type (TNY_MIME_PART (msg));
+
+ if (content_type && !g_strcasecmp (content_type, "multipart/related")) {
+ parent = g_object_ref (msg);
+ } else if (content_type && !g_strcasecmp (content_type, "multipart/mixed")) {
+ TnyList *parts = TNY_LIST (tny_simple_list_new ());
+ TnyIterator *iter;
+
+ tny_mime_part_get_parts (TNY_MIME_PART (msg), parts);
+ iter = tny_list_create_iterator (parts);
+ while (!tny_iterator_is_done (iter)) {
+ TnyMimePart *part;
+ part = TNY_MIME_PART (tny_iterator_get_current (iter));
+ content_type = tny_mime_part_get_content_type (part);
+ if (content_type && !g_strcasecmp (content_type, "multipart/related")) {
+ parent = part;
+ break;
+ } else {
+ g_object_unref (part);
+ }
+ tny_iterator_next (iter);
+ }
+ g_object_unref (iter);
+ g_object_unref (parts);
+ }
+
+ if (parent != NULL) {
+ TnyList *parts = TNY_LIST (tny_simple_list_new ());
+ TnyIterator *iter;
+
+ tny_mime_part_get_parts (TNY_MIME_PART (parent), parts);
+ iter = tny_list_create_iterator (parts);
+ while (!tny_iterator_is_done (iter)) {
+ TnyMimePart *part;
+ part = TNY_MIME_PART (tny_iterator_get_current (iter));
+ content_type = tny_mime_part_get_content_type (part);
+ if (content_type && g_str_has_prefix (content_type, "image/")) {
+ priv->images = g_list_prepend (priv->images, part);
+ } else {
+ g_object_unref (part);
+ }
+ tny_iterator_next (iter);
+ }
+ g_object_unref (iter);
+ g_object_unref (parts);
+ g_object_unref (parent);
+ }
+}
+
+static void
update_last_cid (ModestMsgEditWindow *self, GList *attachments)
{
GList *node;
cc = tny_header_get_cc (header);
bcc = tny_header_get_bcc (header);
subject = tny_header_get_subject (header);
- priority_flags = tny_header_get_flags (header) & TNY_HEADER_FLAG_PRIORITY;
+ priority_flags = tny_header_get_priority (header);
if (to)
modest_recpt_editor_set_recipients (MODEST_RECPT_EDITOR (priv->to_field), to);
wp_text_buffer_load_document_end (WP_TEXT_BUFFER (priv->text_buffer));
g_free (body);
+ /* Add attachments to the view */
+ modest_attachments_view_set_message (MODEST_ATTACHMENTS_VIEW (priv->attachments_view), msg);
+ priv->attachments = modest_attachments_view_get_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view));
+ if (priv->attachments == NULL) {
+ gtk_widget_hide (priv->attachments_caption);
+ } else {
+ gtk_widget_set_no_show_all (priv->attachments_caption, FALSE);
+ gtk_widget_show_all (priv->attachments_caption);
+ }
+ get_related_images (self, msg);
+ update_last_cid (self, priv->attachments);
+ update_last_cid (self, priv->images);
+ replace_with_images (self, priv->images);
+
if (preserve_is_rich && !is_html) {
wp_text_buffer_enable_rich_text (WP_TEXT_BUFFER (priv->text_buffer), FALSE);
/* Get the default format required from configuration */
value that comes from msg <- not sure, should it be
allowed? */
- /* Add attachments to the view */
- modest_attachments_view_set_message (MODEST_ATTACHMENTS_VIEW (priv->attachments_view), msg);
- priv->attachments = modest_attachments_view_get_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view));
- if (priv->attachments == NULL) {
- gtk_widget_hide (priv->attachments_caption);
- } else {
- gtk_widget_set_no_show_all (priv->attachments_caption, FALSE);
- gtk_widget_show_all (priv->attachments_caption);
- replace_with_attachments (self, priv->attachments);
- }
- update_last_cid (self, priv->attachments);
-
DEBUG_BUFFER (WP_TEXT_BUFFER (priv->text_buffer));
gtk_text_buffer_get_start_iter (priv->text_buffer, &iter);
gtk_text_buffer_place_cursor (priv->text_buffer, &iter);
- reset_modified (self);
+ modest_msg_edit_window_reset_modified (self);
modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (self));
text_buffer_can_undo (priv->text_buffer, FALSE, self);
if (msg_folder) {
if (modest_tny_folder_is_local_folder (msg_folder)) {
TnyFolderType type = modest_tny_folder_get_local_or_mmc_folder_type (msg_folder);
+ if (type == TNY_FOLDER_TYPE_INVALID)
+ g_warning ("%s: BUG: TNY_FOLDER_TYPE_INVALID", __FUNCTION__);
+
if (type == TNY_FOLDER_TYPE_DRAFTS)
priv->draft_msg = g_object_ref(msg);
if (type == TNY_FOLDER_TYPE_OUTBOX)
ModestWindow*
-modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean preserve_is_rich)
-{
- GObject *obj;
- ModestWindowPrivate *parent_priv;
- ModestMsgEditWindowPrivate *priv;
- GtkActionGroup *action_group;
- GError *error = NULL;
- GdkPixbuf *window_icon = NULL;
- GtkAction *action;
- ModestConf *conf;
- ModestPair *account_pair = NULL;
- ModestDimmingRulesGroup *menu_rules_group = NULL;
- ModestDimmingRulesGroup *toolbar_rules_group = NULL;
- ModestDimmingRulesGroup *clipboard_rules_group = NULL;
-
- g_return_val_if_fail (msg, NULL);
- g_return_val_if_fail (account_name, NULL);
-
- obj = g_object_new(MODEST_TYPE_MSG_EDIT_WINDOW, NULL);
-
- priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (obj);
- parent_priv = MODEST_WINDOW_GET_PRIVATE (obj);
-
- parent_priv->ui_manager = gtk_ui_manager_new();
- action_group = gtk_action_group_new ("ModestMsgEditWindowActions");
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
-
- /* Add common actions */
- gtk_action_group_add_actions (action_group,
- modest_msg_edit_action_entries,
- G_N_ELEMENTS (modest_msg_edit_action_entries),
- obj);
- gtk_action_group_add_toggle_actions (action_group,
- modest_msg_edit_toggle_action_entries,
- G_N_ELEMENTS (modest_msg_edit_toggle_action_entries),
- obj);
- gtk_action_group_add_radio_actions (action_group,
- modest_msg_edit_alignment_radio_action_entries,
- G_N_ELEMENTS (modest_msg_edit_alignment_radio_action_entries),
- GTK_JUSTIFY_LEFT,
- G_CALLBACK (modest_ui_actions_on_change_justify),
- obj);
- gtk_action_group_add_radio_actions (action_group,
- modest_msg_edit_zoom_action_entries,
- G_N_ELEMENTS (modest_msg_edit_zoom_action_entries),
- 100,
- G_CALLBACK (modest_ui_actions_on_change_zoom),
- obj);
- gtk_action_group_add_radio_actions (action_group,
- modest_msg_edit_priority_action_entries,
- G_N_ELEMENTS (modest_msg_edit_priority_action_entries),
- 0,
- G_CALLBACK (modest_ui_actions_msg_edit_on_change_priority),
- obj);
- gtk_action_group_add_radio_actions (action_group,
- modest_msg_edit_file_format_action_entries,
- G_N_ELEMENTS (modest_msg_edit_file_format_action_entries),
- modest_conf_get_bool (modest_runtime_get_conf (), MODEST_CONF_PREFER_FORMATTED_TEXT, NULL),
- G_CALLBACK (modest_ui_actions_msg_edit_on_change_file_format),
- obj);
- gtk_ui_manager_insert_action_group (parent_priv->ui_manager, action_group, 0);
- g_object_unref (action_group);
+modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean preserve_is_rich)
+{
+ GObject *obj;
+ ModestWindowPrivate *parent_priv;
+ ModestMsgEditWindowPrivate *priv;
+ ModestPair *account_pair = NULL;
+ ModestDimmingRulesGroup *menu_rules_group = NULL;
+ ModestDimmingRulesGroup *toolbar_rules_group = NULL;
+ ModestDimmingRulesGroup *clipboard_rules_group = NULL;
+ ModestWindowMgr *mgr = NULL;
- /* Load the UI definition */
- gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager, MODEST_UIDIR "modest-msg-edit-window-ui.xml",
- &error);
- if (error != NULL) {
- g_warning ("Could not merge modest-msg-edit-window-ui.xml: %s", error->message);
- g_clear_error (&error);
- }
+ g_return_val_if_fail (msg, NULL);
+ g_return_val_if_fail (account_name, NULL);
- /* Add accelerators */
- gtk_window_add_accel_group (GTK_WINDOW (obj),
- gtk_ui_manager_get_accel_group (parent_priv->ui_manager));
+ mgr = modest_runtime_get_window_mgr ();
+
+ obj = G_OBJECT (modest_window_mgr_get_msg_edit_window (mgr));
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (obj);
+ parent_priv = MODEST_WINDOW_GET_PRIVATE (obj);
/* Menubar. Update the state of some toggles */
parent_priv->menubar = menubar_to_menu (parent_priv->ui_manager);
- conf = modest_runtime_get_conf ();
- action = gtk_ui_manager_get_action (parent_priv->ui_manager,
- "/MenuBar/ViewMenu/ShowToolbarMenu/ViewShowToolbarNormalScreenMenu");
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
- modest_conf_get_bool (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR, NULL));
- action = gtk_ui_manager_get_action (parent_priv->ui_manager,
- "/MenuBar/ViewMenu/ShowToolbarMenu/ViewShowToolbarFullScreenMenu");
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
- modest_conf_get_bool (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR_FULLSCREEN, NULL));
-
hildon_window_set_menu (HILDON_WINDOW (obj), GTK_MENU (parent_priv->menubar));
+ priv->from_field_protos = get_transports ();
+ modest_combo_box_set_pair_list (MODEST_COMBO_BOX (priv->from_field), priv->from_field_protos);
+ modest_msg_edit_window_setup_toolbar (MODEST_MSG_EDIT_WINDOW (obj));
+ hildon_window_add_toolbar (HILDON_WINDOW (obj), GTK_TOOLBAR (priv->find_toolbar));
/* Init window */
- init_window (MODEST_MSG_EDIT_WINDOW(obj));
+ connect_signals (MODEST_MSG_EDIT_WINDOW(obj));
restore_settings (MODEST_MSG_EDIT_WINDOW(obj));
modest_window_set_active_account (MODEST_WINDOW(obj), account_name);
- modest_msg_edit_window_setup_toolbar (MODEST_MSG_EDIT_WINDOW (obj));
- hildon_window_add_toolbar (HILDON_WINDOW (obj), GTK_TOOLBAR (priv->find_toolbar));
-
account_pair = modest_pair_list_find_by_first_as_string (priv->from_field_protos, account_name);
if (account_pair != NULL)
modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->from_field), account_pair->first);
text_buffer_refresh_attributes (WP_TEXT_BUFFER (priv->text_buffer), MODEST_MSG_EDIT_WINDOW (obj));
- /* Set window icon */
- window_icon = modest_platform_get_icon (MODEST_APP_MSG_EDIT_ICON);
- if (window_icon) {
- gtk_window_set_icon (GTK_WINDOW (obj), window_icon);
- g_object_unref (window_icon);
- }
-
modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (obj));
- modest_window_check_dimming_rules_group (MODEST_WINDOW (obj), "ModestClipboardDimmingRules");
-
- /* Dim at start clipboard actions */
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/CutMenu");
- gtk_action_set_sensitive (action, FALSE);
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/CopyMenu");
- gtk_action_set_sensitive (action, FALSE);
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/AttachmentsMenu/RemoveAttachmentsMenu");
- gtk_action_set_sensitive (action, FALSE);
-
- /* set initial state of cc and bcc */
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ViewCcFieldMenu");
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
- modest_conf_get_bool(modest_runtime_get_conf(), MODEST_CONF_SHOW_CC, NULL));
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ViewBccFieldMenu");
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
- modest_conf_get_bool(modest_runtime_get_conf(), MODEST_CONF_SHOW_BCC, NULL));
-
modest_window_check_dimming_rules_group (MODEST_WINDOW (obj), "ModestClipboardDimmingRules");
priv->update_caption_visibility = TRUE;
- reset_modified (MODEST_MSG_EDIT_WINDOW (obj));
+ modest_msg_edit_window_reset_modified (MODEST_MSG_EDIT_WINDOW (obj));
+
+ /* Track account-removed signal, this window should be closed
+ in the case we're creating a mail associated to the account
+ that is deleted */
+ priv->account_removed_handler_id =
+ g_signal_connect (G_OBJECT (modest_runtime_get_account_store ()),
+ "account_removed",
+ G_CALLBACK(on_account_removed),
+ obj);
return (ModestWindow*) obj;
}
g_object_ref (cursor->data));
cursor = g_list_next (cursor);
}
+
+ GtkTextTagTable *tag_table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (priv->text_buffer));
+ cursor = priv->images;
+ data->images = NULL;
+ while (cursor) {
+ const gchar *cid;
+ if (!(TNY_IS_MIME_PART(cursor->data))) {
+ g_warning ("strange data in attachment list");
+ cursor = g_list_next (cursor);
+ continue;
+ }
+ cid = tny_mime_part_get_content_id (cursor->data);
+ if (cid) {
+ gchar *image_tag_id;
+ GtkTextTag *image_tag;
+ GtkTextIter iter;
+ image_tag_id = g_strdup_printf ("image-tag-%s", cid);
+ image_tag = gtk_text_tag_table_lookup (tag_table, image_tag_id);
+ g_free (image_tag_id);
+
+ gtk_text_buffer_get_start_iter (priv->text_buffer, &iter);
+ if (image_tag &&
+ ((gtk_text_iter_has_tag (&iter, image_tag))||
+ (gtk_text_iter_forward_to_tag_toggle (&iter, image_tag))))
+ data->images = g_list_append (data->images,
+ g_object_ref (cursor->data));
+ }
+ cursor = g_list_next (cursor);
+ }
data->priority_flags = priv->priority_flags;
g_free (data->to);
g_free (data->cc);
g_free (data->bcc);
+ g_free (data->from);
g_free (data->subject);
g_free (data->plain_body);
g_free (data->html_body);
g_list_foreach (data->attachments, (GFunc)unref_gobject, NULL);
g_list_free (data->attachments);
+ g_list_foreach (data->images, (GFunc)unref_gobject, NULL);
+ g_list_free (data->images);
g_slice_free (MsgData, data);
}
}
-
+#ifdef MODEST_HILDON_VERSION_0
void
modest_msg_edit_window_select_color (ModestMsgEditWindow *window)
{
ModestMsgEditWindowPrivate *priv;
GtkWidget *dialog = NULL;
gint response;
- const GdkColor *new_color = NULL;
-
+ GdkColor *new_color = NULL;
+
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
wp_text_buffer_get_attributes (WP_TEXT_BUFFER (priv->text_buffer), buffer_format, FALSE);
-#ifdef MODEST_HILDON_VERSION_0
dialog = hildon_color_selector_new (GTK_WINDOW (window));
hildon_color_selector_set_color (HILDON_COLOR_SELECTOR (dialog), &(buffer_format->color));
-#else
- dialog = hildon_color_chooser_new ();
- hildon_color_chooser_set_color (HILDON_COLOR_CHOOSER (dialog), &(buffer_format->color));
-#endif /*MODEST_HILDON_VERSION_0*/
g_free (buffer_format);
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- switch (response) {
- case GTK_RESPONSE_OK: {
-#ifdef MODEST_HILDON_VERSION_0
+ if (gtk_dialog_run (GTK_DIALOG (dialog) == GTK_RESPONSE_OK)) {
new_color = hildon_color_selector_get_color (HILDON_COLOR_SELECTOR (dialog));
-#else
- GdkColor col;
- hildon_color_chooser_get_color (HILDON_COLOR_CHOOSER(dialog), &col);
- new_color = &col;
-#endif /*MODEST_HILDON_VERSION_0*/
- }
-
- break;
- default:
- break;
+ if (new_color != NULL) {
+ wp_text_buffer_set_attribute (WP_TEXT_BUFFER (priv->text_buffer), WPT_FORECOLOR,
+ (gpointer) new_color);
+ }
}
gtk_widget_destroy (dialog);
-
- if (new_color != NULL)
- wp_text_buffer_set_attribute (WP_TEXT_BUFFER (priv->text_buffer), WPT_FORECOLOR, (gpointer) new_color);
-
}
+
void
modest_msg_edit_window_select_background_color (ModestMsgEditWindow *window)
{
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
old_color = (GdkColor*)wp_text_buffer_get_background_color (WP_TEXT_BUFFER (priv->text_buffer));
-#ifdef MODEST_HILDON_VERSION_0
dialog = hildon_color_selector_new (GTK_WINDOW (window));
hildon_color_selector_set_color (HILDON_COLOR_SELECTOR (dialog),(GdkColor*)old_color);
-#else
- dialog = hildon_color_chooser_new ();
- hildon_color_chooser_set_color (HILDON_COLOR_CHOOSER (dialog),(GdkColor*)old_color);
-#endif /*MODEST_HILDON_VERSION_9*/
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- switch (response) {
- case GTK_RESPONSE_OK: {
-#ifdef MODEST_HILDON_VERSION_0
+ if (gtk_dialog_run (GTK_DIALOG (dialog) == GTK_RESPONSE_OK)) {
new_color = hildon_color_selector_get_color (HILDON_COLOR_SELECTOR (dialog));
-#else
+ if (new_color != NULL)
+ wp_text_buffer_set_background_color (WP_TEXT_BUFFER (priv->text_buffer), new_color);
+ }
+ gtk_widget_destroy (dialog);
+
+}
+
+#else
+void
+modest_msg_edit_window_select_color (ModestMsgEditWindow *window)
+{
+
+ WPTextBufferFormat *buffer_format = g_new0 (WPTextBufferFormat, 1);
+ ModestMsgEditWindowPrivate *priv;
+ GtkWidget *dialog = NULL;
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+ wp_text_buffer_get_attributes (WP_TEXT_BUFFER (priv->text_buffer), buffer_format, FALSE);
+
+ dialog = hildon_color_chooser_new ();
+ hildon_color_chooser_set_color (HILDON_COLOR_CHOOSER (dialog), &(buffer_format->color));
+ g_free (buffer_format);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
GdkColor col;
hildon_color_chooser_get_color (HILDON_COLOR_CHOOSER(dialog), &col);
- new_color = &col;
-#endif /*MODEST_HILDON_VERSION_0*/
- }
- break;
- default:
- break;
+ wp_text_buffer_set_attribute (WP_TEXT_BUFFER (priv->text_buffer), WPT_FORECOLOR,
+ (gpointer) &col);
}
gtk_widget_destroy (dialog);
+}
+
- if (new_color != NULL)
- wp_text_buffer_set_background_color (WP_TEXT_BUFFER (priv->text_buffer), new_color);
+void
+modest_msg_edit_window_select_background_color (ModestMsgEditWindow *window)
+{
+
+ ModestMsgEditWindowPrivate *priv;
+ GtkWidget *dialog = NULL;
+ GdkColor *old_color = NULL;
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+ old_color = (GdkColor*)wp_text_buffer_get_background_color (WP_TEXT_BUFFER (priv->text_buffer));
+
+ dialog = hildon_color_chooser_new ();
+ hildon_color_chooser_set_color (HILDON_COLOR_CHOOSER (dialog),(GdkColor*)old_color);
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
+ GdkColor col;
+ hildon_color_chooser_get_color (HILDON_COLOR_CHOOSER(dialog), &col);
+ wp_text_buffer_set_background_color (WP_TEXT_BUFFER (priv->text_buffer), &col);
+ }
+ gtk_widget_destroy (dialog);
}
+#endif /*!MODEST_HILDON_VERSION_0*/
+
+
+
static TnyStream* create_stream_for_uri (const gchar* uri)
{
if (!uri)
wp_text_buffer_insert_image (WP_TEXT_BUFFER (priv->text_buffer), &position, g_strdup (tny_mime_part_get_content_id (mime_part)), pixbuf);
}
- priv->attachments = g_list_prepend (priv->attachments, mime_part);
- modest_attachments_view_add_attachment (MODEST_ATTACHMENTS_VIEW (priv->attachments_view),
- mime_part);
- gtk_widget_set_no_show_all (priv->attachments_caption, FALSE);
- gtk_widget_show_all (priv->attachments_caption);
+ priv->images = g_list_prepend (priv->images, mime_part);
gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
g_free (filename);
void
modest_msg_edit_window_offer_attach_file (ModestMsgEditWindow *window)
-{
-
- ModestMsgEditWindowPrivate *priv;
+{
GtkWidget *dialog = NULL;
gint response = 0;
GSList *uris = NULL;
GSList *uri_node;
- priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
-
dialog = hildon_file_chooser_dialog_new (GTK_WINDOW (window), GTK_FILE_CHOOSER_ACTION_OPEN);
gtk_window_set_title (GTK_WINDOW (dialog), _("mcen_ti_select_attachment_title"));
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
tny_mime_part_set_filename (mime_part, basename);
g_free (basename);
- priv->attachments = g_list_prepend (priv->attachments, mime_part);
+ priv->attachments = g_list_prepend (priv->attachments, g_object_ref(mime_part));
modest_attachments_view_add_attachment (MODEST_ATTACHMENTS_VIEW (priv->attachments_view),
mime_part);
gtk_widget_set_no_show_all (priv->attachments_caption, FALSE);
gboolean dialog_response;
GList *node;
gchar *message = NULL;
- const gchar *filename = NULL;
+ gchar *filename = NULL;
if (att_list->next == NULL) {
- filename = tny_mime_part_get_filename (TNY_MIME_PART (att_list->data));
+ if (TNY_IS_MSG (att_list->data)) {
+ TnyHeader *header = tny_msg_get_header (TNY_MSG (att_list->data));
+ if (header) {
+ filename = g_strdup (tny_header_get_subject (header));
+ g_object_unref (header);
+ }
+ if (filename == NULL) {
+ filename = g_strdup (_("mail_va_no_subject"));
+ }
+ } else {
+ filename = g_strdup (tny_mime_part_get_filename (TNY_MIME_PART (att_list->data)));
+ }
} else {
- filename = "";
+ filename = g_strdup ("");
}
message = g_strdup_printf (ngettext("emev_nc_delete_attachment", "emev_nc_delete_attachments",
att_list->next == NULL), filename);
+ g_free (filename);
confirmation_dialog = hildon_note_new_confirmation (GTK_WINDOW (window), message);
g_free (message);
dialog_response = (gtk_dialog_run (GTK_DIALOG (confirmation_dialog))==GTK_RESPONSE_OK);
}
}
-static void
-modest_msg_edit_window_set_zoom (ModestWindow *window,
- gdouble zoom)
-{
- ModestMsgEditWindowPrivate *priv;
- ModestWindowPrivate *parent_priv;
- GtkRadioAction *zoom_radio_action;
-
- g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
-
- priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
- parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
- priv->zoom_level = zoom;
- wp_text_buffer_set_font_scaling_factor (WP_TEXT_BUFFER (priv->text_buffer), zoom*DEFAULT_FONT_SCALE);
-
- /* Zoom level menu options should be updated with the current zoom level */
- parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
- zoom_radio_action = GTK_RADIO_ACTION (gtk_ui_manager_get_action (parent_priv->ui_manager,
- "/MenuBar/ViewMenu/ZoomMenu/Zoom50Menu"));
-#ifdef MODEST_HAVE_HILDON0_WIDGETS
- /* FIXME: Not availible before Gtk 2.10 */
-#else
- gtk_radio_action_set_current_value (zoom_radio_action, (gint) (zoom*100.0+0.1));
-#endif
-}
-
-static gdouble
-modest_msg_edit_window_get_zoom (ModestWindow *window)
-{
- ModestMsgEditWindowPrivate *priv;
-
- g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window), 1.0);
-
- priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
- return priv->zoom_level;
-}
-
-static gboolean
-zoom_allowed (ModestMsgEditWindow *window)
-{
- GtkWidget *focus;
-
- focus = gtk_window_get_focus (GTK_WINDOW (window));
- return (focus != NULL && WP_IS_TEXT_VIEW (focus));
-}
-
-static gboolean
-modest_msg_edit_window_zoom_plus (ModestWindow *window)
-{
- ModestWindowPrivate *parent_priv;
- GtkRadioAction *zoom_radio_action;
- GSList *group, *node;
-
- /* First we check if the text view is focused. If not, zooming is not allowed */
- if (!zoom_allowed (MODEST_MSG_EDIT_WINDOW (window))) {
- hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ckct_ib_cannot_zoom_here"));
- return FALSE;
- }
-
- parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
- zoom_radio_action = GTK_RADIO_ACTION (gtk_ui_manager_get_action (parent_priv->ui_manager,
- "/MenuBar/ViewMenu/ZoomMenu/Zoom50Menu"));
-
- group = gtk_radio_action_get_group (zoom_radio_action);
-
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (group->data))) {
- hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ckct_ib_max_zoom_level_reached"));
- return FALSE;
- }
-
- for (node = group; node != NULL; node = g_slist_next (node)) {
- if ((node->next != NULL) && gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (node->next->data))) {
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (node->data), TRUE);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-static gboolean
-modest_msg_edit_window_zoom_minus (ModestWindow *window)
-{
- ModestWindowPrivate *parent_priv;
- GtkRadioAction *zoom_radio_action;
- GSList *group, *node;
-
- /* First we check if the text view is focused. If not, zooming is not allowed */
- if (!zoom_allowed (MODEST_MSG_EDIT_WINDOW (window))) {
- hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ckct_ib_cannot_zoom_here"));
- return FALSE;
- }
-
- parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
- zoom_radio_action = GTK_RADIO_ACTION (gtk_ui_manager_get_action (parent_priv->ui_manager,
- "/MenuBar/ViewMenu/ZoomMenu/Zoom50Menu"));
-
- group = gtk_radio_action_get_group (zoom_radio_action);
-
- for (node = group; node != NULL; node = g_slist_next (node)) {
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (node->data))) {
- if (node->next != NULL) {
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (node->next->data), TRUE);
- return TRUE;
- } else
- hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ckct_ib_min_zoom_level_reached"));
- break;
- }
- }
- return FALSE;
-}
-
static gboolean
modest_msg_edit_window_window_state_event (GtkWidget *widget, GdkEventWindowState *event, gpointer userdata)
{
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
- priority_flags = priority_flags & (TNY_HEADER_FLAG_PRIORITY);
if (priv->priority_flags != priority_flags) {
GtkAction *priority_action = NULL;
switch (file_format) {
case MODEST_FILE_FORMAT_FORMATTED_TEXT:
wp_text_buffer_enable_rich_text (WP_TEXT_BUFFER (priv->text_buffer), TRUE);
+ remove_tags (WP_TEXT_BUFFER (priv->text_buffer));
break;
case MODEST_FILE_FORMAT_PLAIN_TEXT:
{
/* First we get the currently selected font information */
wp_text_buffer_get_attributes (WP_TEXT_BUFFER (priv->text_buffer), &oldfmt, TRUE);
- g_object_set (G_OBJECT (dialog), "font-scaling", priv->zoom_level, NULL);
switch (oldfmt.text_position) {
case TEXT_POSITION_NORMAL:
fmt.cs.font_size = TRUE;
}
wp_text_buffer_set_format(WP_TEXT_BUFFER(priv->text_buffer), &fmt);
+ text_buffer_refresh_attributes (WP_TEXT_BUFFER (priv->text_buffer), window);
}
gtk_widget_destroy (dialog);
modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (editor));
}
-static void
-reset_modified (ModestMsgEditWindow *editor)
+void
+modest_msg_edit_window_reset_modified (ModestMsgEditWindow *editor)
{
ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (editor);
GtkTextBuffer *buffer;
modest_msg_edit_window_offer_attach_file (window);
}
+const gchar *
+modest_msg_edit_window_get_clipboard_text (ModestMsgEditWindow *win)
+{
+ ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (win);
+
+ return priv->clipboard_text;
+}
+
static void
modest_msg_edit_window_clipboard_owner_change (GtkClipboard *clipboard,
GdkEvent *event,
ModestMsgEditWindow *window)
{
+ ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+ GtkClipboard *selection_clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+ gchar *text = NULL;
if (!GTK_WIDGET_VISIBLE (window))
return;
+ text = gtk_clipboard_wait_for_text (selection_clipboard);
+
+ if (priv->clipboard_text != NULL) {
+ g_free (priv->clipboard_text);
+ }
+ priv->clipboard_text = text;
+
modest_window_check_dimming_rules_group (MODEST_WINDOW (window), "ModestClipboardDimmingRules");
}
static void
GString *result = g_string_new ("");
gchar *current;
gint result_len = 0;
+ const gchar *entry_text = NULL;
+ gint old_length;
+
+ entry_text = gtk_entry_get_text (GTK_ENTRY (editable));
+ old_length = g_utf8_strlen (entry_text, -1);
for (current = new_text; current != NULL && *current != '\0'; current = g_utf8_next_char (current)) {
gunichar c = g_utf8_get_char_validated (current, 8);
g_signal_handlers_unblock_by_func(G_OBJECT(editable), G_CALLBACK(subject_field_insert_text), window);
}
}
+
+ if (result_len + old_length > 1000) {
+ hildon_banner_show_information (GTK_WIDGET (window), NULL,
+ dgettext("hildon-common-strings",
+ "ckdg_ib_maximum_characters_reached"));
+ }
g_string_free (result, TRUE);
}
ModestWindowMgr *mgr = modest_runtime_get_window_mgr ();
if (priv->draft_msg != NULL) {
- header = tny_msg_get_header (priv->draft_msg);
- if (TNY_IS_HEADER (header)) {
- modest_window_mgr_unregister_header (mgr, header);
- }
g_object_unref (priv->draft_msg);
}
if (draft != NULL) {
g_object_ref (draft);
header = tny_msg_get_header (draft);
- if (TNY_IS_HEADER (header))
- modest_window_mgr_register_header (mgr, header);
if (priv->msg_uid) {
g_free (priv->msg_uid);
priv->msg_uid = NULL;
}
priv->msg_uid = modest_tny_folder_get_header_unique_id (header);
+ if (GTK_WIDGET_REALIZED (window))
+ modest_window_mgr_register_window (mgr, MODEST_WINDOW (window));
}
priv->draft_msg = draft;
if (tag == NULL+13) return;
g_object_get (G_OBJECT (tag), "name", &tag_name, NULL);
if ((tag_name != NULL) && (g_str_has_prefix (tag_name, "image-tag-replace-"))) {
- replace_with_attachments (window, priv->attachments);
+ replace_with_images (window, priv->images);
}
}
return NULL;
}
}
+
+static void
+remove_tags (WPTextBuffer *buffer)
+{
+ GtkTextIter start, end;
+
+ gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (buffer), &start);
+ gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (buffer), &end);
+
+ gtk_text_buffer_remove_all_tags (GTK_TEXT_BUFFER (buffer), &start, &end);
+}
+
+static void
+on_account_removed (TnyAccountStore *account_store,
+ TnyAccount *account,
+ gpointer user_data)
+{
+ /* Do nothing if it's a store account, because we use the
+ transport to send the messages */
+ if (tny_account_get_account_type(account) == TNY_ACCOUNT_TYPE_TRANSPORT) {
+ const gchar *parent_acc = NULL;
+ const gchar *our_acc = NULL;
+
+ our_acc = modest_window_get_active_account (MODEST_WINDOW (user_data));
+ parent_acc = modest_tny_account_get_parent_modest_account_name_for_server_account (account);
+ /* Close this window if I'm showing a message of the removed account */
+ if (strcmp (parent_acc, our_acc) == 0)
+ modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (user_data));
+ }
+}
+
+static gboolean
+on_zoom_minus_plus_not_implemented (ModestWindow *window)
+{
+ g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window), FALSE);
+
+ hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ckct_ib_cannot_zoom_here"));
+ return FALSE;
+
+}