summaryrefslogtreecommitdiffstats
path: root/korundum/rubylib/examples/xmlgui.rb
blob: ce5ca4187efaba32d95e55ee974f8ce9c2bdf69e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env ruby

require 'Korundum'
require 'tempfile'

about = KDE::AboutData.new("one", "two", "three")
#KDE::CmdLineArgs.init(about)
KDE::CmdLineArgs.init(ARGV, about)
app = KDE::Application.new()

class Receiver < TQt::Object
   slots "pressed_up()", "close()", "quit()"
   def initialize main, *k
      super(*k)
      @main = main
   end
   def quit
      @main.close
   end
end

RAction = Struct.new :xmlgui_name, :string, :accel, :something
class RAction
   def create receiver, slot, action_collection
      p self.string
      KDE::Action.new self.string, self.accel, receiver, slot, action_collection, self.xmlgui_name
   end
end

# { Quit,          TDEStdAccel::Quit, "file_quit", I18N_NOOP("&Quit"), 0, "exit" },
std_actions = { :quit => RAction.new( "file_quit", ("&Quit"), KDE::Shortcut.new(), "exit" ) }

begin
   m = KDE::MainWindow.new
   @r = Receiver.new m
   mActionCollection = m.actionCollection
   action = std_actions[:quit].create @r, TQ_SLOT("quit()"), mActionCollection
   m.createGUI Dir.pwd + "/xmlgui.rc"
   app.setMainWidget(m)
   m.show
   app.exec()
end