Skip to content

Commit f03096b

Browse files
committed
New station inserted to playlist
1 parent 31e26f9 commit f03096b

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

pyradio/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ def insert_station(self, station, target):
485485
d.appendleft(station)
486486
d.rotate(target)
487487
self.stations = list(d)
488+
self.dirty_playlist = True
488489
return True, self.number_of_stations
489490

490491
def move_station(self, source, target):
@@ -512,6 +513,7 @@ def move_station(self, source, target):
512513
d.rotate(target)
513514
self.stations = list(d)
514515
self.number_of_stations = len(self.stations)
516+
self.dirty_playlist = True
515517
return True
516518

517519
def switch_stations(self, source, target):

pyradio/edit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def keypress(self, char):
439439
elif self._focus == 3:
440440
# ok
441441
self._return_station()
442-
ret = -1
442+
ret = 1
443443
elif self._focus == 4:
444444
# cancel
445445
self.new_station = None

pyradio/radio.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,12 +1036,9 @@ def _format_playlist_line(self, lineNum, pad, station):
10361036
def _print_help(self):
10371037
#logger.error('DE \n\nself.ws.operation_mode = {}'.format(self.ws.operation_mode))
10381038
if self.ws.operation_mode in self._display_help.keys():
1039-
#logger.error('DE in display help')
10401039
self._display_help[self.ws.operation_mode]()
10411040
else:
1042-
#logger.error('DE in redisplay')
10431041
self._redisplay[self.ws.operation_mode]()
1044-
#logger.error('DE end _print_help')
10451042

10461043
def _show_playlist_recovered(self):
10471044
txt = 'Playlist recoverd!'
@@ -1098,7 +1095,6 @@ def _show_main_help(self):
10981095
self._show_help(txt, mode_to_set=self.ws.MAIN_HELP_MODE)
10991096

11001097
def _show_main_help_page_2(self):
1101-
logger.error('DE I am here: _show_main_help_page_2')
11021098
txt = """a| / |A |Add / append new station.
11031099
e |Edit station.
11041100
E |Change station's encoding.
@@ -2207,6 +2203,28 @@ def keypress(self, char):
22072203
self.ws.close_window()
22082204
self._station_editor = None
22092205
self.refreshBody()
2206+
elif ret == 1:
2207+
# ok
2208+
if self.ws.operation_mode == self.ws.EDIT_STATION_MODE:
2209+
if self.stations[self.selection] != self._station_editor.new_station:
2210+
self._cnf.dirty_playlist = True
2211+
self.stations[self.selection] = self._station_editor.new_station
2212+
else:
2213+
if self._station_editor.append:
2214+
self.stations.append(self._station_editor.new_station)
2215+
self.number_of_items = len(self.stations)
2216+
self.selection = self.number_of_items - 1
2217+
self.startPos = self.number_of_items - self.bodyMaxY + 2
2218+
else:
2219+
pass
2220+
ret, self.number_of_items = self._cnf.insert_station(self._station_editor.new_station, self.selection + 1)
2221+
self.stations = self._cnf.stations
2222+
self.selection += 1
2223+
if self.selection >= self.startPos + self.bodyMaxY - 2:
2224+
self.startPos += 1
2225+
2226+
self.ws.close_window()
2227+
self.refreshBody()
22102228
elif ret == 2:
22112229
# display line editor help
22122230
self._show_line_editor_help()
@@ -2809,7 +2827,7 @@ def keypress(self, char):
28092827
if char in ( ord('a'), ord('A') ):
28102828
self._station_editor = PyRadioEditor(self.stations, self.selection, self.bodyWin)
28112829
if char == ord('A'):
2812-
self._station_editor.apend = True
2830+
self._station_editor.append = True
28132831
self._station_editor.show()
28142832
self._station_editor.item = [ '', '', '' ]
28152833
self.ws.operation_mode = self.ws.ADD_STATION_MODE

pyradio/simple_curses_widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def keypress(self, win, char):
304304
returns:
305305
2: display help
306306
1: get next char
307-
0: exit edit mode, string isvalid
307+
0: exit edit mode, string is valid
308308
-1: cancel
309309
"""
310310
word_delim = (' ', '-', '_', '+', '=',

0 commit comments

Comments
 (0)