[Kde-bindings] QtRuby DBus Signal

Yo-Man Yen ymanyen at gmail.com
Wed Feb 29 16:35:05 UTC 2012


Hi folks,

I have a Qt GUI script written in Ruby that I would like to get signal from
DBus when a new USB device is detected. The scripts works if I connect to
my slot to DBUS signal without any parameter, but this does not give me any
info on which device was inserted. However, using QDBusObjectPath as the
parameter to my slot (this works perfectly with C++) I ran into some sort
of binding error
"ruby-1.9.3-p0/gems/qtbindings-4.6.3.4/lib/Qt/qtruby4.rb:469:in
`qt_metacall': Cannot handle 'QDBusObjectPath&' as slot argument
(ArgumentError)" when Qt tries to call my slot.

Is anyone here familiar with the inner working of Qt Ruby binding knows
that might be able to give me some hits on getting info on USB device
inserted into the system? Thanks in advance.

Here is a sample code that will illustrate the error:

    require 'Qt'

    class MyDisk < Qt::Object

      slots 'on_device_added_ext(QDBusObjectPath)',
            'on_device_removed_ext(QDBusObjectPath)'

      def initialize
        super
      end

      def on_device_added_ext message
        puts "Deviced Added with path = #{message.path()}"
      end

      def on_device_removed_ext message
        puts "Deviced Removed with path = #{message.path()}"
      end

    end

    app = Qt::Application.new ARGV
    test = MyDisk.new

    ret = Qt::DBusConnection::systemBus().connect(
                             "org.freedesktop.UDisks",
                             "/org/freedesktop/UDisks",
                             "org.freedesktop.UDisks",
                             "DeviceAdded",
                             test,
SLOT('on_device_added_ext(QDBusObjectPath)'))

    ret = Qt::DBusConnection::systemBus().connect(
                             "org.freedesktop.UDisks",
                             "/org/freedesktop/UDisks",
                             "org.freedesktop.UDisks",
                             "DeviceRemoved",
                             test,
SLOT('on_device_removed_ext(QDBusObjectPath)'))

    app.exec
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20120229/8999d1a0/attachment.html>


More information about the Kde-bindings mailing list