Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
FileBrowser.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/filebrowser.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace dialogs
21{
22
23//==============================================================================
37namespace FileBrowser
38{
39//==============================================================================
70inline bool ATTR_DLL_LOCAL ShowAndGetDirectory(const std::string& shares,
71 const std::string& heading,
72 std::string& path,
73 bool writeOnly = false)
74{
75 using namespace ::kodi::addon;
76 char* retString = nullptr;
77 bool ret = CPrivateBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory(
78 CPrivateBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), path.c_str(),
79 &retString, writeOnly);
80 if (retString != nullptr)
81 {
82 if (std::strlen(retString))
83 path = retString;
84 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
85 retString);
86 }
87 return ret;
88}
89//------------------------------------------------------------------------------
90
91//==============================================================================
105inline bool ATTR_DLL_LOCAL ShowAndGetFile(const std::string& shares,
106 const std::string& mask,
107 const std::string& heading,
108 std::string& path,
109 bool useThumbs = false,
110 bool useFileDirectories = false)
111{
112 using namespace ::kodi::addon;
113 char* retString = nullptr;
114 bool ret = CPrivateBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file(
115 CPrivateBase::m_interface->toKodi->kodiBase, shares.c_str(), mask.c_str(), heading.c_str(),
116 path.c_str(), &retString, useThumbs, useFileDirectories);
117 if (retString != nullptr)
118 {
119 if (std::strlen(retString))
120 path = retString;
121 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
122 retString);
123 }
124 return ret;
125}
126//------------------------------------------------------------------------------
127
128//==============================================================================
144inline bool ATTR_DLL_LOCAL ShowAndGetFileFromDir(const std::string& directory,
145 const std::string& mask,
146 const std::string& heading,
147 std::string& path,
148 bool useThumbs = false,
149 bool useFileDirectories = false,
150 bool singleList = false)
151{
152 using namespace ::kodi::addon;
153 char* retString = nullptr;
154 bool ret =
155 CPrivateBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_from_dir(
156 CPrivateBase::m_interface->toKodi->kodiBase, directory.c_str(), mask.c_str(),
157 heading.c_str(), path.c_str(), &retString, useThumbs, useFileDirectories, singleList);
158 if (retString != nullptr)
159 {
160 if (std::strlen(retString))
161 path = retString;
162 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
163 retString);
164 }
165 return ret;
166}
167//------------------------------------------------------------------------------
168
169//==============================================================================
182inline bool ATTR_DLL_LOCAL ShowAndGetFileList(const std::string& shares,
183 const std::string& mask,
184 const std::string& heading,
185 std::vector<std::string>& fileList,
186 bool useThumbs = false,
187 bool useFileDirectories = false)
188{
189 using namespace ::kodi::addon;
190 char** list = nullptr;
191 unsigned int listSize = 0;
192 bool ret = CPrivateBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_list(
193 CPrivateBase::m_interface->toKodi->kodiBase, shares.c_str(), mask.c_str(), heading.c_str(),
194 &list, &listSize, useThumbs, useFileDirectories);
195 if (ret)
196 {
197 for (unsigned int i = 0; i < listSize; ++i)
198 fileList.emplace_back(list[i]);
199 CPrivateBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(
200 CPrivateBase::m_interface->toKodi->kodiBase, &list, listSize);
201 }
202 return ret;
203}
204//------------------------------------------------------------------------------
205
206//==============================================================================
218inline bool ATTR_DLL_LOCAL ShowAndGetSource(std::string& path,
219 bool allowNetworkShares,
220 const std::string& additionalShare = "",
221 const std::string& type = "")
222{
223 using namespace ::kodi::addon;
224 char* retString = nullptr;
225 bool ret = CPrivateBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_source(
226 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str(), &retString, allowNetworkShares,
227 additionalShare.c_str(), type.c_str());
228 if (retString != nullptr)
229 {
230 if (std::strlen(retString))
231 path = retString;
232 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
233 retString);
234 }
235 return ret;
236}
237//------------------------------------------------------------------------------
238
239//==============================================================================
248inline bool ATTR_DLL_LOCAL ShowAndGetImage(const std::string& shares,
249 const std::string& heading,
250 std::string& path)
251{
252 using namespace ::kodi::addon;
253 char* retString = nullptr;
254 bool ret = CPrivateBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image(
255 CPrivateBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), path.c_str(),
256 &retString);
257 if (retString != nullptr)
258 {
259 if (std::strlen(retString))
260 path = retString;
261 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
262 retString);
263 }
264 return ret;
265}
266//------------------------------------------------------------------------------
267
268//==============================================================================
277inline bool ATTR_DLL_LOCAL ShowAndGetImageList(const std::string& shares,
278 const std::string& heading,
279 std::vector<std::string>& file_list)
280{
281 using namespace ::kodi::addon;
282 char** list = nullptr;
283 unsigned int listSize = 0;
284 bool ret =
285 CPrivateBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image_list(
286 CPrivateBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), &list,
287 &listSize);
288 if (ret)
289 {
290 for (unsigned int i = 0; i < listSize; ++i)
291 file_list.emplace_back(list[i]);
292 CPrivateBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(
293 CPrivateBase::m_interface->toKodi->kodiBase, &list, listSize);
294 }
295 return ret;
296}
297//------------------------------------------------------------------------------
298}; // namespace FileBrowser
299
300} /* namespace dialogs */
301} /* namespace gui */
302} /* namespace kodi */
303
304#endif /* __cplusplus */
bool ATTR_DLL_LOCAL ShowAndGetFile(const std::string &shares, const std::string &mask, const std::string &heading, std::string &path, bool useThumbs=false, bool useFileDirectories=false)
File selection dialog.
Definition FileBrowser.h:105
bool ATTR_DLL_LOCAL ShowAndGetImageList(const std::string &shares, const std::string &heading, std::vector< std::string > &file_list)
Image selection dialog to get several in to a list.
Definition FileBrowser.h:277
bool ATTR_DLL_LOCAL ShowAndGetImage(const std::string &shares, const std::string &heading, std::string &path)
Image selection dialog.
Definition FileBrowser.h:248
bool ATTR_DLL_LOCAL ShowAndGetDirectory(const std::string &shares, const std::string &heading, std::string &path, bool writeOnly=false)
Directory selection dialog.
Definition FileBrowser.h:70
bool ATTR_DLL_LOCAL ShowAndGetFileList(const std::string &shares, const std::string &mask, const std::string &heading, std::vector< std::string > &fileList, bool useThumbs=false, bool useFileDirectories=false)
File selection dialog to get several in to a list.
Definition FileBrowser.h:182
bool ATTR_DLL_LOCAL ShowAndGetFileFromDir(const std::string &directory, const std::string &mask, const std::string &heading, std::string &path, bool useThumbs=false, bool useFileDirectories=false, bool singleList=false)
File selection from a directory.
Definition FileBrowser.h:144
bool ATTR_DLL_LOCAL ShowAndGetSource(std::string &path, bool allowNetworkShares, const std::string &additionalShare="", const std::string &type="")
Source selection dialog.
Definition FileBrowser.h:218