Browse the code

 

Differences between 123 and 124 on /.
Number of edited files: 1 (0 added, 0 deleted and 1 modified)
Revision 124

About 12 years and 7 months ago.

* Added support for del key in playlist (fixes #789)
Added file(s) Deleted file(s) Modified file(s)

 

Old New Code
21
21
from ConfigParser import ConfigParser, NoSectionError
22
22
from gobject import (TYPE_STRING as gString, markup_escape_text)
23
23
from gtk.glade import XML as glade_XML
 
24
from gtk.gdk import KEY_PRESS, keyval_name
24
25
from gtk import (ListStore, TreeViewColumn, CellRendererText,
25
26
                 TREE_VIEW_COLUMN_FIXED, MenuItem)
26
27

                                        
74
75
        playlist_win_tree.set_rules_hint(True)
75
76
        playlist_win_tree.connect('row-activated', self.load_song)
76
77

                                        
 
78
        # Keyboard events
 
79
        def keyboard_event(widget, event):
 
80
            if keyval_name(event.keyval) == 'Delete':
 
81
                selection = widget.get_selection()
 
82
                (mod, iter_) = selection.get_selected()
 
83

                                    
 
84
                if iter_:
 
85
                    # A song is selected
 
86
                    infos = eval(unescape(mod.get_value(iter_, 8)))
 
87
                    filename = infos[8]
 
88

                                    
 
89
                    if (self.named_playlist is not None and self.named_playlist
 
90
                        not in ('s50', 's100', 'a10', 'r50', 'r100')):
 
91
                        self.playlists_management.remove_item_from_playlist(
 
92
                                                 filename, self.named_playlist)
 
93

                                    
 
94
                    del mod[iter_]
 
95

                                    
 
96
        playlist_win_tree.add_events(KEY_PRESS)
 
97
        playlist_win_tree.connect("key_press_event", keyboard_event)
 
98

                                    
77
99
        # Right click context menu
78
100
        playlist_win_tree.connect('button-release-event', self.context_menu,
79
101
                                  playlist_win_tree.get_selection())
80
102