49
49
FOREIGN_PLAYLIST_ASK_MODE = 300
50
50
FOREIGN_PLAYLIST_MESSAGE_MODE = 301
51
51
FOREIGN_PLAYLIST_COPY_ERROR_MODE = 302
52
+ THEME_MODE = 400
53
+ NOT_IMPLEMENTED_YET_MODE = 1000
52
54
53
55
def rel (path ):
54
56
return os .path .join (os .path .abspath (os .path .dirname (__file__ )), path )
@@ -90,6 +92,7 @@ class PyRadio(object):
90
92
91
93
_theme = PyRadioTheme ()
92
94
_theme_name = 'dark'
95
+ _theme_slector = None
93
96
94
97
def __init__ (self , pyradio_config , play = False , req_player = '' , theme = '' ):
95
98
self .cnf = pyradio_config
@@ -526,6 +529,21 @@ def _format_player_string(self):
526
529
return 'vlc'
527
530
return self .player .PLAYER_CMD
528
531
532
+ def _show_theme_selector (self ):
533
+ self .jumpnr = ''
534
+ self ._theme_slector = None
535
+ self ._theme_slector = PyRadioThemeSelector (self .bodyWin ,
536
+ self ._theme_name , self .cnf .theme ,
537
+ 4 , 3 , 4 , 5 , 6 , 9 , self ._theme .getTransparency ())
538
+ #'/home/spiros/edit.log')
539
+ self ._theme_slector .show ()
540
+
541
+ if logger .isEnabledFor (logging .DEBUG ):
542
+ if self .operation_mode == NORMAL_MODE :
543
+ logger .debug ('MODE: NORMAL_MODE => THEME_MODE' )
544
+ else :
545
+ logger .debug ('MODE: PLAYLIST_MODE => THEME_MODE' )
546
+
529
547
def _show_help (self , txt ,
530
548
mode_to_set = MAIN_HELP_MODE ,
531
549
caption = ' Help ' ,
@@ -653,6 +671,14 @@ def _print_help(self):
653
671
if logger .isEnabledFor (logging .DEBUG ):
654
672
logger .debug ('MODE = MAIN_HELP_MODE' )
655
673
674
+ def _print_not_implemented_yet (self ):
675
+ self .previous_operation_mode = self .operation_mode
676
+ txt = '''This feature has not been implemented yet...
677
+ '''
678
+ self ._show_help (txt , NOT_IMPLEMENTED_YET_MODE ,
679
+ caption = ' PyRadio ' ,
680
+ prompt = ' Press any key... ' )
681
+
656
682
def _print_handle_foreign_playlist (self ):
657
683
txt = '''This is a "foreign" playlist (i.e. it does not
658
684
reside in PyRadio's config directory).
@@ -974,6 +1000,9 @@ def _redisplay_transient_window(self):
974
1000
elif self .operation_mode == SEARCH_NORMAL_MODE or \
975
1001
self .operation_mode == SEARCH_PLAYLIST_MODE :
976
1002
self .search .show (self .bodyWin , repaint = True )
1003
+ elif self .operation_mode == THEME_MODE :
1004
+ self ._theme_slector .parent = self .bodyWin
1005
+ self ._show_theme_selector ()
977
1006
978
1007
def play_random (self ):
979
1008
# Pick a random radio station
@@ -984,12 +1013,61 @@ def play_random(self):
984
1013
985
1014
def _toggle_transparency (self ):
986
1015
self ._theme .toggleTransparency ()
1016
+ if self .operation_mode == THEME_MODE :
1017
+ self ._theme_slector .transparent = self ._theme .getTransparency ()
987
1018
self .headWin .refresh ()
988
1019
self .bodyWin .refresh ()
989
1020
self .footerWin .refresh ()
990
- self .cnf .use_transparency = self ._theme ._transparent
1021
+ self .cnf .use_transparency = self ._theme .getTransparency ()
991
1022
992
1023
def keypress (self , char ):
1024
+
1025
+ if self .operation_mode == NOT_IMPLEMENTED_YET_MODE :
1026
+ self .helpWin = None
1027
+ self .operation_mode = self .previous_operation_mode
1028
+ if logger .isEnabledFor (logging .DEBUG ):
1029
+ logger .debug ('MODE: Exiting NOT_IMPLEMENTED_YET_MODE' )
1030
+ self .refreshBody ()
1031
+ return
1032
+
1033
+ if char in (ord ('t' ), ):
1034
+ if self .window_mode != THEME_MODE and \
1035
+ self .operation_mode != MAIN_HELP_MODE and \
1036
+ self .operation_mode != PLAYLIST_HELP_MODE :
1037
+ self .previous_operation_mode = self .operation_mode
1038
+ self .operation_mode = self .window_mode = THEME_MODE
1039
+
1040
+ self ._show_theme_selector ()
1041
+ return
1042
+
1043
+ if self .operation_mode == THEME_MODE :
1044
+ if char not in (ord ('m' ), ord ('v' ), ord ('.' ),
1045
+ ord (',' ), ord ('+' ), ord ('-' ), ord ('T' ),
1046
+ ord ('#' ), curses .KEY_RESIZE ):
1047
+ theme_id , save_theme = self ._theme_slector .keypress (char )
1048
+ if theme_id == - 1 :
1049
+ """ cancel or hide """
1050
+ self ._theme_slector = None
1051
+ self .operation_mode = self .window_mode = self .previous_operation_mode
1052
+ if logger .isEnabledFor (logging .DEBUG ):
1053
+ if self .operation_mode == NORMAL_MODE :
1054
+ logger .debug ('MODE: THEME_MODE => NORMAL_MODE' )
1055
+ else :
1056
+ logger .debug ('MODE: THEME_MODE => PLAYLIST_HELP_MODE' )
1057
+ self .refreshBody ()
1058
+ elif theme_id >= 0 :
1059
+ """ valid theme selection """
1060
+ self ._theme_name = self ._theme_slector .theme_name (theme_id )
1061
+ if logger .isEnabledFor (logging .INFO ):
1062
+ logger .info ('Activating theme: {}' .format (self ._theme_name ))
1063
+ self ._theme .readAndApplyTheme (self ._theme_name )
1064
+ curses .doupdate ()
1065
+ if save_theme :
1066
+ self .cnf .theme = self ._theme_name
1067
+ if logger .isEnabledFor (logging .INFO ):
1068
+ logger .info ('Setting default theme: {}' .format (self ._theme_name ))
1069
+ return
1070
+
993
1071
if char in (ord ('#' ), curses .KEY_RESIZE ):
994
1072
self .setupAndDrawScreen ()
995
1073
return
0 commit comments