summaryrefslogtreecommitdiffstats
path: root/korundum/rubylib/tutorials/p5/p5.rb
blob: 0325aa379d5b41220702df5b225a3764428fa60a (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
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
79
80
81
82
require 'Korundum'
 
class MainWindow < KDE::MainWindow
    slots   'changeLocation()',
            'openURLRequest(const KURL &, const KParts::URLArgs & )',
            'bookLocation()'
 
    def initialize( name )
        super(nil, name)
        setCaption("KDE Tutorial - p5")

        filemenu = TQt::PopupMenu.new
        filemenu.insertItem( i18n( "&Quit" ), $kapp, TQ_SLOT( 'quit()' ) )
        about =
                i18n("p5 1.0\n\n" +
                     "(C) 1999-2002 Antonio Larrosa Jimenez\n" +
                     "larrosa@kde.org\t\tantlarr@supercable.es\n" +
                     "Malaga (Spain)\n\n" +
                     "Simple KDE Tutorial\n" +
                     "This tutorial comes with ABSOLUTELY NO WARRANTY \n" +
                     "This is free software, and you are welcome to redistribute it\n" +
                     "under certain conditions\n");
 
        helpmenu = helpMenu(about)
        menu = menuBar()
        menu.insertItem( i18n( "&File" ), filemenu)
        menu.insertSeparator()
        menu.insertItem(i18n("&Help"), helpmenu)
 
        vbox = TQt::VBox.new( self )
 
        @location = TQt::LineEdit.new( vbox )
        @location.setText( "http://localhost" )
 
        connect( @location , TQ_SIGNAL( 'returnPressed()' ),
                    self, TQ_SLOT( 'changeLocation()' ) )
 
        split = TQt::Splitter.new( vbox )
        split.setOpaqueResize()
 
        bookmark = TQt::PushButton.new( i18n("Add to Bookmarks"), split );
 
        connect( bookmark, TQ_SIGNAL( 'clicked()' ), self, TQ_SLOT( 'bookLocation()' ) )
 
        @browser = KDE::HTMLPart.new( split )
        @browser.openURL( KDE::URL.new(@location.text()) )
 
        connect( @browser.browserExtension(),
                    TQ_SIGNAL( 'openURLRequest( const KURL &, const KParts::URLArgs & )' ),
                    self, TQ_SLOT( 'openURLRequest(const KURL &, const KParts::URLArgs & )' ) )                 
        setCentralWidget(vbox)
    end
 
 
    def changeLocation()
        @browser.openURL( KDE::URL.new(@location.text()) )
    end

    def openURLRequest(url, part)
        @location.text = url.url()
        changeLocation()
    end
 
    def bookLocation()
        dcopRef = KDE::DCOPRef.new("p6", "BookMarkList")
        if ! dcopRef.add(@location.text())
            tqWarning("Error with DCOP\n")
        end
    end
end

    about = KDE::AboutData.new("p5", "Tutorial - p5", "0.1")
    KDE::CmdLineArgs.init(ARGV, about)
    a = KDE::Application.new()
        
    window = MainWindow.new( "Tutorial - p5" )
    window.resize( 300, 200 )
        
    a.mainWidget = window
    window.show
        
    a.exec