Blame SOURCES/GConf-gettext.patch

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