2 * Copyright 2008 by Richard Dale <richard.j.dale@gmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 require 'plasma_applet'
22 module PlasmaScripting
23 class DataEngine < Qt::Object
24 slots :updateAllSources, "removeSource(QString)"
25 signals "sourceAdded(QString)", "sourceRemoved(QString)"
27 attr_accessor :data_engine_script
29 def initialize(parent, args = nil)
31 @data_engine_script = parent
32 connect(@data_engine_script.dataEngine, SIGNAL("sourceAdded(QString)"), self, SIGNAL("sourceAdded(QString)"))
33 connect(@data_engine_script.dataEngine, SIGNAL("sourceRemoved(QString)"), self, SIGNAL("sourceRemoved(QString)"))
39 def sourceRequestEvent(name)
42 def updateSourceEvent(source)
46 if args.length == 2 && !args[1].kind_of?(Qt::Variant)
47 args[1] = Qt::Variant.fromValue(args[1])
48 elsif args.length == 3 && !args[2].kind_of?(Qt::Variant)
49 args[2] = Qt::Variant.fromValue(args[2])
51 @data_engine_script.setData(*args)
54 def removeAllData(source)
55 @data_engine_script.removeAllData(source)
58 def removeData(source, key)
59 @data_engine_script.removeData(source, key)
62 def setMaxSourceCount(limit)
63 @data_engine_script.setMaxSourceCount(limit)
66 def maxSourceCount=(limit)
67 setMaxSourceCount(limit)
70 def setMinimumPollingInterval(minimumMs)
71 @data_engine_script.setMinimumPollingInterval(minimumMs)
74 def minimumPollingInterval=(minimumMs)
75 setMinimumPollingInterval(minimumMs)
78 def minimumPollingInterval
79 @data_engine_script.minimumPollingInterval
82 def setPollingInterval(frequency)
83 @data_engine_script.setPollingInterval(frequency)
86 def pollingInterval=(frequency)
87 setPollingInterval(frequency)
91 @data_engine_script.removeAllSources
98 def removeSource(source)
99 @data_engine_script.dataEngine.removeSource(source)
103 @data_engine_script.dataEngine.updateAllSources
108 module PlasmaScriptengineRuby
109 class DataEngine < Plasma::DataEngineScript
110 def initialize(parent, args)
115 str.gsub(/(^|[_-])(.)/) { $2.upcase }
119 puts "RubyAppletScript::DataEngine#init mainScript: #{mainScript}"
120 program = Qt::FileInfo.new(mainScript)
122 load Qt::File.encodeName(program.filePath).to_s
123 moduleName = camelize(Qt::Dir.new(package.path).dirName)
124 className = camelize(program.baseName)
125 puts "RubyAppletScript::DataEngine#init instantiating: #{moduleName}::#{className}"
126 klass = Object.const_get(moduleName.to_sym).const_get(className.to_sym)
127 @data_engine_script = klass.new(self)
128 @data_engine_script.init
133 @data_engine_script.sources
136 def sourceRequestEvent(name)
137 @data_engine_script.sourceRequestEvent(name)
140 def updateSourceEvent(source)
141 @data_engine_script.updateSourceEvent(source)
146 # kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;