Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep the order of the add-on context menu items as defined in the addon.xml file #14220

Merged
merged 1 commit into from
Jul 25, 2018

Conversation

basrieter
Copy link
Contributor

Kodi add-ons can define context menu items via the <extension point="kodi.context.item"> extension point. However, the order of these menu items are not respected and sorting is done by label.

Description

I removed the sorting by label to find out that Kodi first reads the sub-menus and then the menu items. So instead of first doing the sub-menus and then the items, I now iterate over all the child-items in order and either treat them as a menu or an item.

Motivation and Context

It allows an add-on dev to order their context menus in a better way.

How Has This Been Tested?

Tested it locally on Windows x64.

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed


ELEMENTS elems;
if (CServiceBroker::GetAddonMgr().GetExtElements(elem, "item", elems))
for (unsigned int i = 0; i < elem->num_children; i++)

This comment was marked as spam.

{
for (const auto& elem : elems)
cp_cfg_element_t subElem = elem->children[i];

This comment was marked as spam.

{
for (const auto& elem : elems)
cp_cfg_element_t subElem = elem->children[i];
std::string elementName = subElem.name;

This comment was marked as spam.

for (const auto& elem : elems)
cp_cfg_element_t subElem = elem->children[i];
std::string elementName = subElem.name;
if (elementName.compare("menu") == 0)

This comment was marked as spam.

This comment was marked as spam.

auto label = CServiceBroker::GetAddonMgr().GetExtValue(elem, "label");
auto visCondition = CServiceBroker::GetAddonMgr().GetExtValue(&subElem, "visible");
auto library = CServiceBroker::GetAddonMgr().GetExtValue(&subElem, "@library");
auto label = CServiceBroker::GetAddonMgr().GetExtValue(&subElem, "label");

This comment was marked as spam.

auto label = CServiceBroker::GetAddonMgr().GetExtValue(elem, "label");
auto visCondition = CServiceBroker::GetAddonMgr().GetExtValue(&subElem, "visible");
auto library = CServiceBroker::GetAddonMgr().GetExtValue(&subElem, "@library");
auto label = CServiceBroker::GetAddonMgr().GetExtValue(&subElem, "label");
if (StringUtils::IsNaturalNumber(label))
label = g_localizeStrings.GetAddonString(addonInfo.ID(), atoi(label.c_str()));

This comment was marked as spam.

This comment was marked as spam.

@basrieter
Copy link
Contributor Author

@tamland, @enen92 suggested to ping you so you could have a look at this PR?

@tamland
Copy link
Member

tamland commented Jul 25, 2018

Looks ok to me

@basrieter
Copy link
Contributor Author

Ok, thanks for your feedback!

@yol yol added Type: Improvement non-breaking change which improves existing functionality Component: Add-ons v18 Leia labels Jul 25, 2018
@yol yol added this to the Leia 18.0-alpha3 milestone Jul 25, 2018
@yol yol merged commit 441f6b8 into xbmc:master Jul 25, 2018
@yol
Copy link
Member

yol commented Jul 25, 2018

Jenkins is green and only +1 until now, so merging...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Add-ons Type: Improvement non-breaking change which improves existing functionality v18 Leia
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants