[gtk+] Don't get settings unless we need them
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Don't get settings unless we need them
- Date: Tue, 16 Mar 2010 17:03:29 +0000 (UTC)
commit 590ceded9627da1f25261fc8dc7537bbc0899f23
Author: Hiroyuki Ikezoe <poincare ikezoe net>
Date: Tue Mar 16 13:01:18 2010 -0400
Don't get settings unless we need them
Pointed out in bug 613028.
gtk/gtkstyle.c | 52 +++++++++++++++++++++++++++++++---------------------
1 files changed, 31 insertions(+), 21 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index dd58c9e..f18d76a 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]