Forum: Ruby-Gnome 2 How to avoid freezing a rubygnome GUI?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4828d528e2e46f7c8160c336eb332836?d=identicon&s=25 Robert Heiler (shevegen)
on 2015-05-10 19:23
Hi guys,

Here is my problem.

I have a GUI widget, in ruby-gnome, and I have buttons.

Each button plays a video file.

I use system() for this, and mplayer.

When I click the button, all works well, mplayer plays the
video.

The problem is that, while mplayer plays this file, the
rubygnome GUI "freezes", until that mplayer window is
closed again.

Is there a way to somehow allow the background GUI frame
to not freeze? On the commandline I can play multiple
videos, from different KDE konsole tabs, so I wonder that
must be possible in a GUI too, perhaps via a thread or
something.

Thank you.
77d853d2a3cc819ccb2140155b939fbe?d=identicon&s=25 Levi Levinsten (levi2)
on 2015-05-11 18:18
On an ancient version of ruby-gnome, I used this to do something
similar:

def threaded()
    if(block_given?)
      @_w_events = @window.events
      @window.events = 0
      @window.sensitive = false
      @window.window.cursor=Gdk::Cursor.new(Gdk::Cursor::WATCH)

      Thread.new do
        begin
          yield
        rescue
          #error($!)
        end

        @window.window.cursor = nil
        @window.events = @_w_events
        @window.sensitive = true
      end
    end
end


And then wrap whatever I needed to run like this.

threaded() do
  play_video()
end

You might need to make a few modifications though, because it was on an
ancient version of ruby-gnome, and on Ruby 1.8.6.
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2015-05-12 12:30
Robert Heiler wrote in post #1173363:
> Hi guys,
>

see :

https://www.ruby-forum.com/topic/125038#new
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2015-05-12 15:48
This topic is locked and can not be replied to.