- std::shared_ptr<const wgt::parse::ApplicationIconsInfo> icons_info =
- std::static_pointer_cast<const wgt::parse::ApplicationIconsInfo>(
- parser_->GetManifestData(app_keys::kIconsKey));
- if (icons_info.get()) {
- for (auto& application_icon : icons_info->icons()) {
- icon_x* icon = reinterpret_cast<icon_x*> (calloc(1, sizeof(icon_x)));
- bf::path icon_path = context_->root_application_path.get()
- / app_info->package() / "res" / "wgt" / application_icon.path();
- icon->text = strdup(icon_path.c_str());
+ auto icons_info =
+ GetManifestDataForKey<const wgt::parse::ApplicationIconsInfo>(
+ app_keys::kIconsKey);
+ if (!icons_info) {
+ icons_info.reset(new wgt::parse::ApplicationIconsInfo());
+ }
+ wgt::parse::LocalizedApplicationIconsInfo localized_list =
+ wgt::parse::GetLocalizedIconList(*icons_info, widget_path_);
+ // We need to generate icon for each locale and icons are already set into
+ // lookup order. There isn't said that all icons should be received from
+ // one <icon> tag position so we iterate utils we run out of icons creating
+ // any icon element that are possible for given locale.
+ std::set<std::string> found_locales;
+ for (auto& application_icon : localized_list) {
+ const std::string& locale = application_icon.locale();
+ if (found_locales.find(locale) != found_locales.end())
+ continue;
+ found_locales.insert(locale);
+
+ icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
+ bf::path icon_path = context_->root_application_path.get()
+ / app_info->package() / "res" / "wgt" / application_icon.path();
+ icon->text = strdup(icon_path.c_str());
+ if (!locale.empty())
+ icon->lang = strdup(locale.c_str());
+ else