Commit 590ceded authored by Hiroyuki Ikezoe's avatar Hiroyuki Ikezoe Committed by Matthias Clasen

Don't get settings unless we need them

Pointed out in bug 613028.
parent 996541d0
......@@ -2296,6 +2296,36 @@ scale_or_ref (GdkPixbuf *src,
}
}
static gboolean
lookup_icon_size (GtkStyle *style,
GtkWidget *widget,
GtkIconSize size,
gint *width,
gint *height)
{
GdkScreen *screen;
GtkSettings *settings;
if (widget && gtk_widget_has_screen (widget))
{
screen = gtk_widget_get_screen (widget);
settings = gtk_settings_get_for_screen (screen);
}
else if (style && style->colormap)
{
screen = gdk_colormap_get_screen (style->colormap);
settings = gtk_settings_get_for_screen (screen);
}
else
{
settings = gtk_settings_get_default ();
GTK_NOTE (MULTIHEAD,
g_warning ("Using the default screen for gtk_default_render_icon()"));
}
return gtk_icon_size_lookup_for_settings (settings, size, width, height);
}
static GdkPixbuf *
gtk_default_render_icon (GtkStyle *style,
const GtkIconSource *source,
......@@ -2310,8 +2340,6 @@ gtk_default_render_icon (GtkStyle *style,
GdkPixbuf *scaled;
GdkPixbuf *stated;
GdkPixbuf *base_pixbuf;
GdkScreen *screen;
GtkSettings *settings;
/* Oddly, style can be NULL in this function, because
* GtkIconSet can be used without a style and if so
......@@ -2322,25 +2350,7 @@ gtk_default_render_icon (GtkStyle *style,
g_return_val_if_fail (base_pixbuf != NULL, NULL);
if (widget && gtk_widget_has_screen (widget))
{
screen = gtk_widget_get_screen (widget);
settings = gtk_settings_get_for_screen (screen);
}
else if (style && style->colormap)
{
screen = gdk_colormap_get_screen (style->colormap);
settings = gtk_settings_get_for_screen (screen);
}
else
{
settings = gtk_settings_get_default ();
GTK_NOTE (MULTIHEAD,
g_warning ("Using the default screen for gtk_default_render_icon()"));
}
if (size != (GtkIconSize) -1 && !gtk_icon_size_lookup_for_settings (settings, size, &width, &height))
if (size != (GtkIconSize) -1 && !lookup_icon_size(style, widget, size, &width, &height))
{
g_warning (G_STRLOC ": invalid icon size '%d'", size);
return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment