Move python and ruby dataengine bindings from kde-workspace

This commit is contained in:
David Edmundson 2014-01-27 19:34:34 +01:00
parent 2f4867bf0c
commit 3abddd8d99
12 changed files with 1277 additions and 1 deletions

View File

@ -1,2 +1,7 @@
add_subdirectory(qml)
#add_subdirectory(javascript)
add_subdirectory(ruby)
if (PYTHONLIBRARY_FOUND AND NOT WIN32)
add_subdirectory(python)
endif ()

View File

@ -0,0 +1,23 @@
project(plasma-python)
include(PythonMacros)
# install the library, .desktop, and plasma.py
python_install(plasma_importer.py ${DATA_INSTALL_DIR}/plasma_scriptengine_python)
python_install(pydataengine.py ${DATA_INSTALL_DIR}/plasma_scriptengine_python)
python_install(pyrunner.py ${DATA_INSTALL_DIR}/plasma_scriptengine_python)
# remove the following three lines once we branch 4.5, they are only necessary as long
# as people update kdebase but not yet kdelibs (PYTHON_SITE_PACKAGES_INSTALL_DIR has just
# recently been added to FindPYthonLib.cmake and should be used as install destination). Alex
if(NOT PYTHON_SITE_PACKAGES_INSTALL_DIR)
set(PYTHON_SITE_PACKAGES_INSTALL_DIR ${PYTHON_SITE_PACKAGES_DIR} )
endif()
python_install(plasmascript.py ${PYTHON_SITE_PACKAGES_INSTALL_DIR}/PyKDE4)
install(FILES plasma-scriptengine-dataengine-python.desktop
DESTINATION ${SERVICES_INSTALL_DIR})
install(FILES plasma-scriptengine-runner-python.desktop
DESTINATION ${SERVICES_INSTALL_DIR})

View File

@ -0,0 +1,153 @@
[Desktop Entry]
Name=Python data engine
Name[ar]=محرك بيانات بايثون
Name[ast]=Motor de datos de Python
Name[be@latin]=Systema źviestak u movie Python
Name[bg]=Ядро за данни с Python
Name[bn_IN]=Python ি
Name[bs]=Python pogon podataka
Name[ca]=Motor de dades en Python
Name[ca@valencia]=Motor de dades en Python
Name[cs]=Rozhraní v Pythonu
Name[csb]=Czérownik Phythona
Name[da]=Datamotor til Python
Name[de]=Python-Datentreiber
Name[el]=Μηχανή δεδομένων Python
Name[en_GB]=Python data engine
Name[eo]=Pitona datuma motoro
Name[es]=Motor de datos de Python
Name[et]=Pythoni andmete mootor
Name[eu]=Python-en datu-motorra
Name[fi]=Python-tietomoottori
Name[fr]=Moteur de données Python
Name[fy]=Python gegevens motor
Name[ga]=Inneall sonraí Python
Name[gl]=Motor de datos de Python
Name[gu]= િ િ
Name[he]=מנוע תוכן של Python
Name[hi]= ि
Name[hne]= ि
Name[hr]=Pythonov podatkovni mehanizam
Name[hu]=Adatkezelő modul Python nyelven
Name[ia]=Motor de datos de Python
Name[id]=Mesin data Python
Name[is]=Python gagnavél
Name[it]=Motore di dati di Python
Name[ja]=Python
Name[kk]=Python деректер тетігі
Name[km]= Python
Name[kn]= ಿ
Name[ko]=
Name[lt]=Python duomenų variklis
Name[lv]=Python datu dzinējs
Name[ml]= ി
Name[mr]=Python ि
Name[nb]=Python datamotor
Name[nds]=Python-Datenkarn
Name[nl]=Python (gegevensengine)
Name[nn]=Python-datamotor
Name[or]= ି
Name[pa]=
Name[pl]=Silnik danych w Pythonie
Name[pt]=Motor de dados Python
Name[pt_BR]=Mecanismo de dados Python
Name[ro]=Motor de date Python
Name[ru]=Источник данных на языке Python
Name[si]=Python data engine
Name[sk]=Python dátový nástroj
Name[sl]=Podatkovni vir v Pythonu
Name[sr]=питонски датомотор
Name[sr@ijekavian]=питонски датомотор
Name[sr@ijekavianlatin]=Python datomotor
Name[sr@latin]=Python datomotor
Name[sv]=Python datagränssnitt
Name[ta]=Python data engine
Name[tg]=Системаи санаи Python
Name[th]=
Name[tr]=Python veri motoru
Name[ug]=Python سانلىق-مەلۇمات ماتورى
Name[uk]=Рушій даних Python
Name[wa]=Moteur di dnêyes Python
Name[x-test]=xxPython data enginexx
Name[zh_CN]=Python
Name[zh_TW]=Python
Comment=Plasma data engine support for Python
Comment[ar]=دعم محرك بيانات بلازما للبايثون
Comment[ast]=Sofitu del motor de datos de plasma pa Python
Comment[be@latin]=Absłuhoŭvańnie systemy źviestak Plasma u movie Python
Comment[bg]=Поддръжка за създаване на ядра за данни на Plasma с Python
Comment[bs]=Podrška plazma pogona podataka za Python
Comment[ca]=Implementació de motor de dades del Plasma per al Python
Comment[ca@valencia]=Implementació de motor de dades del Plasma per al Python
Comment[cs]=Podpora datového rozhraní Plasmy v Pythonu
Comment[da]=Plasma datamotor-understøttelse af Python
Comment[de]=Unterstützung für Plasma-Datentreiber in Python
Comment[el]=Υποστήριξη μηχανής δεδομένων Plasma για την Python
Comment[en_GB]=Plasma data engine support for Python
Comment[eo]=Plasma datummotora apogo por Pitono
Comment[es]=Soporte del motor de datos de plasma para Python
Comment[et]=Plasma andmemootori toetus Pythonile
Comment[eu]=Python-erako Plasmaren datu-motorraren euskarria
Comment[fi]=Plasma-tietomoottorituki Python-kielelle
Comment[fr]=Prise en charge du moteur de données Python pour Plasma
Comment[fy]=Plasma-gegevensmotor-stipe foar Python
Comment[ga]=Tacaíocht innill sonraí Plasma le haghaidh Python
Comment[gl]=Motor de datos de Plasma para dar soporte a Python
Comment[gu]= િ િ
Comment[he]=תמיכה במנועי תוכן של Plasma עבור Python
Comment[hi]= ि ि
Comment[hne]= ि
Comment[hr]=Plasmin podatkovni mehanizam koji podržava Python
Comment[hu]=Plazma adatkezelő modul Pythonhoz
Comment[ia]=Supporto de motor de datos de Plasma pro Python
Comment[id]=Mesin data Plasma didukung oleh Python
Comment[is]=Plasma gagnavélarstuðningur fyrir Python
Comment[it]=Supporto al motore di dati di Plasma per Python
Comment[ja]=Python Plasma
Comment[kk]=Python деректер тетігінің Plasma қолдауы
Comment[km]= Python
Comment[kn]=ಿ
Comment[ko]= Plasma
Comment[lt]=Plasma duomenų variklio palaikymas Python kalbai
Comment[lv]=Plasma datu dzinēju atbalsts Python
Comment[ml]=ിി ി ി
Comment[mr]=Python ि Plasma ि
Comment[nb]=Plasma datamotor-støtte for Python
Comment[nds]=Plasma-Datenkarnünnerstütten för Python
Comment[nl]=Plasma-gegevensengine-ondersteuning voor Python
Comment[nn]=Plasma-datamotorstøtte for Python
Comment[or]= ି
Comment[pa]= ਿ
Comment[pl]=Obsługa silnika danych Plazmy w Pythonie
Comment[pt]=Suporte para os motores de dados do Plasma em Python
Comment[pt_BR]=Suporte aos mecanismos de dados em Python
Comment[ro]=Suport motor de date Plasma pentru Python
Comment[ru]=Поддержка источников данных для Python
Comment[si]=Plasma data engine support for Python
Comment[sk]=Podpora dátového nástroja plasmy pre Python
Comment[sl]=Podpora za podatkovne vire napisane v Pythonu
Comment[sr]=Подршка плазма датомотора за питон
Comment[sr@ijekavian]=Подршка плазма датомотора за питон
Comment[sr@ijekavianlatin]=Podrška plasma datomotora za Python
Comment[sr@latin]=Podrška plasma datomotora za Python
Comment[sv]=Plasma datagränssnittstöd för Python
Comment[ta]=Plasma data engine support for Python
Comment[te]= ి
Comment[tg]=Пуштибонии Python дар асоси маълумоти Plasma
Comment[th]=
Comment[tr]=Python için Plasma veri motoru desteği
Comment[ug]=Python نىڭ Plasma سانلىق-مەلۇمات ماتورىنى قوللىشى
Comment[uk]=Підтримка у рушіях даних для Python
Comment[wa]=Sopoirt po Python do moteur di dnêyes di Plasma
Comment[x-test]=xxPlasma data engine support for Pythonxx
Comment[zh_CN]=Python Plasma
Comment[zh_TW]= Python Plasma
X-KDE-ServiceTypes=Plasma/ScriptEngine
Type=Service
Icon=text-x-script
X-KDE-Library=kpythonpluginfactory
X-KDE-PluginKeyword=plasma_scriptengine_python/pydataengine.py
X-EngineName=pythondataengine
X-Plasma-API=python
X-Plasma-ComponentTypes=DataEngine

View File

@ -0,0 +1,135 @@
[Desktop Entry]
Name=Python Runner
Name[ar]=مشغل بايثون
Name[ast]=Llanzador Python
Name[bg]=Стартер с Python
Name[bs]=Python izvođač
Name[ca]=Executor en Python
Name[ca@valencia]=Executor en Python
Name[cs]=Python spouštěč
Name[da]=Python Runner
Name[de]=Python-Starter
Name[el]=Εκτελεστής Python
Name[en_GB]=Python Runner
Name[eo]=Pitona motoro
Name[es]=Lanzador Python
Name[et]=Pythoni käivitaja
Name[eu]=Python abiarazlea
Name[fi]=Python-suoritusohjelma
Name[fr]=Lanceur Python
Name[ga]=Feidhmitheoir Python
Name[gl]=Executor en Python
Name[gu]=Python
Name[he]=Python Runner
Name[hi]=
Name[hr]=Python Runner
Name[hu]=Python-indító
Name[ia]=Executor de Python
Name[id]=Pelari Python
Name[is]=Python keyrari
Name[it]=Esecutore per Python
Name[ja]=Python
Name[kk]=Python-ды жегу
Name[km]= Python
Name[kn]=
Name[ko]=
Name[lt]=Python leistukas
Name[lv]=Python darbinātājs
Name[mr]=
Name[nb]=Python-kjører
Name[nds]=Python-Dreger
Name[nl]=Python-starter
Name[nn]=Python-køyrar
Name[pa]=
Name[pl]=Uruchamianie w Pythonie
Name[pt]=Módulo de Execução em Python
Name[pt_BR]=Execução em Python
Name[ro]=Executor Python
Name[ru]=Модули запуска команд на языке Python
Name[si]=Python
Name[sk]=Python spúšťač
Name[sl]=Zaganjalnik v Pythonu
Name[sr]=питонски извођач
Name[sr@ijekavian]=питонски извођач
Name[sr@ijekavianlatin]=Python izvođač
Name[sr@latin]=Python izvođač
Name[sv]=Python körningsprogram
Name[tg]=Системаи санаи Python
Name[th]=
Name[tr]=Python Çalıştırıcı
Name[ug]=Python ئىجراچىسى
Name[uk]=Запуск для Python
Name[wa]=Enondeu Python
Name[x-test]=xxPython Runnerxx
Name[zh_CN]=Python
Name[zh_TW]=Python
Comment=Plasma Runner support for Python
Comment[ar]=دعم مشغل بلازما لبايثون
Comment[ast]=Implementación de llanzador Plasma pa Python
Comment[bg]=Поддръжка за създаване на стартери на Plasma с Python
Comment[bs]=Podrška plazma izvođača za Python
Comment[ca]=Implementació de l'executor del Plasma per al Python
Comment[ca@valencia]=Implementació de l'executor del Plasma per al Python
Comment[cs]=Podpora Plasma spouštěče pro Python
Comment[da]=Understøttelse af Plasma Runner til Python
Comment[de]=Plasma-Starter-Unterstützung für Python
Comment[el]=Υποστήριξη εκτελεστή Plasma για την Python
Comment[en_GB]=Plasma Runner support for Python
Comment[es]=Implementación de lanzador Plasma para Python
Comment[et]=Plasma käivitaja toetus Pythonile
Comment[eu]=Python-erako Plasmaren abiarazlearen euskarria
Comment[fi]=Plasma-suoritusohjelmatuki Python-kielelle
Comment[fr]=Prise en charge du lanceur Plasma pour Python
Comment[gl]=Executor de Plasma que permite usar Python
Comment[he]=תמיכה ב־Runner של Plasma עבור Python
Comment[hi]= ि
Comment[hr]=Plasma Runner podrška za Python
Comment[hu]=Plazma-indító támogatás Pythonhoz
Comment[ia]=Supporto de executor de Plasma pro Python
Comment[id]=Dukungan Pelari Plasma terhadap Python
Comment[is]=Plasma gagnavélarstuðningur fyrir Python
Comment[it]=Supporto per l'esecutore Plasma per Python
Comment[ja]=Python Plasma
Comment[kk]=Plasma-дағы Python-ды жегуін қолдауы
Comment[km]= Python
Comment[kn]=ಿ
Comment[ko]=Plasma
Comment[lt]=Plasma paleidiklio palaikymas Python kalbai
Comment[lv]=Plasma darbinātāja atbalsts Python
Comment[mr]= ि
Comment[nb]=Plasma kjørerstøtte for Python
Comment[nds]=Plasma-Dregerünnerstütten för Python
Comment[nl]=Plasma-starter-ondersteuning voor Python
Comment[nn]=Plasma-køyrarstøtte for Python
Comment[pa]= ਿ
Comment[pl]=Obsługa programów uruchamiających dla Pythona
Comment[pt]=Suporte para os motores de execução do Plasma em Python
Comment[pt_BR]=Suporte aos mecanismos de execução do Plasma para Python
Comment[ro]=Suport executori Plasma pentru Python
Comment[ru]=Поддержка модулей запуска KRunner на языке Python
Comment[si]=Python
Comment[sk]=Podpora spúšťača plasmy pre Python
Comment[sl]=Podpora za zaganjalnike napisane v Pythonu
Comment[sr]=Подршка плазма извођача за питон
Comment[sr@ijekavian]=Подршка плазма извођача за питон
Comment[sr@ijekavianlatin]=Podrška plasma izvođača za Python
Comment[sr@latin]=Podrška plasma izvođača za Python
Comment[sv]=Plasma körningsstöd för Python
Comment[tg]=Пуштибонии Python дар асоси маълумоти Plasma
Comment[th]=
Comment[tr]=Python için Plasma Çalıştırıcı desteği
Comment[ug]=Python نى قوللايدىغان Plasma ئىجراچىسى
Comment[uk]=Підтримка Python у інструментах запуску
Comment[wa]=Sopoirt po Python di l' enondeu di Plasma
Comment[x-test]=xxPlasma Runner support for Pythonxx
Comment[zh_CN]= Python Plasma
Comment[zh_TW]= Python
X-KDE-ServiceTypes=Plasma/ScriptEngine
Type=Service
Icon=text-x-script
X-KDE-Library=kpythonpluginfactory
X-KDE-PluginKeyword=plasma_scriptengine_python/pyrunner.py
X-EngineName=pythonrunner
X-Plasma-API=python
X-Plasma-ComponentTypes=Runner

View File

@ -0,0 +1,120 @@
# -*- coding: utf-8 -*-
#
# Copyright 2008 Simon Edwards <simon@simonzone.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
import sys
import os
import imp
PY3 = sys.version_info[0] == 3
class PlasmaImporter(object):
def __init__(self):
self.toplevel = {}
self.toplevelcount = {}
self.marker = '<plasma>' + str(id(self))
sys.path.append(self.marker)
sys.path_hooks.append(self.hook)
def hook(self,path):
if path==self.marker:
return self
else:
raise ImportError()
def register_top_level(self,name,path):
if name not in self.toplevel:
self.toplevelcount[name] = 1
self.toplevel[name] = path
else:
self.toplevelcount[name] += 1
def unregister_top_level(self,name):
value = self.toplevelcount[name]-1
self.toplevelcount[name] = value
if value==0:
del self.toplevelcount[name]
del self.toplevel[name]
for key in list(sys.modules.keys()):
if key==name or key.startswith(name+"."):
del sys.modules[key]
def find_module(self,fullname, path=None):
location = self.find_pymod(fullname)
if location is not None:
return self
else:
return None
# Find the given module in the plasma directory.
# Result a tuple on success otherwise None. The tuple contains the location
# of the module/package in disk and a boolean indicating if it is a package
# or module
def find_pymod(self,modulename):
parts = modulename.split('.')
toppackage = parts[0]
rest = parts[1:]
if toppackage in self.toplevel:
path = self.toplevel[toppackage]
if len(rest)==0:
# Simple top level Plasma package
return (path,True)
else:
restpath = apply(os.path.join,rest)
fullpath = os.path.join(path,'contents','code',restpath)
if os.path.isdir(fullpath):
return (fullpath,True)
elif os.path.exists(fullpath+'.py'):
return (fullpath+'.py',False)
else:
return None
def _get_code(self,location):
return open(location).read()
def load_module(self, fullname):
location,ispkg = self.find_pymod(fullname)
if ispkg: # Package dir.
initlocation = os.path.join(location,'__init__.py')
code = None
if os.path.isfile(initlocation):
code = open(initlocation)
else:
code = open(location)
mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
mod.__file__ = location #"<%s>" % self.__class__.__name__
mod.__loader__ = self
if ispkg:
mod.__path__ = [self.marker]
if code is not None:
try:
if PY3:
exec(code in mod.__dict__)
else:
exec code in mod.__dict__
finally:
code.close()
return mod
#plasma_importer = PlasmaImporter()
#plasma_importer.register_top_level('plasma_pyclock','/home/sbe/devel/python_plasma_2/test/plasma-pyclock')
#from plasma_pyclock import main

View File

@ -0,0 +1,225 @@
# -*- coding: utf-8 -*-
#
# Copyright 2008 Simon Edwards <simon@simonzone.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Plasma applet API for Python
from PyQt4.QtCore import QObject
from PyQt4.QtGui import QGraphicsWidget
from PyKDE4.plasma import Plasma # Plasma C++ namespace
#import sip
#import gc
class Applet(QObject):
''' Subclass Applet in your module and return an instance of it in a global function named
applet(). Implement the following functions to breathe life into your applet:
* paint - Draw the applet given a QPainter and some options
It provides the same API as Plasma.Applet; it just has slightly less irritating event names. '''
def __init__(self, parent=None):
# this should be set when the applet is created
QObject.__init__(self, parent)
#sip.settracemask(0x3f)
self.applet = None
self.applet_script = None
self._forward_to_applet = True
def __getattr__(self, key):
# provide transparent access to the real applet instance
if self._forward_to_applet:
try:
return getattr(self.applet_script, key)
except:
return getattr(self.applet, key)
else:
raise AttributeError(key)
def _enableForwardToApplet(self):
self._forward_to_applet = True
def _disableForwardToApplet(self):
self._forward_to_applet = False
# Events
def setApplet(self,applet):
self.applet = applet
def setAppletScript(self,appletScript):
self.applet_script = appletScript
def init(self):
pass
def configChanged(self):
pass
def paintInterface(self, painter, options, rect):
pass
def constraintsEvent(self, flags):
pass
def showConfigurationInterface(self):
self.dlg = self.standardConfigurationDialog()
self.createConfigurationInterface(self.dlg)
self.addStandardConfigurationPages(self.dlg)
self.dlg.show()
def createConfigurationInterface(self, dlg):
pass
def contextualActions(self):
return []
def shape(self):
return QGraphicsWidget.shape(self.applet)
def initExtenderItem(self, item):
print ("Missing implementation of initExtenderItem in the applet " + \
item.config().readEntry('SourceAppletPluginName', '').toString() + \
"!\nAny applet that uses extenders should implement initExtenderItem to " + \
"instantiate a widget.")
def saveState(self, config):
pass
###########################################################################
class DataEngine(QObject):
def __init__(self, parent=None):
QObject.__init__(self, parent)
self.dataengine = None
self.dataengine_script = None
def setDataEngine(self,dataEngine):
self.dataEngine = dataEngine
def setDataEngineScript(self,dataEngineScript):
self.data_engine_script = dataEngineScript
def __getattr__(self, key):
# provide transparent access to the real dataengine script instance
try:
return getattr(self.data_engine_script, key)
except:
return getattr(self.dataEngine, key)
def init(self):
pass
def sources(self):
return []
def sourceRequestEvent(self,name):
return False
def updateSourceEvent(self,source):
return False
def serviceForSource(self,source):
return Plasma.DataEngineScript.serviceForSource(self.data_engine_script,source)
###########################################################################
class Wallpaper(QObject):
def __init__(self, parent=None):
QObject.__init__(self, parent)
self.wallpaper = None
self.wallpaper_script = None
def setWallpaper(self,wallpaper):
self.wallpaper = wallpaper
def setWallpaperScript(self,wallpaperScript):
self.wallpaper_script = wallpaperScript
def __getattr__(self, key):
# provide transparent access to the real wallpaper script instance
try:
return getattr(self.wallpaper_script, key)
except:
return getattr(self.wallpaper, key)
def init(self, config):
pass
def paint(self,painter, exposedRect):
pass
def save(self,config):
pass
def createConfigurationInterface(self,parent):
return None
def mouseMoveEvent(self,event):
pass
def mousePressEvent(self,event):
pass
def mouseReleaseEvent(self,event):
pass
def wheelEvent(self,event):
pass
def renderCompleted(self, image):
pass
def urlDropped(self, url):
pass
###########################################################################
class Runner(QObject):
def __init__(self, parent=None):
QObject.__init__(self, parent)
self.runner = None
self.runner_script = None
def setRunner(self,runner):
self.runner = runner
def setRunnerScript(self,runnerScript):
self.runner_script = runnerScript
def __getattr__(self, key):
# provide transparent access to the real runner script instance
try:
return getattr(self.runner_script, key)
except:
return getattr(self.runner, key)
def init(self):
pass
def match(self, search):
pass
def run(self, search, action):
pass
def prepare(self):
pass
def teardown(self):
pass
def createRunOptions(self, widget):
pass
def reloadConfiguration(self):
pass

View File

@ -0,0 +1,79 @@
# -*- coding: utf-8 -*-
#
# Copyright 2008 Simon Edwards <simon@simonzone.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
import plasma_importer
import os.path
class PythonDataEngineScript(Plasma.DataEngineScript):
importer = None
def __init__(self, parent):
Plasma.DataEngineScript.__init__(self,parent)
if PythonDataEngineScript.importer is None:
PythonDataEngineScript.importer = plasma_importer.PlasmaImporter()
self.initialized = False
def init(self):
self.moduleName = str(self.dataEngine().pluginName())
self.pluginName = 'dataengine_' + self.moduleName.replace('-','_')
PythonDataEngineScript.importer.register_top_level(self.pluginName, str(self.dataEngine().package().path()))
# import the code at the file name reported by mainScript()
relpath = os.path.relpath(str(self.mainScript()),str(self.dataEngine().package().path()))
if relpath.startswith("contents/code/"):
relpath = relpath[14:]
if relpath.endswith(".py"):
relpath = relpath[:-3]
relpath = relpath.replace("/",".")
self.module = __import__(self.pluginName+'.'+relpath)
# The script may not necessarily be called "main"
# So we use __dict__ to look up the right name
basename = os.path.basename(str(self.mainScript()))
basename = os.path.splitext(basename)[0]
self.pydataengine = self.module.__dict__[basename].CreateDataEngine(None)
self.pydataengine.setDataEngine(self.dataEngine())
self.pydataengine.setDataEngineScript(self)
self.pydataengine.init()
self.initialized = True
return True
def __dtor__(self):
PythonDataEngineScript.importer.unregister_top_level(self.pluginName)
self.pydataengine = None
def sources(self):
return self.pydataengine.sources()
def serviceForSource(self,source):
return self.pydataengine.serviceForSource(source)
def sourceRequestEvent(self,name):
return self.pydataengine.sourceRequestEvent(name)
def updateSourceEvent(self,source):
return self.pydataengine.updateSourceEvent(source)
def CreatePlugin(widget_parent, parent, component_data):
return PythonDataEngineScript(parent)

View File

@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-
#
# Copyright 2008 Simon Edwards <simon@simonzone.com>
# Copyright 2009 Petri Damstén <damu@iki.fi>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
import plasma_importer
import os.path
class PythonRunnerScript(Plasma.RunnerScript):
importer = None
def __init__(self, parent):
Plasma.RunnerScript.__init__(self,parent)
if PythonRunnerScript.importer is None:
PythonRunnerScript.importer = plasma_importer.PlasmaImporter()
self.initialized = False
def init(self):
self.moduleName = str(self.runner().package().metadata().pluginName())
self.pluginName = 'runner_' + self.moduleName.replace('-','_')
PythonRunnerScript.importer.register_top_level(self.pluginName, str(self.runner().package().path()))
# import the code at the file name reported by mainScript()
relpath = os.path.relpath(str(self.mainScript()),str(self.runner().package().path()))
if relpath.startswith("contents/code/"):
relpath = relpath[14:]
if relpath.endswith(".py"):
relpath = relpath[:-3]
relpath = relpath.replace("/",".")
self.module = __import__(self.pluginName+'.'+relpath)
basename = os.path.basename(str(self.mainScript()))
basename = os.path.splitext(basename)[0]
self.pyrunner = self.module.__dict__[basename].CreateRunner(None)
self.pyrunner.setRunner(self.runner())
self.pyrunner.setRunnerScript(self)
self.connect(self, SIGNAL('prepare()'), self, SLOT('prepare()'))
self.connect(self, SIGNAL('teardown()'), self, SLOT('teardown()'))
self.connect(self, SIGNAL('createRunOptions(QWidget*)'),
self, SLOT('createRunOptions(QWidget*)'))
self.connect(self, SIGNAL('reloadConfiguration()'),
self, SLOT('reloadConfiguration()'))
self.pyrunner.init()
self.initialized = True
return True
def __dtor__(self):
PythonRunnerScript.importer.unregister_top_level(self.pluginName)
self.pyrunner = None
def match(self, search):
self.pyrunner.match(search)
def run(self, search, action):
self.pyrunner.run(search, action)
@pyqtSignature("prepare()")
def prepare(self):
self.pyrunner.prepare()
@pyqtSignature("teardown()")
def teardown(self):
self.pyrunner.teardown()
@pyqtSignature("createRunOptions(QWidget*)")
def createRunOptions(self, widget):
self.pyrunner.createRunOptions(widget)
@pyqtSignature("reloadConfiguration()")
def reloadConfiguration(self):
self.pyrunner.reloadConfiguration()
def CreatePlugin(widget_parent, parent, component_data):
return PythonRunnerScript(parent)

View File

@ -0,0 +1,4 @@
install(FILES data_engine.rb DESTINATION ${DATA_INSTALL_DIR}/plasma_scriptengine_ruby)
install(FILES plasma-scriptengine-ruby-dataengine.desktop DESTINATION ${SERVICES_INSTALL_DIR})

View File

@ -0,0 +1,140 @@
2010-02-14 Richard Dale <richard.j.dale@gmail.com>
* Special case the constructors of the new Plasma widgets so that they can be
passed a PlasmaScripting::Applet as parent
* Fixed the dialog handling so that it uses the standardConfigurationDialog()
and addStandardConfigurationPages() methods
2009-08-07 Richard Dale <richard.j.dale@gmail.com>
* Fixed typo in the type signature of the initExtenderItem() slot. Thanks to
David Palacio for reporting the bug
2009-07-19 Richard Dale <richard.j.dale@gmail.com>
* Use the new name 'extenderItemRestored()' for the signal to connect to
initExtenderItem()
2009-07-18 Richard Dale <richard.j.dale@gmail.com>
* Add a Ruby version of the C++ extender tutorial example on Techbase
2009-07-17 Richard Dale <richard.j.dale@gmail.com>
* If an applet has implemented an initExtenderItem() method, then connect the
new initScriptingExtenderItem() signal to it.
2009-06-16 Richard Dale <richard.j.dale@gmail.com>
* The resize() method doesn't work with scripting plasmoids, so if it is used
output a warning message, and suggest adding a X-Plasma-DefautSize entry in
the metadata.desktop file.
2009-05-26 Richard Dale <richard.j.dale@gmail.com>
* Add a callback for the configChanged() method in scripting applets
2009-04-27 Richard Dale <richard.j.dale@gmail.com>
* Added some special casing for the new KDE 4.3 widgets, so they work with
PLasmaScripting::Applet arguments
2009-04-22 Richard Dale <richard.j.dale@gmail.com>
* Added PlasmaScripting::Containment and PlasmaScripting::PopupApplet classes,
now that scripting containments and popups can be created
2009-02-10 Richard Dale <richard.j.dale@gmail.com>
* For the methods that need to be special cased to work with
PlasmaScripting::Applet type arguments, add lower case/underscore versions
of the methods
2009-02-05 Richard Dale <richard.j.dale@gmail.com>
* Added various special casing to the Plasma::ToolTipManager class so you can
pass a PlasmaScripting::Applet to the methods. Thanks to Mathieu Jobin for
reporting the bug.
2008-12-22 Richard Dale <richard.j.dale@gmail.com>
* Changed the tiger applet example to find its tiger.svg resource from within
the plasmoid package. Thanks to Rany Keddo for helping to get it working.
2008-12-01 Richard Dale <richard.j.dale@gmail.com>
* Added updateAllSources() and removeSource() slots to the
PlasmScripting::DataEngine
* Add DBus notification to the time data engine example for when the config
changes
2008-11-18 Richard Dale <richard.j.dale@gmail.com>
* Fix problem with the ruby 'type()' method clashing with the one in
Qt::GraphicsItem subclasses reported by David Palacio
* Added a 'dbpedia-queries' data engine for making SPARQL queries to DBpedia
about music albums
* The sources() and init() methods needn't be implemented by a scripting
data engine
2008-11-17 Richard Dale <richard.j.dale@gmail.com>
* Fixed missing constructor bug in Qt::GraphicsProxyWidget reported by David
Palacio. Thanks to David for reporting the bug.
* Improved the names of the Ruby applet and dataengine examples
* Allow a PlasmaScripting::Applet to be a parent of all the Qt::GraphicsItem
sub classes in their constructors
2008-11-05 Richard Dale <richard.j.dale@gmail.com>
* Fixed some bugs in the DataEngineScript class. The expected path was
'plasma/engines' whereas the plasmapkg tool installs them in
'plasma/dataengines'. The mainScript() and package() methods hadn't been
implemented and were added.
* Added a 'ruby_time' example scripting data engine
2008-10-30 Richard Dale <richard.j.dale@gmail.com>
* Separated the script engine plugins from the plasma ruby extension and moved
the script engine code to kdebase with the other script engines
2008-10-23 Richard Dale <richard.j.dale@gmail.com>
* Converted the webapplet to use the script engine api, and renamed it
plasma_applet_ruby_webapplet
2008-08-15 Richard Dale <richard.j.dale@gmail.com>
* Re-added the ruby version of the plasmoidviewer app
2008-08-12 Arno Rehn <arno@arnorehn.de>
* Fix restoring of applet sizes.
2008-08-07 Richard Dale <richard.j.dale@gmail.com>
* The marshaller for Plasma::DataEngine::Data was creating Qt::Variants with
the wrong smoke pointer in the smokeruby_object struct, and this was causing
a crash in the GC marking function.
* In PlasmaScripting::Applet, if a constant such as NoBackground is referenced
and found to be missing, then look for it in Plasma::Applet.
* Fix bugs in the PlasmaScripting::Applet#showConfigurationInterface method
* Special case Plasma::Applet#id so it doesn't get a Ruby warning.
* In PlasmaScriptengineRuby::Applet the module name wasn't being derived
correctly from the Package path
* Add two versions of the clock applet
* plasma_applet_ruby_clock uses the ScriptEngine api and is packaged as a
plasmoid. It can be installed by typing the following command in the
examples/applets directory:
$ plasmapkg --install plasma_applet_ruby_clock --type plasmoid
* analog-clock uses the C++ plugin api. Normally Ruby applets should be
written using the script engine api, and this example is only included
to show how the two apis differ. The clocks are functionally identical.
2008-08-06 Richard Dale <richard.j.dale@gmail.com>
* Add some fixes for the new Plasma::Frame and Plasma::Slider widgets
2008-07-03 Richard Dale <richard.j.dale@gmail.com>
* Add slots and signals for scripting applets and data engines corresponding
to the ones in Plasma::Applet and Plasma::DataEngine
* Change the install destination to plasma_scriptengine_ruby and the modules
of the plugin classes to match
2008-06-30 Richard Dale <richard.j.dale@gmail.com>
* For script engine based applets, add the directory where the mainScript was
found to the ruby load path.
2008-06-29 Richard Dale <richard.j.dale@gmail.com>
* If a method call is invoked on a PlasmaScripting::Applet, then relay it to
the underlying Plasma::Applet in the script engine.
* Add an event filter to the RubyAppletScript::Applet class so that scripting
applets can implement event method handling overrides.
* Change various methods in the QGraphicsView and Plasma api so that they can
accept instances of PlasmaScripting::Applet, and the instance is substituted
for the underlying Plasma::Applet in the ScriptEngine.
2008-06-28 Richard Dale <richard.j.dale@gmail.com>
* Make the Ruby ScriptEngine based plugins work
* Add a Ruby version of the Javascript Tiger applet

View File

@ -0,0 +1,147 @@
=begin
* Copyright 2008 by Richard Dale <richard.j.dale@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
=end
require 'plasma_applet'
module PlasmaScripting
class DataEngine < Qt::Object
slots :updateAllSources, "removeSource(QString)"
signals "sourceAdded(QString)", "sourceRemoved(QString)"
attr_accessor :data_engine_script
def initialize(parent, args = nil)
super(parent)
@data_engine_script = parent
connect(@data_engine_script.dataEngine, SIGNAL("sourceAdded(QString)"), self, SIGNAL("sourceAdded(QString)"))
connect(@data_engine_script.dataEngine, SIGNAL("sourceRemoved(QString)"), self, SIGNAL("sourceRemoved(QString)"))
end
def init
end
def sourceRequestEvent(name)
end
def updateSourceEvent(source)
end
def setData(*args)
if args.length == 2 && !args[1].kind_of?(Qt::Variant)
args[1] = Qt::Variant.fromValue(args[1])
elsif args.length == 3 && !args[2].kind_of?(Qt::Variant)
args[2] = Qt::Variant.fromValue(args[2])
end
@data_engine_script.setData(*args)
end
def removeAllData(source)
@data_engine_script.removeAllData(source)
end
def removeData(source, key)
@data_engine_script.removeData(source, key)
end
def setMaxSourceCount(limit)
@data_engine_script.setMaxSourceCount(limit)
end
def maxSourceCount=(limit)
setMaxSourceCount(limit)
end
def setMinimumPollingInterval(minimumMs)
@data_engine_script.setMinimumPollingInterval(minimumMs)
end
def minimumPollingInterval=(minimumMs)
setMinimumPollingInterval(minimumMs)
end
def minimumPollingInterval
@data_engine_script.minimumPollingInterval
end
def setPollingInterval(frequency)
@data_engine_script.setPollingInterval(frequency)
end
def pollingInterval=(frequency)
setPollingInterval(frequency)
end
def removeAllSources
@data_engine_script.removeAllSources
end
def sources
return []
end
def removeSource(source)
@data_engine_script.dataEngine.removeSource(source)
end
def updateAllSources
@data_engine_script.dataEngine.updateAllSources
end
end
end
module PlasmaScriptengineRuby
class DataEngine < Plasma::DataEngineScript
def initialize(parent, args)
super(parent)
end
def camelize(str)
str.gsub(/(^|[._-])(.)/) { $2.upcase }
end
def init
puts "RubyAppletScript::DataEngine#init mainScript: #{mainScript}"
program = Qt::FileInfo.new(mainScript)
$: << program.path
load Qt::File.encodeName(program.filePath).to_s
moduleName = camelize(Qt::Dir.new(package.path).dirName)
className = camelize(program.baseName)
puts "RubyAppletScript::DataEngine#init instantiating: #{moduleName}::#{className}"
klass = Object.const_get(moduleName.to_sym).const_get(className.to_sym)
@data_engine_script = klass.new(self)
@data_engine_script.init
return true
end
def sources
@data_engine_script.sources
end
def sourceRequestEvent(name)
@data_engine_script.sourceRequestEvent(name)
end
def updateSourceEvent(source)
@data_engine_script.updateSourceEvent(source)
end
end
end
# kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;

View File

@ -0,0 +1,152 @@
[Desktop Entry]
Name=Ruby Widget
Name[ar]=ودجة روبي
Name[ast]=Elementu gráficu en Ruby
Name[be@latin]=Widžet u movie Ruby
Name[bg]=Джаджа на Ruby
Name[bn]=ি
Name[bn_IN]=Ruby
Name[bs]=Ruby grafička kontrola
Name[ca]=Estri Ruby
Name[ca@valencia]=Estri Ruby
Name[cs]=Ruby widget
Name[csb]=Interfejs Ruby
Name[da]=Ruby-widget
Name[de]=Ruby-Miniprogramm
Name[el]=Συστατικό Ruby
Name[en_GB]=Ruby Widget
Name[eo]=Ruby-fenestraĵo
Name[es]=Elemento gráfico en Ruby
Name[et]=Ruby vidin
Name[eu]=Ruby trepeta
Name[fi]=Ruby-sovelma
Name[fr]=Composant graphique Ruby
Name[fy]=Ruby widget
Name[ga]=Giuirléid Ruby
Name[gl]=Widget escrito en Ruby
Name[gu]= િ
Name[he]=ווידג׳ט של Ruby
Name[hi]= ि
Name[hne]= ि
Name[hr]=Ruby widget
Name[hu]=Ruby-elem
Name[ia]=Elemento graphic (Widget) de Ruby
Name[id]=Widget Ruby
Name[is]=Ruby græja
Name[it]=Oggetto Ruby
Name[ja]=Ruby
Name[kk]=Ruby бөлшегі
Name[km]=
Name[kn]=ಿ ಿ (ಿ)
Name[ko]=
Name[ku]=Alava Ruby
Name[lt]=Ruby valdiklis
Name[lv]=Ruby sīkrīks
Name[ml]=ി ി
Name[mr]=Ruby ि
Name[nb]=Ruby-element
Name[nds]=Ruby-Lüttprogramm
Name[nl]=Ruby-widget
Name[nn]=Ruby-element
Name[or]=ି ି
Name[pa]= ਿ
Name[pl]=Element interfejsu w języku Ruby
Name[pt]=Elemento Ruby
Name[pt_BR]=Widget Ruby
Name[ro]=Control Ruby
Name[ru]=Виджет на языке Ruby
Name[si]=Ruby
Name[sk]=Ruby widget
Name[sl]=Gradnik v Ruby
Name[sr]=рубијевски виџет
Name[sr@ijekavian]=рубијевски виџет
Name[sr@ijekavianlatin]=ruby vidžet
Name[sr@latin]=ruby vidžet
Name[sv]=Grafisk Ruby-komponent
Name[ta]=Ruby Widget
Name[tg]=Илова ба Ruby
Name[th]=
Name[tr]=Ruby Gereci
Name[ug]=Ruby ۋىجېتى
Name[uk]=Віджет Ruby
Name[wa]=Ahesse Ruby
Name[x-test]=xxRuby Widgetxx
Name[zh_CN]=Ruby
Name[zh_TW]=Ruby
Comment=Native Plasma widget written in Ruby
Comment[ar]=وجة بلازما أصلية مكتوبة بروبي
Comment[ast]=Elementu gráficu nativu de Plasma escrito en Ruby
Comment[be@latin]=Rodny widžet systemy Plasma, napisany ŭ movie Ruby
Comment[bg]=Оригинална джаджа за Plasma, написана на Ruby
Comment[bs]=Samosvojni plazma grafička kontrola napisana u Ruby-ju
Comment[ca]=Estri nadiu del Plasma escrit en Ruby
Comment[ca@valencia]=Estri nadiu del Plasma escrit en Ruby
Comment[cs]=Nativní plasmoid napsaný v Ruby
Comment[da]=Ægte Plasma-widget skrevet i Ruby
Comment[de]=Echtes Plasma-Programm, geschrieben in Ruby
Comment[el]=Εγγενές συστατικό Plasma γραμμένο σε Ruby
Comment[en_GB]=Native Plasma widget written in Ruby
Comment[es]=Elemento gráfico nativo de Plasma escrito en Ruby
Comment[et]=Rubys kirjutatud Plasma vidin
Comment[eu]=Jatorrizko Plasma trepeta, Ruby lengoaian idatzia
Comment[fi]=Natiivi, Ruby-pohjainen Plasma-sovelma
Comment[fr]=Composant graphique natif de Plasma écrit en Ruby
Comment[fy]=Plasma widget skreaun yn Ruby
Comment[ga]=Giuirléid dhúchasach Plasma scríofa i Ruby
Comment[gl]=Widget nativo de Plasma escrito en Ruby
Comment[gu]= િ
Comment[he]=ווידג׳ט Plasma הנכתב ב־Ruby
Comment[hi]= ि ि ि
Comment[hne]= ि ि ि
Comment[hr]=Izvorna Plasma widget napisana u Rubyu
Comment[hu]=Plasma-elem Ruby nyelven
Comment[ia]=Elemento graphic (widget) native de Plasma scribite in Ruby
Comment[id]=Widget Plasma asli yang ditulis dalam Ruby
Comment[is]=Upprunabundin Plasma græja skrifuð í Ruby
Comment[it]=Oggetto nativo di Plasma scritto in Ruby
Comment[ja]=Ruby Plasma
Comment[kk]=Ruby-дег жазылған Plasma интерфейс бөлшегі
Comment[km]= Ruby
Comment[kn]=ಿಿ ಿ (ಿ)
Comment[ko]= Plasma
Comment[lt]=Nuosavas Plasma valdiklis parašytas Ruby kalba
Comment[lv]=Plasma sīkrīks, rakstīts Ruby
Comment[ml]=ിി ിിി ി
Comment[mr]=Ruby ि Plasma ि
Comment[nb]=Plasmaelement for dette systemet, skrevet i Ruby
Comment[nds]=En orginaal Plasmaelement, schreven in Ruby
Comment[nl]=Plasma-widget geschreven in Ruby
Comment[nn]=Lokalt Plasma-element skrive i Ruby
Comment[or]=Ruby ି ି
Comment[pa]= ਿ ਿ ਿ ਿ
Comment[pl]=Element interfejsu Plazmy napisany w języku Ruby
Comment[pt]=Elemento nativo do Plasma feito em Ruby
Comment[pt_BR]=Widget nativo do Plasma, escrito em Ruby
Comment[ro]=Miniaplicație Plasma scrisă în Ruby
Comment[ru]=Виджет Plasma, написанный на языке Ruby
Comment[si]=Native Plasma widget written in Ruby
Comment[sk]=Natívny plasma widget napísaný v Ruby
Comment[sl]=Lastni gradnik za Plasmo, ki je napisan v Rubyu
Comment[sr]=Самосвојни плазма виџет написан у рубију
Comment[sr@ijekavian]=Самосвојни плазма виџет написан у рубију
Comment[sr@ijekavianlatin]=Samosvojni plasma vidžet napisan u Rubyju
Comment[sr@latin]=Samosvojni plasma vidžet napisan u Rubyju
Comment[sv]=Inbyggd grafisk Plasma-komponent skriven i Ruby
Comment[ta]=Native Plasma widget written in Ruby
Comment[tg]=Модуль Plasma, написанный на языке JavaScript
Comment[th]=
Comment[tr]=Ruby ile yazılmış gerçek Plasma gereci
Comment[ug]=Ruby بىلەن يېزىلغان ئەسلى Plasma كىچىك ئەپ
Comment[uk]=Віджет Плазми, написаний на Ruby
Comment[wa]=Ahesse askepieye po Plasma eyet scrîte e Ruby
Comment[x-test]=xxNative Plasma widget written in Rubyxx
Comment[zh_CN]=使 Ruby Plasma
Comment[zh_TW]= Ruby Plasma
X-KDE-ServiceTypes=Plasma/ScriptEngine
Type=Service
Icon=text-x-script
X-KDE-Library=krubypluginfactory
X-KDE-PluginKeyword=plasma_scriptengine_ruby/data_engine.rb
X-EngineName=ruby-dataengine-script
X-Plasma-API=ruby-script
X-Plasma-ComponentTypes=DataEngine