diff options
author | Philipp Temminghoff <phil65@kodi.tv> | 2016-04-11 19:32:29 +0200 |
---|---|---|
committer | Philipp Temminghoff <phil65@kodi.tv> | 2016-04-11 19:32:29 +0200 |
commit | 30d4ae02c7a946ba67890e85341b8b04cd63dca0 (patch) | |
tree | d0d4d201f3599a043e756401236ab3444cf275ef | |
parent | 4681398aa9194c1ff1d75878b51a78a71ecc9ca8 (diff) | |
parent | 1fae6d32434df5ff870b1966728fa8d2f4b1b868 (diff) |
Merge pull request #9591 from phil65/python_context_menu
[python-api] add xbmcgui.Dialog().contextmenu()
-rw-r--r-- | xbmc/interfaces/legacy/Dialog.cpp | 17 | ||||
-rw-r--r-- | xbmc/interfaces/legacy/Dialog.h | 23 |
2 files changed, 35 insertions, 5 deletions
diff --git a/xbmc/interfaces/legacy/Dialog.cpp b/xbmc/interfaces/legacy/Dialog.cpp index 2345b84e45..1046739285 100644 --- a/xbmc/interfaces/legacy/Dialog.cpp +++ b/xbmc/interfaces/legacy/Dialog.cpp @@ -22,6 +22,7 @@ #include "dialogs/GUIDialogOK.h" #include "dialogs/GUIDialogYesNo.h" #include "dialogs/GUIDialogSelect.h" +#include "dialogs/GUIDialogContextMenu.h" #include "dialogs/GUIDialogTextViewer.h" #include "guilib/GUIWindowManager.h" #include "dialogs/GUIDialogFileBrowser.h" @@ -84,6 +85,22 @@ namespace XBMCAddon return pDialog->IsConfirmed(); } + int Dialog::contextmenu(const std::vector<String>& list) + { + DelayedCallGuard dcguard(languageHook); + CGUIDialogContextMenu* pDialog= (CGUIDialogContextMenu*)g_windowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU); + if (pDialog == NULL) + throw WindowException("Error: Window is NULL, this is not possible :-)"); + + CContextButtons choices; + for(unsigned int i = 0; i < list.size(); i++) + { + choices.Add(i, list[i]); + } + return pDialog->Show(choices); + } + + int Dialog::select(const String& heading, const std::vector<String>& list, int autoclose) { DelayedCallGuard dcguard(languageHook); diff --git a/xbmc/interfaces/legacy/Dialog.h b/xbmc/interfaces/legacy/Dialog.h index c370a5abd8..5a54e3c932 100644 --- a/xbmc/interfaces/legacy/Dialog.h +++ b/xbmc/interfaces/legacy/Dialog.h @@ -68,7 +68,7 @@ namespace XBMCAddon * \n * example:\n * - dialog = xbmcgui.Dialog()\n - * - ret = dialog.yesno('Kodi', 'Do you want to exit this script?')n\n + * - ret = dialog.yesno('Kodi', 'Do you want to exit this script?')\n\n */ bool yesno(const String& heading, const String& line1, const String& line2 = emptyString, @@ -78,6 +78,19 @@ namespace XBMCAddon int autoclose = 0); /** + * contextmenu(list) -- Show a context menu.\n + * \n + * list : string list - list of items.\n + * \n + * *Note, Returns the position of the highlighted item as an integer (-1 if cancelled).\n + * \n + * example:\n + * - dialog = xbmcgui.Dialog()\n + * - ret = dialog.contextmenu(['Option #1', 'Option #2', 'Option #3'])\n\n + */ + int contextmenu(const std::vector<String>& list); + + /** * select(heading, list) -- Show a select dialog.\n * \n * heading : string or unicode - dialog heading.\n @@ -88,7 +101,7 @@ namespace XBMCAddon * \n * example:\n * - dialog = xbmcgui.Dialog()\n - * - ret = dialog.select('Choose a playlist', ['Playlist #1', 'Playlist #2, 'Playlist #3'])n\n + * - ret = dialog.select('Choose a playlist', ['Playlist #1', 'Playlist #2, 'Playlist #3'])\n\n */ int select(const String& heading, const std::vector<String>& list, int autoclose=0); @@ -120,7 +133,7 @@ namespace XBMCAddon * \n * example:\n * - dialog = xbmcgui.Dialog()\n - * - ok = dialog.ok('XBMC', 'There was an error.')n\n + * - ok = dialog.ok('XBMC', 'There was an error.')\n\n */ bool ok(const String& heading, const String& line1, const String& line2 = emptyString, @@ -134,7 +147,7 @@ namespace XBMCAddon * \n * example:\n * - dialog = xbmcgui.Dialog()\n - * - dialog.textviewer('Plot', 'Some movie plot.')n\n + * - dialog.textviewer('Plot', 'Some movie plot.')\n\n */ void textviewer(const String& heading, const String& text); @@ -304,7 +317,7 @@ namespace XBMCAddon *\n * example: * - dialog = xbmcgui.Dialog() - * - d = dialog.input('Enter secret code', type=xbmcgui.INPUT_ALPHANUM, option=xbmcgui.ALPHANUM_HIDE_INPUT)n + * - d = dialog.input('Enter secret code', type=xbmcgui.INPUT_ALPHANUM, option=xbmcgui.ALPHANUM_HIDE_INPUT)\n */ String input(const String& heading, const String& defaultt = emptyString, |