ModestMsgEditWindow *win = (ModestMsgEditWindow *) userdata;
ModestMsgEditWindowPrivate *priv;
+ /* It could happen that the window was already closed */
+ if (!GTK_WIDGET_VISIBLE (win))
+ return FALSE;
+
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(win);
correct_scroll_without_drag_check (win, TRUE);
GtkTextMark *insert;
GtkAdjustment *vadj;
+ /* It could happen that the window was already closed */
+ if (!GTK_WIDGET_VISIBLE (w))
+ return FALSE;
+
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(w);
insert = gtk_text_buffer_get_insert (priv->text_buffer);
return;
}
- priv->correct_scroll_idle = g_idle_add ((GSourceFunc) correct_scroll_without_drag_check_idle,
- (gpointer) w);
+ priv->correct_scroll_idle = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+ (GSourceFunc) correct_scroll_without_drag_check_idle,
+ g_object_ref (w),
+ g_object_unref);
}
static void
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(w);
if (gtk_grab_get_current () == priv->msg_body) {
if (priv->scroll_drag_timeout_id == 0) {
- priv->scroll_drag_timeout_id = g_timeout_add (500, (GSourceFunc) scroll_drag_timeout,
- (gpointer) w);
+ priv->scroll_drag_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT,
+ 500,
+ (GSourceFunc) scroll_drag_timeout,
+ g_object_ref (w),
+ g_object_unref);
}
return;
}
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
+static void
+pixbuf_size_prepared (GdkPixbufLoader *loader,
+ gint width,
+ gint height,
+ ModestMsgEditWindow *self)
+{
+ gint new_height, new_width;
+ gboolean set_size;
+
+ new_height = height;
+ new_width = width;
+ set_size = FALSE;
+
+ if (width > IMAGE_MAX_WIDTH) {
+ new_height = height * IMAGE_MAX_WIDTH / width;
+ new_width = IMAGE_MAX_WIDTH;
+ }
+
+ gdk_pixbuf_loader_set_size (loader, new_width, new_height);
+}
+
static GdkPixbuf *
-pixbuf_from_stream (TnyStream *stream, const gchar *mime_type, guint64 *stream_size)
+pixbuf_from_stream (TnyStream *stream,
+ const gchar *mime_type,
+ guint64 *stream_size,
+ ModestMsgEditWindow *self)
{
GdkPixbufLoader *loader;
GdkPixbuf *pixbuf;
guint64 size;
GError *error = NULL;
-
+
size = 0;
loader = gdk_pixbuf_loader_new_with_mime_type (mime_type, NULL);
*stream_size = 0;
return NULL;
}
+ g_signal_connect (G_OBJECT (loader), "size-prepared", G_CALLBACK (pixbuf_size_prepared), self);
+
+ hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), TRUE);
tny_stream_reset (TNY_STREAM (stream));
while (!tny_stream_is_eos (TNY_STREAM (stream))) {
if (!gdk_pixbuf_loader_write (loader, read_buffer, readed, &error)) {
break;
}
+ /* Allow some UI responsiveness */
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
}
+ hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), FALSE);
gdk_pixbuf_loader_close (loader, &error);
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
+ g_object_ref (self);
for (iter = tny_list_create_iterator (attachments);
!tny_iterator_is_done (iter);
tny_iterator_next (iter)) {
if ((cid != NULL)&&(mime_type != NULL)) {
guint64 stream_size;
TnyStream *stream = tny_mime_part_get_decoded_stream (part);
- GdkPixbuf *pixbuf = pixbuf_from_stream (stream, mime_type, &stream_size);
+ GdkPixbuf *pixbuf = pixbuf_from_stream (stream, mime_type, &stream_size, self);
g_object_unref (stream);
g_object_unref (part);
}
g_object_unref (iter);
+ g_object_unref (self);
}
static void
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")) {
{
ModestMsgEditFormatState *format_state = NULL;
ModestMsgEditWindowPrivate *priv;
- WPTextBufferFormat *buffer_format = g_new0 (WPTextBufferFormat, 1);
+ WPTextBufferFormat *buffer_format;
g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW (self), NULL);
+
+ buffer_format = g_new0 (WPTextBufferFormat, 1);
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
wp_text_buffer_get_attributes (WP_TEXT_BUFFER (priv->text_buffer), buffer_format, TRUE);
const ModestMsgEditFormatState *format_state)
{
ModestMsgEditWindowPrivate *priv;
- WPTextBufferFormat *buffer_format = g_new0 (WPTextBufferFormat, 1);
- WPTextBufferFormat *current_format = g_new0 (WPTextBufferFormat, 1);
+ WPTextBufferFormat *buffer_format;
+ WPTextBufferFormat *current_format;
+
g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (self));
g_return_if_fail (format_state != NULL);
+ buffer_format = g_new0 (WPTextBufferFormat, 1);
+ current_format = g_new0 (WPTextBufferFormat, 1);
+
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
gtk_widget_grab_focus (priv->msg_body);
buffer_format->bold = (format_state->bold != FALSE);
gint response = 0;
GSList *uris = NULL;
GSList *uri_node = NULL;
-
+
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_ia_select_inline_image_title"));
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
}
gtk_widget_destroy (dialog);
+ g_object_ref (window);
+ /* The operation could take some time so allow the dialog to be closed */
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
+
for (uri_node = uris; uri_node != NULL; uri_node = g_slist_next (uri_node)) {
const gchar *uri;
GnomeVFSHandle *handle = NULL;
modest_platform_information_banner (NULL, NULL,
_FM("sfil_ib_opening_not_allowed"));
-
+ g_free (filename);
g_object_unref (mime_part);
gnome_vfs_file_info_unref (info);
continue;
tny_mime_part_set_filename (mime_part, basename);
g_free (basename);
- pixbuf = pixbuf_from_stream (stream, mime_type, &stream_size);
+ pixbuf = pixbuf_from_stream (stream, mime_type, &stream_size, window);
if (pixbuf != NULL) {
priv->images_size += stream_size;
priv->images_count ++;
insert_mark = gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (priv->text_buffer));
gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (priv->text_buffer), &position, insert_mark);
- wp_text_buffer_insert_image (WP_TEXT_BUFFER (priv->text_buffer), &position, g_strdup (tny_mime_part_get_content_id (mime_part)), pixbuf);
+ wp_text_buffer_insert_image (WP_TEXT_BUFFER (priv->text_buffer), &position,
+ tny_mime_part_get_content_id (mime_part), pixbuf);
g_object_unref (pixbuf);
- }
- tny_list_prepend (priv->images, (GObject *) mime_part);
- gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
+ tny_list_prepend (priv->images, (GObject *) mime_part);
+ gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
+ } else {
+ modest_platform_information_banner (NULL, NULL,
+ _("mail_ib_file_operation_failed"));
+ }
+
g_free (filename);
g_object_unref (mime_part);
gnome_vfs_file_info_unref (info);
}
}
-
-
+ g_object_unref (window);
}
static void
if (size > allowed_size) {
modest_platform_information_banner (NULL, NULL,
_FM("sfil_ib_opening_not_allowed"));
+ g_free (filename);
return 0;
}
} else
modest_platform_information_banner (NULL, NULL, _FM("sfil_ib_opening_not_allowed"));
g_object_unref (mime_part);
+ g_free (filename);
gnome_vfs_file_info_unref (info);
return 0;
}
ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
GtkClipboard *selection_clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
gchar *text = NULL;
+
+ /* It could happen that the window was already closed */
if (!GTK_WIDGET_VISIBLE (window))
return;
}
priv->clipboard_text = text;
- if (GTK_WIDGET_VISIBLE (window)) {
- modest_window_check_dimming_rules_group (MODEST_WINDOW (window), MODEST_DIMMING_RULES_CLIPBOARD);
- }
+ modest_window_check_dimming_rules_group (MODEST_WINDOW (window), MODEST_DIMMING_RULES_CLIPBOARD);
+
g_object_unref (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);
+ priv->clipboard_owner_idle = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+ clipboard_owner_change_idle,
+ g_object_ref (window),
+ g_object_unref);
}
}
gboolean a2,
gpointer window)
{
+ /* It could happen that the window was already closed */
if (!GTK_WIDGET_VISIBLE (window))
return;