updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / lib32-gconf / 01_xml-gettext-domain.patch
blobd1323f61f22faa06d99c4e4088e66cf7804a7050
1 # Description: Support calling gettext at runtime and putting the gettext domain into the .schemas file instead of replicating translations in /usr/share/gconf/schemas/*.schemas *and* /var/lib/gconf/defaults/%gconf-tree-$LANG.xml. This saves in the order of 90 MB uncompressed/10 MB compressed on hard disks.
2 # Ubuntu: https://bugs.launchpad.net/bugs/123025
3 # Upstream: http://bugzilla.gnome.org/show_bug.cgi?id=568845
4 --- GConf-2.26.0/backends/markup-tree.c.gettext 2009-04-26 23:33:05.258484987 -0400
5 +++ GConf-2.26.0/backends/markup-tree.c 2009-04-26 23:34:25.026700526 -0400
6 @@ -52,6 +52,7 @@ struct _MarkupEntry
7 char *schema_name;
8 char *mod_user;
9 GTime mod_time;
10 + const char *gettext_domain;
13 static LocalSchemaInfo* local_schema_info_new (void);
14 @@ -1593,6 +1594,8 @@ markup_entry_set_value (MarkupEntry
15 gconf_schema_get_type (schema));
16 gconf_schema_set_owner (current_schema,
17 gconf_schema_get_owner (schema));
18 + gconf_schema_set_gettext_domain (current_schema,
19 + gconf_schema_get_gettext_domain (schema));
22 /* Update mod time */
23 @@ -1805,6 +1808,8 @@ markup_entry_get_value (MarkupEntry *ent
24 else if (c_local_schema && c_local_schema->long_desc)
25 gconf_schema_set_long_desc (schema, c_local_schema->long_desc);
27 + gconf_schema_set_gettext_domain (schema, entry->gettext_domain);
29 return retval;
32 @@ -2339,8 +2344,9 @@ parse_value_element (GMarkupParseContext
33 const char *ltype;
34 const char *list_type;
35 const char *owner;
37 GConfValueType vtype;
38 - const char *dummy1, *dummy2, *dummy3, *dummy4;
39 + const char *dummy1, *dummy2, *dummy3, *dummy4, *dummy5;
41 #if 0
42 g_assert (ELEMENT_IS ("entry") ||
43 @@ -2377,6 +2383,7 @@ parse_value_element (GMarkupParseContext
44 "muser", &dummy2,
45 "mtime", &dummy3,
46 "schema", &dummy4,
47 + "gettext_domain", &dummy5,
49 NULL))
50 return;
51 @@ -2683,6 +2690,7 @@ parse_entry_element (GMarkupParseContext
52 const char *mtime;
53 const char *schema;
54 const char *type;
55 + const char *gettext_domain;
56 const char *dummy1, *dummy2, *dummy3, *dummy4;
57 const char *dummy5, *dummy6, *dummy7;
58 GConfValue *value;
59 @@ -2693,6 +2701,7 @@ parse_entry_element (GMarkupParseContext
60 mtime = NULL;
61 schema = NULL;
62 type = NULL;
63 + gettext_domain = NULL;
65 if (!locate_attributes (context, element_name, attribute_names, attribute_values,
66 error,
67 @@ -2701,6 +2710,7 @@ parse_entry_element (GMarkupParseContext
68 "mtime", &mtime,
69 "schema", &schema,
70 "type", &type,
71 + "gettext_domain", &gettext_domain,
73 /* These are allowed but we don't use them until
74 * parse_value_element
75 @@ -2768,6 +2778,9 @@ parse_entry_element (GMarkupParseContext
77 if (schema)
78 entry->schema_name = g_strdup (schema);
80 + if (gettext_domain)
81 + entry->gettext_domain = g_intern_string (gettext_domain);
83 else
85 @@ -3716,6 +3729,7 @@ write_value_element (GConfValue *value,
86 GConfSchema *schema;
87 GConfValueType stype;
88 const char *owner;
89 + const char *gettext_domain;
91 schema = gconf_value_get_schema (value);
93 @@ -3741,6 +3755,23 @@ write_value_element (GConfValue *value,
95 g_free (s);
98 + gettext_domain = gconf_schema_get_gettext_domain (schema);
100 + if (gettext_domain)
102 + char *s;
104 + s = g_markup_escape_text (gettext_domain, -1);
106 + if (fprintf (f, " gettext_domain=\"%s\"", s) < 0)
108 + g_free (s);
109 + return FALSE;
112 + g_free (s);
115 if (stype == GCONF_VALUE_LIST)
117 diff -up GConf-2.26.0/doc/gconf-1.0.dtd.gettext GConf-2.26.0/doc/gconf-1.0.dtd
118 --- GConf-2.26.0/doc/gconf-1.0.dtd.gettext 2009-04-26 23:33:17.240736103 -0400
119 +++ GConf-2.26.0/doc/gconf-1.0.dtd 2009-04-26 23:34:25.027700384 -0400
120 @@ -7,7 +7,7 @@
121 <!-- A single schema. What I am trying to say is "this set of
122 elements, in any order". Duplicate elements (apart from <locale>) are
123 not allowed). -->
124 -<!ELEMENT schema (key|applyto*|owner?|type|(list_type|(car_type,cdr_type))?|default?|locale*)*>
125 +<!ELEMENT schema (key|applyto*|owner?|type|(list_type|(car_type,cdr_type))?|default?|locale*|gettext_domain?)*>
127 <!-- The key for this schema (e.g. /schemas/apps/foo/bar) -->
128 <!ELEMENT key (#PCDATA)>
129 diff -up GConf-2.26.0/gconf/gconf-internals.c.gettext GConf-2.26.0/gconf/gconf-internals.c
130 --- GConf-2.26.0/gconf/gconf-internals.c.gettext 2009-04-26 23:34:10.994700035 -0400
131 +++ GConf-2.26.0/gconf/gconf-internals.c 2009-04-26 23:34:53.767450191 -0400
132 @@ -513,6 +513,7 @@ gconf_fill_corba_schema_from_gconf_schem
133 cs->short_desc = CORBA_string_dup (gconf_schema_get_short_desc (sc) ? gconf_schema_get_short_desc (sc) : "");
134 cs->long_desc = CORBA_string_dup (gconf_schema_get_long_desc (sc) ? gconf_schema_get_long_desc (sc) : "");
135 cs->owner = CORBA_string_dup (gconf_schema_get_owner (sc) ? gconf_schema_get_owner (sc) : "");
136 + cs->gettext_domain = CORBA_string_dup (gconf_schema_get_gettext_domain (sc) ? gconf_schema_get_gettext_domain (sc) : "");
139 gchar* encoded;
140 @@ -600,6 +601,14 @@ gconf_schema_from_corba_schema(const Con
141 gconf_schema_set_owner(sc, cs->owner);
144 + if (*cs->gettext_domain != '\0')
146 + if (!g_utf8_validate (cs->gettext_domain, -1, NULL))
147 + gconf_log (GCL_ERR, _("Invalid UTF-8 in gettext domain for schema"));
148 + else
149 + gconf_schema_set_gettext_domain(sc, cs->gettext_domain);
153 GConfValue* val;
155 diff -up GConf-2.26.0/gconf/gconf-schema.c.gettext GConf-2.26.0/gconf/gconf-schema.c
156 --- GConf-2.26.0/gconf/gconf-schema.c.gettext 2009-04-26 23:33:26.787483545 -0400
157 +++ GConf-2.26.0/gconf/gconf-schema.c 2009-04-26 23:35:54.240450142 -0400
158 @@ -32,9 +32,10 @@ typedef struct {
159 GConfValueType car_type; /* Pair car type of the described entry */
160 GConfValueType cdr_type; /* Pair cdr type of the described entry */
161 gchar* locale; /* Schema locale */
162 - gchar* owner; /* Name of creating application */
163 + const gchar* owner; /* Name of creating application */
164 gchar* short_desc; /* 40 char or less description, no newlines */
165 gchar* long_desc; /* could be a paragraph or so */
166 + const gchar* gettext_domain; /* description gettext domain */
167 GConfValue* default_value; /* Default value of the key */
168 } GConfRealSchema;
170 @@ -63,7 +64,6 @@ gconf_schema_free (GConfSchema* sc)
171 g_free (real->locale);
172 g_free (real->short_desc);
173 g_free (real->long_desc);
174 - g_free (real->owner);
176 if (real->default_value)
177 gconf_value_free (real->default_value);
178 @@ -91,7 +91,9 @@ gconf_schema_copy (const GConfSchema* sc
180 dest->long_desc = g_strdup (real->long_desc);
182 - dest->owner = g_strdup (real->owner);
183 + dest->gettext_domain = real->gettext_domain;
185 + dest->owner = real->owner;
187 dest->default_value = real->default_value ? gconf_value_copy (real->default_value) : NULL;
189 @@ -136,6 +138,17 @@ gconf_schema_set_locale (GConfSchema* sc
190 REAL_SCHEMA (sc)->locale = NULL;
193 +void
194 +gconf_schema_set_gettext_domain (GConfSchema* sc, const gchar* domain)
196 + g_return_if_fail (domain == NULL || g_utf8_validate (domain, -1, NULL));
198 + if (domain)
199 + REAL_SCHEMA (sc)->gettext_domain = g_intern_string (domain);
200 + else
201 + REAL_SCHEMA (sc)->gettext_domain = NULL;
204 void
205 gconf_schema_set_short_desc (GConfSchema* sc, const gchar* desc)
207 @@ -169,11 +182,8 @@ gconf_schema_set_owner (GConfSchema* sc,
209 g_return_if_fail (owner == NULL || g_utf8_validate (owner, -1, NULL));
211 - if (REAL_SCHEMA (sc)->owner)
212 - g_free (REAL_SCHEMA (sc)->owner);
214 if (owner)
215 - REAL_SCHEMA (sc)->owner = g_strdup (owner);
216 + REAL_SCHEMA (sc)->owner = g_intern_string (owner);
217 else
218 REAL_SCHEMA (sc)->owner = NULL;
220 @@ -228,6 +238,14 @@ gconf_schema_validate (const GConfSchema
221 return FALSE;
224 + if (real->gettext_domain && !g_utf8_validate (real->gettext_domain, -1, NULL))
226 + g_set_error (err, GCONF_ERROR,
227 + GCONF_ERROR_FAILED,
228 + _("Schema contains invalid UTF-8"));
229 + return FALSE;
232 if (real->owner && !g_utf8_validate (real->owner, -1, NULL))
234 g_set_error (err, GCONF_ERROR,
235 @@ -299,11 +317,32 @@ gconf_schema_get_locale (const GConfSche
238 const char*
239 +gconf_schema_get_gettext_domain (const GConfSchema *schema)
241 + g_return_val_if_fail (schema != NULL, NULL);
243 + return REAL_SCHEMA (schema)->gettext_domain;
246 +static inline const char *
247 +schema_translate (const GConfSchema *schema,
248 + const char *string)
250 + if (REAL_SCHEMA (schema)->gettext_domain)
252 + bind_textdomain_codeset (REAL_SCHEMA (schema)->gettext_domain, "UTF-8");
253 + return g_dgettext(REAL_SCHEMA (schema)->gettext_domain, string);
255 + else
256 + return string;
259 +const char*
260 gconf_schema_get_short_desc (const GConfSchema *schema)
262 g_return_val_if_fail (schema != NULL, NULL);
264 - return REAL_SCHEMA (schema)->short_desc;
265 + return schema_translate (schema, REAL_SCHEMA (schema)->short_desc);
268 const char*
269 @@ -311,7 +350,7 @@ gconf_schema_get_long_desc (const GConfS
271 g_return_val_if_fail (schema != NULL, NULL);
273 - return REAL_SCHEMA (schema)->long_desc;
274 + return schema_translate (schema, REAL_SCHEMA (schema)->long_desc);
277 const char*
278 diff -up GConf-2.26.0/gconf/gconf-schema.h.gettext GConf-2.26.0/gconf/gconf-schema.h
279 --- GConf-2.26.0/gconf/gconf-schema.h.gettext 2009-04-26 23:33:33.979744088 -0400
280 +++ GConf-2.26.0/gconf/gconf-schema.h 2009-04-26 23:34:25.030737043 -0400
281 @@ -48,6 +48,8 @@ void gconf_schema_set_cdr_type
282 GConfValueType type);
283 void gconf_schema_set_locale (GConfSchema *sc,
284 const gchar *locale);
285 +void gconf_schema_set_gettext_domain (GConfSchema *sc,
286 + const gchar *domain);
287 void gconf_schema_set_short_desc (GConfSchema *sc,
288 const gchar *desc);
289 void gconf_schema_set_long_desc (GConfSchema *sc,
290 @@ -65,6 +67,7 @@ GConfValueType gconf_schema_get_list_typ
291 GConfValueType gconf_schema_get_car_type (const GConfSchema *schema);
292 GConfValueType gconf_schema_get_cdr_type (const GConfSchema *schema);
293 const char* gconf_schema_get_locale (const GConfSchema *schema);
294 +const char* gconf_schema_get_gettext_domain(const GConfSchema *schema);
295 const char* gconf_schema_get_short_desc (const GConfSchema *schema);
296 const char* gconf_schema_get_long_desc (const GConfSchema *schema);
297 const char* gconf_schema_get_owner (const GConfSchema *schema);
298 diff -up GConf-2.26.0/gconf/gconftool.c.gettext GConf-2.26.0/gconf/gconftool.c
299 --- GConf-2.26.0/gconf/gconftool.c.gettext 2009-04-26 23:33:41.907451190 -0400
300 +++ GConf-2.26.0/gconf/gconftool.c 2009-04-26 23:34:25.034736752 -0400
301 @@ -3295,6 +3295,7 @@ struct _SchemaInfo {
302 GConfValueType cdr_type;
303 GConfValue* global_default;
304 GHashTable* hash;
305 + gchar* gettext_domain;
308 static int
309 @@ -3547,6 +3548,15 @@ extract_global_info(xmlNodePtr node,
310 else
311 g_printerr (_("WARNING: empty <applyto> node"));
313 + else if (strcmp((char *)iter->name, "gettext_domain") == 0)
315 + tmp = (char *)xmlNodeGetContent(iter);
316 + if (tmp)
318 + info->gettext_domain = g_strdup(tmp);
319 + xmlFree(tmp);
322 else
323 g_printerr (_("WARNING: node <%s> not understood below <schema>\n"),
324 iter->name);
325 @@ -3636,6 +3646,9 @@ process_locale_info(xmlNodePtr node, Sch
326 if (info->owner != NULL)
327 gconf_schema_set_owner(schema, info->owner);
329 + if (info->gettext_domain != NULL)
330 + gconf_schema_set_gettext_domain(schema, info->gettext_domain);
332 xmlFree(name);
334 /* Locale-specific info */
335 @@ -3765,6 +3778,7 @@ get_schema_from_xml(xmlNodePtr node, gch
336 info.apply_to = NULL;
337 info.owner = NULL;
338 info.global_default = NULL;
339 + info.gettext_domain = NULL;
340 info.hash = g_hash_table_new(g_str_hash, g_str_equal);
342 extract_global_info(node, &info);
343 @@ -3801,6 +3815,8 @@ get_schema_from_xml(xmlNodePtr node, gch
344 ; /* nothing */
345 else if (strcmp((char *)iter->name, "applyto") == 0)
346 ; /* nothing */
347 + else if (strcmp((char *)iter->name, "gettext_domain") == 0)
348 + ; /* nothing */
349 else if (strcmp((char *)iter->name, "locale") == 0)
351 process_locale_info(iter, &info);
352 diff -up GConf-2.26.0/gconf/GConfX.idl.gettext GConf-2.26.0/gconf/GConfX.idl
353 --- GConf-2.26.0/gconf/GConfX.idl.gettext 2009-04-26 23:33:58.457483190 -0400
354 +++ GConf-2.26.0/gconf/GConfX.idl 2009-04-26 23:34:53.764448732 -0400
355 @@ -16,6 +16,7 @@ struct ConfigSchema {
356 string short_desc;
357 string long_desc;
358 string owner;
359 + string gettext_domain;
360 // Work around lack of recursive data types
361 string encoded_default_value;