Some Ruby Code

In the following code listing you can find the code for a full-featured kmainwindow.

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env ruby # file: kmainwindow.rb $KCODE = 'u' require 'korundum4' # kd4 bindings class CustomWidget < KDE::MainWindow def initialize super resize(520, 535) # Prepare the Actions @actionQuit = KDE::Action.new( self ) { setIcon KDE::Icon.new "application-exit" } connect( @actionQuit, SIGNAL( :triggered ), SLOT( :close ) ) # Prepare the Menu @menuBar = menuBar @menuFile = Qt::Menu.new @menuBar @menuFile.addAction @actionQuit @menuBar.addAction @menuFile.menuAction @helpMenu = helpMenu @menuBar.addAction @helpMenu.menuAction setMenuBar(@menuBar) # Prepare Statusbar @statusBar = statusBar setStatusBar @statusBar # Prepare Toolbar @toolBar = toolBar @toolBar.addAction @actionQuit addToolBar(Qt::TopToolBarArea, @toolBar) # Prepare Central Widget @centralwidget = KDE::TextEdit.new self setCentralWidget @centralwidget retranslateUi end def retranslateUi @menuFile.title = i18n "File" setWindowTitle i18n "MainWindow" # @statusBar.showMessage i18n "Loading" @actionQuit.text = i18n "Quit" @actionQuit.shortcut = KDE::Shortcut.new i18nc( "Quit", "Ctrl+Q" ) end end about = KDE::AboutData.new( "app", # internal application name # language catlog name for i10n (konqueror's catalog for the beginning is better than no catalog) "konqueror", KDE.ki18n("KApp"), # application name in the about menu and everywhere else "0.1", # application version KDE::ki18n("A Tool to easily create HTML formatted Code"), # short description KDE::AboutData::License_GPL_V3, # license KDE::ki18n("(c) 1999-2000, Name"), # copyright info # text in the about box - maybe with \n line breaks KDE::ki18n("just some text in the about box"), # project homepage and eMail adress for bug reports - attention: homepage changes standard dbus/dcop name! "http://homepage.de", "bugs@homepage.de" ) about.setProgramIconName "plasma" # use the plasma-icon instead of question mark KDE::CmdLineArgs.init(ARGV, about) a = KDE::Application.new w = CustomWidget.new a.topWidget = w w.show a.exec

kmainwindow.rb