Class: Sh::ShroomActions
Class Method Summary collapse
Class Method Details
.init ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/sh_actions.rb', line 40 def self.init action = Actions.new 'Add to queue', :song do |song| view = Sh::View.instance if view queue = view.queue if queue queue << song else view.set_queue([song]) end end end action[:stock_image] = Stock::ADD action = Actions.new 'Reread tags', :song do |song| view = Sh::View.instance proc = Proc.new do |s| path = s.path s.delete Database.add_song path end view ? view.update_song(song, &proc) : proc.call(song) end action[:stock_image] = Stock::HARDDISK if try_require 'earworm' and try_require 'rbrainz' action = Actions.new 'Lookup metadata automatically', :song do |song| if song.lookup! view = Sh::View.instance proc = Proc.new {|s| s.save} view ? view.update_song(song, &proc) : proc.call(song) end end action[:stock_image] = Stock::FIND end action = Actions.new 'Add to playlist', :song, :playlist do |song, playlist| playlist << song playlist.save! end action[:stock_image] = Stock::ADD action = Actions.new 'Properties', :song do |song| show_song_properties_dialog(song) end action[:stock_image] = Stock::PROPERTIES end |
.show_song_properties_dialog(song) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/sh_actions.rb', line 88 def self.show_song_properties_dialog song glade = Global::GLADE['dlg_song'] dlg_song = glade['dlg_song'] txt_title = glade['txt_title'] txt_title.text = song.title || File.basename(song.path) spn_track_num = glade['spn_track_num'] spn_track_num.value = song.track_num || 0 # Artists combo box sto_artists = ListStore.new(String, Artist) cmb_artist = glade['cmb_artist'] sel = 0 Artist.order(:name).each_with_index do |artist, i| iter = sto_artists.append iter[0] = artist.name iter[1] = artist sel = i if song.artist && artist.id == song.artist.id end cmb_artist.model = sto_artists cmb_artist.active = sel # Albums combo box sto_albums = ListStore.new(String, Album) cmb_album = glade['cmb_album'] sel = 0 Album.order(:title).each_with_index do |album, i| iter = sto_albums.append iter[0] = album.title iter[1] = album sel = i if song.album && album.id == song.album.id end cmb_album.model = sto_albums cmb_album.active = sel glade['chk_image'].sensitive = false glade['fbtn_image'].sensitive = false glade['btn_add_artist'].sensitive = false glade['btn_add_album'].sensitive = false dlg_song.signal_connect('delete-event') do dlg_song.hide end btn_ok = glade['btn_ok'] ok_handle = btn_ok.signal_connect('clicked') do song.title = txt_title.text song.track_num = spn_track_num.value song.artist = cmb_artist.active_iter[1] song.album = cmb_album.active_iter[1] view = Sh::View.instance proc = Proc.new {|s| s.save} view ? view.update_song(song, &proc) : proc.call(song) dlg_song.hide end btn_cancel = glade['btn_cancel'] close_handle = btn_cancel.signal_connect('clicked') do dlg_song.hide end dlg_song.run btn_ok.signal_handler_disconnect ok_handle btn_cancel.signal_handler_disconnect close_handle end |