Beispiel #1
0
void CGUIAddonWindow::GetContextButtons(int itemNumber, CContextButtons& buttons)
{
  gui_context_menu_pair c_buttons[ADDON_MAX_CONTEXT_ENTRIES] = {0};
  unsigned int size = ADDON_MAX_CONTEXT_ENTRIES;
  if (CBGetContextButtons)
  {
    CBGetContextButtons(m_clientHandle, itemNumber, c_buttons, &size);
    for (unsigned int i = 0; i < size; ++i)
      buttons.push_back(std::pair<unsigned int, std::string>(c_buttons[i].id, c_buttons[i].name));
  }
}
Beispiel #2
0
void CContextMenuManager::AddVisibleItems(const CFileItemPtr& item, CContextButtons& list, const std::string& parent /* = "" */)
{
  if (!item)
    return;

  for (const auto& kv : m_contextAddons)
  {
    if (kv.second->GetParent() == parent && kv.second->IsVisible(item))
      list.push_back(std::make_pair(kv.first, kv.second->GetLabel()));
  }
}
void CContextMenuManager::AddVisibleItems(
  const CFileItemPtr& item, CContextButtons& list, const CContextMenuItem& root /* = CContextMenuItem::MAIN */)
{
  if (!item)
    return;

  const int initialSize = list.size();

  for (const auto& kv : m_items)
    if (IsVisible(kv.second, root, item))
      list.push_back(std::make_pair(kv.first, kv.second.GetLabel()));

  if (root == MAIN || root == MANAGE)
  {
    std::stable_sort(list.begin() + initialSize, list.end(),
      [](const std::pair<int, std::string>& lhs, const std::pair<int, std::string>& rhs)
      {
        return lhs.second < rhs.second;
      }
    );
  }
}