From 55088ba776679b2b784c705f676b623b627b73d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 26 Jan 2012 08:33:21 +0100 Subject: [PATCH] Remove repetitive code in WorkspaceWrapper --- scripting/workspace_wrapper.cpp | 54 ++++++++------------------------- scripting/workspace_wrapper.h | 6 ++-- 2 files changed, 14 insertions(+), 46 deletions(-) diff --git a/scripting/workspace_wrapper.cpp b/scripting/workspace_wrapper.cpp index 3c916eeef9..8804f5d50d 100644 --- a/scripting/workspace_wrapper.cpp +++ b/scripting/workspace_wrapper.cpp @@ -48,64 +48,34 @@ void WorkspaceWrapper::setterName( rettype val ) { \ } GETTERSETTER(int, numberOfDesktops, setNumberOfDesktops) +GETTERSETTER(int, currentDesktop, setCurrentDesktop) #undef GETTERSETTER -QList< KWin::Client* > WorkspaceWrapper::clientList() const -{ - return KWin::Workspace::self()->clientList(); +#define GETTER( rettype, getterName ) \ +rettype WorkspaceWrapper::getterName( ) const { \ + return Workspace::self()->getterName(); \ } +GETTER(KWin::Client*, activeClient) +GETTER(QList< KWin::Client* >, clientList) +GETTER(int, workspaceWidth) +GETTER(int, workspaceHeight) +GETTER(QSize, desktopGridSize) +GETTER(int, desktopGridWidth) +GETTER(int, desktopGridHeight) -KWin::Client* WorkspaceWrapper::activeClient() -{ - return KWin::Workspace::self()->activeClient(); -} +#undef GETTER void WorkspaceWrapper::setActiveClient(KWin::Client* client) { KWin::Workspace::self()->activateClient(client); } -void WorkspaceWrapper::setCurrentDesktop(int desktop) -{ - KWin::Workspace::self()->setCurrentDesktop(desktop); -} - -int WorkspaceWrapper::workspaceWidth() const -{ - return KWin::Workspace::self()->workspaceWidth(); -} - -int WorkspaceWrapper::workspaceHeight() const -{ - return KWin::Workspace::self()->workspaceHeight(); -} - QSize WorkspaceWrapper::workspaceSize() const { return QSize(workspaceWidth(), workspaceHeight()); } -QSize WorkspaceWrapper::desktopGridSize() const -{ - return KWin::Workspace::self()->desktopGridSize(); -} - -int WorkspaceWrapper::desktopGridWidth() const -{ - return KWin::Workspace::self()->desktopGridWidth(); -} - -int WorkspaceWrapper::desktopGridHeight() const -{ - return KWin::Workspace::self()->desktopGridHeight(); -} - -int WorkspaceWrapper::currentDesktop() const -{ - return KWin::Workspace::self()->currentDesktop(); -} - void WorkspaceWrapper::setupClientConnections(KWin::Client *client) { connect(client, SIGNAL(clientMinimized(KWin::Client*,bool)), SIGNAL(clientMinimized(KWin::Client*))); diff --git a/scripting/workspace_wrapper.h b/scripting/workspace_wrapper.h index 3c3b4d8fe8..edd554014b 100644 --- a/scripting/workspace_wrapper.h +++ b/scripting/workspace_wrapper.h @@ -77,11 +77,9 @@ public: rettype getter() const; \ void setter( rettype val ); GETTERSETTERDEF(int, numberOfDesktops, setNumberOfDesktops) + GETTERSETTERDEF(int, currentDesktop, setCurrentDesktop) + GETTERSETTERDEF(KWin::Client*, activeClient, setActiveClient) #undef GETTERSETTERDEF - int currentDesktop() const; - void setCurrentDesktop(int desktop); - KWin::Client *activeClient(); - void setActiveClient(KWin::Client *client); QSize desktopGridSize() const; int desktopGridWidth() const; int desktopGridHeight() const;