Class: MultimediaParadise::Rubio::View::Radio

Inherits:
Object
  • Object
show all
Includes:
Glimmer::LibUI::Application
Defined in:
lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#presenterObject (readonly)

Returns the value of attribute presenter.



31
32
33
# File 'lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb', line 31

def presenter
  @presenter
end

Instance Method Details

#about_message_boxObject



228
229
230
231
232
233
234
235
236
237
# File 'lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb', line 228

def about_message_box
  license = begin
    File.read(File.expand_path('../../../LICENSE.txt', __dir__))
  rescue => e
    puts e.full_message if debug
    ''
  end
  product = "rubio-radio #{Rubio::VERSION}"
  message_box(product, "#{product}\n\n#{license}")
end

#currently_playing_labelObject



182
183
184
185
186
187
188
189
# File 'lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb', line 182

def currently_playing_label
  return unless show_currently_playing && backend == 'vlc -I rc' && !OS.windows?

  label do
    stretchy false
    text <= [@presenter.player, :currently_playing]
  end
end

#help_menuObject



172
173
174
175
176
177
178
179
180
# File 'lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb', line 172

def help_menu
  menu('Help') do
    menu_item('About') do
      on_clicked do
        about_message_box
      end
    end
  end
end

#radio_menuObject



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
124
125
126
127
128
129
130
131
# File 'lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb', line 87

def radio_menu
  menu('Radio') do
    menu_item('Stop') do
      enabled <= [@presenter, 'current_station', on_read: ->(value) { !!value }]
      
      on_clicked do
        @presenter.stop_station
      end
    end

    separator_menu_item

    menu_item('Bookmark') do
      enabled <= [@presenter, 'current_station.bookmarked', on_read: ->(value) { value == false }]
      
      on_clicked do
        toggle_bookmarked_station
      end
    end

    menu_item('Unbookmark') do
      enabled <= [@presenter, 'current_station.bookmarked', on_read: ->(value) { value == true }]
      
      on_clicked do
        toggle_bookmarked_station
      end
    end

    separator_menu_item

    if OS.mac?
      about_menu_item do
        on_clicked do
          about_message_box
        end
      end
    end

    quit_menu_item do
      on_clicked do
        @presenter.player.stop_all
      end
    end
  end
end

#radio_menu_barObject



79
80
81
82
83
84
85
# File 'lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb', line 79

def radio_menu_bar
  return unless OS.mac? || show_menu

  radio_menu
  view_menu
  help_menu
end

#refresh_viewObject



257
258
259
260
261
262
263
264
265
266
# File 'lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb', line 257

def refresh_view
  case @presenter.view
  when :all
    view_all
  when :bookmarks
    view_bookmarks
  when :playing
    view_playing
  end
end

#station_table_columnsObject



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
218
219
220
221
222
223
224
225
226
# File 'lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb', line 191

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.full_message if debug
            message_box(e.message)
          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,
    'country' => :text
  )
end

#toggle_bookmarked_station(station = nil) ⇒ Object



239
240
241
242
243
# File 'lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb', line 239

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_allObject



245
246
247
# File 'lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb', line 245

def view_all
  @station_table.model_array = @presenter.stations
end

#view_bookmarksObject



249
250
251
# File 'lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb', line 249

def view_bookmarks
  @station_table.model_array = @presenter.stations.select(&:bookmarked?)
end

#view_menuObject



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
163
164
165
166
167
168
169
170
# File 'lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb', line 133

def view_menu
  menu('View') do
    radio_menu_item('All') do
      checked <=> [@presenter, :view,
                    on_read: ->(value) { value == :all },
                    on_write: ->(value) { :all },
                  ]
      
      on_clicked do
        view_all
      end
    end

    radio_menu_item('Bookmarks') do
      checked <=> [@presenter, :view,
                    on_read: ->(value) { value == :bookmarks },
                    on_write: ->(value) { :bookmarks },
                  ]
                  
      on_clicked do
        view_bookmarks
      end
    end

    radio_menu_item('Playing') do
      checked <=> [@presenter, :view,
                    on_read: ->(value) { value == :playing },
                    on_write: ->(value) { :playing },
                  ]
                  
      on_clicked do
        view_playing
      end
    end

    separator_menu_item if OS.mac?
  end
end

#view_playingObject



253
254
255
# File 'lib/multimedia_paradise/gui/glimmer/rubio/view/radio.rb', line 253

def view_playing
  @station_table.model_array = @presenter.stations.select(&:playing?)
end