8
8
from shutil import copyfile , move
9
9
from copy import deepcopy
10
10
from .log import Log
11
-
11
+ from . common import *
12
12
13
13
logger = logging .getLogger (__name__ )
14
14
15
- FOREGROUND = 0
16
- BACKGROUND = 1
17
- # for pop up window
18
- CAPTION = 2
19
- BORDER = 3
20
-
21
15
22
16
class PyRadioTheme (object ):
23
17
_colors = {}
@@ -39,28 +33,28 @@ def __del__(self):
39
33
40
34
def _do_init_pairs (self ):
41
35
# not used
42
- curses .init_pair (1 , curses .COLOR_CYAN , self ._active_colors ['Stations' ][ BACKGROUND ])
36
+ curses .init_pair (1 , curses .COLOR_CYAN , self ._active_colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ])
43
37
# PyRadio URL
44
- curses .init_pair (2 , self ._active_colors ['PyRadio URL' ][ FOREGROUND ], self ._active_colors ['Stations' ][ BACKGROUND ])
38
+ curses .init_pair (2 , self ._active_colors [THEME_ITEMS [ 0 ][ 0 ]][ FOREGROUND () ], self ._active_colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ])
45
39
# help border
46
- curses .init_pair (3 , self ._active_colors ['Messages Border' ][ FOREGROUND ], self ._active_colors ['Stations' ][ BACKGROUND ])
40
+ curses .init_pair (3 , self ._active_colors [THEME_ITEMS [ 1 ][ 0 ]][ FOREGROUND () ], self ._active_colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ])
47
41
# station playing no cursor
48
- curses .init_pair (4 , self ._active_colors ['Active Station' ][ FOREGROUND ], self ._active_colors ['Stations' ][ BACKGROUND ])
42
+ curses .init_pair (4 , self ._active_colors [THEME_ITEMS [ 4 ][ 0 ]][ FOREGROUND () ], self ._active_colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ])
49
43
# body win
50
- curses .init_pair (5 , self ._active_colors ['Stations' ][ FOREGROUND ], self ._active_colors ['Stations' ][ BACKGROUND ])
44
+ curses .init_pair (5 , self ._active_colors [THEME_ITEMS [ 3 ][ 0 ]][ FOREGROUND () ], self ._active_colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ])
51
45
# cursor
52
- curses .init_pair (6 , self ._active_colors ['Normal Cursor' ][ FOREGROUND ], self ._active_colors ['Normal Cursor' ][ BACKGROUND ])
46
+ curses .init_pair (6 , self ._active_colors [THEME_ITEMS [ 5 ][ 0 ]][ FOREGROUND () ], self ._active_colors [THEME_ITEMS [ 5 ][ 0 ]][ BACKGROUND () ])
53
47
# status bar
54
- curses .init_pair (7 , self ._active_colors ['Status Bar' ][ FOREGROUND ], self ._active_colors ['Status Bar' ][ BACKGROUND ])
48
+ curses .init_pair (7 , self ._active_colors [THEME_ITEMS [ 2 ][ 0 ]][ FOREGROUND () ], self ._active_colors [THEME_ITEMS [ 2 ][ 0 ]][ BACKGROUND () ])
55
49
# search cursor
56
- curses .init_pair (8 , self ._active_colors ['Normal Cursor' ][ BACKGROUND ], self ._active_colors ['Stations' ][ BACKGROUND ])
50
+ curses .init_pair (8 , self ._active_colors [THEME_ITEMS [ 5 ][ 0 ]][ BACKGROUND () ], self ._active_colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ])
57
51
# cursor when playing
58
- curses .init_pair (9 , self ._active_colors ['Active Cursor' ][ FOREGROUND ], self ._active_colors ['Active Cursor' ][ BACKGROUND ])
52
+ curses .init_pair (9 , self ._active_colors [THEME_ITEMS [ 6 ][ 0 ]][ FOREGROUND () ], self ._active_colors [THEME_ITEMS [ 6 ][ 0 ]][ BACKGROUND () ])
59
53
60
54
def restoreActiveTheme (self ):
61
55
self ._active_colors = deepcopy (self ._read_colors )
62
56
if self ._transparent :
63
- self ._active_colors ['Stations' ][ BACKGROUND ] = - 1
57
+ self ._active_colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] = - 1
64
58
self ._do_init_pairs ()
65
59
66
60
def readAndApplyTheme (self , a_theme , use_transparency = None ):
@@ -75,10 +69,10 @@ def readAndApplyTheme(self, a_theme, use_transparency=None):
75
69
self ._active_colors = deepcopy (self ._colors )
76
70
if use_transparency is None :
77
71
if self ._transparent :
78
- self ._active_colors ['Stations' ][ BACKGROUND ] = - 1
72
+ self ._active_colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] = - 1
79
73
else :
80
74
if use_transparency :
81
- self ._active_colors ['Stations' ][ BACKGROUND ] = - 1
75
+ self ._active_colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] = - 1
82
76
self ._do_init_pairs ()
83
77
self ._read_colors = deepcopy (self ._colors )
84
78
@@ -95,108 +89,108 @@ def open_theme(self, a_theme = ''):
95
89
a_theme = 'dark'
96
90
97
91
if a_theme == 'dark' or a_theme == 'default' :
98
- self ._colors ['Stations' ] = [ curses .COLOR_WHITE , curses .COLOR_BLACK ]
99
- self ._colors ['Status Bar' ] = [ curses .COLOR_BLACK , curses .COLOR_GREEN ]
92
+ self ._colors [THEME_ITEMS [ 3 ][ 0 ] ] = [ curses .COLOR_WHITE , curses .COLOR_BLACK ]
93
+ self ._colors [THEME_ITEMS [ 2 ][ 0 ] ] = [ curses .COLOR_BLACK , curses .COLOR_GREEN ]
100
94
# selection
101
- self ._colors ['Normal Cursor' ] = [ curses .COLOR_BLACK , curses .COLOR_MAGENTA ]
102
- self ._colors ['Active Cursor' ] = [ curses .COLOR_BLACK , curses .COLOR_GREEN ]
103
- self ._colors ['Active Station' ] = [ curses .COLOR_GREEN , self ._colors ['Stations' ][ BACKGROUND ] ]
95
+ self ._colors [THEME_ITEMS [ 5 ][ 0 ] ] = [ curses .COLOR_BLACK , curses .COLOR_MAGENTA ]
96
+ self ._colors [THEME_ITEMS [ 6 ][ 0 ] ] = [ curses .COLOR_BLACK , curses .COLOR_GREEN ]
97
+ self ._colors [THEME_ITEMS [ 4 ][ 0 ]] = [ curses .COLOR_GREEN , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] ]
104
98
# Titles
105
- self ._colors ['Titles' ] = [ curses . COLOR_GREEN , self ._colors ['Stations' ][ BACKGROUND ] ]
106
- self ._colors ['PyRadio URL' ] = [ curses .COLOR_BLUE , self ._colors ['Stations' ][ BACKGROUND ] ]
99
+ # calculated value: self._colors['Titles'] = self._colors[THEME_ITEMS[4][0] ]
100
+ self ._colors [THEME_ITEMS [ 0 ][ 0 ]] = [ curses .COLOR_BLUE , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] ]
107
101
# help window
108
- self ._colors ['Messages' ] = [ self ._colors ['Titles' ][ FOREGROUND ], curses . COLOR_YELLOW ]
109
- self ._colors ['Messages Border ' ] = [ curses . COLOR_YELLOW , self ._colors ['Stations' ][ BACKGROUND ] ]
102
+ self ._colors [THEME_ITEMS [ 1 ][ 0 ]] = [ curses . COLOR_YELLOW , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND ()] ]
103
+ # calculated value: self._colors['Messages'] = [ self._colors[THEME_ITEMS[4][0]][FOREGROUND()] , self._colors[THEME_ITEMS[2][0]][FOREGROUND() ] ]
110
104
# info
111
105
self ._colors ['Colors' ] = 8
112
106
self ._colors ['Name' ] = 'dark'
113
107
self ._colors ['Path' ] = ''
114
108
115
109
elif a_theme == 'dark_16_colors' :
116
- self ._colors ['Stations' ] = [ 15 , 8 ]
117
- self ._colors ['Status Bar' ] = [ curses .COLOR_BLACK , 10 ]
110
+ self ._colors [THEME_ITEMS [ 3 ][ 0 ] ] = [ 15 , 8 ]
111
+ self ._colors [THEME_ITEMS [ 2 ][ 0 ] ] = [ curses .COLOR_BLACK , 10 ]
118
112
# selection
119
- self ._colors ['Normal Cursor' ] = [ curses .COLOR_BLACK , 13 ]
120
- self ._colors ['Active Cursor' ] = [ curses .COLOR_BLACK , 10 ]
121
- self ._colors ['Active Station' ] = [ 10 , self ._colors ['Stations' ][ BACKGROUND ] ]
113
+ self ._colors [THEME_ITEMS [ 5 ][ 0 ] ] = [ curses .COLOR_BLACK , 13 ]
114
+ self ._colors [THEME_ITEMS [ 6 ][ 0 ] ] = [ curses .COLOR_BLACK , 10 ]
115
+ self ._colors [THEME_ITEMS [ 4 ][ 0 ]] = [ 10 , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] ]
122
116
# Titles
123
- self ._colors ['Titles' ] = [ 10 , self ._colors ['Stations' ][ BACKGROUND ] ]
124
- self ._colors ['PyRadio URL' ] = [ 12 , self ._colors ['Stations' ][ BACKGROUND ] ]
117
+ # calculated value: self._colors['Titles'] = self._colors[THEME_ITEMS[4][0] ]
118
+ self ._colors [THEME_ITEMS [ 0 ][ 0 ]] = [ 12 , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] ]
125
119
# help window
126
- self ._colors ['Messages' ] = [ self ._colors ['Titles' ][ FOREGROUND ], 11 ]
127
- self ._colors ['Messages Border ' ] = [ 11 , self ._colors ['Stations' ][ BACKGROUND ] ]
120
+ self ._colors [THEME_ITEMS [ 1 ][ 0 ]] = [ 11 , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND ()] ]
121
+ # calculated value: self._colors['Messages'] = [ self._colors[THEME_ITEMS[4][0]][FOREGROUND()] , self._colors[THEME_ITEMS[2][0]][FOREGROUND() ] ]
128
122
# info
129
123
self ._colors ['Colors' ] = 16
130
124
self ._colors ['Name' ] = 'dark_16_colors'
131
125
self ._colors ['Path' ] = ''
132
126
133
127
elif a_theme == 'light' :
134
- self ._colors ['Stations' ] = [ curses .COLOR_BLACK , curses .COLOR_WHITE ]
135
- self ._colors ['Status Bar' ] = [ curses .COLOR_WHITE , curses .COLOR_BLUE ]
128
+ self ._colors [THEME_ITEMS [ 3 ][ 0 ] ] = [ curses .COLOR_BLACK , curses .COLOR_WHITE ]
129
+ self ._colors [THEME_ITEMS [ 2 ][ 0 ] ] = [ curses .COLOR_WHITE , curses .COLOR_BLUE ]
136
130
# selection
137
- self ._colors ['Normal Cursor' ] = [ curses .COLOR_WHITE , curses .COLOR_MAGENTA ]
138
- self ._colors ['Active Cursor' ] = [ curses .COLOR_WHITE , curses .COLOR_BLUE ]
139
- self ._colors ['Active Station' ] = [ curses .COLOR_RED , self ._colors ['Stations' ][ BACKGROUND ] ]
131
+ self ._colors [THEME_ITEMS [ 5 ][ 0 ] ] = [ curses .COLOR_WHITE , curses .COLOR_MAGENTA ]
132
+ self ._colors [THEME_ITEMS [ 6 ][ 0 ] ] = [ curses .COLOR_WHITE , curses .COLOR_BLUE ]
133
+ self ._colors [THEME_ITEMS [ 4 ][ 0 ]] = [ curses .COLOR_RED , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] ]
140
134
# Titles
141
- self ._colors ['Titles' ] = [ curses . COLOR_RED , self ._colors ['Stations' ][ BACKGROUND ] ]
142
- self ._colors ['PyRadio URL' ] = [ curses .COLOR_BLUE , self ._colors ['Stations' ][ BACKGROUND ] ]
135
+ # calculated value: self._colors['Titles'] = self._colors[THEME_ITEMS[4][0] ]
136
+ self ._colors [THEME_ITEMS [ 0 ][ 0 ]] = [ curses .COLOR_BLUE , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] ]
143
137
# help window
144
- self ._colors ['Messages' ] = [ self ._colors ['Titles' ][ FOREGROUND ], curses . COLOR_RED ]
145
- self ._colors ['Messages Border ' ] = [ curses . COLOR_MAGENTA , self ._colors ['Stations' ][ BACKGROUND ] ]
138
+ self ._colors [THEME_ITEMS [ 1 ][ 0 ]] = [ curses . COLOR_MAGENTA , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND ()] ]
139
+ # calculated value: self._colors['Messages'] = [ self._colors[THEME_ITEMS[4][0]][FOREGROUND()] , self._colors[THEME_ITEMS[2][0]][FOREGROUND() ] ]
146
140
# info
147
141
self ._colors ['Colors' ] = 8
148
142
self ._colors ['Name' ] = 'dark'
149
143
self ._colors ['Path' ] = ''
150
144
151
145
elif a_theme == 'light_16_colors' :
152
- self ._colors ['Stations' ] = [ 8 , 15 ]
153
- self ._colors ['Status Bar' ] = [ 15 , 12 ]
146
+ self ._colors [THEME_ITEMS [ 3 ][ 0 ] ] = [ 8 , 15 ]
147
+ self ._colors [THEME_ITEMS [ 2 ][ 0 ] ] = [ 15 , 12 ]
154
148
# selection
155
- self ._colors ['Normal Cursor' ] = [ 15 , 13 ]
156
- self ._colors ['Active Cursor' ] = [ 15 , 12 ]
157
- self ._colors ['Active Station' ] = [ 9 , self ._colors ['Stations' ][ BACKGROUND ] ]
149
+ self ._colors [THEME_ITEMS [ 5 ][ 0 ] ] = [ 15 , 13 ]
150
+ self ._colors [THEME_ITEMS [ 6 ][ 0 ] ] = [ 15 , 12 ]
151
+ self ._colors [THEME_ITEMS [ 4 ][ 0 ]] = [ 9 , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] ]
158
152
# Titles
159
- self ._colors ['Titles' ] = [ 9 , self ._colors ['Stations' ][ BACKGROUND ] ]
160
- self ._colors ['PyRadio URL' ] = [ 12 , self ._colors ['Stations' ][ BACKGROUND ] ]
153
+ # calculated value: self._colors['Titles'] = self._colors[THEME_ITEMS[4][0] ]
154
+ self ._colors [THEME_ITEMS [ 0 ][ 0 ]] = [ 12 , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] ]
161
155
# help window
162
- self ._colors ['Messages' ] = [ self ._colors ['Titles' ][ FOREGROUND ], 9 ]
163
- self ._colors ['Messages Border ' ] = [ 13 , self ._colors ['Stations' ][ BACKGROUND ] ]
156
+ self ._colors [THEME_ITEMS [ 1 ][ 0 ]] = [ 13 , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND ()] ]
157
+ # calculated value: self._colors['Messages'] = [ self._colors[THEME_ITEMS[4][0]][FOREGROUND()] , self._colors[THEME_ITEMS[2][0]][FOREGROUND() ] ]
164
158
# info
165
159
self ._colors ['Colors' ] = 16
166
160
self ._colors ['Name' ] = 'light_16_colors'
167
161
self ._colors ['Path' ] = ''
168
162
169
163
elif a_theme == 'black_on_white' or a_theme == 'bow' :
170
- self ._colors ['Stations' ] = [ 245 , 15 ]
171
- self ._colors ['Status Bar' ] = [ 15 , 245 ]
164
+ self ._colors [THEME_ITEMS [ 3 ][ 0 ] ] = [ 245 , 15 ]
165
+ self ._colors [THEME_ITEMS [ 2 ][ 0 ] ] = [ 15 , 245 ]
172
166
# selection
173
- self ._colors ['Normal Cursor' ] = [ 15 , 245 ]
174
- self ._colors ['Active Cursor' ] = [ 0 , 245 ]
175
- self ._colors ['Active Station' ] = [ 0 , self ._colors ['Stations' ][ BACKGROUND ] ]
167
+ self ._colors [THEME_ITEMS [ 5 ][ 0 ] ] = [ 15 , 245 ]
168
+ self ._colors [THEME_ITEMS [ 6 ][ 0 ] ] = [ 0 , 245 ]
169
+ self ._colors [THEME_ITEMS [ 4 ][ 0 ]] = [ 0 , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] ]
176
170
# Titles
177
- self ._colors ['Titles' ] = [ 0 , self ._colors ['Stations' ][ BACKGROUND ] ]
178
- self ._colors ['PyRadio URL' ] = [ 0 , self ._colors ['Stations' ][ BACKGROUND ] ]
171
+ # calculated value: self._colors['Titles'] = self._colors[THEME_ITEMS[4][0] ]
172
+ self ._colors [THEME_ITEMS [ 0 ][ 0 ]] = [ 0 , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] ]
179
173
# help window
180
- self ._colors ['Messages' ] = [ self ._colors ['Titles' ][ FOREGROUND ], 245 ]
181
- self ._colors ['Messages Border ' ] = [ 245 , self ._colors ['Stations' ][ BACKGROUND ] ]
174
+ self ._colors [THEME_ITEMS [ 1 ][ 0 ]] = [ 245 , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND ()] ]
175
+ # calculated value: self._colors['Messages'] = [ self._colors[THEME_ITEMS[4][0]][FOREGROUND()] , self._colors[THEME_ITEMS[2][0]][FOREGROUND() ] ]
182
176
# info
183
177
self ._colors ['Colors' ] = 256
184
178
self ._colors ['Name' ] = 'black_on_white'
185
179
self ._colors ['Path' ] = ''
186
180
187
181
elif a_theme == 'white_on_black' or a_theme == 'wob' :
188
- self ._colors ['Stations' ] = [ 247 , 235 ]
189
- self ._colors ['Status Bar' ] = [ 234 , 253 ]
182
+ self ._colors [THEME_ITEMS [ 3 ][ 0 ] ] = [ 247 , 235 ]
183
+ self ._colors [THEME_ITEMS [ 2 ][ 0 ] ] = [ 234 , 253 ]
190
184
# selection
191
- self ._colors ['Normal Cursor' ] = [ 235 , 247 , ]
192
- self ._colors ['Active Cursor' ] = [ 235 , 253 ]
193
- self ._colors ['Active Station' ] = [ 255 , self ._colors ['Stations' ][ BACKGROUND ] ]
185
+ self ._colors [THEME_ITEMS [ 5 ][ 0 ] ] = [ 235 , 247 , ]
186
+ self ._colors [THEME_ITEMS [ 6 ][ 0 ] ] = [ 235 , 253 ]
187
+ self ._colors [THEME_ITEMS [ 4 ][ 0 ]] = [ 255 , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] ]
194
188
# Titles
195
- self ._colors ['Titles' ] = [ 255 , self ._colors ['Stations' ][ BACKGROUND ] ]
196
- self ._colors ['PyRadio URL' ] = [ 253 , self ._colors ['Stations' ][ BACKGROUND ] ]
189
+ # calculated value: self._colors['Titles'] = self._colors[THEME_ITEMS[4][0] ]
190
+ self ._colors [THEME_ITEMS [ 0 ][ 0 ]] = [ 253 , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND () ] ]
197
191
# help window
198
- self ._colors ['Messages' ] = [ self ._colors ['Titles' ][ FOREGROUND ], 235 ]
199
- self ._colors ['Messages Border ' ] = [ 247 , self ._colors ['Stations' ][ BACKGROUND ] ]
192
+ self ._colors [THEME_ITEMS [ 1 ][ 0 ]] = [ 247 , self ._colors [THEME_ITEMS [ 3 ][ 0 ]][ BACKGROUND ()] ]
193
+ # calculated value: self._colors['Messages'] = [ self._colors[THEME_ITEMS[4][0]][FOREGROUND()] , self._colors[THEME_ITEMS[2][0]][FOREGROUND() ] ]
200
194
# info
201
195
self ._colors ['Colors' ] = 256
202
196
self ._colors ['Name' ] = 'white_on_black'
0 commit comments