Forum: Ruby Interfaces

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ranjan Ghosh (Guest)
on 2006-03-26 22:21
(Received via mailing list)
Hi everyone!

Since I've switched to Linux I've been looking for a way to write
again. On Windows I used Delphi. I looked at its Linux counterpart Kylix
didnt like it at all. Especially, I wanted to write KDE applications
just wasnt possible. So I looked at other KDE bindings. I tried C++ but
that time for compiling and confusing Makefiles and type definitions
really for me either. Now with Ruby and Korundum I think I've finally
my new language. Its amazing how fast you get things done. My first
application should contain a konsole part. I've looked up in the KDE
and found the snippet below. I tried to translate it to ruby.
This worked great for the part until setCentralWidget.
I'm now having a real Terminal inside my application with just a few
of code. Amazing. Unfortuately I cant do anything with it right now.
In order to communicate it seems that I need a so-called
In C++ this is done by using a type-cast / qt_cast. Calling the qt_cast
from my KParts::Part object just yields a "*void not supported as return
value" message in Ruby. If I just try to call showShellInDir on my
object it
doesnt work of course because its not a method of KPart. I'm puzzled
now. Can this be done at all in Ruby (perhaps by calling "extend" or

Thanks in advance for any help here!



  // fetch the Library..
  KLibFactory* factory = KLibLoader::self()->factory( "libkonsolepart"
  if ( factory == 0L )
    // inform the user that he should install konsole..
  // fetch the part..
  KParts::Part* p = static_cast<KParts::Part*>(
      factory->create( this, "tralala", "QObject",
                       "KParts::ReadOnlyPart" ) );
  assert( p );
  setCentralWidget( p->widget() );

  // cast the part to the TerminalInterface..
  TerminalInterface* t =
static_cast<TerminalInterface*>( p->qt_cast( "TerminalInterface" ) );
  if( ! t )
    // This probably happens because the konsole that is installed
    // comes from before KDE 3.2 , and the TerminalInterface is not
    // available..  What you can do here is either inform the user
    // that he needs a more recent konsole, or try to deliver the
    // functionality in some other way...
  // now use the interface in all sorts of ways, e.g.
  //    t->showShellInDir( QDir::home().path() );
  // or:
  //    QStrList l;
  //    l.append( "python" );
  //    t->startProgram( QString::fromUtf8( "/usr/bin/python" ), l);
  // or connect to one of the signals.  Connect to the Part object,
  // not to the TerminalInterface, since the latter is no QObject,
  // and as such cannot have signals..:
  //    connect( p, SIGNAL( processExited( int ) ),
  //             this, SLOT( shellExited( int ) ) );
  // etc.
This topic is locked and can not be replied to.