diff options
author | Sergey Udaltsov <svu@gnome.org> | 2008-04-23 20:57:36 +0000 |
---|---|---|
committer | Sergey Udaltsov <svu@gnome.org> | 2008-04-23 20:57:36 +0000 |
commit | 1fda0d3b54c3e5c4518c0b2335060509eed6985c (patch) | |
tree | cab7fdc4e20919318888b94a60fc6e378f3d901e /libxklavier/xklavier_config_iso.c | |
parent | 29bf297d9a28276922cf0b157a277bd1f91cd56b (diff) | |
download | libxklavier-1fda0d3b54c3e5c4518c0b2335060509eed6985c.tar.gz |
per-country browsing is complete
Diffstat (limited to 'libxklavier/xklavier_config_iso.c')
-rw-r--r-- | libxklavier/xklavier_config_iso.c | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/libxklavier/xklavier_config_iso.c b/libxklavier/xklavier_config_iso.c index e453fb2..10a520a 100644 --- a/libxklavier/xklavier_config_iso.c +++ b/libxklavier/xklavier_config_iso.c @@ -225,10 +225,10 @@ xkl_config_registry_foreach_iso_code(XklConfigRegistry * config, gint ni; xmlNodeSetPtr nodes = xpath_obj->nodesetval; if (nodes != NULL) { - xmlNodePtr *pnode = nodes->nodeTab; + xmlNodePtr *node = nodes->nodeTab; for (ni = nodes->nodeNr; --ni >= 0;) { gchar *iso_code = - (gchar *) (*pnode)-> + (gchar *) (*node)-> children->content; const gchar *description; iso_code = @@ -246,7 +246,7 @@ xkl_config_registry_foreach_iso_code(XklConfigRegistry * config, g_strdup (description)); g_free(iso_code); - pnode++; + node++; } } xmlXPathFreeObject(xpath_obj); @@ -307,7 +307,7 @@ xkl_config_registry_foreach_country_variant(XklConfigRegistry * TwoConfigItemsProcessFunc func, gpointer data) { - const gchar *xpath_exprs[] = { + const gchar *layout_xpath_exprs[] = { XKBCR_LAYOUT_PATH "[configItem/name = '%s']", XKBCR_LAYOUT_PATH "[configItem/countryList/iso3166Id = '%s']", @@ -315,6 +315,12 @@ xkl_config_registry_foreach_country_variant(XklConfigRegistry * }; const gboolean are_low_ids[] = { TRUE, FALSE }; + const gchar *variant_xpath_exprs[] = { + XKBCR_VARIANT_PATH + "[configItem/countryList/iso3166Id = '%s']", + NULL + }; + xmlXPathObjectPtr xpath_obj; const gchar **xpath_expr; @@ -323,11 +329,11 @@ xkl_config_registry_foreach_country_variant(XklConfigRegistry * if (!xkl_config_registry_is_initialized(config)) return; - for (xpath_expr = xpath_exprs; *xpath_expr; + for (xpath_expr = layout_xpath_exprs; *xpath_expr; xpath_expr++, is_low_id++) { - gchar *acc = - *is_low_id ? g_ascii_strdown(country_code, - -1) : g_strdup(country_code); + gchar *acc = *is_low_id ? g_ascii_strdown(country_code, + -1) : + g_strdup(country_code); gchar *xpe = g_strdup_printf(*xpath_expr, acc); g_free(acc); xpath_obj = @@ -338,15 +344,46 @@ xkl_config_registry_foreach_country_variant(XklConfigRegistry * xmlNodeSetPtr nodes = xpath_obj->nodesetval; if (nodes != NULL) { gint ni; - xmlNodePtr *pnode = nodes->nodeTab; + xmlNodePtr *node = nodes->nodeTab; XklConfigItem *ci = xkl_config_item_new(); for (ni = nodes->nodeNr; --ni >= 0;) { if (xkl_read_config_item - (config, *pnode, ci)) + (config, *node, ci)) func(config, ci, NULL, data); - pnode++; + node++; + } + g_object_unref(G_OBJECT(ci)); + } + xmlXPathFreeObject(xpath_obj); + } + g_free(xpe); + } + + for (xpath_expr = variant_xpath_exprs; *xpath_expr; xpath_expr++) { + gchar *xpe = g_strdup_printf(*xpath_expr, country_code); + xpath_obj = + xmlXPathEval((unsigned char *) xpe, + xkl_config_registry_priv(config, + xpath_context)); + if (xpath_obj != NULL) { + xmlNodeSetPtr nodes = xpath_obj->nodesetval; + if (nodes != NULL) { + gint ni; + xmlNodePtr *node = nodes->nodeTab; + XklConfigItem *ci = xkl_config_item_new(); + XklConfigItem *pci = xkl_config_item_new(); + for (ni = nodes->nodeNr; --ni >= 0;) { + if (xkl_read_config_item + (config, *node, ci) && + xkl_read_config_item + (config, + (*node)->parent->parent, pci)) + func(config, pci, ci, + data); + node++; } + g_object_unref(G_OBJECT(pci)); g_object_unref(G_OBJECT(ci)); } xmlXPathFreeObject(xpath_obj); |