views:

160

answers:

1
+2  Q: 

Custom threads?

How does one create custom threads to run in a Gtk application?

Given this simplistic example:

@w = Gtk::Window.new "testtest"
@l = Gtk::Label.new "test"
@w.add @l
@w.show_all
Gtk.main

How could I run a thread like this?

Thread.start { loop { puts 'thread running'; @l.text = Time.now.to_s; sleep 1 }}

I got that timeout-based approach working with #timeout_add, but that isn't very nice and doesn't work for what I'm really trying to achieve: waiting for a dbus signal.

I've tried many things, each of which either hang the gtk thread or my own thread. I also tried using http://ruby-gnome2.sourceforge.jp/hiki.cgi?tips%5Fthreads but I'm not sure if it's actually the same problem)

+1  A: 

I know Redcar moved from gtk because I believe it couldn't get the tests to work right.

http://redcareditor.com/blog/2009/08/redcar-is-moving-to-jruby/

http://groups.google.com/group/redcar-editor/browse_thread/thread/1a4d4718cf10c170/fa5e481d6365cb41?lnk=gst&q=gtk+test#fa5e481d6365cb41

so you could actually ask daniel or on that mailing list.

in terms of diagnosing the hang I suppose you could use strace or what not to see where it's hanging. Also running with 1.9 might help as you can set certain C calls a "non blocking" in binary extensions. GL. -r

rogerdpack