aboutsummaryrefslogtreecommitdiff
path: root/dragon.c
diff options
context:
space:
mode:
Diffstat (limited to 'dragon.c')
-rw-r--r--dragon.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/dragon.c b/dragon.c
index f81a39c..b096a92 100644
--- a/dragon.c
+++ b/dragon.c
@@ -204,24 +204,32 @@ void add_file_button(GFile *file) {
dragdata->uri = uri;
GtkButton *button = add_button(filename, dragdata, TARGET_TYPE_URI);
- GFileInfo *fileinfo = g_file_query_info(file, "*", 0, NULL, NULL);
- GIcon *icon = g_file_info_get_icon(fileinfo);
- GtkIconInfo *icon_info = gtk_icon_theme_lookup_by_gicon(icon_theme,
- icon, 48, 0);
-
- // Try a few fallback mimetypes if no icon can be found
- if (!icon_info)
- icon_info = icon_info_from_content_type("application/octet-stream");
- if (!icon_info)
- icon_info = icon_info_from_content_type("text/x-generic");
- if (!icon_info)
- icon_info = icon_info_from_content_type("text/plain");
-
- if (icon_info) {
- GtkWidget *image = gtk_image_new_from_pixbuf(
- gtk_icon_info_load_icon(icon_info, NULL));
+ GdkPixbuf *pb = gdk_pixbuf_new_from_file_at_size(filename, 96, 96, NULL);
+ if (pb) {
+ GtkWidget *image = gtk_image_new_from_pixbuf(pb);
+ gtk_button_set_always_show_image(button, true);
gtk_button_set_image(button, image);
gtk_button_set_always_show_image(button, true);
+ } else {
+ GFileInfo *fileinfo = g_file_query_info(file, "*", 0, NULL, NULL);
+ GIcon *icon = g_file_info_get_icon(fileinfo);
+ GtkIconInfo *icon_info = gtk_icon_theme_lookup_by_gicon(icon_theme,
+ icon, 48, 0);
+
+ // Try a few fallback mimetypes if no icon can be found
+ if (!icon_info)
+ icon_info = icon_info_from_content_type("application/octet-stream");
+ if (!icon_info)
+ icon_info = icon_info_from_content_type("text/x-generic");
+ if (!icon_info)
+ icon_info = icon_info_from_content_type("text/plain");
+
+ if (icon_info) {
+ GtkWidget *image = gtk_image_new_from_pixbuf(
+ gtk_icon_info_load_icon(icon_info, NULL));
+ gtk_button_set_image(button, image);
+ gtk_button_set_always_show_image(button, true);
+ }
}
if (!icons_only)
bgstack15