[Feature] modify saving font type at the request of Deokjin Kim .
authorJing Yigang <yigang.jing@samsung.com>
Tue, 4 Sep 2012 02:17:50 +0000 (10:17 +0800)
committerJing Yigang <yigang.jing@samsung.com>
Tue, 4 Sep 2012 02:17:50 +0000 (10:17 +0800)
setting-common/src/setting-common-general-func.c

index bae736c..18cbe02 100755 (executable)
@@ -1049,6 +1049,7 @@ void *font_conf_doc_parse(char *doc_name, char *font_name)
 
        cur = cur->xmlChildrenNode;
 
+       Eina_Bool is_changed = EINA_FALSE;
        while(cur != NULL)
        {
                if((!xmlStrcmp(cur->name, (const xmlChar *)"match")))
@@ -1058,6 +1059,18 @@ void *font_conf_doc_parse(char *doc_name, char *font_name)
                        {
                                if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit")))
                                {
+                                       xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
+                                       SETTING_TRACE_DEBUG("name is: %s", name);
+                                       /* if name is not 'family', break */
+                                       if (xmlStrcmp(name, (const xmlChar *)"family"))
+                                       {
+                                               xmlFree(name);
+                                               name = NULL;
+                                               break;
+                                       }
+                                       xmlFree(name);
+                                       name = NULL;
+
                                        cur3 = cur2->xmlChildrenNode;
                                        while(cur3 != NULL)
                                        {
@@ -1065,23 +1078,62 @@ void *font_conf_doc_parse(char *doc_name, char *font_name)
                                                {
                                                        xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
                                                        key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
-                                                       SETTING_TRACE_DEBUG("after changed, string is: %s\n", key);
+                                                       SETTING_TRACE_DEBUG("after changed, string is: %s", key);
+                                                       xmlFree(key);
+                                                       key = NULL;
+                                                       is_changed = EINA_TRUE;
+                                               }
+                                               cur3 = cur3->next;
+                                       }
+                               }
+                               cur2 = cur2->next;
+                       }
+               } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias")))
+               {
+                       cur2 = cur->xmlChildrenNode;
+                       while (cur2 != NULL)
+                       {
+                               if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family")))
+                               {
+                                       xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
+                                       key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
+                                       SETTING_TRACE_DEBUG("after changed, string is: %s", key);
+                                       xmlFree(key);
+                                       key = NULL;
+                                       is_changed = EINA_TRUE;
+                               } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer")))
+                               {
+                                       cur3 = cur2->xmlChildrenNode;
+                                       while (cur3 != NULL)
+                                       {
+                                               if((!xmlStrcmp(cur3->name, (const xmlChar *)"family")))
+                                               {
+                                                       xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
+                                                       key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
+                                                       SETTING_TRACE_DEBUG("after changed, string is: %s", key);
                                                        xmlFree(key);
                                                        key = NULL;
-                                                       return doc;
+                                                       is_changed = EINA_TRUE;
+                                                       cur3 = cur3->next;
+                                                       break; /* just set first element, so break */
                                                }
                                                cur3 = cur3->next;
                                        }
                                }
                                cur2 = cur2->next;
                        }
+
                }
                cur = cur->next;
        }
 
-       xmlFreeDoc(doc);
-       doc = NULL;
-       return NULL;
+       if (is_changed) {
+               return doc;
+       } else {
+               xmlFreeDoc(doc);
+               doc = NULL;
+               return NULL;
+       }
 }
 
 /**