From 26d069981dc42fa1195d9d953e77eadae4097572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 26 Jan 2012 08:22:54 +0100 Subject: [PATCH] Add property for number of desktops to scripting Adding macros to define the wraping code. --- scripting/workspace_wrapper.cpp | 13 +++++++++++++ scripting/workspace_wrapper.h | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/scripting/workspace_wrapper.cpp b/scripting/workspace_wrapper.cpp index 8a9543aef8..3c916eeef9 100644 --- a/scripting/workspace_wrapper.cpp +++ b/scripting/workspace_wrapper.cpp @@ -33,11 +33,24 @@ WorkspaceWrapper::WorkspaceWrapper(QObject* parent) : QObject(parent) connect(ws, SIGNAL(clientAdded(KWin::Client*)), SLOT(setupClientConnections(KWin::Client*))); connect(ws, SIGNAL(clientRemoved(KWin::Client*)), SIGNAL(clientRemoved(KWin::Client*))); connect(ws, SIGNAL(clientActivated(KWin::Client*)), SIGNAL(clientActivated(KWin::Client*))); + connect(ws, SIGNAL(numberDesktopsChanged(int)), SIGNAL(numberDesktopsChanged(int))); foreach (KWin::Client *client, ws->clientList()) { setupClientConnections(client); } } +#define GETTERSETTER( rettype, getterName, setterName ) \ +rettype WorkspaceWrapper::getterName( ) const { \ + return Workspace::self()->getterName(); \ +} \ +void WorkspaceWrapper::setterName( rettype val ) { \ + Workspace::self()->setterName( val ); \ +} + +GETTERSETTER(int, numberOfDesktops, setNumberOfDesktops) + +#undef GETTERSETTER + QList< KWin::Client* > WorkspaceWrapper::clientList() const { return KWin::Workspace::self()->clientList(); diff --git a/scripting/workspace_wrapper.h b/scripting/workspace_wrapper.h index f2b1f8257e..3c3b4d8fe8 100644 --- a/scripting/workspace_wrapper.h +++ b/scripting/workspace_wrapper.h @@ -42,6 +42,10 @@ class WorkspaceWrapper : public QObject Q_PROPERTY(int workspaceWidth READ workspaceWidth) Q_PROPERTY(int workspaceHeight READ workspaceHeight) Q_PROPERTY(QSize workspaceSize READ workspaceSize) + /** + * The number of desktops currently used. Minimum number of desktops is 1, maximum 20. + **/ + Q_PROPERTY(int desktops READ numberOfDesktops WRITE setNumberOfDesktops NOTIFY numberDesktopsChanged) private: Q_DISABLE_COPY(WorkspaceWrapper) @@ -60,9 +64,20 @@ signals: void clientActivated(KWin::Client*); void clientFullScreenSet(KWin::Client*, bool, bool); void clientSetKeepAbove(KWin::Client*, bool); + /** + * Signal emitted whenever the number of desktops changed. + * To get the current number of desktops use the property desktops. + * @param oldNumberOfDesktops The previous number of desktops. + **/ + void numberDesktopsChanged(int oldNumberOfDesktops); public: WorkspaceWrapper(QObject* parent = 0); +#define GETTERSETTERDEF( rettype, getter, setter ) \ +rettype getter() const; \ +void setter( rettype val ); + GETTERSETTERDEF(int, numberOfDesktops, setNumberOfDesktops) +#undef GETTERSETTERDEF int currentDesktop() const; void setCurrentDesktop(int desktop); KWin::Client *activeClient();