summaryrefslogtreecommitdiffstats
path: root/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkrc.c.diff
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkrc.c.diff')
-rw-r--r--meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkrc.c.diff581
1 files changed, 581 insertions, 0 deletions
diff --git a/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkrc.c.diff b/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkrc.c.diff
new file mode 100644
index 0000000000..a6b4f999ac
--- /dev/null
+++ b/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkrc.c.diff
@@ -0,0 +1,581 @@
1--- gtk+-2.6.4/gtk/gtkrc.c 2005-02-01 20:07:40.000000000 +0200
2+++ gtk+-2.6.4/gtk/gtkrc.c 2005-04-06 16:19:37.848784472 +0300
3@@ -56,6 +56,7 @@
4 #include "gtkprivate.h"
5 #include "gtksettings.h"
6 #include "gtkwindow.h"
7+#include "gtkhashtable.h"
8
9 #ifdef G_OS_WIN32
10 #include <io.h>
11@@ -105,6 +106,14 @@
12 GtkStyle *default_style;
13 };
14
15+#define GTK_RC_STYLE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_RC_STYLE, GtkRcStylePrivate))
16+
17+typedef struct _GtkRcStylePrivate GtkRcStylePrivate;
18+
19+struct _GtkRcStylePrivate {
20+ GSList *logical_color_hashes;
21+};
22+
23 static GtkRcContext *gtk_rc_context_get (GtkSettings *settings);
24
25 static guint gtk_rc_style_hash (const gchar *name);
26@@ -179,6 +188,13 @@
27 GScanner *scanner,
28 GtkRcStyle *rc_style,
29 GtkIconFactory *factory);
30+static guint gtk_rc_parse_logical_color (GScanner *scanner,
31+ GtkRcStyle *rc_style,
32+ GtkHashTable *hash);
33+static guint gtk_rc_parse_color_full (GScanner *scanner,
34+ GdkColor *color,
35+ GtkRcStyle *style);
36+
37 static void gtk_rc_clear_hash_node (gpointer key,
38 gpointer data,
39 gpointer user_data);
40@@ -277,7 +293,8 @@
41 { "stock", GTK_RC_TOKEN_STOCK },
42 { "im_module_file", GTK_RC_TOKEN_IM_MODULE_FILE },
43 { "LTR", GTK_RC_TOKEN_LTR },
44- { "RTL", GTK_RC_TOKEN_RTL }
45+ { "RTL", GTK_RC_TOKEN_RTL },
46+ { "logical_color", GTK_RC_TOKEN_LOGICAL_COLOR }
47 };
48
49 static GHashTable *realized_style_ht = NULL;
50@@ -954,6 +971,7 @@
51 static void
52 gtk_rc_style_init (GtkRcStyle *style)
53 {
54+ GtkRcStylePrivate *priv = GTK_RC_STYLE_GET_PRIVATE (style);
55 guint i;
56
57 style->name = NULL;
58@@ -976,6 +994,7 @@
59
60 style->rc_style_lists = NULL;
61 style->icon_factories = NULL;
62+ priv->logical_color_hashes = NULL;
63 }
64
65 static void
66@@ -991,6 +1010,21 @@
67 klass->create_rc_style = gtk_rc_style_real_create_rc_style;
68 klass->merge = gtk_rc_style_real_merge;
69 klass->create_style = gtk_rc_style_real_create_style;
70+
71+ g_type_class_add_private (object_class, sizeof (GtkRcStylePrivate));
72+}
73+
74+static void
75+free_object_list (GSList *list)
76+{
77+ GSList *tmp_list = list;
78+ while (tmp_list)
79+ {
80+ g_object_unref (tmp_list->data);
81+ tmp_list = tmp_list->next;
82+ }
83+ g_slist_free (list);
84+
85 }
86
87 static void
88@@ -998,9 +1032,11 @@
89 {
90 GSList *tmp_list1, *tmp_list2;
91 GtkRcStyle *rc_style;
92+ GtkRcStylePrivate *rc_priv;
93 gint i;
94
95 rc_style = GTK_RC_STYLE (object);
96+ rc_priv = GTK_RC_STYLE_GET_PRIVATE (rc_style);
97
98 if (rc_style->name)
99 g_free (rc_style->name);
100@@ -1059,13 +1095,8 @@
101 rc_style->rc_properties = NULL;
102 }
103
104- tmp_list1 = rc_style->icon_factories;
105- while (tmp_list1)
106- {
107- g_object_unref (tmp_list1->data);
108- tmp_list1 = tmp_list1->next;
109- }
110- g_slist_free (rc_style->icon_factories);
111+ free_object_list (rc_style->icon_factories);
112+ free_object_list (rc_priv->logical_color_hashes);
113
114 G_OBJECT_CLASS (parent_class)->finalize (object);
115 }
116@@ -1125,6 +1156,14 @@
117 return g_object_new (G_OBJECT_TYPE (style), NULL);
118 }
119
120+GSList *
121+_gtk_rc_style_get_logical_color_hashes (GtkRcStyle *rc_style)
122+{
123+ GtkRcStylePrivate *priv = GTK_RC_STYLE_GET_PRIVATE (rc_style);
124+
125+ return priv->logical_color_hashes;
126+}
127+
128 static gint
129 gtk_rc_properties_cmp (gconstpointer bsearch_node1,
130 gconstpointer bsearch_node2)
131@@ -1499,6 +1538,22 @@
132 context->rc_files = NULL;
133
134 gtk_rc_parse_default_files (context);
135+/*Hildon- Swapped these sections of code, so the styles from the
136+ XSettings theme are available when parsing with gtk_rc_context_parse_string*/
137+ g_free (context->theme_name);
138+ g_free (context->key_theme_name);
139+
140+ g_object_get (context->settings,
141+ "gtk-theme-name", &context->theme_name,
142+ "gtk-key-theme-name", &context->key_theme_name,
143+ NULL);
144+
145+ if (context->theme_name && context->theme_name[0])
146+ gtk_rc_parse_named (context, context->theme_name, NULL);
147+ if (context->key_theme_name && context->key_theme_name[0])
148+ gtk_rc_parse_named (context, context->key_theme_name, "key");
149+
150+/*****/
151
152 tmp_list = global_rc_files;
153 while (tmp_list)
154@@ -1512,19 +1567,6 @@
155
156 tmp_list = tmp_list->next;
157 }
158-
159- g_free (context->theme_name);
160- g_free (context->key_theme_name);
161-
162- g_object_get (context->settings,
163- "gtk-theme-name", &context->theme_name,
164- "gtk-key-theme-name", &context->key_theme_name,
165- NULL);
166-
167- if (context->theme_name && context->theme_name[0])
168- gtk_rc_parse_named (context, context->theme_name, NULL);
169- if (context->key_theme_name && context->key_theme_name[0])
170- gtk_rc_parse_named (context, context->key_theme_name, "key");
171
172 g_object_thaw_notify (G_OBJECT (context->settings));
173
174@@ -1905,10 +1947,19 @@
175 {
176 GScanner *scanner;
177 guint i;
178+ gchar *name_str;
179 gboolean done;
180
181 scanner = gtk_rc_scanner_new ();
182
183+ if (input_name != NULL)
184+ {
185+ name_str = (gchar *) g_malloc(strlen(input_name) + 7);
186+ sprintf(name_str, "%s.cache", input_name);
187+ /*osso_g_scanner_cache_open (scanner, name_str);*/
188+ g_free(name_str);
189+ }
190+
191 if (input_fd >= 0)
192 {
193 g_assert (input_string == NULL);
194@@ -2062,6 +2113,29 @@
195 return style;
196 }
197
198+static GSList *
199+concat_object_lists (GSList *list_a, GSList *list_b)
200+{
201+ GSList *copy;
202+
203+ copy = g_slist_copy (list_b);
204+ if (copy)
205+ {
206+ GSList *iter;
207+
208+ iter = copy;
209+ while (iter != NULL)
210+ {
211+ g_object_ref (iter->data);
212+ iter = g_slist_next (iter);
213+ }
214+
215+ return g_slist_concat (list_a, copy);
216+ }
217+ else
218+ return list_a;
219+}
220+
221 /* Reuses or frees rc_styles */
222 static GtkStyle *
223 gtk_rc_init_style (GtkRcContext *context,
224@@ -2083,6 +2157,7 @@
225 GtkRcStyle *base_style = NULL;
226 GtkRcStyle *proto_style;
227 GtkRcStyleClass *proto_style_class;
228+ GtkRcStylePrivate *proto_priv;
229 GSList *tmp_styles;
230 GType rc_style_type = GTK_TYPE_RC_STYLE;
231
232@@ -2109,12 +2184,13 @@
233
234 proto_style_class = GTK_RC_STYLE_GET_CLASS (base_style);
235 proto_style = proto_style_class->create_rc_style (base_style);
236+ proto_priv = GTK_RC_STYLE_GET_PRIVATE (proto_style);
237
238 tmp_styles = rc_styles;
239 while (tmp_styles)
240 {
241 GtkRcStyle *rc_style = tmp_styles->data;
242- GSList *factories;
243+ GtkRcStylePrivate *rc_priv = GTK_RC_STYLE_GET_PRIVATE (rc_style);
244
245 proto_style_class->merge (proto_style, rc_style);
246
247@@ -2122,22 +2198,12 @@
248 if (!g_slist_find (rc_style->rc_style_lists, rc_styles))
249 rc_style->rc_style_lists = g_slist_prepend (rc_style->rc_style_lists, rc_styles);
250
251- factories = g_slist_copy (rc_style->icon_factories);
252- if (factories)
253- {
254- GSList *iter;
255-
256- iter = factories;
257- while (iter != NULL)
258- {
259- g_object_ref (iter->data);
260- iter = g_slist_next (iter);
261- }
262-
263- proto_style->icon_factories = g_slist_concat (proto_style->icon_factories,
264- factories);
265-
266- }
267+ proto_style->icon_factories =
268+ concat_object_lists (proto_style->icon_factories,
269+ rc_style->icon_factories);
270+ proto_priv->logical_color_hashes =
271+ concat_object_lists (proto_priv->logical_color_hashes,
272+ rc_priv->logical_color_hashes);
273
274 tmp_styles = tmp_styles->next;
275 }
276@@ -2515,9 +2581,11 @@
277 GtkRcStyle *rc_style;
278 GtkRcStyle *orig_style;
279 GtkRcStyle *parent_style;
280+ GtkRcStylePrivate *rc_priv = NULL;
281 guint token;
282 gint i;
283 GtkIconFactory *our_factory = NULL;
284+ GtkHashTable *our_hash = NULL;
285
286 token = g_scanner_get_next_token (scanner);
287 if (token != GTK_RC_TOKEN_STYLE)
288@@ -2533,12 +2601,6 @@
289 else
290 orig_style = NULL;
291
292- /* If there's a list, its first member is always the factory belonging
293- * to this RcStyle
294- */
295- if (rc_style && rc_style->icon_factories)
296- our_factory = rc_style->icon_factories->data;
297-
298 if (!rc_style)
299 {
300 rc_style = gtk_rc_style_new ();
301@@ -2550,6 +2612,16 @@
302 for (i = 0; i < 5; i++)
303 rc_style->color_flags[i] = 0;
304 }
305+
306+ rc_priv = GTK_RC_STYLE_GET_PRIVATE (rc_style);
307+
308+ /* If there's a list, its first member is always the factory belonging
309+ * to this RcStyle
310+ */
311+ if (rc_style->icon_factories)
312+ our_factory = rc_style->icon_factories->data;
313+ if (rc_priv->logical_color_hashes)
314+ our_hash = rc_priv->logical_color_hashes->data;
315
316 token = g_scanner_peek_next_token (scanner);
317 if (token == G_TOKEN_EQUAL_SIGN)
318@@ -2566,8 +2638,8 @@
319 parent_style = gtk_rc_style_find (context, scanner->value.v_string);
320 if (parent_style)
321 {
322- GSList *factories;
323-
324+ GtkRcStylePrivate *parent_priv = GTK_RC_STYLE_GET_PRIVATE (parent_style);
325+
326 for (i = 0; i < 5; i++)
327 {
328 rc_style->color_flags[i] = parent_style->color_flags[i];
329@@ -2621,17 +2693,24 @@
330 rc_style->icon_factories = g_slist_prepend (rc_style->icon_factories,
331 our_factory);
332 }
333-
334- rc_style->icon_factories = g_slist_concat (rc_style->icon_factories,
335- g_slist_copy (parent_style->icon_factories));
336-
337- factories = parent_style->icon_factories;
338- while (factories != NULL)
339+ rc_style->icon_factories = concat_object_lists (rc_style->icon_factories,
340+ parent_style->icon_factories);
341+ }
342+
343+ /* Also append parent's color hashes, adding a ref to them */
344+ if (parent_priv->logical_color_hashes != NULL)
345+ {
346+ /* See comment above .. */
347+ if (our_hash == NULL)
348 {
349- g_object_ref (factories->data);
350- factories = factories->next;
351+ our_hash = _gtk_hash_table_new ();
352+ rc_priv->logical_color_hashes = g_slist_prepend (rc_priv->logical_color_hashes,
353+ our_hash);
354 }
355- }
356+
357+ rc_priv->logical_color_hashes = concat_object_lists (rc_priv->logical_color_hashes,
358+ parent_priv->logical_color_hashes);
359+ }
360 }
361 }
362
363@@ -2689,12 +2768,22 @@
364 }
365 token = gtk_rc_parse_stock (context, scanner, rc_style, our_factory);
366 break;
367+ case GTK_RC_TOKEN_LOGICAL_COLOR:
368+ if (our_hash == NULL)
369+ {
370+ our_hash = _gtk_hash_table_new ();
371+ rc_priv->logical_color_hashes = g_slist_prepend (rc_priv->logical_color_hashes,
372+ our_hash);
373+ }
374+ token = gtk_rc_parse_logical_color (scanner, rc_style, our_hash);
375+ break;
376 case G_TOKEN_IDENTIFIER:
377 if (is_c_identifier (scanner->next_value.v_identifier) &&
378 scanner->next_value.v_identifier[0] >= 'A' &&
379 scanner->next_value.v_identifier[0] <= 'Z') /* match namespaced type names */
380 {
381 GtkRcProperty prop = { 0, 0, NULL, { 0, }, };
382+ gchar *name;
383
384 g_scanner_get_next_token (scanner); /* eat type name */
385 prop.type_name = g_quark_from_string (scanner->value.v_identifier);
386@@ -2712,8 +2801,10 @@
387 }
388
389 /* it's important that we do the same canonification as GParamSpecPool here */
390- g_strcanon (scanner->value.v_identifier, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
391- prop.property_name = g_quark_from_string (scanner->value.v_identifier);
392+ name = g_strdup (scanner->value.v_identifier);
393+ g_strcanon (name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
394+ prop.property_name = g_quark_from_string (name);
395+ g_free (name);
396
397 token = gtk_rc_parse_assignment (scanner, &prop);
398 if (token == G_TOKEN_NONE)
399@@ -2825,7 +2916,7 @@
400 return G_TOKEN_EQUAL_SIGN;
401
402 style->color_flags[state] |= GTK_RC_BG;
403- return gtk_rc_parse_color (scanner, &style->bg[state]);
404+ return gtk_rc_parse_color_full (scanner, &style->bg[state], style);
405 }
406
407 static guint
408@@ -2848,7 +2939,7 @@
409 return G_TOKEN_EQUAL_SIGN;
410
411 style->color_flags[state] |= GTK_RC_FG;
412- return gtk_rc_parse_color (scanner, &style->fg[state]);
413+ return gtk_rc_parse_color_full (scanner, &style->fg[state], style);
414 }
415
416 static guint
417@@ -2871,7 +2962,7 @@
418 return G_TOKEN_EQUAL_SIGN;
419
420 style->color_flags[state] |= GTK_RC_TEXT;
421- return gtk_rc_parse_color (scanner, &style->text[state]);
422+ return gtk_rc_parse_color_full (scanner, &style->text[state], style);
423 }
424
425 static guint
426@@ -2894,7 +2985,7 @@
427 return G_TOKEN_EQUAL_SIGN;
428
429 style->color_flags[state] |= GTK_RC_BASE;
430- return gtk_rc_parse_color (scanner, &style->base[state]);
431+ return gtk_rc_parse_color_full (scanner, &style->base[state], style);
432 }
433
434 static guint
435@@ -3345,11 +3436,45 @@
436
437 return G_TOKEN_NONE;
438 }
439+static gboolean
440+lookup_logical_color (GtkRcStyle *style,
441+ const char *color_name,
442+ GdkColor *color)
443+{
444+ GtkRcStylePrivate *priv = GTK_RC_STYLE_GET_PRIVATE (style);
445+ GSList *iter;
446+
447+ iter = priv->logical_color_hashes;
448+ while (iter != NULL)
449+ {
450+ GdkColor *match = g_hash_table_lookup (GTK_HASH_TABLE (iter->data)->hash,
451+ color_name);
452+ if (match)
453+ {
454+ color->red = match->red;
455+ color->green = match->green;
456+ color->blue = match->blue;
457+ return TRUE;
458+ }
459+
460+ iter = g_slist_next (iter);
461+ }
462+
463+ return FALSE;
464+}
465
466 guint
467 gtk_rc_parse_color (GScanner *scanner,
468 GdkColor *color)
469 {
470+ return gtk_rc_parse_color_full (scanner, color, NULL);
471+}
472+
473+static guint
474+gtk_rc_parse_color_full (GScanner *scanner,
475+ GdkColor *color,
476+ GtkRcStyle *style)
477+{
478 guint token;
479
480 g_return_val_if_fail (scanner != NULL, G_TOKEN_ERROR);
481@@ -3407,11 +3532,14 @@
482 case G_TOKEN_STRING:
483 if (!gdk_color_parse (scanner->value.v_string, color))
484 {
485- g_scanner_warn (scanner, "Invalid color constant '%s'",
486- scanner->value.v_string);
487- return G_TOKEN_STRING;
488+ if (!(style && lookup_logical_color (style, scanner->value.v_string, color)))
489+ {
490+ g_scanner_warn (scanner, "Invalid color constant '%s'",
491+ scanner->value.v_string);
492+ return G_TOKEN_STRING;
493+ }
494 }
495- else
496+
497 return G_TOKEN_NONE;
498
499 default:
500@@ -3625,8 +3753,8 @@
501 }
502
503 static guint
504-gtk_rc_parse_stock_id (GScanner *scanner,
505- gchar **stock_id)
506+gtk_rc_parse_hash_key (GScanner *scanner,
507+ gchar **hash_key)
508 {
509 guint token;
510
511@@ -3639,12 +3767,12 @@
512 if (token != G_TOKEN_STRING)
513 return G_TOKEN_STRING;
514
515- *stock_id = g_strdup (scanner->value.v_string);
516+ *hash_key = g_strdup (scanner->value.v_string);
517
518 token = g_scanner_get_next_token (scanner);
519 if (token != G_TOKEN_RIGHT_BRACE)
520 {
521- g_free (*stock_id);
522+ g_free (*hash_key);
523 return G_TOKEN_RIGHT_BRACE;
524 }
525
526@@ -3854,7 +3982,7 @@
527 if (token != GTK_RC_TOKEN_STOCK)
528 return GTK_RC_TOKEN_STOCK;
529
530- token = gtk_rc_parse_stock_id (scanner, &stock_id);
531+ token = gtk_rc_parse_hash_key (scanner, &stock_id);
532 if (token != G_TOKEN_NONE)
533 return token;
534
535@@ -3965,3 +4093,46 @@
536 }
537
538 #endif
539+
540+static guint
541+gtk_rc_parse_logical_color (GScanner *scanner,
542+ GtkRcStyle *rc_style,
543+ GtkHashTable *hash)
544+{
545+ gchar *color_id = NULL;
546+ guint token;
547+ GdkColor *color;
548+
549+ token = g_scanner_get_next_token (scanner);
550+ if (token != GTK_RC_TOKEN_LOGICAL_COLOR)
551+ return GTK_RC_TOKEN_LOGICAL_COLOR;
552+
553+ token = gtk_rc_parse_hash_key (scanner, &color_id);
554+ if (token != G_TOKEN_NONE)
555+ return token;
556+
557+ token = g_scanner_get_next_token (scanner);
558+ if (token != G_TOKEN_EQUAL_SIGN)
559+ {
560+ g_free (color_id);
561+ return G_TOKEN_EQUAL_SIGN;
562+ }
563+
564+ color = g_new (GdkColor, 1);
565+ token = gtk_rc_parse_color_full (scanner, color, rc_style);
566+ if (token != G_TOKEN_NONE)
567+ {
568+ g_free (color_id);
569+ g_free (color);
570+ return token;
571+ }
572+
573+ /* Because the hash is created with destroy functions,
574+ * g_hash_table_insert will free any old values for us,
575+ * if a mapping with the specified key already exists. */
576+ g_hash_table_insert (hash->hash, color_id, color);
577+
578+ return G_TOKEN_NONE;
579+}
580+
581+