summaryrefslogtreecommitdiffstats
path: root/korundum/rubylib/examples/dcop/dcopslot.rb
blob: 99fd6fefff270b1ff316b7a9bbdec428efdd1df0 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env ruby

retquire 'Korundum'

# This is an example of a KDE class that has 'k_dcop' slots declarations, but
# isn't a subclass of DCOPObject. The following four methods are added to your
# class:
#
#		  	interfaces()
#			functions()
#			connectDCOPSignal()
#			disconnectDCOPSignal()
#
# See the call to connectDCOPSignal() towards the end of the code as
# an example. The name of the dcop object is always the name of the
# ruby class, and they are Singletons - you can only instantiate one
# of them.
#
# The petshop.rb example in this directory demonstrates more complex
# use of korundum dcop by subclassing a DCOPObject.
#
class MyWidget < KDE::PushButton

	k_dcop	'void mySlot(TQString)', 
			'TQPoint getPoint(TQString)',
			'TQMap<TQCString,DCOPRef> actionMap()', 
			'TQValueList<DCOPRef> windowList()',
			'TQValueList<TQCString> propertyNames(bool)',
			'KURL::List urlList()',
			'bool isFoo()',
			'bool hasBar()'
				
	def initialize(parent, name)
		super
	end
	
	def mySlot(greeting)
		puts "greeting: #{greeting}"
	end
	
	def getPoint(msg)
		puts "message: #{msg}"
		return TQt::Point.new(50, 100)
	end
	
	def actionMap()
		map = {}
		map['foobar'] = KDE::DCOPRef.new("myapp", "myobj")
		return map
	end
	
	def windowList()
		list = []
		list[0] = KDE::DCOPRef.new("myapp", "myobj")
		return list
	end
	
	def propertyNames(b)
		return ["thisProperty", "thatProperty"]
	end
	
	def urlList()
		list = []
		list << KDE::URL.new("http://www.kde.org/") << KDE::URL.new("http://dot.kde.org/")
		return list
	end
	
	def isFoo
		true
	end
	
	def hasBar
		true
	end
end

about = KDE::AboutData.new("dcopslot", "dcopSlotTest", "0.1")
KDE::CmdLineArgs.init(ARGV, about)
a = KDE::UniqueApplication.new()
slottest = MyWidget.new(nil, "mywidget") { setText "DCOP Slot Test" }
a.mainWidget = slottest
slottest.caption = a.makeStdCaption("DCOP Slot Test")
result = slottest.connectDCOPSignal("dcopsignal", "SenderWidget", "testEmitSignal(TQString)", "mySlot(TQString)", true)
puts "result: #{result}"

slottest.show()
# TQt::Internal::setDebug TQt::QtDebugChannel::TQTDB_ALL
a.exec()