[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Re: Review Request: ScriptEngine's as Containments
From:       Sebastian Sauer <mail () dipe ! org>
Date:       2008-03-05 20:10:48
Message-ID: 200803052110.48394.mail () dipe ! org
[Download RAW message or body]

On Wednesday 05 March 2008, Sebastian Sauer wrote:
> inspired by http://aseigo.blogspot.com/2008/03/power-of-containments.html
> :)
>
> The attached patch does enable Containments (tested with panels) written
> using a ScriptEngine like SuperKaramba.

I forgot to also patch the package.cpp. Refreshed patch that also includes 
that part and some codingstyle fixes is attached.

["ScriptEngineContainment.patch" (text/x-diff)]

Index: servicetypes/plasma-containment.desktop
===================================================================
--- servicetypes/plasma-containment.desktop	(revision 782420)
+++ servicetypes/plasma-containment.desktop	(working copy)
@@ -44,3 +44,5 @@
 Comment[zh_CN]=Plasma 小程序容器和背景绘制程序
 Comment[zh_TW]=Plasma 小程式容器與背景畫家
 
+[PropertyDef::X-Plasma-Language]
+Type=QString
Index: package.cpp
===================================================================
--- package.cpp	(revision 782420)
+++ package.cpp	(working copy)
@@ -312,7 +312,7 @@
     KDesktopFile config(service);
     KConfigGroup cg = config.desktopGroup();
     cg.writeEntry("Type", "Service");
-    cg.writeEntry("X-KDE-ServiceTypes", "Plasma/Applet");
+    cg.writeEntry("X-KDE-ServiceTypes", "Plasma/Applet,Plasma/Containment");
     cg.writeEntry("X-KDE-PluginInfo-EnabledByDefault", true);
 
     QFile icon(iconPath);
Index: applet.cpp
===================================================================
--- applet.cpp	(revision 782420)
+++ applet.cpp	(working copy)
@@ -1359,11 +1359,16 @@
     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 @@
 
     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;
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 782420)
+++ CMakeLists.txt	(working copy)
@@ -222,6 +222,7 @@
 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


_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic