]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/gtk+/gtk+-2.6.4-1.osso7/gtkstyle.c.diff
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / gtk+ / gtk+-2.6.4-1.osso7 / gtkstyle.c.diff
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
3 @@ -38,6 +38,7 @@
4  #include "gtkthemes.h"
5  #include "gtkiconfactory.h"
6  #include "gtksettings.h"       /* _gtk_settings_parse_convert() */
7 +#include "gtkhashtable.h"
8  
9  #define LIGHTNESS_MULT  1.3
10  #define DARKNESS_MULT   0.7
11 @@ -49,6 +50,14 @@
12    GValue      value;
13  } PropertyValue;
14  
15 +#define GTK_STYLE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_STYLE, GtkStylePrivate))
16 +
17 +typedef struct _GtkStylePrivate GtkStylePrivate;
18 +
19 +struct _GtkStylePrivate {
20 +  GSList *logical_color_hashes;
21 +};
22 +
23  /* --- prototypes --- */
24  static void     gtk_style_init                 (GtkStyle       *style);
25  static void     gtk_style_class_init           (GtkStyleClass  *klass);
26 @@ -655,6 +664,7 @@
27    klass->draw_layout = gtk_default_draw_layout;
28    klass->draw_resize_grip = gtk_default_draw_resize_grip;
29  
30 +  g_type_class_add_private (object_class, sizeof (GtkStylePrivate));
31    
32    /**
33     * GtkStyle::realize:
34 @@ -714,9 +724,28 @@
35  }
36  
37  static void
38 +free_object_list (GSList *list)
39 +{
40 +  if (list)
41 +    {
42 +      GSList *tmp_list = list;
43 +
44 +      while (tmp_list)
45 +       {
46 +         g_object_unref (tmp_list->data);
47 +         tmp_list = tmp_list->next;
48 +       }
49 +
50 +      g_slist_free (list);
51 +    }
52 +    
53 +}
54 +
55 +static void
56  gtk_style_finalize (GObject *object)
57  {
58    GtkStyle *style = GTK_STYLE (object);
59 +  GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
60  
61    g_return_if_fail (style->attach_count == 0);
62  
63 @@ -745,19 +774,9 @@
64            g_slist_free_1 (style->styles);
65          }
66      }
67 -
68 -  if (style->icon_factories)
69 -    {
70 -      GSList *tmp_list = style->icon_factories;
71 -
72 -      while (tmp_list)
73 -       {
74 -         g_object_unref (tmp_list->data);
75 -         tmp_list = tmp_list->next;
76 -       }
77 -
78 -      g_slist_free (style->icon_factories);
79 -    }
80 +  
81 +  free_object_list (style->icon_factories);
82 +  free_object_list (priv->logical_color_hashes);
83  
84    pango_font_description_free (style->font_desc);
85    
86 @@ -1003,6 +1022,51 @@
87    return gtk_icon_factory_lookup_default (stock_id);
88  }
89  
90 + /**
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
95 + *
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
100 + * switch occurs.
101 + *
102 + * Return value: %TRUE if the mapping was found.
103 + */
104 +gboolean
105 +gtk_style_lookup_logical_color (GtkStyle   *style,
106 +                               const char *color_name,
107 +                               GdkColor   *color)
108 +{
109 +  GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
110 +  GSList *iter;
111 +
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);
115 +  
116 +  iter = priv->logical_color_hashes;
117 +  while (iter != NULL)
118 +    {
119 +      GdkColor *mapping = g_hash_table_lookup (GTK_HASH_TABLE (iter->data)->hash,
120 +                                              color_name);
121 +      if (mapping)
122 +        {
123 +          color->red = mapping->red;
124 +          color->green = mapping->green;
125 +          color->blue = mapping->blue;
126 +          return TRUE;
127 +        }
128 +      
129 +      iter = g_slist_next (iter);
130 +    }
131 +
132 +  return FALSE;
133 +}
134 +
135  /**
136   * gtk_draw_hline:
137   * @style: a #GtkStyle
138 @@ -1717,10 +1781,32 @@
139    clear_property_cache (style);
140  }
141  
142 +static GSList *
143 +copy_object_list (GSList *list)
144 +{
145 +  if (list)
146 +    {
147 +      GSList *iter;
148 +
149 +      iter = list;
150 +      while (iter != NULL)
151 +        {
152 +          g_object_ref (iter->data);
153 +          iter = g_slist_next (iter);
154 +        }
155 +      
156 +      return g_slist_copy (list);
157 +    }
158 +  else
159 +    return NULL;
160 +}
161 +
162  static void
163  gtk_style_real_init_from_rc (GtkStyle   *style,
164                              GtkRcStyle *rc_style)
165  {
166 +  GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
167 +  GSList *logical_color_hashes;
168    gint i;
169  
170    /* cache _should_ be still empty */
171 @@ -1746,19 +1832,10 @@
172    if (rc_style->ythickness >= 0)
173      style->ythickness = rc_style->ythickness;
174  
175 -  if (rc_style->icon_factories)
176 -    {
177 -      GSList *iter;
178 +  style->icon_factories = copy_object_list (rc_style->icon_factories);
179  
180 -      style->icon_factories = g_slist_copy (rc_style->icon_factories);
181 -      
182 -      iter = style->icon_factories;
183 -      while (iter != NULL)
184 -        {
185 -          g_object_ref (iter->data);
186 -          iter = g_slist_next (iter);
187 -        }
188 -    }
189 +  logical_color_hashes = _gtk_rc_style_get_logical_color_hashes (rc_style);
190 +  priv->logical_color_hashes = copy_object_list (logical_color_hashes);
191  }
192  
193  static gint
194 @@ -2065,7 +2142,7 @@
195                         const gchar         *detail)
196  {
197    GdkPixbuf *pixbuf;
198 -  
199 +
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);
202    
203 @@ -2156,7 +2233,7 @@
204      {
205        return gdk_pixbuf_scale_simple (src,
206                                        width, height,
207 -                                      GDK_INTERP_BILINEAR);
208 +                                      GDK_INTERP_NEAREST);
209      }
210  }
211  
212 @@ -2183,7 +2260,6 @@
213     */
214  
215    base_pixbuf = gtk_icon_source_get_pixbuf (source);
216 -
217    g_return_val_if_fail (base_pixbuf != NULL, NULL);
218  
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,
222     * leave it alone.
223     */
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);
229    else
230      scaled = g_object_ref (base_pixbuf);
231 @@ -2224,7 +2302,7 @@
232        if (state == GTK_STATE_INSENSITIVE)
233          {
234            stated = gdk_pixbuf_copy (scaled);      
235 -          
236 +
237            gdk_pixbuf_saturate_and_pixelate (scaled, stated,
238                                              0.8, TRUE);
239            
240 @@ -2232,8 +2310,8 @@
241          }
242        else if (state == GTK_STATE_PRELIGHT)
243          {
244 -          stated = gdk_pixbuf_copy (scaled);      
245 -          
246 +          stated = gdk_pixbuf_copy (scaled);
247 +
248            gdk_pixbuf_saturate_and_pixelate (scaled, stated,
249                                              1.2, FALSE);
250