Class: Rubio::View::Radio
- Inherits:
-
Object
- Object
- Rubio::View::Radio
- Includes:
- Glimmer::LibUI::Application
- Defined in:
- lib/rubio/view/radio.rb
Instance Attribute Summary collapse
-
#presenter ⇒ Object
readonly
Returns the value of attribute presenter.
Instance Method Summary collapse
- #about_message_box ⇒ Object
- #currently_playing_label ⇒ Object
- #help_menu ⇒ Object
- #radio_menu ⇒ Object
- #radio_menu_bar ⇒ Object
- #refresh_view ⇒ Object
- #station_table_columns ⇒ Object
- #toggle_bookmarked_station(station = nil) ⇒ Object
- #view_all ⇒ Object
- #view_bookmarks ⇒ Object
- #view_menu ⇒ Object
- #view_playing ⇒ Object
Instance Attribute Details
#presenter ⇒ Object (readonly)
Returns the value of attribute presenter.
23 24 25 |
# File 'lib/rubio/view/radio.rb', line 23 def presenter @presenter end |
Instance Method Details
#about_message_box ⇒ Object
219 220 221 222 223 224 225 226 227 228 |
# File 'lib/rubio/view/radio.rb', line 219 def license = begin File.read(File.('../../../LICENSE.txt', __dir__)) rescue => e puts e. if debug '' end product = "rubio-radio #{Rubio::VERSION}" (product, "#{product}\n\n#{license}") end |
#currently_playing_label ⇒ Object
174 175 176 177 178 179 180 181 |
# File 'lib/rubio/view/radio.rb', line 174 def return unless && backend == 'vlc -I rc' && !OS.windows? label do stretchy false text <= [@presenter.player, :currently_playing] end end |
#help_menu ⇒ Object
164 165 166 167 168 169 170 171 172 |
# File 'lib/rubio/view/radio.rb', line 164 def ('Help') do ('About') do on_clicked do end end end end |
#radio_menu ⇒ Object
79 80 81 82 83 84 85 86 87 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 |
# File 'lib/rubio/view/radio.rb', line 79 def ('Radio') do ('Stop') do enabled <= [@presenter, 'current_station', on_read: ->(value) { !!value }] on_clicked do @presenter.stop_station end end ('Bookmark') do enabled <= [@presenter, 'current_station.bookmarked', on_read: ->(value) { value == false }] on_clicked do toggle_bookmarked_station end end ('Unbookmark') do enabled <= [@presenter, 'current_station.bookmarked', on_read: ->(value) { value == true }] on_clicked do toggle_bookmarked_station end end if OS.mac? do on_clicked do end end end do on_clicked do @presenter.player.stop_all end end end end |
#radio_menu_bar ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/rubio/view/radio.rb', line 71 def return unless OS.mac? || end |
#refresh_view ⇒ Object
248 249 250 251 252 253 254 255 256 257 |
# File 'lib/rubio/view/radio.rb', line 248 def refresh_view case @presenter.view when :all view_all when :bookmarks view_bookmarks when :playing end end |
#station_table_columns ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/rubio/view/radio.rb', line 183 def station_table_columns table_columns = { 'Play' => { button: { on_clicked: lambda { |row| station = @station_table.refined_model_array[row] begin @presenter.select_station(station) rescue => e puts e. if debug (e.) end } } } } if show_bookmarks table_columns.merge!( 'Bookmark' => { button: { on_clicked: lambda { |row| station = @station_table.refined_model_array[row] toggle_bookmarked_station(station) } } } ) end table_columns.merge!( 'name' => :text, 'language' => :text ) end |
#toggle_bookmarked_station(station = nil) ⇒ Object
230 231 232 233 234 |
# File 'lib/rubio/view/radio.rb', line 230 def toggle_bookmarked_station(station = nil) station ||= @presenter.current_station @presenter.toggle_bookmarked_station(station) view_bookmarks if @presenter.view == :bookmarks && !station.bookmarked end |
#view_all ⇒ Object
236 237 238 |
# File 'lib/rubio/view/radio.rb', line 236 def view_all @station_table.model_array = @presenter.stations end |
#view_bookmarks ⇒ Object
240 241 242 |
# File 'lib/rubio/view/radio.rb', line 240 def view_bookmarks @station_table.model_array = @presenter.stations.select(&:bookmarked?) end |
#view_menu ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/rubio/view/radio.rb', line 125 def ('View') do ('All') do checked <=> [@presenter, :view, on_read: ->(value) { value == :all }, on_write: ->(value) { :all }, ] on_clicked do view_all end end ('Bookmarks') do checked <=> [@presenter, :view, on_read: ->(value) { value == :bookmarks }, on_write: ->(value) { :bookmarks }, ] on_clicked do view_bookmarks end end ('Playing') do checked <=> [@presenter, :view, on_read: ->(value) { value == :playing }, on_write: ->(value) { :playing }, ] on_clicked do end end if OS.mac? end end |
#view_playing ⇒ Object
244 245 246 |
# File 'lib/rubio/view/radio.rb', line 244 def @station_table.model_array = @presenter.stations.select(&:playing?) end |