|
4 | 4 | ''' Implements Kodi Helper functions '''
|
5 | 5 | from __future__ import absolute_import, division, unicode_literals
|
6 | 6 | import xbmc
|
7 |
| -from xbmcgui import Dialog |
8 | 7 | from xbmcaddon import Addon
|
9 | 8 | from .unicodehelper import from_unicode, to_unicode
|
10 | 9 |
|
@@ -34,6 +33,56 @@ def has_socks():
|
34 | 33 | return has_socks.installed
|
35 | 34 |
|
36 | 35 |
|
| 36 | +def browsesingle(type, heading, shares='', mask='', useThumbs=False, treatAsFolder=False, defaultt=None): # pylint: disable=invalid-name,redefined-builtin |
| 37 | + ''' Show a Kodi browseSingle dialog ''' |
| 38 | + from xbmcgui import Dialog |
| 39 | + if not heading: |
| 40 | + heading = ADDON.getAddonInfo('name') |
| 41 | + return Dialog().browseSingle(type=type, heading=heading, shares=shares, mask=mask, useThumbs=useThumbs, treatAsFolder=treatAsFolder, defaultt=defaultt) |
| 42 | + |
| 43 | + |
| 44 | +def notification(heading='', message='', icon='info', time=4000): |
| 45 | + ''' Show a Kodi notification ''' |
| 46 | + from xbmcgui import Dialog |
| 47 | + if not heading: |
| 48 | + heading = ADDON.getAddonInfo('name') |
| 49 | + return Dialog().notification(heading=heading, message=message, icon=icon, time=time) |
| 50 | + |
| 51 | + |
| 52 | +def ok_dialog(heading='', message='', autoanswer=None): |
| 53 | + ''' Show Kodi's OK dialog ''' |
| 54 | + if autoanswer is not None and get_setting('automatic_install') == 'true': |
| 55 | + return autoanswer |
| 56 | + from xbmcgui import Dialog |
| 57 | + if not heading: |
| 58 | + heading = ADDON.getAddonInfo('name') |
| 59 | + return Dialog().ok(heading=heading, line1=message) |
| 60 | + |
| 61 | + |
| 62 | +def progress_dialog(): |
| 63 | + ''' Show Kodi's Progress dialog ''' |
| 64 | + from xbmcgui import DialogProgress |
| 65 | + return DialogProgress() |
| 66 | + |
| 67 | + |
| 68 | +def textviewer(heading='', text='', usemono=False): |
| 69 | + ''' Show a Kodi textviewer dialog ''' |
| 70 | + from xbmcgui import Dialog |
| 71 | + if not heading: |
| 72 | + heading = ADDON.getAddonInfo('name') |
| 73 | + return Dialog().textviewer(heading=heading, text=text, usemono=usemono) |
| 74 | + |
| 75 | + |
| 76 | +def yesno_dialog(heading='', message='', nolabel=None, yeslabel=None, autoclose=0, autoanswer=None): |
| 77 | + ''' Show Kodi's Yes/No dialog ''' |
| 78 | + if autoanswer is not None and get_setting('automatic_install') == 'true': |
| 79 | + return autoanswer |
| 80 | + from xbmcgui import Dialog |
| 81 | + if not heading: |
| 82 | + heading = ADDON.getAddonInfo('name') |
| 83 | + return Dialog().yesno(heading=heading, line1=message, nolabel=nolabel, yeslabel=yeslabel, autoclose=autoclose) |
| 84 | + |
| 85 | + |
37 | 86 | def localize(string_id, **kwargs):
|
38 | 87 | ''' Return the translated string from the .po language files, optionally translating variables '''
|
39 | 88 | if kwargs:
|
@@ -82,7 +131,7 @@ def get_proxies():
|
82 | 131 | if httpproxytype != 0 and not socks_supported:
|
83 | 132 | # Only open the dialog the first time (to avoid multiple popups)
|
84 | 133 | if socks_supported is None:
|
85 |
| - Dialog().ok('', localize(30042)) # Requires PySocks |
| 134 | + ok_dialog('', localize(30042)) # Requires PySocks |
86 | 135 | return None
|
87 | 136 |
|
88 | 137 | proxy_types = ['http', 'socks4', 'socks4a', 'socks5', 'socks5h']
|
|
0 commit comments