@@ -1231,7 +1231,7 @@ def get_internal_header(self, pad, width):
1231
1231
highlight = - 1
1232
1232
return highlight , ((title , columns_separotors , columns [self ._output_format ]), )
1233
1233
1234
- def select_servers (self , with_config = False , return_function = None , init = False ):
1234
+ def select_servers (self , with_config = False , return_function = None , init = False , global_functions = None ):
1235
1235
''' RadioBrowser select servers '''
1236
1236
if init :
1237
1237
self ._server_selection_window = None
@@ -1246,15 +1246,18 @@ def select_servers(self, with_config=False, return_function=None, init=False):
1246
1246
self ._config_win ._params [0 ]['ping_timeout' ],
1247
1247
Y = 11 , X = 19 ,
1248
1248
show_random = True ,
1249
- return_function = return_function )
1249
+ return_function = return_function ,
1250
+ global_functions = global_functions
1251
+ )
1250
1252
else :
1251
1253
self ._server_selection_window = RadioBrowserServersSelect (
1252
1254
self .parent ,
1253
1255
self ._dns_info .server_urls ,
1254
1256
self ._server ,
1255
1257
self ._default_ping_count ,
1256
1258
self ._default_ping_timeout ,
1257
- return_function = return_function
1259
+ return_function = return_function ,
1260
+ global_functions = global_functions
1258
1261
)
1259
1262
else :
1260
1263
self ._server_selection_window .set_parent (self .parent )
@@ -2043,7 +2046,7 @@ def save_config(self):
2043
2046
''' config not modified '''
2044
2047
return - 4
2045
2048
2046
- def select_servers (self , with_config = False , return_function = None , init = False ):
2049
+ def select_servers (self , with_config = False , return_function = None , init = False , global_functions = None ):
2047
2050
''' RadioBrowserConfigWindow select servers '''
2048
2051
if init :
2049
2052
self ._server_selection_window = None
@@ -2056,7 +2059,9 @@ def select_servers(self, with_config=False, return_function=None, init=False):
2056
2059
self ._params [0 ]['ping_timeout' ],
2057
2060
Y = 11 , X = 19 ,
2058
2061
show_random = True ,
2059
- return_function = return_function )
2062
+ return_function = return_function ,
2063
+ global_functions = global_functions
2064
+ )
2060
2065
else :
2061
2066
self ._server_selection_window .set_parent (self ._win )
2062
2067
# self.keyboard_handler = self._server_selection_window
@@ -3814,7 +3819,8 @@ def __init__(self,
3814
3819
Y = None ,
3815
3820
X = None ,
3816
3821
show_random = False ,
3817
- return_function = None ):
3822
+ return_function = None ,
3823
+ global_functions = None ):
3818
3824
''' Server selection Window
3819
3825
if Y and X are valid (not None)
3820
3826
keypress just returns 0
@@ -3830,7 +3836,7 @@ def __init__(self,
3830
3836
self ._return_function = return_function
3831
3837
3832
3838
self .servers = RadioBrowserServers (
3833
- parent , servers , current_server , show_random
3839
+ parent , servers , current_server , show_random , global_functions
3834
3840
)
3835
3841
self .maxY = self .servers .maxY + 2
3836
3842
self .maxX = self .servers .maxX + 2
@@ -3954,7 +3960,7 @@ class RadioBrowserServers(object):
3954
3960
_too_small = False
3955
3961
from_config = False
3956
3962
3957
- def __init__ (self , parent , servers , current_server , show_random = False ):
3963
+ def __init__ (self , parent , servers , current_server , show_random = False , global_functions = None ):
3958
3964
self ._parent = parent
3959
3965
self .items = list (servers )
3960
3966
self .server = current_server
@@ -3973,6 +3979,12 @@ def __init__(self, parent, servers, current_server, show_random=False):
3973
3979
self .items [i ] = self .items [i ].replace ('(' , ' ' * (s_max - len (self .items [i ])) + '(' )
3974
3980
self .maxY = len (self .items )
3975
3981
self .maxX = len (self .items [0 ])
3982
+ self ._global_functions = {}
3983
+ # if global_functions is not None:
3984
+ # logger.error('\n\n{}\n\n'.format(global_functions))
3985
+ # self._global_functions = deepcopy(global_functions)
3986
+ # if 't' in self._global_functions.keys():
3987
+ # del self._global_functions['t']
3976
3988
3977
3989
if show_random :
3978
3990
self .items .reverse ()
@@ -4032,7 +4044,10 @@ def keypress(self, char):
4032
4044
if self ._too_small :
4033
4045
return 1
4034
4046
4035
- if char in (
4047
+ if chr (char ) in self ._global_functions .keys ():
4048
+ self ._global_functions [chr (char )]()
4049
+ return 1
4050
+ elif char in (
4036
4051
curses .KEY_EXIT , ord ('q' ), 27 ,
4037
4052
ord ('h' ), curses .KEY_LEFT
4038
4053
):
0 commit comments