#include <tny-account-store.h>
#include <tny-fs-stream.h>
#include <tny-vfs-stream.h>
+#include <tny-camel-mem-stream.h>
#include <config.h>
static void modest_msg_edit_window_clipboard_owner_change (GtkClipboard *clipboard,
GdkEvent *event,
ModestMsgEditWindow *window);
+static void modest_msg_edit_window_clipboard_owner_handle_change_in_idle (ModestMsgEditWindow *window);
static void subject_field_move_cursor (GtkEntry *entry,
GtkMovementStep step,
gint a1,
gboolean scroll_drag_timeout (gpointer userdata);
static void correct_scroll (ModestMsgEditWindow *w);
-static void correct_scroll_without_drag_check (ModestMsgEditWindow *w);
+static void correct_scroll_without_drag_check (ModestMsgEditWindow *w, gboolean only_if_focused);
static void text_buffer_end_user_action (GtkTextBuffer *buffer,
ModestMsgEditWindow *userdata);
static void text_buffer_mark_set (GtkTextBuffer *buffer,
void vadj_changed (GtkAdjustment *adj,
ModestMsgEditWindow *window);
-
-
-
-
static void DEBUG_BUFFER (WPTextBuffer *buffer)
{
#ifdef DEBUG
ModestPairList *from_field_protos;
GtkWidget *from_field;
+ gchar *original_account_name;
GtkWidget *to_field;
GtkWidget *cc_field;
GtkWidget *scroll;
guint scroll_drag_timeout_id;
+ gdouble last_upper;
- gint last_cid;
+ gint next_cid;
TnyList *attachments;
TnyList *images;
guint64 images_size;
gulong clipboard_change_handler_id;
gulong default_clipboard_change_handler_id;
gulong account_removed_handler_id;
+ guint clipboard_owner_idle;
gchar *clipboard_text;
TnyMsg *draft_msg;
priv->images = TNY_LIST (tny_simple_list_new ());
priv->images_size = 0;
priv->images_count = 0;
- priv->last_cid = 0;
+ priv->next_cid = 0;
priv->cc_caption = NULL;
priv->bcc_caption = NULL;
priv->clipboard_change_handler_id = 0;
priv->default_clipboard_change_handler_id = 0;
priv->account_removed_handler_id = 0;
+ priv->clipboard_owner_idle = 0;
priv->clipboard_text = NULL;
priv->sent = FALSE;
priv->scroll_drag_timeout_id = 0;
+ priv->last_upper = 0.0;
modest_window_mgr_register_help_id (modest_runtime_get_window_mgr(),
GTK_WINDOW(obj),"applications_email_editor");
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(win);
- correct_scroll_without_drag_check (win);
+ correct_scroll_without_drag_check (win, TRUE);
priv->scroll_drag_timeout_id = 0;
}
static void
-correct_scroll_without_drag_check (ModestMsgEditWindow *w)
+correct_scroll_without_drag_check (ModestMsgEditWindow *w, gboolean only_if_focused)
{
ModestMsgEditWindowPrivate *priv;
GtkTextMark *insert;
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(w);
+ if (only_if_focused && !gtk_widget_is_focus (priv->msg_body))
+ return;
+
insert = gtk_text_buffer_get_insert (priv->text_buffer);
gtk_text_buffer_get_iter_at_mark (priv->text_buffer, &iter, insert);
if ((offset + rectangle.y + rectangle.height) >
((gint) (vadj->value +vadj->page_size))) {
- new_value = (offset + rectangle.y) + vadj->page_size * 0.75;
+ new_value = (offset + rectangle.y) - vadj->page_size * 0.25;
if (new_value > vadj->upper - vadj->page_size)
new_value = vadj->upper - vadj->page_size;
} else if ((offset + rectangle.y) < ((gint) vadj->value)) {
return;
}
- correct_scroll_without_drag_check (w);
+ correct_scroll_without_drag_check (w, TRUE);
}
static void
gtk_text_buffer_end_user_action (buffer);
}
+static void
+cut_clipboard_check (GtkTextView *text_view,
+ gpointer userdata)
+{
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (text_view);
+ if (!modest_text_utils_buffer_selection_is_valid (buffer)) {
+ g_signal_stop_emission_by_name ((gpointer )text_view, "cut-clipboard");
+ }
+}
+
+static void
+copy_clipboard_check (GtkTextView *text_view,
+ gpointer userdata)
+{
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (text_view);
+ if (!modest_text_utils_buffer_selection_is_valid (buffer)) {
+ g_signal_stop_emission_by_name ((gpointer )text_view, "copy-clipboard");
+ }
+}
+
void vadj_changed (GtkAdjustment *adj,
ModestMsgEditWindow *window)
{
- correct_scroll (window);
+ ModestMsgEditWindowPrivate *priv;
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+
+ if (priv->last_upper != adj->upper) {
+ priv->last_upper = adj->upper;
+ correct_scroll (window);
+ }
}
static void
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), "modified-changed",
+ G_CALLBACK (body_changed), obj);
g_signal_connect (G_OBJECT (priv->text_buffer), "insert-text",
G_CALLBACK (text_buffer_insert_text), obj);
g_signal_connect (G_OBJECT (obj), "window-state-event",
g_signal_connect (G_OBJECT (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD)), "owner-change",
G_CALLBACK (modest_msg_edit_window_clipboard_owner_change), obj);
+ g_signal_connect (G_OBJECT (priv->msg_body), "cut-clipboard", G_CALLBACK (cut_clipboard_check), NULL);
+ g_signal_connect (G_OBJECT (priv->msg_body), "copy-clipboard", G_CALLBACK (copy_clipboard_check), NULL);
+
}
static void
g_source_remove (priv->scroll_drag_timeout_id);
priv->scroll_drag_timeout_id = 0;
}
+ if (priv->clipboard_owner_idle > 0) {
+ g_source_remove (priv->clipboard_owner_idle);
+ priv->clipboard_owner_idle = 0;
+ }
+ if (priv->original_account_name)
+ g_free (priv->original_account_name);
g_free (priv->msg_uid);
g_free (priv->last_search);
g_slist_free (priv->font_items_group);
tny_stream_reset (TNY_STREAM (stream));
while (!tny_stream_is_eos (TNY_STREAM (stream))) {
+ GError *error = NULL;
unsigned char read_buffer[128];
gint readed;
readed = tny_stream_read (TNY_STREAM (stream), (char *) read_buffer, 128);
size += readed;
- if (!gdk_pixbuf_loader_write (loader, read_buffer, readed, NULL))
+ if (!gdk_pixbuf_loader_write (loader, read_buffer, readed, &error)) {
break;
+ }
}
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
- g_object_ref (pixbuf);
+ if (pixbuf)
+ g_object_ref (pixbuf);
gdk_pixbuf_loader_close (loader, NULL);
g_object_unref (loader);
+ if (!pixbuf)
+ return NULL;
+
if (gdk_pixbuf_get_width (pixbuf) > IMAGE_MAX_WIDTH) {
GdkPixbuf *new_pixbuf;
gint new_height;
const gchar *mime_type = tny_mime_part_get_content_type (part);
if ((cid != NULL)&&(mime_type != NULL)) {
guint64 stream_size;
- TnyStream *stream = tny_mime_part_get_stream (part);
+ TnyStream *stream = tny_mime_part_get_decoded_stream (part);
GdkPixbuf *pixbuf = pixbuf_from_stream (stream, mime_type, &stream_size);
}
g_object_unref (part);
}
+ g_object_unref (iter);
}
static void
}
static void
-update_last_cid (ModestMsgEditWindow *self, TnyList *attachments)
+update_next_cid (ModestMsgEditWindow *self, TnyList *attachments)
{
TnyIterator *iter;
ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
if (cid != NULL) {
char *invalid = NULL;
gint int_cid = strtol (cid, &invalid, 10);
- if ((invalid != NULL) && (*invalid == '\0') && (int_cid > priv->last_cid)) {
- priv->last_cid = int_cid;
+ if ((invalid != NULL) && (*invalid == '\0') && (int_cid >= priv->next_cid)) {
+ priv->next_cid = int_cid + 1;
}
}
g_object_unref (part);
}
+ g_object_unref (iter);
}
static void
set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich)
{
TnyHeader *header;
- const gchar *to, *cc, *bcc, *subject;
+ gchar *to, *cc, *bcc, *subject;
gchar *body;
ModestMsgEditWindowPrivate *priv;
GtkTextIter iter;
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
header = tny_msg_get_header (msg);
- to = tny_header_get_to (header);
- cc = tny_header_get_cc (header);
- bcc = tny_header_get_bcc (header);
- subject = tny_header_get_subject (header);
+ to = tny_header_dup_to (header);
+ cc = tny_header_dup_cc (header);
+ bcc = tny_header_dup_bcc (header);
+ subject = tny_header_dup_subject (header);
priority_flags = tny_header_get_priority (header);
if (to)
gtk_widget_show_all (priv->attachments_caption);
}
get_related_images (self, msg);
- update_last_cid (self, priv->attachments);
- update_last_cid (self, priv->images);
+ update_next_cid (self, priv->attachments);
+ update_next_cid (self, priv->images);
replace_with_images (self, priv->images);
if (preserve_is_rich && !is_html) {
gtk_text_buffer_get_start_iter (priv->text_buffer, &iter);
gtk_text_buffer_place_cursor (priv->text_buffer, &iter);
- modest_msg_edit_window_reset_modified (self);
+ modest_msg_edit_window_set_modified (self, FALSE);
modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (self));
modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self));
}
g_object_unref (msg_folder);
}
+
+ g_free (to);
+ g_free (subject);
+ g_free (cc);
+ g_free (bcc);
}
static void
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;
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_combo_box_set_active_id (MODEST_COMBO_BOX (priv->from_field), (gpointer) 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));
modest_window_set_active_account (MODEST_WINDOW(obj), account_name);
- 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);
+ priv->original_account_name = (account_name) ? g_strdup (account_name) : NULL;
parent_priv->ui_dimming_manager = modest_ui_dimming_manager_new ();
menu_rules_group = modest_dimming_rules_group_new (MODEST_DIMMING_RULES_MENU, FALSE);
g_object_unref (menu_rules_group);
g_object_unref (toolbar_rules_group);
g_object_unref (clipboard_rules_group);
- gtk_widget_show_all (GTK_WIDGET (obj));
-
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));
modest_window_check_dimming_rules_group (MODEST_WINDOW (obj), MODEST_DIMMING_RULES_CLIPBOARD);
priv->update_caption_visibility = TRUE;
- modest_msg_edit_window_reset_modified (MODEST_MSG_EDIT_WINDOW (obj));
+ modest_msg_edit_window_set_modified (MODEST_MSG_EDIT_WINDOW (obj), FALSE);
/* Track account-removed signal, this window should be closed
in the case we're creating a mail associated to the account
"account_removed",
G_CALLBACK(on_account_removed),
obj);
-
+
+ modest_msg_edit_window_clipboard_owner_handle_change_in_idle (MODEST_MSG_EDIT_WINDOW (obj));
+
return (ModestWindow*) obj;
}
g_object_unref (part);
tny_iterator_next (att_iter);
}
+ g_object_unref (att_iter);
data->priority_flags = priv->priority_flags;
switch (buffer_format->justification)
{
case GTK_JUSTIFY_LEFT:
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/AlignmentLeftMenu");
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/AlignmentMenu/AlignmentLeftMenu");
break;
case GTK_JUSTIFY_CENTER:
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/AlignmentCenterMenu");
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/AlignmentMenu/AlignmentCenterMenu");
break;
case GTK_JUSTIFY_RIGHT:
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/AlignmentRightMenu");
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/AlignmentMenu/AlignmentRightMenu");
break;
default:
break;
-static TnyStream* create_stream_for_uri (const gchar* uri)
+static TnyStream*
+create_stream_for_uri (const gchar* uri)
{
if (!uri)
return NULL;
GnomeVFSHandle *handle = NULL;
GnomeVFSResult test = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ);
if (test == GNOME_VFS_OK) {
- /* Create the tinymail stream: */
- /* Presumably tinymai will call gnome_vfs_close (handle) later. */
- result = TNY_STREAM (tny_vfs_stream_new (handle));
+ TnyStream *vfssstream = TNY_STREAM (tny_vfs_stream_new (handle));
+ /* Streams over OBEX (Bluetooth) are not seekable but
+ * we expect them to be (we might need to read them
+ * several times). So if this is a Bluetooth URI just
+ * read the whole file into memory (this is not a fast
+ * protocol so we can assume that these files are not
+ * going to be very big) */
+ if ((g_ascii_strncasecmp (uri, "obex://", 7) == 0)||
+ (g_ascii_strncasecmp (uri, "upnpav://", 9) == 0)) {
+ TnyStream *memstream = tny_camel_mem_stream_new ();
+ tny_stream_write_to_stream (vfssstream, memstream);
+ g_object_unref (vfssstream);
+ result = memstream;
+ } else {
+ result = vfssstream;
+ }
}
return result;
result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ);
if (result == GNOME_VFS_OK) {
GdkPixbuf *pixbuf;
- GnomeVFSFileInfo info;
+ GnomeVFSFileInfo *info;
gchar *filename, *basename, *escaped_filename;
TnyMimePart *mime_part;
gchar *content_id;
GnomeVFSURI *vfs_uri;
guint64 stream_size;
+ gnome_vfs_close (handle);
vfs_uri = gnome_vfs_uri_new (uri);
escaped_filename = g_path_get_basename (gnome_vfs_uri_get_path (vfs_uri));
filename = gnome_vfs_unescape_string_for_display (escaped_filename);
g_free (escaped_filename);
gnome_vfs_uri_unref (vfs_uri);
+ info = gnome_vfs_file_info_new ();
- if (gnome_vfs_get_file_info (uri, &info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE
+ if (gnome_vfs_get_file_info (uri, info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE
| GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE)
== GNOME_VFS_OK)
- mime_type = gnome_vfs_file_info_get_mime_type (&info);
+ mime_type = gnome_vfs_file_info_get_mime_type (info);
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"));
+
+ 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->last_cid);
+ content_id = g_strdup_printf ("%d", priv->next_cid);
tny_mime_part_set_content_id (mime_part, content_id);
g_free (content_id);
- priv->last_cid++;
+ priv->next_cid++;
basename = g_path_get_basename (filename);
tny_mime_part_set_filename (mime_part, basename);
gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
g_free (filename);
g_object_unref (mime_part);
+ gnome_vfs_file_info_unref (info);
}
}
gint response = 0;
GSList *uris = NULL;
GSList *uri_node;
+ GnomeVFSFileSize total_size, allowed_size;
+ ModestMsgEditWindowPrivate *priv;
+ gint att_num;
+ guint64 att_size;
+
+ g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(window));
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+
+ if (modest_platform_check_memory_low (MODEST_WINDOW(window)))
+ return;
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);
+ modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog));
response = gtk_dialog_run (GTK_DIALOG (dialog));
switch (response) {
}
gtk_widget_destroy (dialog);
+ /* allowed size is the maximum size - what's already there */
+ modest_attachments_view_get_sizes (
+ MODEST_ATTACHMENTS_VIEW (priv->attachments_view),
+ &att_num, &att_size);
+ allowed_size = MODEST_MAX_ATTACHMENT_SIZE - att_size;
+
+ total_size = 0;
for (uri_node = uris; uri_node != NULL; uri_node = g_slist_next (uri_node)) {
+
const gchar *uri = (const gchar *) uri_node->data;
- modest_msg_edit_window_attach_file_one (window, uri);
+
+ total_size += modest_msg_edit_window_attach_file_one
+ (window, uri, allowed_size);
+
+ if (total_size > allowed_size) {
+ g_warning ("%s: total size: %u",
+ __FUNCTION__, (unsigned int)total_size);
+ break;
+ }
+
+ allowed_size -= total_size;
+
+
}
g_slist_foreach (uris, (GFunc) g_free, NULL);
g_slist_free (uris);
}
-void
-modest_msg_edit_window_attach_file_one (
- ModestMsgEditWindow *window,
- const gchar *uri)
+
+GnomeVFSFileSize
+modest_msg_edit_window_attach_file_one (ModestMsgEditWindow *window,
+ const gchar *uri,
+ GnomeVFSFileSize allowed_size)
+
{
- g_return_if_fail (window);
- g_return_if_fail (uri);
+ GnomeVFSHandle *handle = NULL;
+ ModestMsgEditWindowPrivate *priv;
+ GnomeVFSResult result;
+ GnomeVFSFileSize size = 0;
+
+ g_return_val_if_fail (window, 0);
+ g_return_val_if_fail (uri, 0);
- ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
-
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
- GnomeVFSHandle *handle = NULL;
- GnomeVFSResult result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ);
+ result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ);
if (result == GNOME_VFS_OK) {
TnyMimePart *mime_part;
TnyStream *stream;
gchar *escaped_filename;
gchar *filename;
gchar *content_id;
- GnomeVFSFileInfo info;
+ GnomeVFSFileInfo *info;
GnomeVFSURI *vfs_uri;
+ gnome_vfs_close (handle);
vfs_uri = gnome_vfs_uri_new (uri);
filename = gnome_vfs_unescape_string_for_display (escaped_filename);
g_free (escaped_filename);
gnome_vfs_uri_unref (vfs_uri);
+
+ info = gnome_vfs_file_info_new ();
if (gnome_vfs_get_file_info (uri,
- &info,
+ info,
GNOME_VFS_FILE_INFO_GET_MIME_TYPE)
== GNOME_VFS_OK)
- mime_type = gnome_vfs_file_info_get_mime_type (&info);
+ mime_type = gnome_vfs_file_info_get_mime_type (info);
mime_part = tny_platform_factory_new_mime_part
(modest_runtime_get_platform_factory ());
- stream = TNY_STREAM (tny_vfs_stream_new (handle));
- tny_mime_part_construct (mime_part, stream, mime_type, "base64");
+ /* try to get the attachment's size; this may fail for weird
+ * file systems, like obex, upnp... */
+ if (allowed_size != 0 &&
+ info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) {
+ size = info->size;
+ if (size > allowed_size) {
+ g_warning ("%s: attachment too big", __FUNCTION__);
+ modest_platform_information_banner (NULL, NULL, dgettext("hildon-fm", "sfil_ib_opening_not_allowed"));
+ return 0;
+ }
+ } else
+ g_warning ("%s: could not get attachment size", __FUNCTION__);
+
+ stream = create_stream_for_uri (uri);
+
+ if (stream == NULL) {
+
+ modest_platform_information_banner (NULL, NULL, dgettext("hildon-fm", "sfil_ib_opening_not_allowed"));
+ g_object_unref (mime_part);
+ gnome_vfs_file_info_unref (info);
+ return 0;
+ }
+
+ tny_mime_part_construct (mime_part, stream, mime_type, "base64");
g_object_unref (stream);
- content_id = g_strdup_printf ("%d", priv->last_cid);
+ content_id = g_strdup_printf ("%d", priv->next_cid);
tny_mime_part_set_content_id (mime_part, content_id);
g_free (content_id);
- priv->last_cid++;
+ priv->next_cid++;
basename = g_path_get_basename (filename);
tny_mime_part_set_filename (mime_part, basename);
tny_list_prepend (priv->attachments, (GObject *) mime_part);
modest_attachments_view_add_attachment (MODEST_ATTACHMENTS_VIEW (priv->attachments_view),
mime_part,
- info.size == 0, info.size);
+ info->size == 0, info->size);
gtk_widget_set_no_show_all (priv->attachments_caption, FALSE);
gtk_widget_show_all (priv->attachments_caption);
gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
g_free (filename);
g_object_unref (mime_part);
+ gnome_vfs_file_info_unref (info);
}
+
+ return size;
}
void
if (TNY_IS_MSG (part)) {
TnyHeader *header = tny_msg_get_header (TNY_MSG (part));
if (header) {
- filename = g_strdup (tny_header_get_subject (header));
+ filename = tny_header_dup_subject (header);
g_object_unref (header);
}
if (filename == NULL) {
filename = g_strdup ("");
}
message = g_strdup_printf (ngettext("emev_nc_delete_attachment", "emev_nc_delete_attachments",
- (tny_list_get_length (att_list) == 1)), filename);
+ tny_list_get_length (att_list)), filename);
g_free (filename);
confirmation_dialog = hildon_note_new_confirmation (GTK_WINDOW (window), message);
g_free (message);
gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
g_object_unref (mime_part);
}
+ g_object_unref (iter);
}
g_object_unref (att_list);
g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
g_return_if_fail ((editor == NULL) || (MODEST_IS_RECPT_EDITOR (editor)));
+
+ /* we check for low-mem; in that case, show a warning, and don't allow
+ * for the addressbook
+ */
+ if (modest_platform_check_memory_low (MODEST_WINDOW(window)))
+ return;
+
+
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
if (editor == NULL) {
break;
}
modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (window));
+ text_buffer_refresh_attributes (WP_TEXT_BUFFER (priv->text_buffer), window);
}
}
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
dialog = hildon_font_selection_dialog_new (GTK_WINDOW (window), NULL);
+ modest_window_mgr_set_modal (modest_runtime_get_window_mgr(),
+ GTK_WINDOW(dialog));
/* First we get the currently selected font information */
wp_text_buffer_get_attributes (WP_TEXT_BUFFER (priv->text_buffer), &oldfmt, TRUE);
}
void
-modest_msg_edit_window_reset_modified (ModestMsgEditWindow *editor)
+modest_msg_edit_window_set_modified (ModestMsgEditWindow *editor,
+ gboolean modified)
{
ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (editor);
GtkTextBuffer *buffer;
buffer = modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR(priv->to_field));
- gtk_text_buffer_set_modified (buffer, FALSE);
+ gtk_text_buffer_set_modified (buffer, modified);
buffer = modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR(priv->cc_field));
- gtk_text_buffer_set_modified (buffer, FALSE);
+ gtk_text_buffer_set_modified (buffer, modified);
buffer = modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR(priv->bcc_field));
- gtk_text_buffer_set_modified (buffer, FALSE);
- gtk_text_buffer_set_modified (priv->text_buffer, FALSE);
+ gtk_text_buffer_set_modified (buffer, modified);
+ gtk_text_buffer_set_modified (priv->text_buffer, modified);
}
gboolean
modest_msg_edit_window_is_modified (ModestMsgEditWindow *editor)
{
ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (editor);
+ const char *account_name;
GtkTextBuffer *buffer;
buffer = modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR(priv->to_field));
return TRUE;
if (gtk_text_buffer_get_modified (priv->text_buffer))
return TRUE;
+ account_name = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->from_field));
+ if (!priv->original_account_name || strcmp(account_name, priv->original_account_name)) {
+ return TRUE;
+ }
return FALSE;
}
if (!GTK_WIDGET_VISIBLE (window))
return;
+ g_object_ref (window);
text = gtk_clipboard_wait_for_text (selection_clipboard);
if (priv->clipboard_text != NULL) {
}
priv->clipboard_text = text;
- modest_window_check_dimming_rules_group (MODEST_WINDOW (window), MODEST_DIMMING_RULES_CLIPBOARD);
+ if (GTK_WIDGET_VISIBLE (window)) {
+ modest_window_check_dimming_rules_group (MODEST_WINDOW (window), MODEST_DIMMING_RULES_CLIPBOARD);
+ }
+ g_object_unref (window);
}
+
+static gboolean clipboard_owner_change_idle (gpointer userdata)
+{
+ ModestMsgEditWindow *window = (ModestMsgEditWindow *) userdata;
+ ModestMsgEditWindowPrivate *priv;
+
+ gdk_threads_enter ();
+ g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window), FALSE);
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+
+ priv->clipboard_owner_idle = 0;
+ modest_msg_edit_window_clipboard_owner_change (NULL, NULL, window);
+ gdk_threads_leave ();
+
+ return FALSE;
+}
+
+static void
+modest_msg_edit_window_clipboard_owner_handle_change_in_idle (ModestMsgEditWindow *window)
+{
+ ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+ if (priv->clipboard_owner_idle == 0) {
+ priv->clipboard_owner_idle = g_idle_add (clipboard_owner_change_idle, window);
+ }
+}
+
static void
subject_field_move_cursor (GtkEntry *entry,
GtkMovementStep step,
if (result) {
gtk_text_buffer_select_range (priv->text_buffer, &match_start, &match_end);
gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (priv->msg_body), &match_start, 0.0, TRUE, 0.0, 0.0);
+ correct_scroll_without_drag_check (MODEST_MSG_EDIT_WINDOW (window), FALSE);
} else {
g_free (priv->last_search);
priv->last_search = NULL;