summaryrefslogtreecommitdiffstats
path: root/interfaces/terminal/test/main.cc
blob: 0b32eec8e2339e66857babff5cc58bf548aaf1f1 (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
#include <kde_terminal_interface.h>
#include <kparts/part.h>
#include <ktrader.h>
#include <klibloader.h>
#include <kmainwindow.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <tqdir.h>
#include <assert.h>
#include <kmessagebox.h>
#include <cassert>
#include "main.h"
#include "main.moc"

Win::Win()
{
    KLibFactory* factory = KLibLoader::self()->factory( "libkonsolepart" );
    assert( factory );
    KParts::Part* p = static_cast<KParts::Part*>( factory->create( this, "tralala", TQOBJECT_OBJECT_NAME_STRING, "KParts::ReadOnlyPart" ) );
    setCentralWidget( p->widget() );

    TerminalInterface* t = ::tqqt_cast<TerminalInterface*>( p );
    t->showShellInDir( TQDir::home().path() );
//     TQStrList l;
//     l.append( "python" );
//     t->startProgram( TQString::fromUtf8( "/usr/bin/python" ), l );

    connect( p, TQT_SIGNAL( processExited( int ) ),
             this, TQT_SLOT( pythonExited( int ) ) );
}


int main( int argc, char** argv )
{
    KAboutData* about = new KAboutData( "tetest", "TETest", "0.1" );
    TDECmdLineArgs::init( argc, argv, about );
    KApplication a;
    Win* win = new Win();
    win->show();
    return a.exec();
};

#include <iostream>

void Win::pythonExited()
{
    std::cerr << "hee, " << p << std::endl;
    std::cerr << ( ::tqqt_cast<TerminalInterface>(p) ) << std::endl;
    // KMessageBox::sorry( this, TQString::fromUtf8( "Exited, status was %1" ).arg( status ) );
    disconnect(p, TQT_SIGNAL( processExited() ),
            this, TQT_SLOT( pythonExited() ));
    TerminalInterface* t = ::tqqt_cast<TerminalInterface*>( p );
    TQStrList l;
    l.append( "echo" );
    l.append( "hello world" );
    t->startProgram( TQString::fromUtf8( "/bin/echo" ), l );
}

void Win::forked()
{
    std::cerr << "hello from the child process!" << std::endl;
}