[Kde-bindings] Why does this program stop ?
Han Holl
han.holl at pobox.com
Wed Nov 29 20:31:49 UTC 2006
Hi,
I'm trying to construct a little program that shows the state of another
computer (a mythtv recorder) in the systemtray.
After I click 'yes' the program stops, instead of hiding the dialog.
I have no idea why.
Cheers,
Han Holl
Here is the program, mercifully short:
#!/usr/bin/ruby -w
$KCODE = 'u'
$LOAD_PATH << File.dirname($0)
require 'Korundum'
class KdeTray < KDE::UniqueApplication
k_dcop 'void set_state(int)'
@@actions = %w{aan uit}
@@buttons = %w{ button_cancel button_ok }
slots 'yes()'
def yes
STDERR.puts "/usr/local/bin/tvr #{@@actions[@state]}"
system("/usr/local/bin/tvr #{@@actions[@state]}")
@w.hide
end
def caption
"TVR #{@@actions[@state]}zetten"
end
def initialize
super()
@file = '/var/tmp/tvr-ready'
@state = test(?f, @file) ? 1 : 0
STDERR.puts caption
# @main = Qt::HBox.new
@caption = caption
@w = KDE::DialogBase.new(@caption, KDE::DialogBase::Yes +
KDE::DialogBase::No )
@w.resize( Qt::Size.new(220, 50) )
Qt::Object.connect(@w, SIGNAL('yesClicked()'), self, SLOT('yes()'))
@tray = KDE::SystemTray.new(@w, 'tvr')
setMainWidget(@w)
Qt::Object.connect(@tray, SIGNAL('quitSelected()'), self, SLOT('quit()'))
@tray.setPixmap(iconLoader.loadIcon(@@buttons[@state],
KDE::Icon::Toolbar))
@tray.show
end
def set_state(state)
@state = state
@tray.setPixmap(iconLoader.loadIcon(@@buttons[@state],
KDE::Icon::Toolbar))
end
end
KDE::CmdLineArgs.init(ARGV, KDE::AboutData.new("tray", "", '', '', 0))
app = KdeTray.new
app.exec
More information about the Kde-bindings
mailing list