From 35b7295e6b0753e6ed3c384e93e30f7f88292bff Mon Sep 17 00:00:00 2001 From: Roberto Bermudez Date: Mon, 1 Apr 2024 01:33:39 +0200 Subject: [PATCH] Passing medialit to mediaplayer to add the popup --- application/ui/banshy/application_window.rb | 2 +- application/ui/banshy/media_list_display.rb | 18 +++++++++--------- application/ui/banshy/media_player.rb | 9 ++++++++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/application/ui/banshy/application_window.rb b/application/ui/banshy/application_window.rb index d5b2b3b..d66e0cb 100755 --- a/application/ui/banshy/application_window.rb +++ b/application/ui/banshy/application_window.rb @@ -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 diff --git a/application/ui/banshy/media_list_display.rb b/application/ui/banshy/media_list_display.rb index 9816225..ceeaa7a 100644 --- a/application/ui/banshy/media_list_display.rb +++ b/application/ui/banshy/media_list_display.rb @@ -77,6 +77,15 @@ 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 @@ -84,14 +93,5 @@ def clean_display @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 diff --git a/application/ui/banshy/media_player.rb b/application/ui/banshy/media_player.rb index 28a4cb8..e9ebdf7 100644 --- a/application/ui/banshy/media_player.rb +++ b/application/ui/banshy/media_player.rb @@ -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) @@ -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