Blame SOURCES/GConf-gettext.patch

8bcab4
diff -up GConf-2.26.0/backends/markup-tree.c.gettext GConf-2.26.0/backends/markup-tree.c
8bcab4
--- GConf-2.26.0/backends/markup-tree.c.gettext	2009-04-26 23:33:05.258484987 -0400
8bcab4
+++ GConf-2.26.0/backends/markup-tree.c	2009-04-26 23:34:25.026700526 -0400
8bcab4
@@ -52,6 +52,7 @@ struct _MarkupEntry
8bcab4
   char       *schema_name;
8bcab4
   char       *mod_user;
8bcab4
   GTime       mod_time;
8bcab4
+  const char *gettext_domain;
8bcab4
 };
8bcab4
 
8bcab4
 static LocalSchemaInfo* local_schema_info_new  (void);
8bcab4
@@ -1593,6 +1594,8 @@ markup_entry_set_value (MarkupEntry     
8bcab4
                              gconf_schema_get_type (schema));
8bcab4
       gconf_schema_set_owner (current_schema,
8bcab4
                               gconf_schema_get_owner (schema));
8bcab4
+      gconf_schema_set_gettext_domain (current_schema,
8bcab4
+                              gconf_schema_get_gettext_domain (schema));
8bcab4
     }
8bcab4
 
8bcab4
   /* Update mod time */
8bcab4
@@ -1805,6 +1808,8 @@ markup_entry_get_value (MarkupEntry *ent
8bcab4
       else if (c_local_schema && c_local_schema->long_desc)
8bcab4
         gconf_schema_set_long_desc (schema, c_local_schema->long_desc);
8bcab4
 
8bcab4
+      gconf_schema_set_gettext_domain (schema, entry->gettext_domain);
8bcab4
+
8bcab4
       return retval;
8bcab4
     }
8bcab4
 }
8bcab4
@@ -2339,8 +2344,9 @@ parse_value_element (GMarkupParseContext
8bcab4
   const char *ltype;
8bcab4
   const char *list_type;
8bcab4
   const char *owner;
8bcab4
+
8bcab4
   GConfValueType vtype;
8bcab4
-  const char *dummy1, *dummy2, *dummy3, *dummy4;
8bcab4
+  const char *dummy1, *dummy2, *dummy3, *dummy4, *dummy5;
8bcab4
   
8bcab4
 #if 0
8bcab4
   g_assert (ELEMENT_IS ("entry") ||
8bcab4
@@ -2377,6 +2383,7 @@ parse_value_element (GMarkupParseContext
8bcab4
                           "muser", &dummy2,
8bcab4
                           "mtime", &dummy3,
8bcab4
                           "schema", &dummy4,
8bcab4
+                          "gettext_domain", &dummy5,
8bcab4
 
8bcab4
                           NULL))
8bcab4
     return;
8bcab4
@@ -2683,6 +2690,7 @@ parse_entry_element (GMarkupParseContext
8bcab4
       const char *mtime;
8bcab4
       const char *schema;
8bcab4
       const char *type;
8bcab4
+      const char *gettext_domain;
8bcab4
       const char *dummy1, *dummy2, *dummy3, *dummy4;
8bcab4
       const char *dummy5, *dummy6, *dummy7;
8bcab4
       GConfValue *value;
8bcab4
@@ -2693,6 +2701,7 @@ parse_entry_element (GMarkupParseContext
8bcab4
       mtime = NULL;
8bcab4
       schema = NULL;
8bcab4
       type = NULL;
8bcab4
+      gettext_domain = NULL;
8bcab4
 
8bcab4
       if (!locate_attributes (context, element_name, attribute_names, attribute_values,
8bcab4
                               error,
8bcab4
@@ -2701,6 +2710,7 @@ parse_entry_element (GMarkupParseContext
8bcab4
                               "mtime", &mtime,
8bcab4
                               "schema", &schema,
8bcab4
                               "type", &type,
8bcab4
+                              "gettext_domain", &gettext_domain,
8bcab4
                           
8bcab4
                               /* These are allowed but we don't use them until
8bcab4
                                * parse_value_element
8bcab4
@@ -2768,6 +2778,9 @@ parse_entry_element (GMarkupParseContext
8bcab4
        */
8bcab4
       if (schema)
8bcab4
         entry->schema_name = g_strdup (schema);
8bcab4
+
8bcab4
+      if (gettext_domain)
8bcab4
+        entry->gettext_domain = g_intern_string (gettext_domain);
8bcab4
     }
8bcab4
   else
8bcab4
     {
8bcab4
@@ -3716,6 +3729,7 @@ write_value_element (GConfValue *value,
8bcab4
         GConfSchema *schema;
8bcab4
         GConfValueType stype;
8bcab4
         const char *owner;
8bcab4
+        const char *gettext_domain;
8bcab4
         
8bcab4
         schema = gconf_value_get_schema (value);
8bcab4
 
8bcab4
@@ -3741,6 +3755,23 @@ write_value_element (GConfValue *value,
8bcab4
             
8bcab4
             g_free (s);
8bcab4
           }
8bcab4
+
8bcab4
+        gettext_domain = gconf_schema_get_gettext_domain (schema);
8bcab4
+        
8bcab4
+        if (gettext_domain)
8bcab4
+          {
8bcab4
+            char *s;
8bcab4
+
8bcab4
+            s = g_markup_escape_text (gettext_domain, -1);
8bcab4
+            
8bcab4
+            if (fprintf (f, " gettext_domain=\"%s\"", s) < 0)
8bcab4
+              {
8bcab4
+                g_free (s);
8bcab4
+                return FALSE;
8bcab4
+              }
8bcab4
+            
8bcab4
+            g_free (s);
8bcab4
+          }
8bcab4
         
8bcab4
         if (stype == GCONF_VALUE_LIST)
8bcab4
           {
8bcab4
diff -up GConf-2.26.0/doc/gconf-1.0.dtd.gettext GConf-2.26.0/doc/gconf-1.0.dtd
8bcab4
--- GConf-2.26.0/doc/gconf-1.0.dtd.gettext	2009-04-26 23:33:17.240736103 -0400
8bcab4
+++ GConf-2.26.0/doc/gconf-1.0.dtd	2009-04-26 23:34:25.027700384 -0400
8bcab4
@@ -7,7 +7,7 @@
8bcab4
 
8bcab4
 elements, in any order". Duplicate elements (apart from <locale>) are
8bcab4
 not allowed). -->
8bcab4
-
8bcab4
+
8bcab4
 
8bcab4
 
8bcab4
 
8bcab4
diff -up GConf-2.26.0/gconf/gconf-internals.c.gettext GConf-2.26.0/gconf/gconf-internals.c
8bcab4
--- GConf-2.26.0/gconf/gconf-internals.c.gettext	2009-04-26 23:34:10.994700035 -0400
8bcab4
+++ GConf-2.26.0/gconf/gconf-internals.c	2009-04-26 23:34:53.767450191 -0400
8bcab4
@@ -513,6 +513,7 @@ gconf_fill_corba_schema_from_gconf_schem
8bcab4
   cs->short_desc = CORBA_string_dup (gconf_schema_get_short_desc (sc) ? gconf_schema_get_short_desc (sc) : "");
8bcab4
   cs->long_desc = CORBA_string_dup (gconf_schema_get_long_desc (sc) ? gconf_schema_get_long_desc (sc) : "");
8bcab4
   cs->owner = CORBA_string_dup (gconf_schema_get_owner (sc) ? gconf_schema_get_owner (sc) : "");
8bcab4
+  cs->gettext_domain = CORBA_string_dup (gconf_schema_get_gettext_domain (sc) ? gconf_schema_get_gettext_domain (sc) : "");
8bcab4
 
8bcab4
   {
8bcab4
     gchar* encoded;
8bcab4
@@ -600,6 +601,14 @@ gconf_schema_from_corba_schema(const Con
8bcab4
         gconf_schema_set_owner(sc, cs->owner);
8bcab4
     }
8bcab4
       
8bcab4
+  if (*cs->gettext_domain != '\0')
8bcab4
+    {
8bcab4
+      if (!g_utf8_validate (cs->gettext_domain, -1, NULL))
8bcab4
+        gconf_log (GCL_ERR, _("Invalid UTF-8 in gettext domain for schema"));
8bcab4
+      else
8bcab4
+        gconf_schema_set_gettext_domain(sc, cs->gettext_domain);
8bcab4
+    }
8bcab4
+      
8bcab4
   {
8bcab4
     GConfValue* val;
8bcab4
 
8bcab4
diff -up GConf-2.26.0/gconf/gconf-schema.c.gettext GConf-2.26.0/gconf/gconf-schema.c
8bcab4
--- GConf-2.26.0/gconf/gconf-schema.c.gettext	2009-04-26 23:33:26.787483545 -0400
8bcab4
+++ GConf-2.26.0/gconf/gconf-schema.c	2009-04-26 23:35:54.240450142 -0400
8bcab4
@@ -32,9 +32,10 @@ typedef struct {
8bcab4
   GConfValueType car_type; /* Pair car type of the described entry */
8bcab4
   GConfValueType cdr_type; /* Pair cdr type of the described entry */
8bcab4
   gchar* locale;       /* Schema locale */
8bcab4
-  gchar* owner;        /* Name of creating application */
8bcab4
+  const gchar* owner;        /* Name of creating application */
8bcab4
   gchar* short_desc;   /* 40 char or less description, no newlines */
8bcab4
   gchar* long_desc;    /* could be a paragraph or so */
8bcab4
+  const gchar* gettext_domain; /* description gettext domain */
8bcab4
   GConfValue* default_value; /* Default value of the key */
8bcab4
 } GConfRealSchema;
8bcab4
 
8bcab4
@@ -63,7 +64,6 @@ gconf_schema_free (GConfSchema* sc)
8bcab4
   g_free (real->locale);
8bcab4
   g_free (real->short_desc);
8bcab4
   g_free (real->long_desc);
8bcab4
-  g_free (real->owner);
8bcab4
 
8bcab4
   if (real->default_value)
8bcab4
     gconf_value_free (real->default_value);
8bcab4
@@ -91,7 +91,9 @@ gconf_schema_copy (const GConfSchema* sc
8bcab4
 
8bcab4
   dest->long_desc = g_strdup (real->long_desc);
8bcab4
 
8bcab4
-  dest->owner = g_strdup (real->owner);
8bcab4
+  dest->gettext_domain = real->gettext_domain;
8bcab4
+
8bcab4
+  dest->owner = real->owner;
8bcab4
 
8bcab4
   dest->default_value = real->default_value ? gconf_value_copy (real->default_value) : NULL;
8bcab4
   
8bcab4
@@ -136,6 +138,17 @@ gconf_schema_set_locale (GConfSchema* sc
8bcab4
     REAL_SCHEMA (sc)->locale = NULL;
8bcab4
 }
8bcab4
 
8bcab4
+void
8bcab4
+gconf_schema_set_gettext_domain (GConfSchema* sc, const gchar* domain)
8bcab4
+{
8bcab4
+  g_return_if_fail (domain == NULL || g_utf8_validate (domain, -1, NULL));
8bcab4
+  
8bcab4
+  if (domain)
8bcab4
+    REAL_SCHEMA (sc)->gettext_domain = g_intern_string (domain);
8bcab4
+  else 
8bcab4
+    REAL_SCHEMA (sc)->gettext_domain = NULL;
8bcab4
+}
8bcab4
+
8bcab4
 void          
8bcab4
 gconf_schema_set_short_desc (GConfSchema* sc, const gchar* desc)
8bcab4
 {
8bcab4
@@ -169,11 +182,8 @@ gconf_schema_set_owner (GConfSchema* sc,
8bcab4
 {
8bcab4
   g_return_if_fail (owner == NULL || g_utf8_validate (owner, -1, NULL));
8bcab4
   
8bcab4
-  if (REAL_SCHEMA (sc)->owner)
8bcab4
-    g_free (REAL_SCHEMA (sc)->owner);
8bcab4
-
8bcab4
   if (owner)
8bcab4
-    REAL_SCHEMA (sc)->owner = g_strdup (owner);
8bcab4
+    REAL_SCHEMA (sc)->owner = g_intern_string (owner);
8bcab4
   else
8bcab4
     REAL_SCHEMA (sc)->owner = NULL;
8bcab4
 }
8bcab4
@@ -228,6 +238,14 @@ gconf_schema_validate (const GConfSchema
8bcab4
       return FALSE;
8bcab4
     }
8bcab4
 
8bcab4
+  if (real->gettext_domain && !g_utf8_validate (real->gettext_domain, -1, NULL))
8bcab4
+    {
8bcab4
+      g_set_error (err, GCONF_ERROR,
8bcab4
+                   GCONF_ERROR_FAILED,
8bcab4
+                   _("Schema contains invalid UTF-8"));
8bcab4
+      return FALSE;
8bcab4
+    }
8bcab4
+
8bcab4
   if (real->owner && !g_utf8_validate (real->owner, -1, NULL))
8bcab4
     {
8bcab4
       g_set_error (err, GCONF_ERROR,
8bcab4
@@ -299,11 +317,32 @@ gconf_schema_get_locale (const GConfSche
8bcab4
 }
8bcab4
 
8bcab4
 const char*
8bcab4
+gconf_schema_get_gettext_domain (const GConfSchema *schema)
8bcab4
+{
8bcab4
+  g_return_val_if_fail (schema != NULL, NULL);
8bcab4
+
8bcab4
+  return REAL_SCHEMA (schema)->gettext_domain;
8bcab4
+}
8bcab4
+
8bcab4
+static inline const char *
8bcab4
+schema_translate (const GConfSchema *schema,
8bcab4
+                  const char        *string)
8bcab4
+{
8bcab4
+  if (REAL_SCHEMA (schema)->gettext_domain)
8bcab4
+    {
8bcab4
+      bind_textdomain_codeset (REAL_SCHEMA (schema)->gettext_domain, "UTF-8");
8bcab4
+      return g_dgettext(REAL_SCHEMA (schema)->gettext_domain, string);
8bcab4
+    }
8bcab4
+  else
8bcab4
+    return string;
8bcab4
+}
8bcab4
+
8bcab4
+const char*
8bcab4
 gconf_schema_get_short_desc (const GConfSchema *schema)
8bcab4
 {
8bcab4
   g_return_val_if_fail (schema != NULL, NULL);
8bcab4
 
8bcab4
-  return REAL_SCHEMA (schema)->short_desc;
8bcab4
+ return schema_translate (schema, REAL_SCHEMA (schema)->short_desc);
8bcab4
 }
8bcab4
 
8bcab4
 const char*
8bcab4
@@ -311,7 +350,7 @@ gconf_schema_get_long_desc (const GConfS
8bcab4
 {
8bcab4
   g_return_val_if_fail (schema != NULL, NULL);
8bcab4
 
8bcab4
-  return REAL_SCHEMA (schema)->long_desc;
8bcab4
+ return schema_translate (schema, REAL_SCHEMA (schema)->long_desc);
8bcab4
 }
8bcab4
 
8bcab4
 const char*
8bcab4
diff -up GConf-2.26.0/gconf/gconf-schema.h.gettext GConf-2.26.0/gconf/gconf-schema.h
8bcab4
--- GConf-2.26.0/gconf/gconf-schema.h.gettext	2009-04-26 23:33:33.979744088 -0400
8bcab4
+++ GConf-2.26.0/gconf/gconf-schema.h	2009-04-26 23:34:25.030737043 -0400
8bcab4
@@ -48,6 +48,8 @@ void gconf_schema_set_cdr_type          
8bcab4
                                             GConfValueType  type);
8bcab4
 void gconf_schema_set_locale               (GConfSchema    *sc,
8bcab4
                                             const gchar    *locale);
8bcab4
+void gconf_schema_set_gettext_domain       (GConfSchema    *sc,
8bcab4
+                                            const gchar    *domain);
8bcab4
 void gconf_schema_set_short_desc           (GConfSchema    *sc,
8bcab4
                                             const gchar    *desc);
8bcab4
 void gconf_schema_set_long_desc            (GConfSchema    *sc,
8bcab4
@@ -65,6 +67,7 @@ GConfValueType gconf_schema_get_list_typ
8bcab4
 GConfValueType gconf_schema_get_car_type      (const GConfSchema *schema);
8bcab4
 GConfValueType gconf_schema_get_cdr_type      (const GConfSchema *schema);
8bcab4
 const char*    gconf_schema_get_locale        (const GConfSchema *schema);
8bcab4
+const char*    gconf_schema_get_gettext_domain(const GConfSchema *schema);
8bcab4
 const char*    gconf_schema_get_short_desc    (const GConfSchema *schema);
8bcab4
 const char*    gconf_schema_get_long_desc     (const GConfSchema *schema);
8bcab4
 const char*    gconf_schema_get_owner         (const GConfSchema *schema);
8bcab4
diff -up GConf-2.26.0/gconf/gconftool.c.gettext GConf-2.26.0/gconf/gconftool.c
8bcab4
--- GConf-2.26.0/gconf/gconftool.c.gettext	2009-04-26 23:33:41.907451190 -0400
8bcab4
+++ GConf-2.26.0/gconf/gconftool.c	2009-04-26 23:34:25.034736752 -0400
8bcab4
@@ -3295,6 +3295,7 @@ struct _SchemaInfo {
8bcab4
   GConfValueType cdr_type;
8bcab4
   GConfValue* global_default;
8bcab4
   GHashTable* hash;
8bcab4
+  gchar* gettext_domain;
8bcab4
 };
8bcab4
 
8bcab4
 static int
8bcab4
@@ -3547,6 +3548,15 @@ extract_global_info(xmlNodePtr node,
8bcab4
               else
8bcab4
                 g_printerr (_("WARNING: empty <applyto> node"));
8bcab4
             }
8bcab4
+          else if (strcmp((char *)iter->name, "gettext_domain") == 0)
8bcab4
+            {
8bcab4
+              tmp = (char *)xmlNodeGetContent(iter);
8bcab4
+              if (tmp)
8bcab4
+                {
8bcab4
+                  info->gettext_domain = g_strdup(tmp);
8bcab4
+                  xmlFree(tmp);
8bcab4
+                }
8bcab4
+            }
8bcab4
           else
8bcab4
             g_printerr (_("WARNING: node <%s> not understood below <schema>\n"),
8bcab4
 			iter->name);
8bcab4
@@ -3636,6 +3646,9 @@ process_locale_info(xmlNodePtr node, Sch
8bcab4
   if (info->owner != NULL)
8bcab4
     gconf_schema_set_owner(schema, info->owner);
8bcab4
 
8bcab4
+  if (info->gettext_domain != NULL)
8bcab4
+    gconf_schema_set_gettext_domain(schema, info->gettext_domain);
8bcab4
+
8bcab4
   xmlFree(name);
8bcab4
 
8bcab4
   /* Locale-specific info */
8bcab4
@@ -3765,6 +3778,7 @@ get_schema_from_xml(xmlNodePtr node, gch
8bcab4
   info.apply_to = NULL;
8bcab4
   info.owner = NULL;
8bcab4
   info.global_default = NULL;
8bcab4
+  info.gettext_domain = NULL;
8bcab4
   info.hash = g_hash_table_new(g_str_hash, g_str_equal);
8bcab4
   
8bcab4
   extract_global_info(node, &info;;
8bcab4
@@ -3801,6 +3815,8 @@ get_schema_from_xml(xmlNodePtr node, gch
8bcab4
             ;  /* nothing */
8bcab4
           else if (strcmp((char *)iter->name, "applyto") == 0)
8bcab4
             ;  /* nothing */
8bcab4
+          else if (strcmp((char *)iter->name, "gettext_domain") == 0)
8bcab4
+            ;  /* nothing */
8bcab4
           else if (strcmp((char *)iter->name, "locale") == 0)
8bcab4
             {
8bcab4
               process_locale_info(iter, &info;;
8bcab4
diff -up GConf-2.26.0/gconf/GConfX.idl.gettext GConf-2.26.0/gconf/GConfX.idl
8bcab4
--- GConf-2.26.0/gconf/GConfX.idl.gettext	2009-04-26 23:33:58.457483190 -0400
8bcab4
+++ GConf-2.26.0/gconf/GConfX.idl	2009-04-26 23:34:53.764448732 -0400
8bcab4
@@ -16,6 +16,7 @@ struct ConfigSchema {
8bcab4
   string short_desc;
8bcab4
   string long_desc;
8bcab4
   string owner;
8bcab4
+  string gettext_domain;
8bcab4
   // Work around lack of recursive data types
8bcab4
   string encoded_default_value;
8bcab4
 };