Commit Graph

9 Commits (master)

Author SHA1 Message Date
David Edmundson 4bb12f3f01 Allow configuring script's screen edges from the KCM
Summary:
Modify the kwinscreenedges KCM to also list scripts which support screen
edge activation and read/write the appropriate value in the script's
config.

In order to only show relevant scripts an additional .desktop metadata
field is added.

Test Plan:
Opened KCM set a hot corner for minimize all.
Tested it
unset it, and set on another corner
Tested again

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: graesslin, plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D2972
2016-10-07 15:20:14 +01:00
David Edmundson b32cdc5653 Add method unregisterScreenEdge to scripting
Test Plan: Used in a script. Works.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2261
2016-10-07 13:29:29 +01:00
Martin Gräßlin 0168e8f2c1 Add documentation for global KWin object in KWin scripting 2013-01-11 18:12:25 +01:00
Martin Gräßlin 62dd1d57f0 Fix documentation error for global KWin script method
SVN_SILENT
2012-10-28 09:50:34 +01:00
Martin Gräßlin 2764565f9d Allow Scripts to add menus to the UserActionsMenu
A script can register a callback through registerUserActionsMenu to be
informed when the UserActionsMenu is about to be shown. This menu calls
the Scripting component to gather actions to add to a Scripts submenu.

The Scripting component now asks all scripts for the actions, which will
invoke the registered callbacks with the Client for which the menu is to
be shown as argument.

The callback is supposed to return a JSON structure describing how the
menu should look like. The returned object can either be a menu item or
a complete menu. If multiple menu items or menus are supposed to be added
by the script it should just register multiple callbacks.

The structure for an item looks like the following:
{
    text: "My caption",
    checkable: true,
    checked: false,
    triggered: function (action) {
       print("The triggered action as parameter");
    }
}

The structure for a complete menu looks quite similar:
{
    text: "My menu caption",
    items: [
         {...}, {...} // items as described above
    ]
}

The C++ part of the script parses the returned object and generates
either QAction or QMenu from it. All objects become children of the
scripts QMenu provided by the UserActionsMenu.

Before the menu is shown again the existing menu is deleted to ensure
that no outdated values from no longer existing scripts are around. This
means the scripts are queried each time the menu is shown.

FEATURE: 303756
FIXED-IN: 4.10
REVIEW: 106285
2012-09-07 07:32:00 +02:00
Martin Gräßlin d2a9199cd9 Support for calling D-Bus methods from scripts
A new global method is exported to perform a remote method call
through D-Bus. The call is always performed async invoking a
callback once the call completed passing through the arguments
received from D-Bus.

Possible code looks like the following:
callDBus("org.kde.kwin", "/KWin", "org.kde.KWin", "currentDesktop", function (desktop) {
  print("Current Desktop through D-Bus: ", desktop);
});

REVIEW: 105396
2012-07-05 15:19:42 +02:00
Martin Gräßlin c9c4e020e2 Screen Edge bindings for Scripts and Scripted Effects
ScreenEdge is changed to emit a signal whenever a screen edge
got activated without an action or effect taking care of it.

A Script can reserve one to many callbacks for an edge and the
callback get's triggered whenever the signal is emitted. On
deconstruction of the Script the edge is unreserved again.

FEATURE: 299275
FIXED-IN: 4.9.0
REVIEW: 104904
2012-05-15 17:54:31 +02:00
Martin Gräßlin 1f97345e35 Asserts for KWin scripts
Further debugging functionality for KWin scripts. Added assert
methods validate the to be tested parameter and throw a script
error if the value is not valid.

Following methods are available:
* assert(value)
* assertTrue(boolean)
* assertFalse(boolean)
* assertEquals(expected, actual)
* assertNull(nullValue)
* assertNotNull(notNullValue)

All methods take an additional optional parameter which is used
as the error message if provided.

Methods to validate the number of arguments and types of the
parameters are added and throw syntax or type errors.

REVIEW: 104870
2012-05-10 10:00:54 +02:00
Martin Gräßlin e59a96b57c Documentation for global JavaScript methods/properties
The documentation is in an XML file which mimics the
XML output of doxygen, which can be converted to
MediaWiki syntax with the tools found in
kde:scratch/graesslin/kwin-scripting-api-generator git
repository.

BUG: 297640
FIXED-IN: 4.9.0
2012-04-10 20:41:57 +02:00