1 --- gtk+-2.6.4/gtk/gtkstyle.c 2005-01-18 18:43:45.000000000 +0200
2 +++ gtk+-2.6.4/gtk/gtkstyle.c 2005-04-06 16:19:37.951768816 +0300
5 #include "gtkiconfactory.h"
6 #include "gtksettings.h" /* _gtk_settings_parse_convert() */
7 +#include "gtkhashtable.h"
9 #define LIGHTNESS_MULT 1.3
10 #define DARKNESS_MULT 0.7
15 +#define GTK_STYLE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_STYLE, GtkStylePrivate))
17 +typedef struct _GtkStylePrivate GtkStylePrivate;
19 +struct _GtkStylePrivate {
20 + GSList *logical_color_hashes;
23 /* --- prototypes --- */
24 static void gtk_style_init (GtkStyle *style);
25 static void gtk_style_class_init (GtkStyleClass *klass);
27 klass->draw_layout = gtk_default_draw_layout;
28 klass->draw_resize_grip = gtk_default_draw_resize_grip;
30 + g_type_class_add_private (object_class, sizeof (GtkStylePrivate));
38 +free_object_list (GSList *list)
42 + GSList *tmp_list = list;
46 + g_object_unref (tmp_list->data);
47 + tmp_list = tmp_list->next;
50 + g_slist_free (list);
56 gtk_style_finalize (GObject *object)
58 GtkStyle *style = GTK_STYLE (object);
59 + GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
61 g_return_if_fail (style->attach_count == 0);
64 g_slist_free_1 (style->styles);
68 - if (style->icon_factories)
70 - GSList *tmp_list = style->icon_factories;
74 - g_object_unref (tmp_list->data);
75 - tmp_list = tmp_list->next;
78 - g_slist_free (style->icon_factories);
81 + free_object_list (style->icon_factories);
82 + free_object_list (priv->logical_color_hashes);
84 pango_font_description_free (style->font_desc);
86 @@ -1003,6 +1022,51 @@
87 return gtk_icon_factory_lookup_default (stock_id);
91 + * gtk_style_lookup_logical_color:
92 + * @style: a #GtkStyle
93 + * @color_name: the name of the logical color to look up
94 + * @color: the #GdkColor to fill in
96 + * Looks up @color_name in the style's logical color mappings,
97 + * filling in @color and returning %TRUE if found, otherwise
98 + * returning %FALSE. Do not cache the found mapping, because
99 + * it depends on the #GtkStyle and might change when a theme
102 + * Return value: %TRUE if the mapping was found.
105 +gtk_style_lookup_logical_color (GtkStyle *style,
106 + const char *color_name,
109 + GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
112 + g_return_val_if_fail (GTK_IS_STYLE (style), FALSE);
113 + g_return_val_if_fail (color_name != NULL, FALSE);
114 + g_return_val_if_fail (color != NULL, FALSE);
116 + iter = priv->logical_color_hashes;
117 + while (iter != NULL)
119 + GdkColor *mapping = g_hash_table_lookup (GTK_HASH_TABLE (iter->data)->hash,
123 + color->red = mapping->red;
124 + color->green = mapping->green;
125 + color->blue = mapping->blue;
129 + iter = g_slist_next (iter);
137 * @style: a #GtkStyle
138 @@ -1717,10 +1781,32 @@
139 clear_property_cache (style);
143 +copy_object_list (GSList *list)
150 + while (iter != NULL)
152 + g_object_ref (iter->data);
153 + iter = g_slist_next (iter);
156 + return g_slist_copy (list);
163 gtk_style_real_init_from_rc (GtkStyle *style,
164 GtkRcStyle *rc_style)
166 + GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
167 + GSList *logical_color_hashes;
170 /* cache _should_ be still empty */
171 @@ -1746,19 +1832,10 @@
172 if (rc_style->ythickness >= 0)
173 style->ythickness = rc_style->ythickness;
175 - if (rc_style->icon_factories)
178 + style->icon_factories = copy_object_list (rc_style->icon_factories);
180 - style->icon_factories = g_slist_copy (rc_style->icon_factories);
182 - iter = style->icon_factories;
183 - while (iter != NULL)
185 - g_object_ref (iter->data);
186 - iter = g_slist_next (iter);
189 + logical_color_hashes = _gtk_rc_style_get_logical_color_hashes (rc_style);
190 + priv->logical_color_hashes = copy_object_list (logical_color_hashes);
194 @@ -2065,7 +2142,7 @@
200 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
201 g_return_val_if_fail (GTK_STYLE_GET_CLASS (style)->render_icon != NULL, NULL);
203 @@ -2156,7 +2233,7 @@
205 return gdk_pixbuf_scale_simple (src,
207 - GDK_INTERP_BILINEAR);
208 + GDK_INTERP_NEAREST);
212 @@ -2183,7 +2260,6 @@
215 base_pixbuf = gtk_icon_source_get_pixbuf (source);
217 g_return_val_if_fail (base_pixbuf != NULL, NULL);
219 if (widget && gtk_widget_has_screen (widget))
220 @@ -2213,7 +2289,9 @@
221 /* If the size was wildcarded, and we're allowed to scale, then scale; otherwise,
224 - if (size != (GtkIconSize)-1 && gtk_icon_source_get_size_wildcarded (source))
225 + /* Hildon addition: Device icons are never scaled */
226 + if (size != (GtkIconSize)-1 && gtk_icon_source_get_size_wildcarded (source)
227 + && size < HILDON_ICON_SIZE_26)
228 scaled = scale_or_ref (base_pixbuf, width, height);
230 scaled = g_object_ref (base_pixbuf);
231 @@ -2224,7 +2302,7 @@
232 if (state == GTK_STATE_INSENSITIVE)
234 stated = gdk_pixbuf_copy (scaled);
237 gdk_pixbuf_saturate_and_pixelate (scaled, stated,
240 @@ -2232,8 +2310,8 @@
242 else if (state == GTK_STATE_PRELIGHT)
244 - stated = gdk_pixbuf_copy (scaled);
246 + stated = gdk_pixbuf_copy (scaled);
248 gdk_pixbuf_saturate_and_pixelate (scaled, stated,