Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
ContextMenu.h
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/gui/dialogs/context_menu.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace dialogs
21{
22
23//==============================================================================
35namespace ContextMenu
36{
37//==============================================================================
68inline int ATTR_DLL_LOCAL Show(const std::string& heading, const std::vector<std::string>& entries)
69{
70 using namespace ::kodi::addon;
71 unsigned int size = static_cast<unsigned int>(entries.size());
72 const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char**)));
73 for (unsigned int i = 0; i < size; ++i)
74 {
75 cEntries[i] = entries[i].c_str();
76 }
77 int ret = CPrivateBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(
78 CPrivateBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size);
79 free(cEntries);
80 return ret;
81}
82//------------------------------------------------------------------------------
83
84//==============================================================================
115inline int ATTR_DLL_LOCAL Show(const std::string& heading,
116 const std::vector<std::pair<std::string, std::string>>& entries)
117{
118 using namespace ::kodi::addon;
119 unsigned int size = static_cast<unsigned int>(entries.size());
120 const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char**)));
121 for (unsigned int i = 0; i < size; ++i)
122 {
123 cEntries[i] = entries[i].second.c_str();
124 }
125 int ret = CPrivateBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(
126 CPrivateBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size);
127 free(cEntries);
128 return ret;
129}
130//------------------------------------------------------------------------------
131
132//==============================================================================
163inline int ATTR_DLL_LOCAL Show(const std::string& heading,
164 const std::vector<std::pair<int, std::string>>& entries)
165{
166 using namespace ::kodi::addon;
167 unsigned int size = static_cast<unsigned int>(entries.size());
168 const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char**)));
169 for (unsigned int i = 0; i < size; ++i)
170 {
171 cEntries[i] = entries[i].second.c_str();
172 }
173 int ret = CPrivateBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(
174 CPrivateBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size);
175 free(cEntries);
176 return ret;
177}
178//------------------------------------------------------------------------------
179}; // namespace ContextMenu
180
181} /* namespace dialogs */
182} /* namespace gui */
183} /* namespace kodi */
184
185#endif /* __cplusplus */
int ATTR_DLL_LOCAL Show(const std::string &heading, const std::vector< std::string > &entries)
Show a context menu dialog about given parts.
Definition ContextMenu.h:68