Forum: Ruby Interfaces

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
36778257b99fbb3e19fe184bd833a39c?d=identicon&s=25 Ranjan Ghosh (Guest)
on 2006-03-26 20:21
(Received via mailing list)
Hi everyone!

Since I've switched to Linux I've been looking for a way to write
applications
again. On Windows I used Delphi. I looked at its Linux counterpart Kylix
and
didnt like it at all. Especially, I wanted to write KDE applications
which
just wasnt possible. So I looked at other KDE bindings. I tried C++ but
all
that time for compiling and confusing Makefiles and type definitions
wasnt
really for me either. Now with Ruby and Korundum I think I've finally
found
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
docs
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
lines
of code. Amazing. Unfortuately I cant do anything with it right now.
In order to communicate it seems that I need a so-called
Terminalnterface.
In C++ this is done by using a type-cast / qt_cast. Calling the qt_cast
method
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
right
now. Can this be done at all in Ruby (perhaps by calling "extend" or
whatever)?

Thanks in advance for any help here!

Ranjan

======

  // fetch the Library..
  KLibFactory* factory = KLibLoader::self()->factory( "libkonsolepart"
);
  if ( factory == 0L )
  {
    // inform the user that he should install konsole..
    return;
  };
  // 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...
    return;
  };
  // 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.