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.
7e17d370dc95b48cd82944a62f1caf76?d=identicon&s=25 Robert H. (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.
De9653edd5992e0560cbdee75d5fabe9?d=identicon&s=25 Levi L. (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.
9d2d160377d47a2144b12d36ab63126f?d=identicon&s=25 Regis d. (raubarede)
on 2015-05-12 12:30
Robert Heiler wrote in post #1173363:
> Hi guys,
>

see :

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