@@ -84,6 +84,8 @@ class PyRadio(object):
84
84
_theme = PyRadioTheme ()
85
85
_theme_name = 'dark'
86
86
_theme_selector = None
87
+ _theme_not_supported_thread = None
88
+ _theme_not_supported_notification_duration = 1.75
87
89
theme_forced_selection = []
88
90
89
91
_config_win = None
@@ -163,8 +165,12 @@ def setup(self, stdscr):
163
165
curses .use_default_colors ()
164
166
self ._theme ._transparent = self ._cnf .use_transparency
165
167
self ._theme .config_dir = self ._cnf .stations_dir
166
- self ._theme .readAndApplyTheme (self ._theme_name )
167
- self ._theme_name = self ._theme .applied_theme_name
168
+ ret , ret_theme_name = self ._theme .readAndApplyTheme (self ._theme_name )
169
+ if ret == 0 :
170
+ self ._theme_name = self ._theme .applied_theme_name
171
+ else :
172
+ self ._theme_name = ret_theme_name
173
+ self ._cnf .theme_not_supported = True
168
174
169
175
self .log = Log ()
170
176
# For the time being, supported players are mpv, mplayer and vlc.
@@ -701,7 +707,7 @@ def _show_theme_selector(self, changed_from_config=False):
701
707
self .jumpnr = ''
702
708
self ._random_requested = False
703
709
self ._theme_selector = None
704
- logger .error ('DE\n \n self._theme = {0}\n self._theme_name = {1}\n self._cnf.theme = {2}\n \n ' .format (self ._theme , self ._theme_name , self ._cnf .theme ))
710
+ # logger.error('DE\n\nself._theme = {0}\nself._theme_name = {1}\nself._cnf.theme = {2}\n\n'.format(self._theme, self._theme_name, self._cnf.theme))
705
711
self ._theme_selector = PyRadioThemeSelector (self .bodyWin , self ._cnf , self ._theme ,
706
712
self ._theme_name , self ._theme ._applied_theme_max_colors , self ._cnf .theme ,
707
713
4 , 3 , 4 , 5 , 6 , 9 , self ._theme .getTransparency ())
@@ -950,6 +956,29 @@ def closeRecoveryNotification(self, *arg, **karg):
950
956
#arg[1].release()
951
957
self .refreshBody ()
952
958
959
+ def _show_theme_not_supported (self ):
960
+ if self ._cnf .theme_not_supported_notification_shown :
961
+ return
962
+ txt = 'Error loading selected theme!\n ____Using default theme.'
963
+ self ._show_help (txt , mode_to_set = self .operation_mode , caption = '' ,
964
+ prompt = '' , is_message = True )
965
+ # start 1750 ms counter
966
+ if self ._theme_not_supported_thread :
967
+ if self ._theme_not_supported_thread .is_alive :
968
+ self ._theme_not_supported_thread .cancel ()
969
+ self ._theme_not_supported_thread = None
970
+ self ._theme_not_supported_thread = threading .Timer (self ._theme_not_supported_notification_duration , self .closeThemeNotSupportedNotification )
971
+ self ._theme_not_supported_thread .start ()
972
+ curses .doupdate ()
973
+
974
+ def closeThemeNotSupportedNotification (self , * arg , ** karg ):
975
+ #arg[1].acquire()
976
+ self ._cnf .theme_not_supported = False
977
+ self ._cnf .theme_not_supported_notification_shown = True
978
+ self ._theme_not_supported_notification_duration = 0.75
979
+ #arg[1].release()
980
+ self .refreshBody ()
981
+
953
982
def _show_theme_help (self ):
954
983
txt = """Up|/|j|/|PgUp
955
984
Down|/|k|/|PgDown |Change theme selection.
@@ -1526,6 +1555,9 @@ def _redisplay_transient_window(self):
1526
1555
self ._theme_selector .set_theme (self .theme_forced_selection )
1527
1556
self ._print_ask_to_create_theme ()
1528
1557
1558
+ if self ._cnf .theme_not_supported :
1559
+ self ._show_theme_not_supported ()
1560
+
1529
1561
def play_random (self ):
1530
1562
# Pick a random radio station
1531
1563
if self .number_of_items > 0 :
@@ -1896,8 +1928,12 @@ def keypress(self, char):
1896
1928
# restore theme, if necessary
1897
1929
if self ._cnf .opts ['theme' ][1 ] != self ._config_win ._config_options ['theme' ][1 ]:
1898
1930
#self._config_win._apply_a_theme(self._cnf.opts['theme'][1])
1899
- self ._theme .readAndApplyTheme (self ._cnf .opts ['theme' ][1 ])
1900
- self ._theme_name = self ._cnf .theme
1931
+ ret , ret_theme_name = self ._theme .readAndApplyTheme (self ._cnf .opts ['theme' ][1 ])
1932
+ if ret == 0 :
1933
+ self ._theme_name = self ._cnf .theme
1934
+ else :
1935
+ self ._theme_name = ret_theme_name
1936
+ self ._cnf .theme_not_supported = True
1901
1937
curses .doupdate ()
1902
1938
# make sure config is not saved
1903
1939
self ._config_win ._saved_config_options ['dirty_config' ][1 ] = False
@@ -2039,6 +2075,8 @@ def keypress(self, char):
2039
2075
ord ('?' ), ord ('#' ), curses .KEY_RESIZE ):
2040
2076
theme_id , save_theme = self ._theme_selector .keypress (char )
2041
2077
2078
+ #if self._cnf.theme_not_supported:
2079
+ # self._show_theme_not_supported()
2042
2080
if theme_id == - 1 :
2043
2081
""" cancel or hide """
2044
2082
self ._theme_name = self ._theme_selector ._applied_theme_name
@@ -2070,8 +2108,16 @@ def keypress(self, char):
2070
2108
self ._config_win ._saved_config_options ['theme' ][1 ] = self ._theme_name
2071
2109
if logger .isEnabledFor (logging .INFO ):
2072
2110
logger .info ('Activating theme: {}' .format (self ._theme_name ))
2073
- self ._theme .readAndApplyTheme (self ._theme_name ,
2111
+ ret , ret_theme_name = self ._theme .readAndApplyTheme (self ._theme_name ,
2074
2112
theme_path = self ._theme_selector ._themes [theme_id ][1 ])
2113
+ if isinstance (ret , tuple ):
2114
+ ret = ret [0 ]
2115
+ if ret == - 1 :
2116
+ self ._theme_name = ret_theme_name
2117
+ self ._cnf .theme_not_supported = True
2118
+ self ._cnf .theme_not_supported_notification_shown = False
2119
+ self ._show_theme_not_supported ()
2120
+ #self.refreshBody()
2075
2121
curses .doupdate ()
2076
2122
# update config window
2077
2123
if self ._config_win :
0 commit comments