Skip to content

Commit cbed61f

Browse files
committed
Config window: Implementing "Connection timeout"
1 parent 327a27e commit cbed61f

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

pyradio/config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ default_encoding = utf-8
4848
# unreachable, and display the "Failed to connect to: [station]"
4949
# message.
5050
#
51-
# Valid values: 1 - ..
51+
# Valid values: 5 - 60
5252
# Default value: 10
5353
connection_timeout = 10
5454

pyradio/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ def _save_config(self):
695695
# unreachable, and display the "Failed to connect to: [station]"
696696
# message.
697697
#
698-
# Valid values: 1 - ..
698+
# Valid values: 5 - 60
699699
# Default value: 10
700700
connection_timeout = {4}
701701

pyradio/radio.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,8 +1918,8 @@ class PyRadioConfigWindow(object):
19181918
_help_text.append(['This is the encoding used by default when reading data provided by a station such as song title, etc. If reading said data ends up in an error, "utf-8" will be used instead.',
19191919
'|', 'Default value: utf-8'])
19201920
_help_text.append(['PyRadio will wait for this number of seconds to get a station/server message indicating that playback has actually started.', '|',
1921-
'If this does not happen within this number of seconds after the connection is initiated, PyRadio will consider the station unreachable, and display the "Failed to connect to: station" message.',
1922-
'|', 'Valid values: 1 - 60', 'Default value: 10'])
1921+
'If this does not happen within this number of seconds after the connection is initiated, PyRadio will consider the station unreachable, and display the "Failed to connect to: station" message.', '|', 'Press "h"/Left or "l"/Right to change value.',
1922+
'|', 'Valid values: 5 - 60', 'Default value: 10'])
19231923
_help_text.append(None)
19241924
_help_text.append(['The theme to be used by default.', '|', 'Hardcoded themes:',
19251925
' * dark (8 colors)', ' * light (8 colors)',
@@ -2072,6 +2072,30 @@ def _print_options_help(self):
20722072
def keypress(self, char):
20732073
if self._too_small:
20742074
return 1, []
2075+
val = list(self._config_options.items())[self.selection]
2076+
if val[0] == 'connection_timeout':
2077+
if char in (curses.KEY_RIGHT, ord('l')):
2078+
t = int(val[1][1])
2079+
if t < 60:
2080+
t += 1
2081+
self._config_options[val[0]][1] = str(t)
2082+
self._win.addstr(self.selection+1,
2083+
3 + len(val[1][0]),
2084+
str(t) + ' ', curses.color_pair(6))
2085+
self._win.refresh()
2086+
return -1, []
2087+
2088+
elif char in (curses.KEY_LEFT, ord('h')):
2089+
t = int(val[1][1])
2090+
if t > 5:
2091+
t -= 1
2092+
self._config_options[val[0]][1] = str(t)
2093+
self._win.addstr(self.selection+1,
2094+
3 + len(val[1][0]),
2095+
str(t) + ' ', curses.color_pair(6))
2096+
self._win.refresh()
2097+
return -1, []
2098+
20752099
if char in (ord('k'), curses.KEY_UP):
20762100
self._put_cursor(-1)
20772101
self.refresh_selection()

0 commit comments

Comments
 (0)