From df33c633ee19e9420f7d8f660cac71d71bea90c3 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 22 Jun 2010 14:29:28 -0400 Subject: Use an appropriate icon when dragging attachments. --- widgets/misc/e-attachment.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'widgets/misc/e-attachment.c') diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c index ba4e4004b3..1872de6b77 100644 --- a/widgets/misc/e-attachment.c +++ b/widgets/misc/e-attachment.c @@ -56,6 +56,7 @@ struct _EAttachmentPrivate { GFile *file; + GIcon *icon; GFileInfo *file_info; GCancellable *cancellable; CamelMimePart *mime_part; @@ -85,6 +86,7 @@ enum { PROP_ENCRYPTED, PROP_FILE, PROP_FILE_INFO, + PROP_ICON, PROP_LOADING, PROP_MIME_PART, PROP_PERCENT, @@ -357,7 +359,11 @@ attachment_update_icon_column (EAttachment *attachment) E_ATTACHMENT_STORE_COLUMN_ICON, icon, -1); - g_object_unref (icon); + /* Cache the icon to reuse for things like drag-n-drop. */ + if (attachment->priv->icon != NULL) + g_object_unref (attachment->priv->icon); + attachment->priv->icon = icon; + g_object_notify (G_OBJECT (attachment), "icon"); } static void @@ -601,6 +607,12 @@ attachment_get_property (GObject *object, E_ATTACHMENT (object))); return; + case PROP_ICON: + g_value_set_object ( + value, e_attachment_get_icon ( + E_ATTACHMENT (object))); + return; + case PROP_SHOWN: g_value_set_boolean ( value, e_attachment_get_shown ( @@ -659,6 +671,11 @@ attachment_dispose (GObject *object) priv->file = NULL; } + if (priv->icon != NULL) { + g_object_unref (priv->icon); + priv->icon = NULL; + } + if (priv->file_info != NULL) { g_object_unref (priv->file_info); priv->file_info = NULL; @@ -771,6 +788,16 @@ attachment_class_init (EAttachmentClass *class) G_TYPE_FILE_INFO, G_PARAM_READABLE)); + g_object_class_install_property ( + object_class, + PROP_ICON, + g_param_spec_object ( + "icon", + "Icon", + NULL, + G_TYPE_ICON, + G_PARAM_READABLE)); + g_object_class_install_property ( object_class, PROP_LOADING, @@ -1178,6 +1205,14 @@ e_attachment_get_file_info (EAttachment *attachment) return attachment->priv->file_info; } +GIcon * +e_attachment_get_icon (EAttachment *attachment) +{ + g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL); + + return attachment->priv->icon; +} + gboolean e_attachment_get_loading (EAttachment *attachment) { -- cgit v1.2.3