mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 15:58:31 +00:00
added possibiliy to use submenus in the skin setup menus
This commit is contained in:
@@ -134,28 +134,27 @@ bool cXmlParser::ReadGlobals(cGlobals *globals, string xmlFile, bool mandatory)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cXmlParser::ReadSkinSetup(cSkinSetup *skinSetup, string skin, string xmlFile) {
|
||||
bool cXmlParser::ReadSkinSetup(cSkinSetup *skinSetup, string xmlFile) {
|
||||
this->skinSetup = skinSetup;
|
||||
string xmlPath = *cString::sprintf("%s%s/%s", *config.skinPath, skin.c_str(), xmlFile.c_str());
|
||||
|
||||
if (!FileExists(xmlPath))
|
||||
if (!FileExists(xmlFile))
|
||||
return false;
|
||||
if (ctxt == NULL) {
|
||||
esyslog("skindesigner: Failed to allocate parser context");
|
||||
return false;
|
||||
}
|
||||
|
||||
doc = xmlCtxtReadFile(ctxt, xmlPath.c_str(), NULL, XML_PARSE_NOENT | XML_PARSE_DTDVALID);
|
||||
doc = xmlCtxtReadFile(ctxt, xmlFile.c_str(), NULL, XML_PARSE_NOENT | XML_PARSE_DTDVALID);
|
||||
|
||||
if (doc == NULL ) {
|
||||
esyslog("skindesigner: ERROR: skin setup %s not parsed successfully.", xmlPath.c_str());
|
||||
esyslog("skindesigner: ERROR: skin setup %s not parsed successfully.", xmlFile.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
root = xmlDocGetRootElement(doc);
|
||||
|
||||
if (ctxt->valid == 0) {
|
||||
esyslog("skindesigner: Failed to validate %s", xmlPath.c_str());
|
||||
esyslog("skindesigner: Failed to validate %s", xmlFile.c_str());
|
||||
return false;
|
||||
}
|
||||
if (root == NULL) {
|
||||
@@ -281,8 +280,8 @@ bool cXmlParser::ParseSkinSetup(string skin) {
|
||||
node = node->next;
|
||||
continue;
|
||||
}
|
||||
if (!xmlStrcmp(node->name, (const xmlChar *) "parameters")) {
|
||||
ParseSetupParameter(node->xmlChildrenNode);
|
||||
if (!xmlStrcmp(node->name, (const xmlChar *) "menu")) {
|
||||
ParseSetupMenu(node->xmlChildrenNode);
|
||||
node = node->next;
|
||||
continue;
|
||||
} else if (!xmlStrcmp(node->name, (const xmlChar *) "translations")) {
|
||||
@@ -324,64 +323,88 @@ string cXmlParser::GetPath(string xmlFile) {
|
||||
return path;
|
||||
}
|
||||
|
||||
void cXmlParser::ParseSetupParameter(xmlNodePtr node) {
|
||||
void cXmlParser::ParseSetupMenu(xmlNodePtr node) {
|
||||
if (!node)
|
||||
return;
|
||||
if (!skinSetup)
|
||||
return;
|
||||
|
||||
while (node != NULL) {
|
||||
|
||||
if (node->type != XML_ELEMENT_NODE) {
|
||||
node = node->next;
|
||||
continue;
|
||||
}
|
||||
if (xmlStrcmp(node->name, (const xmlChar *) "parameter")) {
|
||||
node = node->next;
|
||||
continue;
|
||||
}
|
||||
xmlAttrPtr attr = node->properties;
|
||||
if (attr == NULL) {
|
||||
node = node->next;
|
||||
continue;
|
||||
}
|
||||
xmlChar *paramType = NULL;
|
||||
xmlChar *paramName = NULL;
|
||||
xmlChar *paramDisplayText = NULL;
|
||||
xmlChar *paramMin = NULL;
|
||||
xmlChar *paramMax = NULL;
|
||||
xmlChar *paramValue = NULL;
|
||||
while (NULL != attr) {
|
||||
if (!xmlStrcmp(attr->name, (const xmlChar *) "type")) {
|
||||
paramType = xmlGetProp(node, attr->name);
|
||||
} else if (!xmlStrcmp(attr->name, (const xmlChar *) "name")) {
|
||||
paramName = xmlGetProp(node, attr->name);
|
||||
} else if (!xmlStrcmp(attr->name, (const xmlChar *) "displaytext")) {
|
||||
paramDisplayText = xmlGetProp(node, attr->name);
|
||||
} else if (!xmlStrcmp(attr->name, (const xmlChar *) "min")) {
|
||||
paramMin = xmlGetProp(node, attr->name);
|
||||
} else if (!xmlStrcmp(attr->name, (const xmlChar *) "max")) {
|
||||
paramMax = xmlGetProp(node, attr->name);
|
||||
}
|
||||
attr = attr->next;
|
||||
}
|
||||
paramValue = xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||
skinSetup->SetParameter(paramType, paramName, paramDisplayText, paramMin, paramMax, paramValue);
|
||||
|
||||
if (paramType)
|
||||
xmlFree(paramType);
|
||||
if (paramName)
|
||||
xmlFree(paramName);
|
||||
if (paramDisplayText)
|
||||
xmlFree(paramDisplayText);
|
||||
if (paramMin)
|
||||
xmlFree(paramMin);
|
||||
if (paramMax)
|
||||
xmlFree(paramMax);
|
||||
if (paramValue)
|
||||
xmlFree(paramValue);
|
||||
if (!xmlStrcmp(node->name, (const xmlChar *) "parameter")) {
|
||||
ParseSetupParameter(node);
|
||||
} else if (!xmlStrcmp(node->name, (const xmlChar *) "submenu")) {
|
||||
xmlAttrPtr attr = node->properties;
|
||||
xmlChar *subMenuName = NULL;
|
||||
xmlChar *subDisplayText = NULL;
|
||||
while (NULL != attr) {
|
||||
if (!xmlStrcmp(attr->name, (const xmlChar *) "name")) {
|
||||
subMenuName = xmlGetProp(node, attr->name);
|
||||
} else if (!xmlStrcmp(attr->name, (const xmlChar *) "displaytext")) {
|
||||
subDisplayText = xmlGetProp(node, attr->name);
|
||||
}
|
||||
attr = attr->next;
|
||||
}
|
||||
skinSetup->SetSubMenu(subMenuName, subDisplayText);
|
||||
ParseSetupMenu(node->xmlChildrenNode);
|
||||
if (subMenuName)
|
||||
xmlFree(subMenuName);
|
||||
if (subDisplayText)
|
||||
xmlFree(subDisplayText);
|
||||
}
|
||||
node = node->next;
|
||||
}
|
||||
skinSetup->SubMenuDone();
|
||||
}
|
||||
|
||||
void cXmlParser::ParseSetupParameter(xmlNodePtr node) {
|
||||
if (!node)
|
||||
return;
|
||||
if (!skinSetup)
|
||||
return;
|
||||
|
||||
xmlAttrPtr attr = node->properties;
|
||||
if (attr == NULL) {
|
||||
return;
|
||||
}
|
||||
xmlChar *paramType = NULL;
|
||||
xmlChar *paramName = NULL;
|
||||
xmlChar *paramDisplayText = NULL;
|
||||
xmlChar *paramMin = NULL;
|
||||
xmlChar *paramMax = NULL;
|
||||
xmlChar *paramValue = NULL;
|
||||
while (NULL != attr) {
|
||||
if (!xmlStrcmp(attr->name, (const xmlChar *) "type")) {
|
||||
paramType = xmlGetProp(node, attr->name);
|
||||
} else if (!xmlStrcmp(attr->name, (const xmlChar *) "name")) {
|
||||
paramName = xmlGetProp(node, attr->name);
|
||||
} else if (!xmlStrcmp(attr->name, (const xmlChar *) "displaytext")) {
|
||||
paramDisplayText = xmlGetProp(node, attr->name);
|
||||
} else if (!xmlStrcmp(attr->name, (const xmlChar *) "min")) {
|
||||
paramMin = xmlGetProp(node, attr->name);
|
||||
} else if (!xmlStrcmp(attr->name, (const xmlChar *) "max")) {
|
||||
paramMax = xmlGetProp(node, attr->name);
|
||||
}
|
||||
attr = attr->next;
|
||||
}
|
||||
paramValue = xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||
skinSetup->SetParameter(paramType, paramName, paramDisplayText, paramMin, paramMax, paramValue);
|
||||
if (paramType)
|
||||
xmlFree(paramType);
|
||||
if (paramName)
|
||||
xmlFree(paramName);
|
||||
if (paramDisplayText)
|
||||
xmlFree(paramDisplayText);
|
||||
if (paramMin)
|
||||
xmlFree(paramMin);
|
||||
if (paramMax)
|
||||
xmlFree(paramMax);
|
||||
if (paramValue)
|
||||
xmlFree(paramValue);
|
||||
}
|
||||
|
||||
void cXmlParser::ParseGlobalColors(xmlNodePtr node) {
|
||||
|
@@ -31,6 +31,7 @@ private:
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr root;
|
||||
string GetPath(string xmlFile);
|
||||
void ParseSetupMenu(xmlNodePtr node);
|
||||
void ParseSetupParameter(xmlNodePtr node);
|
||||
void ParseGlobalColors(xmlNodePtr node);
|
||||
void InsertColor(string name, string value);
|
||||
@@ -51,7 +52,7 @@ public:
|
||||
bool ReadView(cTemplateView *view, string xmlFile);
|
||||
bool ReadPluginView(string plugName, int templateNumber, string templateName);
|
||||
bool ReadGlobals(cGlobals *globals, string xmlFile, bool mandatory);
|
||||
bool ReadSkinSetup(cSkinSetup *skinSetup, string skin, string xmlFile);
|
||||
bool ReadSkinSetup(cSkinSetup *skinSetup, string xmlFile);
|
||||
bool ParseView(void);
|
||||
bool ParsePluginView(string plugName, int templateNumber);
|
||||
bool ParseGlobals(void);
|
||||
|
Reference in New Issue
Block a user