@@ -168,7 +168,6 @@ class PyRadio(object):
168
168
is onen and focus is not in line editor '''
169
169
_chars_to_bypass_on_editor = (ord ('m' ), ord ('v' ), ord ('.' ),
170
170
ord (',' ), ord ('+' ), ord ('-' ))
171
-
172
171
''' Number of stations to change with the page up/down keys '''
173
172
pageChange = 5
174
173
@@ -450,7 +449,6 @@ def __init__(self, pyradio_config,
450
449
'.' : self ._volume_up ,
451
450
'-' : self ._volume_down ,
452
451
',' : self ._volume_down ,
453
- 'm' : self ._volume_mute ,
454
452
'v' : self ._volume_save
455
453
}
456
454
@@ -480,6 +478,20 @@ def __init__(self, pyradio_config,
480
478
curses .BUTTON_SHIFT : 'BUTTON_SHIFT' ,
481
479
}
482
480
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
+
483
495
def __del__ (self ):
484
496
self .transientWin = None
485
497
@@ -4572,6 +4584,12 @@ def _handle_limited_height_keys(self, char):
4572
4584
self ._update_status_bar_right ()
4573
4585
self ._volume_save ()
4574
4586
4587
+ elif char in (ord ('W' ), ):
4588
+ self ._toggle_titles_logging ()
4589
+
4590
+ elif char in (ord ('w' ), ):
4591
+ self ._tag_a_title ()
4592
+
4575
4593
def _browser_server_selection (self ):
4576
4594
if self ._cnf ._online_browser :
4577
4595
self ._cnf ._online_browser .select_servers ()
@@ -4798,6 +4816,37 @@ def _can_show_theme_window_in_browser_search(self):
4798
4816
else :
4799
4817
return True
4800
4818
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
+
4801
4850
def keypress (self , char ):
4802
4851
if self ._system_asked_to_terminate :
4803
4852
''' Make sure we exit when signal received '''
@@ -4818,42 +4867,15 @@ def keypress(self, char):
4818
4867
self .ws .NORMAL_MODE ,
4819
4868
self .ws .PLAYLIST_MODE
4820
4869
):
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 ()
4842
4871
return
4843
4872
4844
4873
elif char in (ord ('W' ), ) and self .ws .operation_mode in (
4845
4874
self .ws .NORMAL_MODE ,
4846
4875
self .ws .PLAYLIST_MODE
4847
4876
):
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 ()
4854
4878
return
4855
- # if self._limited_width_mode:
4856
- # return
4857
4879
4858
4880
''' if small exit '''
4859
4881
if self ._limited_height_mode or self ._limited_width_mode :
@@ -4991,9 +5013,11 @@ def keypress(self, char):
4991
5013
self ._print_playlist_not_saved_error ()
4992
5014
else :
4993
5015
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
+ )
4997
5021
if self .ws .operation_mode == self .ws .NORMAL_MODE :
4998
5022
#self._rename_playlist_dialog.checked_checkbox = (False, False)
4999
5023
if self ._cnf .is_register :
@@ -5014,10 +5038,12 @@ def keypress(self, char):
5014
5038
''' do not create playlist from registers list '''
5015
5039
self ._update_status_bar_right (status_suffix = '' )
5016
5040
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
+ )
5021
5047
self ._rename_playlist_dialog .title = ' Create Playlist '
5022
5048
self ._rename_playlist_dialog .show ()
5023
5049
self .ws .operation_mode = self .ws .CREATE_PLAYLIST_MODE
@@ -5498,10 +5524,6 @@ def keypress(self, char):
5498
5524
''' In station editor '''
5499
5525
# logger.error('DE char = {0} - {1}'.format(char, chr(char)))
5500
5526
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
5505
5527
ret = self ._station_editor .keypress (char )
5506
5528
if ret == - 3 :
5507
5529
self ._print_editor_url_error ()
@@ -5578,10 +5600,6 @@ def keypress(self, char):
5578
5600
5579
5601
elif self .ws .operation_mode in (self .ws .RENAME_PLAYLIST_MODE , self .ws .CREATE_PLAYLIST_MODE ):
5580
5602
''' 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
5585
5603
ret , self .old_filename , self .new_filename , copy , open_file , pl_create = self ._rename_playlist_dialog .keypress (char )
5586
5604
# logger.error('DE\n\n **** ps.p {}\n\n'.format(self._cnf._ps._p))
5587
5605
if ret not in (0 , 2 ):
@@ -6213,7 +6231,7 @@ def keypress(self, char):
6213
6231
6214
6232
elif char in (ord ('+' ), ord ('=' ), ord ('.' ),
6215
6233
ord ('-' ), ord (',' ), ord ('m' ),
6216
- ord ('v' )):
6234
+ ord ('v' ), ord ( 'W' ), ord ( 'w' ) ):
6217
6235
self ._handle_limited_height_keys (char )
6218
6236
return
6219
6237
@@ -6682,7 +6700,8 @@ def keypress(self, char):
6682
6700
self .stations ,
6683
6701
self .selection ,
6684
6702
self .outerBodyWin ,
6685
- self ._cnf .default_encoding )
6703
+ self ._cnf .default_encoding ,
6704
+ global_functions = self ._global_functions )
6686
6705
if char == ord ('A' ):
6687
6706
self ._station_editor .append = True
6688
6707
self ._station_editor .show ()
@@ -6741,6 +6760,7 @@ def keypress(self, char):
6741
6760
self .selection ,
6742
6761
self .outerBodyWin ,
6743
6762
self ._cnf .default_encoding ,
6763
+ global_functions = self ._global_functions ,
6744
6764
adding = False )
6745
6765
self ._station_editor .show (self .stations [self .selection ])
6746
6766
self .ws .operation_mode = self .ws .EDIT_STATION_MODE
0 commit comments