Skip to content

Commit

Permalink
ctrl-i to vertically center current playing song
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Horowitz committed Oct 21, 2007
1 parent b8265ee commit eb4090c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -2,6 +2,7 @@ v1.3 - Pending
+ Playlist queue support (requires mpd >= 0.14)
+ Allow multiple columns in current playlist by using "|" (xsdnyd)
+ Use xmms-like search filter by default when user types (no more ctrl-j)
+ Ctrl-i shortcut to center currently playing song
+ Use case insensitive sorting for library (holy_robot)
+ Ignore "the" when sorting library in artist/album views (holy_robot)
+ Better logic when sorting playlists and new "dir+file" sort option (sed)
Expand Down
4 changes: 2 additions & 2 deletions TODO
@@ -1,9 +1,9 @@
v1.3
pref for lyrics saving location..
queueing with multiple playlist columns: adjust column widths better
queueing with multiple playlist columns: adjust column widths better?
why the heck doesn't the treeviewcolumn header arrow update when sorting is reversed?

v1.4
pref for lyrics saving location..
allow additional columns for library (like current)
genre mode (genre -> artist -> album)
better playlist support (mpd 0.13 only):
Expand Down
20 changes: 15 additions & 5 deletions sonata.py
Expand Up @@ -464,6 +464,7 @@ def __init__(self, window=None, sugar=False):
('updatekey2', None, 'Update Key 2', '<Ctrl><Shift>u', None, self.updatedb_path),
('connectkey', None, 'Connect Key', '<Alt>c', None, self.connectkey_pressed),
('disconnectkey', None, 'Disconnect Key', '<Alt>d', None, self.disconnectkey_pressed),
('centerplaylistkey', None, 'Center Playlist Key', '<Ctrl>i', None, self.center_playlist),
)

toggle_actions = (
Expand Down Expand Up @@ -552,6 +553,7 @@ def __init__(self, window=None, sugar=False):
<menuitem action="updatekey2"/>
<menuitem action="connectkey"/>
<menuitem action="disconnectkey"/>
<menuitem action="centerplaylistkey"/>
</popup>
</ui>
"""
Expand Down Expand Up @@ -3125,6 +3127,9 @@ def queueinfo_get_queueid(self, queue_map, songid):
map_num += 1
return strqueue

def center_playlist(self, event):
self.keep_song_visible_in_list(vertically_center=True)

def playlist_files_unchanged(self, prev_songs):
# Go through each playlist object and check if the current and previous filenames match:
if prev_songs == None:
Expand Down Expand Up @@ -3152,19 +3157,23 @@ def hide_all_header_indicators(self, treeview, show_sorted_column):
else:
column.set_sort_indicator(False)

def keep_song_visible_in_list(self):
def keep_song_visible_in_list(self, vertically_center=False):
if self.filterbox_visible:
return
if self.expanded and len(self.currentdata)>0:
try:
row = self.songinfo.pos
visible_rect = self.current.get_visible_rect()
row_rect = self.current.get_background_area(row, self.columns[0])
if row_rect.y + row_rect.height > visible_rect.height:
top_coord = (row_rect.y + row_rect.height - visible_rect.height) + visible_rect.y
if vertically_center:
top_coord = (row_rect.y + row_rect.height - int(visible_rect.height/2)) + visible_rect.y
self.current.scroll_to_point(-1, top_coord)
elif row_rect.y < 0:
self.current.scroll_to_cell(row)
else:
if row_rect.y + row_rect.height > visible_rect.height:
top_coord = (row_rect.y + row_rect.height - visible_rect.height) + visible_rect.y
self.current.scroll_to_point(-1, top_coord)
elif row_rect.y < 0:
self.current.scroll_to_cell(row)
except:
pass

Expand Down Expand Up @@ -6726,6 +6735,7 @@ def about_shortcuts(self, button):
[[ "Enter/Space", _("Play selected song") ],
[ "Delete", _("Remove selected song(s)") ],
[ "Ctrl-E", _("Add selected song(s) to playlist queue") ],
[ "Ctrl-I", _("Center currently playing song") ],
[ "Ctrl-Shift-E", _("Remove selected song(s) from playlist queue") ],
[ "Ctrl-Shift-S", _("Save playlist") ],
[ "Ctrl-Delete", _("Clear list") ]]
Expand Down
1 change: 1 addition & 0 deletions website/documentation.html
Expand Up @@ -172,6 +172,7 @@ <h2>Documentation</h2>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Enter/Space</b>: Play selected song<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Delete</b>: Remove selected song(s)<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Ctrl-E</b>: Add selected song(s) to playlist queue<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Ctrl-I</b>: Center currently playing song<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Ctrl-Shift-E</b>: Remove selected song(s) from playlist queue<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Ctrl-Shift-S</b>: Save playlist<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Ctrl-Delete</b>: Clear list<br/>
Expand Down

0 comments on commit eb4090c

Please sign in to comment.