summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-03-26 13:15:19 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-03-26 13:17:51 -0400
commit23cb72875d0b4fe684ddbab8e623988a2a803254 (patch)
tree3e32b07bb03074cb9698d81d41236338a762fcf8
parent5940de98dda76d25eed71ed088e107838224a576 (diff)
downloadgtk+-23cb72875d0b4fe684ddbab8e623988a2a803254.tar.gz
filechooser: Check that icons exist
Otherwise we end up showing missing-image in the file chooser, and thats sad.
-rw-r--r--gtk/gtkfilechooserutils.c9
-rw-r--r--gtk/gtkfilechooserutils.h8
-rw-r--r--gtk/gtkfilechooserwidget.c8
3 files changed, 17 insertions, 8 deletions
diff --git a/gtk/gtkfilechooserutils.c b/gtk/gtkfilechooserutils.c
index de3ffa15d5..af319303a0 100644
--- a/gtk/gtkfilechooserutils.c
+++ b/gtk/gtkfilechooserutils.c
@@ -447,9 +447,10 @@ _gtk_file_consider_as_remote (GFile *file)
}
GIcon *
-_gtk_file_info_get_icon (GFileInfo *info,
- int icon_size,
- int scale)
+_gtk_file_info_get_icon (GFileInfo *info,
+ int icon_size,
+ int scale,
+ GtkIconTheme *icon_theme)
{
GIcon *icon;
GdkPixbuf *pixbuf;
@@ -468,7 +469,7 @@ _gtk_file_info_get_icon (GFileInfo *info,
}
icon = g_file_info_get_icon (info);
- if (icon)
+ if (icon && gtk_icon_theme_has_gicon (icon_theme, icon))
return g_object_ref (icon);
/* Use general fallback for all files without icon */
diff --git a/gtk/gtkfilechooserutils.h b/gtk/gtkfilechooserutils.h
index 46625b6c86..9481704ad9 100644
--- a/gtk/gtkfilechooserutils.h
+++ b/gtk/gtkfilechooserutils.h
@@ -21,6 +21,7 @@
#define __GTK_FILE_CHOOSER_UTILS_H__
#include "gtkfilechooserprivate.h"
+#include "gtkicontheme.h"
G_BEGIN_DECLS
@@ -52,9 +53,10 @@ char * _gtk_file_chooser_label_for_file (GFile *file);
gboolean _gtk_file_info_consider_as_directory (GFileInfo *info);
gboolean _gtk_file_has_native_path (GFile *file);
gboolean _gtk_file_consider_as_remote (GFile *file);
-GIcon * _gtk_file_info_get_icon (GFileInfo *info,
- int icon_size,
- int scale);
+GIcon * _gtk_file_info_get_icon (GFileInfo *info,
+ int icon_size,
+ int scale,
+ GtkIconTheme *icon_theme);
G_END_DECLS
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index f6a58f3218..6f612c1c63 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -4448,7 +4448,13 @@ file_system_model_set (GtkFileSystemModel *model,
{
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_ICON))
{
- g_value_take_object (value, _gtk_file_info_get_icon (info, ICON_SIZE, gtk_widget_get_scale_factor (GTK_WIDGET (impl))));
+ int scale;
+ GtkIconTheme *icon_theme;
+
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (impl));
+ icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (impl)));
+
+ g_value_take_object (value, _gtk_file_info_get_icon (info, ICON_SIZE, scale, icon_theme));
}
else
{