[Kde-bindings] KDE/kdebindings/qtruby

Richard Dale Richard_Dale at tipitina.demon.co.uk
Mon Oct 16 21:09:35 UTC 2006


SVN commit 596188 by rdale:

* Fixed Qt::DBusInterface.call() so it automatically wraps the arguments
  as Qt::Variants. Thanks to prullmann for testing and finding problems.

* Improved the pingpong example to be more like the C++ version.

CCMAIL: kde-bindings at kde.org



 M  +7 -0      ChangeLog  
 M  +4 -3      rubylib/examples/qdbus/pingpong/ping.rb  
 M  +13 -3     rubylib/qtruby/lib/Qt/qtruby4.rb  


--- trunk/KDE/kdebindings/qtruby/ChangeLog #596187:596188
@@ -1,3 +1,10 @@
+2006-10-16  Richard Dale  <rdale at foton.es>
+
+	* Fixed Qt::DBusInterface.call() so it automatically wraps the arguments
+	  as Qt::Variants. Thanks to prullmann for testing and finding problems.
+
+	* Improved the pingpong example to be more like the C++ version.
+
 2006-10-13  Richard Dale  <rdale at foton.es>
 
 	* Added marshallers for QList<QPair<QString,QString> > and QGradiantStops
--- trunk/KDE/kdebindings/qtruby/rubylib/examples/qdbus/pingpong/ping.rb #596187:596188
@@ -37,15 +37,16 @@
 	
 iface = Qt::DBusInterface.new(SERVICE_NAME, "/", "", Qt::DBusConnection.sessionBus)
 if iface.valid?
-	reply = iface.ping(ARGV.length > 0 ? ARGV[0] : "")
+	message = iface.call("ping", ARGV.length > 0 ? ARGV[0] : "")
+	reply = Qt::DBusReply.new(message)
 	if reply.valid?
 		puts("Reply was: %s\n" % reply.value)
 		exit(0)
 	end
 	
-	$stderr.puts("Call failed: %s\n", reply.error.message)
+	$stderr.puts("Call failed: %s\n" % reply.error.message)
 	exit(1)
 end
 	
 $stderr.puts("%s\n" % Qt::DBusConnection.sessionBus.lastError.message)
-exit(1)
\ No newline at end of file
+exit(1)
--- trunk/KDE/kdebindings/qtruby/rubylib/qtruby/lib/Qt/qtruby4.rb #596187:596188
@@ -435,6 +435,18 @@
 	end
 
 	class DBusInterface < Qt::Base 
+
+		def call(method_name, *args)
+			if args.length == 0
+				return super(method_name.to_sym)
+			else
+				# If the method is Qt::DBusInterface.call(), create an Array 
+				# 'dbusArgs' of Qt::Variants from '*args'
+				qdbusArgs = args.collect {|arg| qVariantFromValue(arg)}
+				return super(method_name, *qdbusArgs)
+			end
+		end
+
 		def method_missing(id, *args)
 			begin
 				# First look for a method in the Smoke runtime
@@ -444,9 +456,7 @@
 				if args.length == 0
 					return call(id.to_s).value
 				else
-					# create an Array 'dbusArgs' of Qt::Variants from '*args'
-					qdbusArgs = args.collect {|arg| qVariantFromValue(arg)}
-					return call(id.to_s, *dbusArgs).value
+					return call(id.to_s, *args).value
 				end
 			end
 		end



More information about the Kde-bindings mailing list