diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index 00ae3511c9..544f79e9f6 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -37,7 +37,7 @@ #include "win32/gdkwin32.h" #endif /* G_OS_WIN32 */ -#include "gtkicontheme.h" +#include "gtkiconthemeprivate.h" #include "gtkcsspalettevalueprivate.h" #include "gtkcssrgbavalueprivate.h" #include "gtkdebug.h" @@ -5462,6 +5462,15 @@ gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme *icon_theme, info = gtk_icon_info_new_for_pixbuf (icon_theme, pixbuf); } + return info; + } + else if (G_IS_FILE_ICON (icon)) + { + GFile *file = g_file_icon_get_file (G_FILE_ICON (icon)); + + info = gtk_icon_info_new_for_file (file, size, scale); + info->forced_size = (flags & GTK_ICON_LOOKUP_FORCE_SIZE) != 0; + return info; } else if (G_IS_LOADABLE_ICON (icon)) @@ -5469,32 +5478,6 @@ gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme *icon_theme, info = icon_info_new (ICON_THEME_DIR_UNTHEMED, size, 1); info->loadable = G_LOADABLE_ICON (g_object_ref (icon)); info->is_svg = FALSE; - - if (G_IS_FILE_ICON (icon)) - { - GFile *file = g_file_icon_get_file (G_FILE_ICON (icon)); - if (file != NULL) - { - info->icon_file = g_object_ref (file); - info->is_resource = g_file_has_uri_scheme (file, "resource"); - - if (info->is_resource) - { - gchar *uri; - - uri = g_file_get_uri (file); - info->filename = g_strdup (uri + 11); /* resource:// */ - g_free (uri); - } - else - { - info->filename = g_file_get_path (file); - } - - info->is_svg = suffix_from_name (info->filename) == ICON_SUFFIX_SVG; - } - } - info->desired_size = size; info->desired_scale = scale; info->forced_size = (flags & GTK_ICON_LOOKUP_FORCE_SIZE) != 0; @@ -5573,3 +5556,37 @@ gtk_icon_info_new_for_pixbuf (GtkIconTheme *icon_theme, return info; } + +GtkIconInfo * +gtk_icon_info_new_for_file (GFile *file, + gint size, + gint scale) +{ + GtkIconInfo *info; + + info = icon_info_new (ICON_THEME_DIR_UNTHEMED, size, 1); + info->loadable = G_LOADABLE_ICON (g_file_icon_new (file)); + info->icon_file = g_object_ref (file); + info->is_resource = g_file_has_uri_scheme (file, "resource"); + + if (info->is_resource) + { + gchar *uri; + + uri = g_file_get_uri (file); + info->filename = g_strdup (uri + 11); /* resource:// */ + g_free (uri); + } + else + { + info->filename = g_file_get_path (file); + } + + info->is_svg = suffix_from_name (info->filename) == ICON_SUFFIX_SVG; + + info->desired_size = size; + info->desired_scale = scale; + info->forced_size = FALSE; + + return info; +} diff --git a/gtk/gtkiconthemeprivate.h b/gtk/gtkiconthemeprivate.h index 77d95615c4..ca9d5177b0 100644 --- a/gtk/gtkiconthemeprivate.h +++ b/gtk/gtkiconthemeprivate.h @@ -19,6 +19,7 @@ #define __GTK_ICON_THEME_PRIVATE_H__ #include +#include void gtk_icon_theme_lookup_symbolic_colors (GtkCssStyle *style, GdkRGBA *color_out, @@ -26,4 +27,8 @@ void gtk_icon_theme_lookup_symbolic_colors (GtkCssStyle *style, GdkRGBA *warning_out, GdkRGBA *error_out); +GtkIconInfo *gtk_icon_info_new_for_file (GFile *file, + gint size, + gint scale); + #endif /* __GTK_ICON_THEME_PRIVATE_H__ */