mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-15 05:00:09 +00:00
icontheme: Use textures more
We were going via GLoadablieIcon/GInputStream for everything previously and we have no API for that with GdkTexture. With this commit, gdk-pixbuf isn't used anymore when starting widget-factory for anything but SVG.
This commit is contained in:
parent
a85f4ec6c2
commit
b5da07f0e1
@ -3742,31 +3742,6 @@ gtk_icon_paintable_is_symbolic (GtkIconPaintable *icon)
|
|||||||
return icon->is_symbolic;
|
return icon->is_symbolic;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLoadableIcon *
|
|
||||||
icon_get_loadable (GtkIconPaintable *icon)
|
|
||||||
{
|
|
||||||
GFile *file;
|
|
||||||
GLoadableIcon *loadable;
|
|
||||||
|
|
||||||
if (icon->loadable)
|
|
||||||
return g_object_ref (icon->loadable);
|
|
||||||
|
|
||||||
if (icon->is_resource)
|
|
||||||
{
|
|
||||||
char *uri = g_strconcat ("resource://", icon->filename, NULL);
|
|
||||||
file = g_file_new_for_uri (uri);
|
|
||||||
g_free (uri);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
file = g_file_new_for_path (icon->filename);
|
|
||||||
|
|
||||||
loadable = G_LOADABLE_ICON (g_file_icon_new (file));
|
|
||||||
|
|
||||||
g_object_unref (file);
|
|
||||||
|
|
||||||
return loadable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This function contains the complicated logic for deciding
|
/* This function contains the complicated logic for deciding
|
||||||
* on the size at which to load the icon and loading it at
|
* on the size at which to load the icon and loading it at
|
||||||
* that size.
|
* that size.
|
||||||
@ -3826,19 +3801,57 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
|||||||
else
|
else
|
||||||
icon->texture = gdk_texture_new_from_resource (icon->filename);
|
icon->texture = gdk_texture_new_from_resource (icon->filename);
|
||||||
}
|
}
|
||||||
|
else if (icon->filename)
|
||||||
|
{
|
||||||
|
if (icon->is_svg)
|
||||||
|
{
|
||||||
|
GdkPixbuf *source_pixbuf;
|
||||||
|
|
||||||
|
if (gtk_icon_paintable_is_symbolic (icon))
|
||||||
|
source_pixbuf = gtk_make_symbolic_pixbuf_from_path (icon->filename,
|
||||||
|
pixel_size, pixel_size,
|
||||||
|
icon->desired_scale,
|
||||||
|
&load_error);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GFile *file = g_file_new_for_path (icon->filename);
|
||||||
|
GInputStream *stream = G_INPUT_STREAM (g_file_read (file, NULL, &load_error));
|
||||||
|
|
||||||
|
g_object_unref (file);
|
||||||
|
if (stream)
|
||||||
|
{
|
||||||
|
source_pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream,
|
||||||
|
"svg",
|
||||||
|
pixel_size, pixel_size,
|
||||||
|
TRUE, NULL,
|
||||||
|
&load_error);
|
||||||
|
g_object_unref (stream);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
source_pixbuf = NULL;
|
||||||
|
}
|
||||||
|
if (source_pixbuf)
|
||||||
|
{
|
||||||
|
icon->texture = gdk_texture_new_for_pixbuf (source_pixbuf);
|
||||||
|
g_object_unref (source_pixbuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
icon->texture = gdk_texture_new_from_filename (icon->filename, &load_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GLoadableIcon *loadable;
|
|
||||||
GInputStream *stream;
|
GInputStream *stream;
|
||||||
GdkPixbuf *source_pixbuf;
|
GdkPixbuf *source_pixbuf;
|
||||||
|
|
||||||
loadable = icon_get_loadable (icon);
|
g_assert (icon->loadable);
|
||||||
stream = g_loadable_icon_load (loadable,
|
|
||||||
|
stream = g_loadable_icon_load (icon->loadable,
|
||||||
pixel_size,
|
pixel_size,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
&load_error);
|
&load_error);
|
||||||
g_object_unref (loadable);
|
|
||||||
|
|
||||||
if (stream)
|
if (stream)
|
||||||
{
|
{
|
||||||
/* SVG icons are a special case - we just immediately scale them
|
/* SVG icons are a special case - we just immediately scale them
|
||||||
@ -3846,17 +3859,11 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
|||||||
*/
|
*/
|
||||||
if (icon->is_svg)
|
if (icon->is_svg)
|
||||||
{
|
{
|
||||||
if (gtk_icon_paintable_is_symbolic (icon))
|
source_pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream,
|
||||||
source_pixbuf = gtk_make_symbolic_pixbuf_from_path (icon->filename,
|
"svg",
|
||||||
pixel_size, pixel_size,
|
pixel_size, pixel_size,
|
||||||
icon->desired_scale,
|
TRUE, NULL,
|
||||||
&load_error);
|
&load_error);
|
||||||
else
|
|
||||||
source_pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream,
|
|
||||||
"svg",
|
|
||||||
pixel_size, pixel_size,
|
|
||||||
TRUE, NULL,
|
|
||||||
&load_error);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
source_pixbuf = _gdk_pixbuf_new_from_stream (stream,
|
source_pixbuf = _gdk_pixbuf_new_from_stream (stream,
|
||||||
@ -3869,7 +3876,6 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
|||||||
g_object_unref (source_pixbuf);
|
g_object_unref (source_pixbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!icon->texture)
|
if (!icon->texture)
|
||||||
|
Loading…
Reference in New Issue
Block a user