summaryrefslogtreecommitdiffstats
path: root/abs/extra/gconf/01_xml-gettext-domain.patch
blob: 7491ca8fb8345975e3385147f89617dc26d87edc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# 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.
# Ubuntu: https://bugs.launchpad.net/bugs/123025
# Upstream: http://bugzilla.gnome.org/show_bug.cgi?id=568845
diff -Nur -x '*.orig' -x '*~' gconf-2.25.0/backends/markup-tree.c gconf-2.25.0.new/backends/markup-tree.c
--- gconf-2.25.0/backends/markup-tree.c	2009-01-10 05:55:08.000000000 +0100
+++ gconf-2.25.0.new/backends/markup-tree.c	2009-01-23 12:11:48.000000000 +0100
@@ -52,6 +52,7 @@
   char       *schema_name;
   char       *mod_user;
   GTime       mod_time;
+  char       *gettext_domain;
 };
 
 static LocalSchemaInfo* local_schema_info_new  (void);
@@ -1351,6 +1352,7 @@
     gconf_value_free (entry->value);
   g_free (entry->schema_name);
   g_free (entry->mod_user);
+  g_free (entry->gettext_domain);
 
   g_slist_foreach (entry->local_schemas,
                    (GFunc) local_schema_info_free,
@@ -1593,6 +1595,8 @@
                              gconf_schema_get_type (schema));
       gconf_schema_set_owner (current_schema,
                               gconf_schema_get_owner (schema));
+      gconf_schema_set_gettext_domain (current_schema,
+                              gconf_schema_get_gettext_domain (schema));
     }
 
   /* Update mod time */
@@ -1805,6 +1809,8 @@
       else if (c_local_schema && c_local_schema->long_desc)
         gconf_schema_set_long_desc (schema, c_local_schema->long_desc);
 
+      gconf_schema_set_gettext_domain (schema, entry->gettext_domain);
+
       return retval;
     }
 }
@@ -2339,8 +2345,9 @@
   const char *ltype;
   const char *list_type;
   const char *owner;
+
   GConfValueType vtype;
-  const char *dummy1, *dummy2, *dummy3, *dummy4;
+  const char *dummy1, *dummy2, *dummy3, *dummy4, *dummy5;
   
 #if 0
   g_assert (ELEMENT_IS ("entry") ||
@@ -2377,6 +2384,7 @@
                           "muser", &dummy2,
                           "mtime", &dummy3,
                           "schema", &dummy4,
+                          "gettext_domain", &dummy5,
 
                           NULL))
     return;
@@ -2682,6 +2690,7 @@
       const char *mtime;
       const char *schema;
       const char *type;
+      const char *gettext_domain;
       const char *dummy1, *dummy2, *dummy3, *dummy4;
       const char *dummy5, *dummy6, *dummy7;
       GConfValue *value;
@@ -2692,6 +2701,7 @@
       mtime = NULL;
       schema = NULL;
       type = NULL;
+      gettext_domain = NULL;
 
       if (!locate_attributes (context, element_name, attribute_names, attribute_values,
                               error,
@@ -2700,6 +2710,7 @@
                               "mtime", &mtime,
                               "schema", &schema,
                               "type", &type,
+                              "gettext_domain", &gettext_domain,
                           
                               /* These are allowed but we don't use them until
                                * parse_value_element
@@ -2767,6 +2778,9 @@
        */
       if (schema)
         entry->schema_name = g_strdup (schema);
+
+      if (gettext_domain)
+        entry->gettext_domain = g_strdup (gettext_domain);
     }
   else
     {
@@ -3705,6 +3719,7 @@
         GConfSchema *schema;
         GConfValueType stype;
         const char *owner;
+        const char *gettext_domain;
         
         schema = gconf_value_get_schema (value);
 
@@ -3730,6 +3745,23 @@
             
             g_free (s);
           }
+
+        gettext_domain = gconf_schema_get_gettext_domain (schema);
+        
+        if (gettext_domain)
+          {
+            char *s;
+
+            s = g_markup_escape_text (gettext_domain, -1);
+            
+            if (fprintf (f, " gettext_domain=\"%s\"", s) < 0)
+              {
+                g_free (s);
+                return FALSE;
+              }
+            
+            g_free (s);
+          }
         
         if (stype == GCONF_VALUE_LIST)
           {
diff -Nur -x '*.orig' -x '*~' gconf-2.25.0/gconf/gconf-schema.c gconf-2.25.0.new/gconf/gconf-schema.c
--- gconf-2.25.0/gconf/gconf-schema.c	2009-01-10 05:55:07.000000000 +0100
+++ gconf-2.25.0.new/gconf/gconf-schema.c	2009-01-23 12:11:48.000000000 +0100
@@ -35,6 +35,7 @@
   gchar* owner;        /* Name of creating application */
   gchar* short_desc;   /* 40 char or less description, no newlines */
   gchar* long_desc;    /* could be a paragraph or so */
+  gchar* gettext_domain; /* description gettext domain */
   GConfValue* default_value; /* Default value of the key */
 } GConfRealSchema;
 
@@ -63,6 +64,7 @@
   g_free (real->locale);
   g_free (real->short_desc);
   g_free (real->long_desc);
+  g_free (real->gettext_domain);
   g_free (real->owner);
 
   if (real->default_value)
@@ -91,6 +93,8 @@
 
   dest->long_desc = g_strdup (real->long_desc);
 
+  dest->gettext_domain = g_strdup (real->gettext_domain);
+
   dest->owner = g_strdup (real->owner);
 
   dest->default_value = real->default_value ? gconf_value_copy (real->default_value) : NULL;
@@ -136,6 +140,20 @@
     REAL_SCHEMA (sc)->locale = NULL;
 }
 
+void
+gconf_schema_set_gettext_domain (GConfSchema* sc, const gchar* domain)
+{
+  g_return_if_fail (domain == NULL || g_utf8_validate (domain, -1, NULL));
+  
+  if (REAL_SCHEMA (sc)->gettext_domain)
+    g_free (REAL_SCHEMA (sc)->gettext_domain);
+
+  if (domain)
+    REAL_SCHEMA (sc)->gettext_domain = g_strdup (domain);
+  else 
+    REAL_SCHEMA (sc)->gettext_domain = NULL;
+}
+
 void          
 gconf_schema_set_short_desc (GConfSchema* sc, const gchar* desc)
 {
@@ -228,6 +246,14 @@
       return FALSE;
     }
 
+  if (real->gettext_domain && !g_utf8_validate (real->gettext_domain, -1, NULL))
+    {
+      g_set_error (err, GCONF_ERROR,
+                   GCONF_ERROR_FAILED,
+                   _("Schema contains invalid UTF-8"));
+      return FALSE;
+    }
+
   if (real->owner && !g_utf8_validate (real->owner, -1, NULL))
     {
       g_set_error (err, GCONF_ERROR,
@@ -299,11 +325,22 @@
 }
 
 const char*
+gconf_schema_get_gettext_domain (const GConfSchema *schema)
+{
+  g_return_val_if_fail (schema != NULL, NULL);
+
+  return REAL_SCHEMA (schema)->gettext_domain;
+}
+
+const char*
 gconf_schema_get_short_desc (const GConfSchema *schema)
 {
   g_return_val_if_fail (schema != NULL, NULL);
 
-  return REAL_SCHEMA (schema)->short_desc;
+ if (REAL_SCHEMA (schema)->gettext_domain)
+    return g_dgettext(REAL_SCHEMA (schema)->gettext_domain, REAL_SCHEMA (schema)->short_desc);
+  else
+    return REAL_SCHEMA (schema)->short_desc;
 }
 
 const char*
@@ -311,7 +348,10 @@
 {
   g_return_val_if_fail (schema != NULL, NULL);
 
-  return REAL_SCHEMA (schema)->long_desc;
+  if (REAL_SCHEMA (schema)->gettext_domain)
+    return dgettext(REAL_SCHEMA (schema)->gettext_domain, REAL_SCHEMA (schema)->long_desc);
+  else
+    return REAL_SCHEMA (schema)->long_desc;
 }
 
 const char*
diff -Nur -x '*.orig' -x '*~' gconf-2.25.0/gconf/gconf-schema.h gconf-2.25.0.new/gconf/gconf-schema.h
--- gconf-2.25.0/gconf/gconf-schema.h	2009-01-10 05:55:07.000000000 +0100
+++ gconf-2.25.0.new/gconf/gconf-schema.h	2009-01-23 12:11:48.000000000 +0100
@@ -48,6 +48,8 @@
                                             GConfValueType  type);
 void gconf_schema_set_locale               (GConfSchema    *sc,
                                             const gchar    *locale);
+void gconf_schema_set_gettext_domain       (GConfSchema    *sc,
+                                            const gchar    *domain);
 void gconf_schema_set_short_desc           (GConfSchema    *sc,
                                             const gchar    *desc);
 void gconf_schema_set_long_desc            (GConfSchema    *sc,
@@ -65,6 +67,7 @@
 GConfValueType gconf_schema_get_car_type      (const GConfSchema *schema);
 GConfValueType gconf_schema_get_cdr_type      (const GConfSchema *schema);
 const char*    gconf_schema_get_locale        (const GConfSchema *schema);
+const char*    gconf_schema_get_gettext_domain(const GConfSchema *schema);
 const char*    gconf_schema_get_short_desc    (const GConfSchema *schema);
 const char*    gconf_schema_get_long_desc     (const GConfSchema *schema);
 const char*    gconf_schema_get_owner         (const GConfSchema *schema);
diff -Nur -x '*.orig' -x '*~' gconf-2.25.0/gconf/gconftool.c gconf-2.25.0.new/gconf/gconftool.c
--- gconf-2.25.0/gconf/gconftool.c	2009-01-10 05:55:07.000000000 +0100
+++ gconf-2.25.0.new/gconf/gconftool.c	2009-01-23 12:11:48.000000000 +0100
@@ -3293,6 +3293,7 @@
   GConfValueType cdr_type;
   GConfValue* global_default;
   GHashTable* hash;
+  gchar* gettext_domain;
 };
 
 static int
@@ -3545,6 +3546,15 @@
               else
                 g_printerr (_("WARNING: empty <applyto> node"));
             }
+          else if (strcmp((char *)iter->name, "gettext_domain") == 0)
+            {
+              tmp = (char *)xmlNodeGetContent(iter);
+              if (tmp)
+                {
+                  info->gettext_domain = g_strdup(tmp);
+                  xmlFree(tmp);
+                }
+            }
           else
             g_printerr (_("WARNING: node <%s> not understood below <schema>\n"),
 			iter->name);
@@ -3634,6 +3644,9 @@
   if (info->owner != NULL)
     gconf_schema_set_owner(schema, info->owner);
 
+  if (info->gettext_domain != NULL)
+    gconf_schema_set_gettext_domain(schema, info->gettext_domain);
+
   xmlFree(name);
 
   /* Locale-specific info */
@@ -3763,6 +3776,7 @@
   info.apply_to = NULL;
   info.owner = NULL;
   info.global_default = NULL;
+  info.gettext_domain = NULL;
   info.hash = g_hash_table_new(g_str_hash, g_str_equal);
   
   extract_global_info(node, &info);
@@ -3799,6 +3813,8 @@
             ;  /* nothing */
           else if (strcmp((char *)iter->name, "applyto") == 0)
             ;  /* nothing */
+          else if (strcmp((char *)iter->name, "gettext_domain") == 0)
+            ;  /* nothing */
           else if (strcmp((char *)iter->name, "locale") == 0)
             {
               process_locale_info(iter, &info);