forked from AuroraMiddleware/gtk
filechooser: Check that icons exist
Otherwise we end up showing missing-image in the file chooser, and thats sad.
This commit is contained in:
parent
5940de98dd
commit
23cb72875d
@ -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 */
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user