[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwin
Subject:    Re: Review Request: Allow Scripts to add menus to the UserActionsMenu
From:       "Commit Hook" <null () kde ! org>
Date:       2012-09-07 5:32:28
Message-ID: 20120907053228.17381.27727 () vidsolbach ! de
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/106285/#review18638
-----------------------------------------------------------


This review has been submitted with commit 846715c278582f17deb501eade3b2641c70d6b4f \
by Martin Gräßlin to branch master.

- Commit Hook


On Aug. 31, 2012, 2:12 p.m., Martin Gräßlin wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/106285/
> -----------------------------------------------------------
> 
> (Updated Aug. 31, 2012, 2:12 p.m.)
> 
> 
> Review request for kwin.
> 
> 
> Description
> -------
> 
> 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
> 
> 
> This addresses bug 303756.
> http://bugs.kde.org/show_bug.cgi?id=303756
> 
> 
> Diffs
> -----
> 
> kwin/scripting/documentation-global.xml 0b1c05869e1279ef4a38b0a559e22f9da8fb933e 
> kwin/scripting/scripting.h d48b3699b2d847dfd51fc84287f57c3fb441982f 
> kwin/scripting/scripting.cpp 8786bce8dcee01e1bb12ea5d6cb198474b90e993 
> kwin/scripting/scriptingutils.h ff8f99fa44ff2c101a61249b0555962b5a853f4d 
> kwin/useractions.h 094a614ef4c94424968cf230e376e2f1a8615245 
> kwin/useractions.cpp ea0071741e5b313ed9857bbaca4da734ec1e0089 
> kwin/workspace.h fdd2223e578324f1b309feec5fe796d0ec73d7d5 
> 
> Diff: http://git.reviewboard.kde.org/r/106285/diff/
> 
> 
> Testing
> -------
> 
> registerUserActionsMenu(function (client) {
> var opacity = Math.round(client.opacity*100);
> return {
> text: "Window Opacity",
> items: [{
> text: "100 %",
> checkable: true,
> checked: opacity == 100,
> triggered: function () {
> 	client.opacity = 1.0;
> }
> }, {
> text: "75 %",
> checkable: true,
> checked: opacity == 75,
> triggered: function () {
> 	client.opacity = 0.75;
> }
> }, {
> text: "50 %",
> checkable: true,
> checked: opacity == 50,
> triggered: function () {
> 	client.opacity = 0.5;
> }
> }, {
> text: "25 %",
> checkable: true,
> checked: opacity == 25,
> triggered: function () {
> 	client.opacity = 0.25;
> }
> }, {
> text: "10 %",
> checkable: true,
> checked: opacity == 10,
> triggered: function () {
> 	client.opacity = 0.1;
> }
> }
> ]
> };
> });
> 
> 
> Thanks,
> 
> Martin Gräßlin
> 
> 


[Attachment #5 (text/html)]

<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;">  <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/106285/">http://git.reviewboard.kde.org/r/106285/</a>
  </td>
    </tr>
   </table>
   <br />





 <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This review has been \
submitted with commit 846715c278582f17deb501eade3b2641c70d6b4f by Martin Gräßlin to \
branch master.</pre>  <br />







<p>- Commit</p>


<br />
<p>On August 31st, 2012, 2:12 p.m., Martin Gräßlin wrote:</p>






<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;">  <tr>
  <td>

<div>Review request for kwin.</div>
<div>By Martin Gräßlin.</div>


<p style="color: grey;"><i>Updated Aug. 31, 2012, 2:12 p.m.</i></p>






<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">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: &quot;My caption&quot;,
    checkable: true,
    checked: false,
    triggered: function (action) {
       print(&quot;The triggered action as parameter&quot;);
    }
}

The structure for a complete menu looks quite similar:
{
    text: &quot;My menu caption&quot;,
    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</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">registerUserActionsMenu(function (client) {  var opacity = \
Math.round(client.opacity*100);  return {
    text: &quot;Window Opacity&quot;,
    items: [{
      text: &quot;100 %&quot;,
      checkable: true,
      checked: opacity == 100,
      triggered: function () {
	client.opacity = 1.0;
      }
    }, {
      text: &quot;75 %&quot;,
      checkable: true,
      checked: opacity == 75,
      triggered: function () {
	client.opacity = 0.75;
      }
    }, {
      text: &quot;50 %&quot;,
      checkable: true,
      checked: opacity == 50,
      triggered: function () {
	client.opacity = 0.5;
      }
    }, {
      text: &quot;25 %&quot;,
      checkable: true,
      checked: opacity == 25,
      triggered: function () {
	client.opacity = 0.25;
      }
    }, {
      text: &quot;10 %&quot;,
      checkable: true,
      checked: opacity == 10,
      triggered: function () {
	client.opacity = 0.1;
      }
    }
    ]
  };
});</pre>
  </td>
 </tr>
</table>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="http://bugs.kde.org/show_bug.cgi?id=303756">303756</a>


</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>kwin/scripting/documentation-global.xml <span style="color: \
grey">(0b1c05869e1279ef4a38b0a559e22f9da8fb933e)</span></li>

 <li>kwin/scripting/scripting.h <span style="color: \
grey">(d48b3699b2d847dfd51fc84287f57c3fb441982f)</span></li>

 <li>kwin/scripting/scripting.cpp <span style="color: \
grey">(8786bce8dcee01e1bb12ea5d6cb198474b90e993)</span></li>

 <li>kwin/scripting/scriptingutils.h <span style="color: \
grey">(ff8f99fa44ff2c101a61249b0555962b5a853f4d)</span></li>

 <li>kwin/useractions.h <span style="color: \
grey">(094a614ef4c94424968cf230e376e2f1a8615245)</span></li>

 <li>kwin/useractions.cpp <span style="color: \
grey">(ea0071741e5b313ed9857bbaca4da734ec1e0089)</span></li>

 <li>kwin/workspace.h <span style="color: \
grey">(fdd2223e578324f1b309feec5fe796d0ec73d7d5)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/106285/diff/" style="margin-left: \
3em;">View Diff</a></p>




  </td>
 </tr>
</table>








  </div>
 </body>
</html>



_______________________________________________
kwin mailing list
kwin@kde.org
https://mail.kde.org/mailman/listinfo/kwin


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic