diff options
author | Srinivasa Ragavan <sragavan@novell.com> | 2005-07-29 12:05:17 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@src.gnome.org> | 2005-07-29 12:05:17 +0800 |
commit | 5fae90205947e4e468ca89c15698128752602dde (patch) | |
tree | d5637374f6baf3edf2f1cf4f4920ac052d2039b4 /widgets/misc | |
parent | 29bded8a17c8cdde0611bd98f4d39b47a8abd585 (diff) | |
download | gsoc2013-evolution-5fae90205947e4e468ca89c15698128752602dde.tar gsoc2013-evolution-5fae90205947e4e468ca89c15698128752602dde.tar.gz gsoc2013-evolution-5fae90205947e4e468ca89c15698128752602dde.tar.bz2 gsoc2013-evolution-5fae90205947e4e468ca89c15698128752602dde.tar.lz gsoc2013-evolution-5fae90205947e4e468ca89c15698128752602dde.tar.xz gsoc2013-evolution-5fae90205947e4e468ca89c15698128752602dde.tar.zst gsoc2013-evolution-5fae90205947e4e468ca89c15698128752602dde.zip |
used ref instead of copying the entire mime part. Also commited
2005-07-29 Srinivasa Ragavan <sragavan@novell.com>
* e-attachment.c: (e_attachment_new_from_mime_part) used ref instead of
copying the entire mime part. Also commited
(2005-07-15 Diego Gonzalez <diego@pemas.net>) patch
svn path=/trunk/; revision=29921
Diffstat (limited to 'widgets/misc')
-rw-r--r-- | widgets/misc/ChangeLog | 14 | ||||
-rw-r--r-- | widgets/misc/e-attachment.c | 22 | ||||
-rw-r--r-- | widgets/misc/e-image-chooser.c | 37 |
3 files changed, 28 insertions, 45 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index f061e9ef28..538616cc44 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,17 @@ +2005-07-29 Srinivasa Ragavan <sragavan@novell.com> + + * e-attachment.c: (e_attachment_new_from_mime_part) used ref instead of + copying the entire mime part. + +2005-07-15 Diego Gonzalez <diego@pemas.net> + + * e-image-chooser.c (image_drag_data_received_cb) modificatio to + avoid getting into an infinite loop. Also remove some debug + output. + (set_image_from_data): substitute calls to gdk_pixbuf_unref and + gdk_pixbuf_ref and use g_object_ref/unref instead. The first ones + are deprecated API. + 2005-07-25 Srinivasa Ragavan <sragavan@novell.com> * e-attachment-bar,c: (e_attachment_bar_remove_selected) (e_attachment_bar_edit_selected) diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c index c813e9965a..8dc2a089af 100644 --- a/widgets/misc/e-attachment.c +++ b/widgets/misc/e-attachment.c @@ -505,31 +505,13 @@ EAttachment * e_attachment_new_from_mime_part (CamelMimePart *part) { EAttachment *new; - CamelMimePart *mime_part; - CamelStream *stream; g_return_val_if_fail (CAMEL_IS_MIME_PART (part), NULL); - stream = camel_stream_mem_new (); - if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (part), stream) == -1) { - camel_object_unref (stream); - return NULL; - } - - camel_stream_reset (stream); - mime_part = camel_mime_part_new (); - - if (camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (mime_part), stream) == -1) { - camel_object_unref (mime_part); - camel_object_unref (stream); - return NULL; - } - - camel_object_unref (stream); - new = g_object_new (E_TYPE_ATTACHMENT, NULL); new->editor_gui = NULL; - new->body = mime_part; + camel_object_ref (part); + new->body = part; new->guessed_type = FALSE; new->is_available_local = TRUE; new->size = 0; diff --git a/widgets/misc/e-image-chooser.c b/widgets/misc/e-image-chooser.c index ac71a20d24..60529de65b 100644 --- a/widgets/misc/e-image-chooser.c +++ b/widgets/misc/e-image-chooser.c @@ -236,7 +236,7 @@ set_image_from_data (EImageChooser *chooser, pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); if (pixbuf) - gdk_pixbuf_ref (pixbuf); + g_object_ref (pixbuf); gdk_pixbuf_loader_close (loader, NULL); g_object_unref (loader); @@ -306,11 +306,11 @@ set_image_from_data (EImageChooser *chooser, chooser->priv->image_height / 2 - new_height / 2); gtk_image_set_from_pixbuf (GTK_IMAGE (chooser->priv->image), composite); - gdk_pixbuf_unref (scaled); - gdk_pixbuf_unref (composite); + g_object_unref (scaled); + g_object_unref (composite); } - gdk_pixbuf_unref (pixbuf); + g_object_unref (pixbuf); g_free (chooser->priv->image_buf); chooser->priv->image_buf = data; @@ -408,8 +408,6 @@ image_drag_data_received_cb (GtkWidget *widget, target_type = gdk_atom_name (selection_data->target); - printf ("target_type == %s\n", target_type); - if (!strcmp (target_type, URI_LIST_TYPE)) { GnomeVFSResult result; GnomeVFSHandle *handle; @@ -423,33 +421,22 @@ image_drag_data_received_cb (GtkWidget *widget, else uri = g_strdup (selection_data->data); - printf ("uri == %s\n", uri); - result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ); if (result == GNOME_VFS_OK) { result = gnome_vfs_get_file_info_from_handle (handle, &info, GNOME_VFS_FILE_INFO_DEFAULT); if (result == GNOME_VFS_OK) { - GnomeVFSFileSize num_left; GnomeVFSFileSize num_read; - GnomeVFSFileSize total_read; - printf ("file size = %d\n", (int)info.size); buf = g_malloc (info.size); - num_left = info.size; - total_read = 0; - - while ((result = gnome_vfs_read (handle, buf + total_read, num_left, &num_read)) == GNOME_VFS_OK) { - num_left -= num_read; - total_read += num_read; - } - - printf ("read %d bytes\n", (int)total_read); - if (set_image_from_data (chooser, buf, total_read)) { - handled = TRUE; - } - else { - /* XXX we should pop up a warning dialog here */ + if ((result = gnome_vfs_read (handle, buf, info.size, &num_read)) == GNOME_VFS_OK) { + if (set_image_from_data (chooser, buf, num_read)) { + handled = TRUE; + } else { + /* XXX we should pop up a warning dialog here */ + g_free (buf); + } + } else { g_free (buf); } } |