aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-attachment-view.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-06-23 02:29:28 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-06-23 02:29:28 +0800
commitdf33c633ee19e9420f7d8f660cac71d71bea90c3 (patch)
tree04a168b76fce4e192b772dac2aa3c62c189ead2a /widgets/misc/e-attachment-view.c
parent94a9b040083f0a2d3b9d75b58ec641fe021e1a98 (diff)
downloadgsoc2013-evolution-df33c633ee19e9420f7d8f660cac71d71bea90c3.tar
gsoc2013-evolution-df33c633ee19e9420f7d8f660cac71d71bea90c3.tar.gz
gsoc2013-evolution-df33c633ee19e9420f7d8f660cac71d71bea90c3.tar.bz2
gsoc2013-evolution-df33c633ee19e9420f7d8f660cac71d71bea90c3.tar.lz
gsoc2013-evolution-df33c633ee19e9420f7d8f660cac71d71bea90c3.tar.xz
gsoc2013-evolution-df33c633ee19e9420f7d8f660cac71d71bea90c3.tar.zst
gsoc2013-evolution-df33c633ee19e9420f7d8f660cac71d71bea90c3.zip
Use an appropriate icon when dragging attachments.
Diffstat (limited to 'widgets/misc/e-attachment-view.c')
-rw-r--r--widgets/misc/e-attachment-view.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/widgets/misc/e-attachment-view.c b/widgets/misc/e-attachment-view.c
index b810e402c4..36356e8724 100644
--- a/widgets/misc/e-attachment-view.c
+++ b/widgets/misc/e-attachment-view.c
@@ -1218,8 +1218,6 @@ e_attachment_view_motion_notify_event (EAttachmentView *view,
context = gtk_drag_begin (
widget, targets, GDK_ACTION_COPY, 1, (GdkEvent *) event);
- gtk_drag_set_icon_default (context);
-
return TRUE;
}
@@ -1408,6 +1406,7 @@ e_attachment_view_drag_begin (EAttachmentView *view,
GdkDragContext *context)
{
EAttachmentViewPrivate *priv;
+ guint n_selected;
g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
@@ -1421,6 +1420,48 @@ e_attachment_view_drag_begin (EAttachmentView *view,
g_warn_if_fail (priv->selected == NULL);
priv->selected = e_attachment_view_get_selected_attachments (view);
+ n_selected = g_list_length (priv->selected);
+
+ if (n_selected > 1)
+ gtk_drag_set_icon_stock (
+ context, GTK_STOCK_DND_MULTIPLE, 0, 0);
+
+ else if (n_selected == 1) {
+ EAttachment *attachment;
+ GtkIconTheme *icon_theme;
+ GtkIconInfo *icon_info;
+ GIcon *icon;
+ gint width, height;
+
+ attachment = E_ATTACHMENT (priv->selected->data);
+ icon = e_attachment_get_icon (attachment);
+ g_return_if_fail (icon != NULL);
+
+ icon_theme = gtk_icon_theme_get_default ();
+ gtk_icon_size_lookup (GTK_ICON_SIZE_DND, &width, &height);
+
+ icon_info = gtk_icon_theme_lookup_by_gicon (
+ icon_theme, icon, MIN (width, height),
+ GTK_ICON_LOOKUP_USE_BUILTIN);
+
+ if (icon_info != NULL) {
+ GdkPixbuf *pixbuf;
+ GError *error = NULL;
+
+ pixbuf = gtk_icon_info_load_icon (icon_info, &error);
+
+ if (pixbuf != NULL) {
+ gtk_drag_set_icon_pixbuf (
+ context, pixbuf, 0, 0);
+ g_object_unref (pixbuf);
+ } else if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ gtk_icon_info_free (icon_info);
+ }
+ }
}
void