Skip to content

Commit

Permalink
Passing medialit to mediaplayer to add the popup
Browse files Browse the repository at this point in the history
  • Loading branch information
robertobermudez committed Mar 31, 2024
1 parent ba8f47d commit 35b7295
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion application/ui/banshy/application_window.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def initialize(application)
end

def attach_components
@buffer = Banshy::MediaPlayer.new
@tree_view = MediaTreeView.new self
@media_display = MediaListDisplay.new(media_search)
@buffer = Banshy::MediaPlayer.new @media_display
@automatic_forwarder = AutomaticForwarder.new(self, buffer)
grid_2.attach @tree_view, 0, 0, 1, 1
grid_2.attach @media_display, 1, 0, 1, 1
Expand Down
18 changes: 9 additions & 9 deletions application/ui/banshy/media_list_display.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,21 @@ def search_handler
end
end

def init_popup_menu(another_widget = media_list_box)
another_widget.add_events Gdk::EventMask::BUTTON_PRESS_MASK
another_widget.signal_connect 'button_press_event' do |widget, event|
if event.button == 3
MediaBoxPopupMenu.new(selected_row, media_list_box, queue).popup(nil, nil, event.button, event.time) if selected
end
end
end

private

def clean_display
media_list_box.unselect_all
@selected = nil
media_list_box.children.each { |child| media_list_box.remove child }
end

def init_popup_menu
media_list_box.add_events Gdk::EventMask::BUTTON_PRESS_MASK
media_list_box.signal_connect 'button_press_event' do |widget, event|
if event.button == 3
MediaBoxPopupMenu.new(selected_row, media_list_box, queue).popup(nil, nil, event.button, event.time) if selected
end
end
end
end
end
9 changes: 8 additions & 1 deletion application/ui/banshy/media_player.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ def init

attr_reader :playing, :file, :ready, :music_pip, :video_pip

def initialize
def initialize(media_list_display)
super()
@pipeline = nil
@file = nil
@ready = false
@playing = false
@media_list_display = media_list_display
popup_handler
end

def load(file)
Expand Down Expand Up @@ -120,6 +122,11 @@ def finished?
current_position == duration_seconds && duration_seconds != -1
end

def popup_handler
add_events Gdk::EventMask::BUTTON_PRESS_MASK
@media_list_display.init_popup_menu self
end

private

def load_pipeline
Expand Down

0 comments on commit 35b7295

Please sign in to comment.