Skip to content

Commit 64a102f

Browse files
committed
- Cahnging save shortcut (^W and w) to ^E (and e) for RadioBrowser
Search Window - RadioBrowser Search Window uses global functions - Removing sudo from linux install
1 parent 9bbdb79 commit 64a102f

File tree

6 files changed

+97
-63
lines changed

6 files changed

+97
-63
lines changed

devel/build_install_pyradio

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,13 @@ for prog in sed ;do
404404
done
405405

406406
# uninstall previous versions
407-
uninstall 1
407+
# uninstall 1
408408

409-
# delete any files that were left from previous attempt
410-
sudo find . -iname "*.pyc" -delete 2>/dev/null
411-
sudo find . -iname "*.egg" -delete 2>/dev/null
409+
# # delete any files that were left from previous attempt
410+
# sudo find . -iname "*.pyc" -delete 2>/dev/null
411+
# sudo find . -iname "*.egg" -delete 2>/dev/null
412412

413-
echo "***** installing for user..."
413+
# echo "***** installing for user..."
414414
do_dev
415415

416416
if [ -e requirements.txt ];then

pyradio.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" Copyright (C) 2011 Ben Dowling <http://www.coderholic.com/pyradio>
22
.\" This manual is freely distributable under the terms of the GPL.
33
.\"
4-
.TH pyradio 1 "April 2022" PyRadio
4+
.TH pyradio 1 "May 2022" PyRadio
55

66
.SH Name
77
.PP

pyradio/browser.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2815,7 +2815,7 @@ def _print_history_legend(self):
28152815
self._win.addstr(msg, curses.color_pair(4))
28162816
self._other_chgat(self.maxY - 3, thisX, msg)
28172817
#self._carret_chgat(self.maxY-3, thisX, msg)
2818-
msg = 'Add/Del: ^Y/^X, Make default: ^B, Save history: ^W'
2818+
msg = 'Add/Del: ^Y/^X, Make default: ^B, Save history: ^E'
28192819
thisX = self.maxX - 2 - len(msg)
28202820
self._win.addstr(self.maxY - 2, thisX, msg)
28212821
self._carret_chgat(self.maxY-2, thisX, msg)
@@ -3052,15 +3052,15 @@ def keypress(self, char):
30523052

30533053
elif char in (curses.ascii.SO, ):
30543054
''' ^N - Next history item '''
3055-
logger.error('^N')
30563055
self._ctrl_n()
30573056

30583057
elif char in (curses.ascii.DLE, ):
30593058
''' ^P - Previous history item '''
30603059
self._ctrl_p()
30613060

3062-
elif char in (curses.ascii.ETB, ):
3063-
''' ^W - Save search history '''
3061+
# elif char in (curses.ascii.ETB, ):
3062+
elif char in (curses.ascii.ENQ, ):
3063+
''' ^E - Save search history '''
30643064
self._handle_new_or_existing_search_term()
30653065
''' Save search history '''
30663066
return 5
@@ -3143,10 +3143,9 @@ def keypress(self, char):
31433143
''' ^P - Previous history item '''
31443144
self._ctrl_p()
31453145

3146-
elif char in (ord('w'), ):
3147-
''' ^W - Save search history '''
3146+
elif char in (ord('e'), ):
3147+
''' ^E - Save search history '''
31483148
self._handle_new_or_existing_search_term()
3149-
''' Save search history '''
31503149
return 5
31513150

31523151
elif char in (ord('f'), ):

pyradio/edit.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,14 @@ class PyRadioEditor(object):
198198
# 3: show all
199199
_too_small = False
200200

201+
_global_functions = {}
202+
201203
def __init__(self,
202204
stations,
203205
selection,
204206
parent,
205207
config_encoding,
208+
global_functions=None,
206209
adding=True):
207210
self._stations = stations
208211
self._selection = selection
@@ -213,6 +216,9 @@ def __init__(self,
213216
self._orig_encoding = config_encoding
214217
self._config_encoding = config_encoding
215218
self._adding = adding
219+
self._global_functions = global_functions
220+
if self._global_functions is None:
221+
self._global_functions = {}
216222

217223
@property
218224
def append(self):
@@ -622,6 +628,8 @@ def keypress(self, char):
622628
self.new_station = None
623629
self._reset_editors_modes()
624630
ret = -1
631+
elif chr(char) in self._global_functions.keys():
632+
self._global_functions[chr(char)]()
625633

626634
if self._focus > 1:
627635
self._reset_editors_modes()
@@ -645,7 +653,9 @@ class PyRadioRenameFile(object):
645653
""" PyRadio copy file dialog """
646654

647655
def __init__(self, filename, parent, create=False,
648-
open_afterwards=True, title='', opened_from_editor=False):
656+
open_afterwards=True, title='',
657+
opened_from_editor=False,
658+
global_functions=None):
649659
self._invalid_chars = '<>|:"\\/?*'
650660
self.maxY = self.maxX = 0
651661
self._win = self._parent_win = self._line_editor = None
@@ -681,6 +691,9 @@ def __init__(self, filename, parent, create=False,
681691
self._open_afterwards = open_afterwards
682692
self._title = title if title else ' Rename Playlist '
683693
self._opened_from_editor = opened_from_editor
694+
self._global_functions = global_functions
695+
if self._global_functions is None:
696+
self._global_functions = {}
684697

685698
def __del__(self):
686699
try:
@@ -1135,6 +1148,8 @@ def keypress(self, char):
11351148
# cancel
11361149
self._widgets[0].string = ''
11371150
ret = -1
1151+
elif chr(char) in self._global_functions.keys():
1152+
self._global_functions[chr(char)]()
11381153
#self._show_title()
11391154
#self.show()
11401155
return self._get_result(ret)

pyradio/radio.py

Lines changed: 68 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ class PyRadio(object):
168168
is onen and focus is not in line editor '''
169169
_chars_to_bypass_on_editor = (ord('m'), ord('v'), ord('.'),
170170
ord(','), ord('+'), ord('-'))
171-
172171
''' Number of stations to change with the page up/down keys '''
173172
pageChange = 5
174173

@@ -450,7 +449,6 @@ def __init__(self, pyradio_config,
450449
'.': self._volume_up,
451450
'-': self._volume_down,
452451
',': self._volume_down,
453-
'm': self._volume_mute,
454452
'v': self._volume_save
455453
}
456454

@@ -480,6 +478,20 @@ def __init__(self, pyradio_config,
480478
curses.BUTTON_SHIFT: 'BUTTON_SHIFT',
481479
}
482480

481+
self._global_functions = {
482+
'w': self._tag_a_title,
483+
'W': self._toggle_titles_logging,
484+
'T': self._toggle_transparency,
485+
'+': self._volume_up,
486+
'=': self._volume_up,
487+
'.': self._volume_up,
488+
'-': self._volume_down,
489+
',': self._volume_down,
490+
'm': self._volume_mute,
491+
'v': self._volume_save
492+
}
493+
494+
483495
def __del__(self):
484496
self.transientWin = None
485497

@@ -4572,6 +4584,12 @@ def _handle_limited_height_keys(self, char):
45724584
self._update_status_bar_right()
45734585
self._volume_save()
45744586

4587+
elif char in (ord('W'), ):
4588+
self._toggle_titles_logging()
4589+
4590+
elif char in (ord('w'), ):
4591+
self._tag_a_title()
4592+
45754593
def _browser_server_selection(self):
45764594
if self._cnf._online_browser:
45774595
self._cnf._online_browser.select_servers()
@@ -4798,6 +4816,37 @@ def _can_show_theme_window_in_browser_search(self):
47984816
else:
47994817
return True
48004818

4819+
def _toggle_titles_logging(self):
4820+
self.toggle_titles_logging()
4821+
self.log.write_start_log_station_and_title()
4822+
if self._cnf.titles_log.titles_handler:
4823+
self._show_delayed_notification('___Titles Log Enabled___')
4824+
else:
4825+
self._show_delayed_notification('___Titles Log Disabled___')
4826+
4827+
def _tag_a_title(self):
4828+
if self.player.isPlaying():
4829+
if self._cnf.can_like_a_station():
4830+
toggled = False
4831+
if self._cnf.titles_log.titles_handler is None:
4832+
self.toggle_titles_logging()
4833+
self.log.write_start_log_station_and_title()
4834+
toggled = True
4835+
ret = self._cnf.titles_log.tag_title(self.log)
4836+
if toggled:
4837+
self.toggle_titles_logging()
4838+
else:
4839+
ret = 2
4840+
4841+
if ret == 0:
4842+
self._show_delayed_notification('___Title tagged as liked___')
4843+
elif ret == 1:
4844+
self._show_delayed_notification('___Error liking Title___', delay=1.2)
4845+
else:
4846+
self._show_delayed_notification('___Title already tagged as liked___')
4847+
else:
4848+
self._show_delayed_notification('___Error: Player not in playback___', delay=1.2)
4849+
48014850
def keypress(self, char):
48024851
if self._system_asked_to_terminate:
48034852
''' Make sure we exit when signal received '''
@@ -4818,42 +4867,15 @@ def keypress(self, char):
48184867
self.ws.NORMAL_MODE,
48194868
self.ws.PLAYLIST_MODE
48204869
):
4821-
if self.player.isPlaying():
4822-
if self._cnf.can_like_a_station():
4823-
toggled = False
4824-
if self._cnf.titles_log.titles_handler is None:
4825-
self.toggle_titles_logging()
4826-
self.log.write_start_log_station_and_title()
4827-
toggled = True
4828-
ret = self._cnf.titles_log.tag_title(self.log)
4829-
if toggled:
4830-
self.toggle_titles_logging()
4831-
else:
4832-
ret = 2
4833-
4834-
if ret == 0:
4835-
self._show_delayed_notification('___Title tagged as liked___')
4836-
elif ret == 1:
4837-
self._show_delayed_notification('___Error liking Title___', delay=1.2)
4838-
else:
4839-
self._show_delayed_notification('___Title already tagged as liked___')
4840-
else:
4841-
self._show_delayed_notification('___Error: Player not in playback___', delay=1.2)
4870+
self._tag_a_title()
48424871
return
48434872

48444873
elif char in (ord('W'), ) and self.ws.operation_mode in (
48454874
self.ws.NORMAL_MODE,
48464875
self.ws.PLAYLIST_MODE
48474876
):
4848-
self.toggle_titles_logging()
4849-
self.log.write_start_log_station_and_title()
4850-
if self._cnf.titles_log.titles_handler:
4851-
self._show_delayed_notification('___Titles Log Enabled___')
4852-
else:
4853-
self._show_delayed_notification('___Titles Log Disabled___')
4877+
self._toggle_titles_logging()
48544878
return
4855-
# if self._limited_width_mode:
4856-
# return
48574879

48584880
''' if small exit '''
48594881
if self._limited_height_mode or self._limited_width_mode:
@@ -4991,9 +5013,11 @@ def keypress(self, char):
49915013
self._print_playlist_not_saved_error()
49925014
else:
49935015
self._rename_playlist_dialog = PyRadioRenameFile(
4994-
self._cnf.station_path if self.ws.operation_mode == self.ws.NORMAL_MODE else self.stations[self.selection][3],
4995-
self.outerBodyWin,
4996-
opened_from_editor=True if self.ws.operation_mode == self.ws.NORMAL_MODE else False)
5016+
self._cnf.station_path if self.ws.operation_mode == self.ws.NORMAL_MODE else self.stations[self.selection][3],
5017+
self.outerBodyWin,
5018+
opened_from_editor=True if self.ws.operation_mode == self.ws.NORMAL_MODE else False,
5019+
global_functions=self._global_functions,
5020+
)
49975021
if self.ws.operation_mode == self.ws.NORMAL_MODE:
49985022
#self._rename_playlist_dialog.checked_checkbox = (False, False)
49995023
if self._cnf.is_register:
@@ -5014,10 +5038,12 @@ def keypress(self, char):
50145038
''' do not create playlist from registers list '''
50155039
self._update_status_bar_right(status_suffix='')
50165040
self._rename_playlist_dialog = PyRadioRenameFile(
5017-
self._cnf.station_path,
5018-
self.outerBodyWin,
5019-
opened_from_editor=False,
5020-
create=True)
5041+
self._cnf.station_path,
5042+
self.outerBodyWin,
5043+
opened_from_editor=False,
5044+
global_functions=self._global_functions,
5045+
create=True
5046+
)
50215047
self._rename_playlist_dialog.title = ' Create Playlist '
50225048
self._rename_playlist_dialog.show()
50235049
self.ws.operation_mode = self.ws.CREATE_PLAYLIST_MODE
@@ -5498,10 +5524,6 @@ def keypress(self, char):
54985524
''' In station editor '''
54995525
# logger.error('DE char = {0} - {1}'.format(char, chr(char)))
55005526
restart_player = False
5501-
if char in self._chars_to_bypass_on_editor and \
5502-
self._station_editor.focus > 1:
5503-
self.volume_functions[chr(char)]()
5504-
return
55055527
ret = self._station_editor.keypress(char)
55065528
if ret == -3:
55075529
self._print_editor_url_error()
@@ -5578,10 +5600,6 @@ def keypress(self, char):
55785600

55795601
elif self.ws.operation_mode in (self.ws.RENAME_PLAYLIST_MODE, self.ws.CREATE_PLAYLIST_MODE):
55805602
''' Rename playlist '''
5581-
if char in self._chars_to_bypass_on_editor and \
5582-
self._rename_playlist_dialog.focus > 0:
5583-
self.volume_functions[chr(char)]()
5584-
return
55855603
ret, self.old_filename, self.new_filename, copy, open_file, pl_create = self._rename_playlist_dialog.keypress(char)
55865604
# logger.error('DE\n\n **** ps.p {}\n\n'.format(self._cnf._ps._p))
55875605
if ret not in (0, 2):
@@ -6213,7 +6231,7 @@ def keypress(self, char):
62136231

62146232
elif char in (ord('+'), ord('='), ord('.'),
62156233
ord('-'), ord(','), ord('m'),
6216-
ord('v')):
6234+
ord('v'), ord('W'), ord('w')):
62176235
self._handle_limited_height_keys(char)
62186236
return
62196237

@@ -6682,7 +6700,8 @@ def keypress(self, char):
66826700
self.stations,
66836701
self.selection,
66846702
self.outerBodyWin,
6685-
self._cnf.default_encoding)
6703+
self._cnf.default_encoding,
6704+
global_functions=self._global_functions)
66866705
if char == ord('A'):
66876706
self._station_editor.append = True
66886707
self._station_editor.show()
@@ -6741,6 +6760,7 @@ def keypress(self, char):
67416760
self.selection,
67426761
self.outerBodyWin,
67436762
self._cnf.default_encoding,
6763+
global_functions=self._global_functions,
67446764
adding=False)
67456765
self._station_editor.show(self.stations[self.selection])
67466766
self.ws.operation_mode = self.ws.EDIT_STATION_MODE

pyradio_rb.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" Copyright (C) 2011 Ben Dowling <http://www.coderholic.com/pyradio>
22
.\" This manual is freely distributable under the terms of the GPL.
33
.\"
4-
.TH pyradio_rb 1 "April 2022" pyradio
4+
.TH pyradio_rb 1 "May 2022" pyradio
55

66
.SH Name
77
.PP

0 commit comments

Comments
 (0)