[Kde-bindings] KDE/kdebindings/csharp/plasma
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Mon Dec 1 13:16:24 UTC 2008
SVN commit 891256 by rdale:
* Added UpdateAllSources() and RemoveSource() slots to the
PlasmScripting.DataEngine
* Used reflection to call various protected methods in the underlying applet
or dataEngine from the PlasmaScripting.Applet and PlasmaScripting.DataEngine
classes
CCMAIL: kde-bindings at kde.org
M +7 -0 ChangeLog
M +1 -1 examples/dataengines/time/timeengine.cs
M +2 -0 src/PlasmaScriptengineKimono_DataEngine.cs
M +48 -5 src/PlasmaScripting_Applet.cs
M +23 -3 src/PlasmaScripting_DataEngine.cs
M +4 -0 src/PlasmaScripting_QGraphicsWidget.cs
--- trunk/KDE/kdebindings/csharp/plasma/ChangeLog #891255:891256
@@ -1,3 +1,10 @@
+2008-12-01 Richard Dale <richard.j.dale at gmail.com>
+* Added UpdateAllSources() and RemoveSource() slots to the
+ PlasmScripting.DataEngine
+* Used reflection to call various protected methods in the underlying applet
+ or dataEngine from the PlasmaScripting.Applet and PlasmaScripting.DataEngine
+ classes
+
2008-11-28 Richard Dale <richard.j.dale at gmail.com>
* Added a time data engine example
* Brought the Scripting Data Engine Init() method in line with the Applet code
--- trunk/KDE/kdebindings/csharp/plasma/examples/dataengines/time/timeengine.cs #891255:891256
@@ -49,7 +49,7 @@
base.Init();
//QDBusInterface *ktimezoned = new QDBusInterface("org.kde.kded", "/modules/ktimezoned", "org.kde.KTimeZoned");
QDBusConnection dbus = QDBusConnection.SessionBus();
- dbus.Connect("", "", "org.kde.KTimeZoned", "configChanged", this, SLOT("UpdateAllSources()"));
+ dbus.Connect("", "", "org.kde.KTimeZoned", "configChanged", this, SLOT("updateAllSources()"));
}
public override List<string> Sources() {
--- trunk/KDE/kdebindings/csharp/plasma/src/PlasmaScriptengineKimono_DataEngine.cs #891255:891256
@@ -104,3 +104,5 @@
}
}
}
+
+// kate: space-indent on; indent-width 4; replace-tabs on; mixed-indent off;
--- trunk/KDE/kdebindings/csharp/plasma/src/PlasmaScripting_Applet.cs #891255:891256
@@ -25,6 +25,7 @@
using QyotoQGraphicsWidget = Qyoto.QGraphicsWidget;
using Qyoto;
using System.Collections.Generic;
+ using System.Reflection;
/// <remarks>
/// Applet provides several important roles for add-ons widgets in Plasma.
/// First, it is the base class for the plugin system and therefore is the
@@ -447,8 +448,7 @@
/// <short> </short>
[Q_SLOT("Plasma::Extender* extender()")]
protected Plasma.Extender Extender() {
-// return applet.Extender();
- return null;
+ return (Plasma.Extender) appletType.GetMethod("Extender").Invoke(applet, null);
}
public Applet(AppletScript parent) : base(parent) {
Connect(applet, SIGNAL("releaseVisualFocus()"), this, SIGNAL("releaseVisualFocus()"));
@@ -467,8 +467,20 @@
/// failed to launch
/// </param></remarks> <short> Call this method when the applet fails to launch properly.</short>
protected void SetFailedToLaunch(bool failed, string reason) {
+ Object[] parameters = new Object[2];
+ parameters[0] = failed;
+ parameters[1] = reason;
+ MethodInfo method = appletType.GetMethod( "SetFailedToLaunch",
+ new Type[] { typeof(System.Boolean),
+ typeof(System.String) } );
+ method.Invoke(applet, parameters);
}
protected void SetFailedToLaunch(bool failed) {
+ Object[] parameters = new Object[1];
+ parameters[0] = failed;
+ MethodInfo method = appletType.GetMethod( "SetFailedToLaunch",
+ new Type[] {typeof(System.Boolean)} );
+ method.Invoke(applet, parameters);
}
/// <remarks>
/// When called, the Applet should write any information needed as part
@@ -491,8 +503,20 @@
/// or false if it doesn't
/// </param></remarks> <short> When the applet needs to be configured before being usable, this method can be called to show a standard interface prompting the user to configure the applet </short>
protected void SetConfigurationRequired(bool needsConfiguring, string reason) {
+ Object[] parameters = new Object[2];
+ parameters[0] = needsConfiguring;
+ parameters[1] = reason;
+ MethodInfo method = appletType.GetMethod( "SetConfigurationRequired",
+ new Type[] { typeof(System.Boolean),
+ typeof(System.String) } );
+ method.Invoke(applet, parameters);
}
protected void SetConfigurationRequired(bool needsConfiguring) {
+ Object[] parameters = new Object[1];
+ parameters[0] = needsConfiguring;
+ MethodInfo method = appletType.GetMethod( "SetConfigurationRequired",
+ new Type[] {typeof(System.Boolean)} );
+ method.Invoke(applet, parameters);
}
/// <remarks>
/// Reimplement this method so provide a configuration interface,
@@ -507,6 +531,9 @@
/// Sets whether or not this Applet is acting as a Containment
/// </remarks> <short> Sets whether or not this Applet is acting as a Containment </short>
protected void SetIsContainment(bool isContainment) {
+ Object[] parameters = new Object[1];
+ parameters[0] = isContainment;
+ appletType.GetMethod("SetIsContainment").Invoke(applet, parameters);
}
/// <remarks>
/// Called when any of the geometry constraints have been updated.
@@ -527,12 +554,18 @@
/// <param> name="item" the item to watch for mouse move
/// </param></remarks> <short> Register the widgets that manage mouse clicks but you still want to be able to drag the applet around when holding the mouse pointer on that widget.</short>
protected void RegisterAsDragHandle(QGraphicsItem item) {
+ Object[] parameters = new Object[1];
+ parameters[0] = item;
+ appletType.GetMethod("RegisterAsDragHandle").Invoke(applet, parameters);
}
/// <remarks>
/// Unregister a widget registered with registerAsDragHandle.
/// <param> name="item" the item to unregister
/// </param></remarks> <short> Unregister a widget registered with registerAsDragHandle.</short>
protected void UnregisterAsDragHandle(QGraphicsItem item) {
+ Object[] parameters = new Object[1];
+ parameters[0] = item;
+ appletType.GetMethod("UnregisterAsDragHandle").Invoke(applet, parameters);
}
/// <remarks>
/// <param> name="item" the item to look for if it is registered or not
@@ -540,7 +573,9 @@
/// </return>
/// <short> </short>
protected bool IsRegisteredAsDragHandle(QGraphicsItem item) {
- return false;
+ Object[] parameters = new Object[1];
+ parameters[0] = item;
+ return (bool) appletType.GetMethod("IsRegisteredAsDragHandle").Invoke(applet, parameters);
}
/// <remarks>
/// </remarks> <short> </short>
@@ -574,14 +609,20 @@
/// Reimplemented from QGraphicsItem
/// </remarks> <short> Reimplemented from QGraphicsItem </short>
protected virtual QVariant ItemChange(QGraphicsItem.GraphicsItemChange change, QVariant value) {
- return new QVariant();
+ Object[] parameters = new Object[2];
+ parameters[0] = change;
+ parameters[1] = value;
+ return (QVariant) appletType.GetMethod("ItemChange").Invoke(applet, parameters);
}
/// <remarks>
/// Reimplemented from QGraphicsItem
/// </remarks> <short> Reimplemented from QGraphicsItem </short>
protected new virtual QPainterPath Shape() {
- return new QPainterPath();
+ return appletScript.Shape();
}
+ protected QSizeF Size() {
+ return appletScript.Size();
+ }
/// <remarks>
/// Reimplemented from QGraphicsLayoutItem
/// </remarks> <short> Reimplemented from QGraphicsLayoutItem </short>
@@ -643,3 +684,5 @@
void Activate();
}
}
+
+// kate: space-indent on; indent-width 4; replace-tabs on; mixed-indent off;
--- trunk/KDE/kdebindings/csharp/plasma/src/PlasmaScripting_DataEngine.cs #891255:891256
@@ -40,6 +40,7 @@
public class DataEngine : QObject, IDisposable {
private DataEngineScript dataEngineScript;
private Plasma.DataEngine dataEngine;
+ private Type dataEngineType;
public Plasma.DataEngine PlasmaDataEngine {
get { return dataEngine; }
@@ -60,6 +61,7 @@
public DataEngine(DataEngineScript parent) : base(parent) {
dataEngineScript = parent;
dataEngine = parent.DataEngine();
+ dataEngineType = dataEngine.GetType();
Connect(dataEngine, SIGNAL("sourceAdded(QString)"), this, SIGNAL("sourceAdded(QString)"));
Connect(dataEngine, SIGNAL("sourceRemoved(QString)"), this, SIGNAL("sourceRemoved(QString)"));
}
@@ -82,7 +84,7 @@
return new List<string>();
}
/// <remarks>
- /// <param> name="source" the source to targe the Service at
+ /// <param> name="source" the source to target the Service at
/// </param></remarks> <return> a Service that has the source as a destination. The service
/// is parented to the DataEngine, but may be deleted by the
/// caller when finished with it
@@ -291,6 +293,9 @@
/// <param> name="source" the DataContainer to add to the DataEngine
/// </param></remarks> <short> Adds an already constructed data source.</short>
protected void AddSource(Plasma.DataContainer source) {
+ Object[] parameters = new Object[1];
+ parameters[0] = source;
+ dataEngineType.GetMethod("AddSource").Invoke(dataEngine, parameters);
}
/// <remarks>
/// Sets an upper limit on the number of data sources to keep in this engine.
@@ -353,6 +358,9 @@
/// Sets the engine name for the DataEngine
/// </remarks> <short> Sets the engine name for the DataEngine </short>
protected void SetName(string name) {
+ Object[] parameters = new Object[1];
+ parameters[0] = name;
+ dataEngineType.GetMethod("SetName").Invoke(dataEngine, parameters);
}
/// <remarks>
/// Call this method when you call setData directly on a DataContainer instead
@@ -361,6 +369,7 @@
/// </remarks> <short> Call this method when you call setData directly on a DataContainer instead of using the DataEngine.SetData methods.</short>
[Q_SLOT("void scheduleSourcesUpdated()")]
protected void ScheduleSourcesUpdated() {
+ dataEngineType.GetMethod("ScheduleSourcesUpdated").Invoke(dataEngine, null);
}
/// <remarks>
/// Removes a data source.
@@ -368,12 +377,20 @@
/// </param></remarks> <short> Removes a data source.</short>
[Q_SLOT("void removeSource(const QString&)")]
protected void RemoveSource(string source) {
+ Object[] parameters = new Object[1];
+ parameters[0] = source;
+ dataEngineType.GetMethod("RemoveSource").Invoke(dataEngine, parameters);
}
+ /// <remarks>
+ /// Immediately updates all existing sources when called
+ /// </remarks> <short> Immediately updates all existing sources when called </short>
+ [Q_SLOT("void updateAllSources()")]
+ protected void UpdateAllSources() {
+ dataEngineType.GetMethod("UpdateAllSources").Invoke(dataEngine, null);
+ }
~DataEngine() {
- interceptor.Invoke("~DataEngine", "~DataEngine()", typeof(void));
}
public new void Dispose() {
- interceptor.Invoke("~DataEngine", "~DataEngine()", typeof(void));
}
protected new IDataEngineSignals Emit {
get { return (IDataEngineSignals) Q_EMIT; }
@@ -395,3 +412,6 @@
void SourceRemoved(string source);
}
}
+
+// kate: space-indent on; indent-width 4; replace-tabs on; mixed-indent off;
+
--- trunk/KDE/kdebindings/csharp/plasma/src/PlasmaScripting_QGraphicsWidget.cs #891255:891256
@@ -8,6 +8,7 @@
public class QGraphicsWidget : QObject {
protected AppletScript appletScript;
protected Plasma.Applet applet;
+ protected Type appletType;
public new const int Type = 11;
@@ -62,6 +63,7 @@
public QGraphicsWidget(AppletScript parent) : base(parent) {
appletScript = parent;
applet = parent.Applet();
+ appletType = applet.GetType();
}
public QGraphicsLayout Layout() {
return applet.Layout();
@@ -827,3 +829,5 @@
public interface IQGraphicsWidgetSignals : IQObjectSignals {
}
}
+
+// kate: space-indent on; indent-width 4; replace-tabs on; mixed-indent off;
More information about the Kde-bindings
mailing list