forked from AuroraMiddleware/gtk
icon theme: Add a way to create GtkIconInfos from files
This is sometimes needed, and calling into actual icon theme code just for it is confusing - the resulting icon does not depend on the icon theme at all. https://bugzilla.gnome.org/show_bug.cgi?id=760536
This commit is contained in:
parent
c667f9f1d1
commit
7d717c8113
@ -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;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define __GTK_ICON_THEME_PRIVATE_H__
|
||||
|
||||
#include <gtk/gtkicontheme.h>
|
||||
#include <gtk/gtkcssstyleprivate.h>
|
||||
|
||||
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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user