X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-sidebar-attachments.c;h=7fb7f00e72f52fb6a8522d62dcea44403070b11a;hb=f0b7075e647626890908db0d630d88a4e4f779b5;hp=4bdf5d96acdd6d0fb069b6666b0af47e503ca38a;hpb=443f76987b7447e3614939f4a60774ece2ad44fe;p=evince.git diff --git a/shell/ev-sidebar-attachments.c b/shell/ev-sidebar-attachments.c index 4bdf5d96..7fb7f00e 100644 --- a/shell/ev-sidebar-attachments.c +++ b/shell/ev-sidebar-attachments.c @@ -29,8 +29,8 @@ #include #include #include -#include +#include "ev-file-helpers.h" #include "ev-sidebar-attachments.h" #include "ev-sidebar-page.h" @@ -98,20 +98,28 @@ static GdkPixbuf * icon_theme_get_pixbuf_from_mime_type (GtkIconTheme *icon_theme, const gchar *mime_type) { - GdkPixbuf *pixbuf = NULL; - gchar *icon; - - icon = gnome_icon_lookup (icon_theme, - NULL, NULL, - NULL, NULL, - mime_type, - GNOME_ICON_LOOKUP_FLAGS_NONE, - NULL); - - pixbuf = gtk_icon_theme_load_icon (icon_theme, - icon, 48, 0, NULL); - g_free (icon); - + const char *separator; + GString *icon_name; + GdkPixbuf *pixbuf; + + separator = strchr (mime_type, '/'); + if (!separator) + return NULL; /* maybe we should return a GError with "invalid MIME-type" */ + + icon_name = g_string_new ("gnome-mime-"); + g_string_append_len (icon_name, mime_type, separator - mime_type); + g_string_append_c (icon_name, '-'); + g_string_append (icon_name, separator + 1); + pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str, 48, 0, NULL); + g_string_free (icon_name, TRUE); + if (pixbuf) + return pixbuf; + + icon_name = g_string_new ("gnome-mime-"); + g_string_append_len (icon_name, mime_type, separator - mime_type); + pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str, 48, 0, NULL); + g_string_free (icon_name, TRUE); + return pixbuf; } @@ -398,7 +406,8 @@ ev_sidebar_attachments_drag_data_get (GtkWidget *widget, EvAttachment *attachment; GtkTreePath *path; GtkTreeIter iter; - gchar *uri, *filename; + GFile *file; + gchar *filename; GError *error = NULL; path = (GtkTreePath *) l->data; @@ -409,15 +418,19 @@ ev_sidebar_attachments_drag_data_get (GtkWidget *widget, COLUMN_ATTACHMENT, &attachment, -1); - filename = g_build_filename (g_get_tmp_dir (), + filename = g_build_filename (ev_tmp_dir (), ev_attachment_get_name (attachment), NULL); + file = g_file_new_for_path (filename); + g_free (filename); - uri = g_filename_to_uri (filename, NULL, NULL); + if (ev_attachment_save (attachment, file, &error)) { + gchar *uri; - if (ev_attachment_save (attachment, filename, &error)) { + uri = g_file_get_uri (file); g_string_append (uri_list, uri); g_string_append_c (uri_list, '\n'); + g_free (uri); } if (error) { @@ -425,8 +438,8 @@ ev_sidebar_attachments_drag_data_get (GtkWidget *widget, g_error_free (error); } - g_free (uri); gtk_tree_path_free (path); + g_object_unref (file); g_object_unref (attachment); }