diff --git a/scripting/workspace_wrapper.cpp b/scripting/workspace_wrapper.cpp index d9ac497377..6530986d40 100644 --- a/scripting/workspace_wrapper.cpp +++ b/scripting/workspace_wrapper.cpp @@ -272,6 +272,21 @@ QString WorkspaceWrapper::desktopName(int desktop) const return VirtualDesktopManager::self()->name(desktop); } +void WorkspaceWrapper::createDesktop(int position, const QString &name) const +{ + VirtualDesktopManager::self()->createVirtualDesktop(position, name); +} + +void WorkspaceWrapper::removeDesktop(int position) const +{ + VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForX11Id(position + 1); + if (!vd) { + return; + } + + VirtualDesktopManager::self()->removeVirtualDesktop(vd->id()); +} + QString WorkspaceWrapper::supportInformation() const { return Workspace::self()->supportInformation(); diff --git a/scripting/workspace_wrapper.h b/scripting/workspace_wrapper.h index 33262c2625..d0fb00108e 100644 --- a/scripting/workspace_wrapper.h +++ b/scripting/workspace_wrapper.h @@ -255,6 +255,17 @@ void setter( rettype val ); * Returns the name for the given @p desktop. */ Q_SCRIPTABLE QString desktopName(int desktop) const; + /** + * Create a new virtual desktop at the requested position. + * @param position The position of the desktop. It should be in range [0, count]. + * @param name The name for the new desktop, if empty the default name will be used. + */ + Q_SCRIPTABLE void createDesktop(int position, const QString &name) const; + /** + * Remove the virtual desktop at the requested position + * @param position The position of the desktop to be removed. It should be in range [0, count - 1]. + */ + Q_SCRIPTABLE void removeDesktop(int position) const; /** * Provides support information about the currently running KWin instance. */