From 1420d4ba6042d12935b0e82f189bd51fb8d17d7e Mon Sep 17 00:00:00 2001 From: Sebastian Sauer Date: Wed, 5 Mar 2008 21:12:33 +0000 Subject: [PATCH] Enables ScriptEngine's like Apple's Dashboard Widgets or SuperKaramba's to implement containments too. Right, that means you are now able to write your own Panel or even Desktop using a scripting language :) FEATURE svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=782729 --- CMakeLists.txt | 1 + applet.cpp | 15 +++++++++++---- package.cpp | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dc6a0a9b..9c1870b48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -222,6 +222,7 @@ endif(QT_QTOPENGL_FOUND AND OPENGL_FOUND) install(FILES servicetypes/plasma-animator.desktop servicetypes/plasma-applet.desktop + servicetypes/plasma-containment.desktop servicetypes/plasma-dataengine.desktop servicetypes/plasma-packagestructure.desktop servicetypes/plasma-runner.desktop diff --git a/applet.cpp b/applet.cpp index b0176088f..6f676176f 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1359,11 +1359,16 @@ Applet* Applet::load(const QString& appletName, uint appletId, const QVariantLis QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(appletName); KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint); + bool isContainment = false; if (offers.isEmpty()) { //TODO: what would be -really- cool is offer to try and download the applet // from the network at this point - kDebug() << "offers is empty for " << appletName; - return 0; + offers = KServiceTypeTrader::self()->query("Plasma/Containment", constraint); + isContainment = true; + if (!offers.isEmpty()) { + kDebug() << "offers is empty for " << appletName; + return 0; + } } /* else if (offers.count() > 1) { kDebug() << "hey! we got more than one! let's blindly take the first one"; } */ @@ -1376,8 +1381,10 @@ Applet* Applet::load(const QString& appletName, uint appletId, const QVariantLis if (!offer->property("X-Plasma-Language").toString().isEmpty()) { kDebug() << "we have a script in the language of" << offer->property("X-Plasma-Language").toString(); - Applet *applet = new Applet(0, offer->storageId(), appletId); - return applet; + if (isContainment) { + return new Containment(0, offer->storageId(), appletId); + } + return new Applet(0, offer->storageId(), appletId); } QVariantList allArgs; diff --git a/package.cpp b/package.cpp index 32878bdfa..b4c37f6e5 100644 --- a/package.cpp +++ b/package.cpp @@ -312,7 +312,9 @@ bool Package::registerPackage(const PackageMetadata &data, const QString &iconPa KDesktopFile config(service); KConfigGroup cg = config.desktopGroup(); cg.writeEntry("Type", "Service"); - cg.writeEntry("X-KDE-ServiceTypes", "Plasma/Applet"); + //TODO do we really like to just install all packages as applet/containment? Probably + //it would make sense to let the packages themself decide what they are. + cg.writeEntry("X-KDE-ServiceTypes", "Plasma/Applet,Plasma/Containment"); cg.writeEntry("X-KDE-PluginInfo-EnabledByDefault", true); QFile icon(iconPath);