home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / komunikace / kmeleon / K-Meleon1.1.3en-US.exe / chrome / embed.jar / kmprefs / content / pref-kgestures.xul < prev    next >
Extensible Markup Language  |  2007-04-23  |  13KB  |  374 lines

  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/css" href="chrome://global/skin/"?>
  3. <?xml-stylesheet type="text/css" href="chrome://kmprefs/skin/"?>
  4. <!DOCTYPE page SYSTEM "chrome://kmprefs/locale/pref-kgestures.dtd">
  5. <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
  6. id="prefGestures" onunload="kGestures.exit()">
  7.  
  8. <stringbundle id="pref_bundle" src="chrome://kmprefs/locale/pref.properties"/>
  9. <stringbundle id="xml_bundle" src="chrome://kmprefs/locale/kmprefs/xml.properties"/>
  10. <stringbundle id="gestures_bundle" src="chrome://kmprefs/locale/kplugins/gestures.properties"/>
  11. <stringbundle id="kplugin_bundle" src="chrome://kmprefs/locale/kplugins/kplugins.properties"/>
  12.  
  13. <script type="application/x-javascript" src="chrome://kmprefs/content/pref.js"/>
  14. <script type="application/x-javascript" src="chrome://kmprefs/content/kmprefs/xml.js"/>
  15. <script type="application/x-javascript">
  16. <![CDATA[
  17. var menu;
  18.  
  19. CFGtoXML.init("gestures");
  20.  
  21. var DefActions,
  22.     UsrActions = new XML("file:///"+getFile(getFolder("KUserSettings"),"gestures.xml").path);
  23. if(getFile(getFolder("KDefSettings"),"gestures.xml").exists())
  24.     DefActions = new XML("file:///"+getFile(getFolder("KDefSettings"),"gestures.xml").path);
  25. else
  26.     DefActions = new XML("chrome://kmprefs/content/kplugins/gestures.xml");
  27.  
  28. function init(e) {
  29.     var item = document.createElement("menuitem");
  30.     item.setAttribute("value","");
  31.     item.setAttribute("label",document.getElementById("gestures_bundle").getString("action_none"));
  32.  
  33.     menu = document.createElement("menupopup");
  34.     menu.appendChild(item);
  35.  
  36.     for(var i=0,src=[UsrActions,DefActions];i<src.length;i++) try {
  37.         for(var j=0,actions=src[i].data.getElementsByTagName("action"),command,caption,item;j<actions.length;j++) {
  38.             command = actions[j].getAttribute("command");
  39.             caption = actions[j].getAttribute("caption");
  40.             item = document.createElement("menuitem");
  41.             if(command.indexOf("(")>0) {
  42.                 var plugin = command.split("(")[0];
  43.                 caption += " " + document.getElementById("gestures_bundle").getString("required_plugin").replace(/%S/,kPlugin.fullName(plugin));
  44.                 if(!kPlugin.load(plugin)) item.setAttribute("disabled",true);
  45.             }
  46.             item.setAttribute("value",command);
  47.             item.setAttribute("label",caption);
  48.             menu.appendChild(item);
  49.         }
  50.     } catch(e) {}
  51.     kGestures.init();
  52. }
  53.  
  54. var kGestures = {
  55.  
  56. _base: null,
  57. _pref: null,
  58. _menu: null,
  59.  
  60. load: null,
  61. init: function() {
  62.     this.load  = kPlugin.load("gestures");
  63.     this._base = "kmeleon.plugins.gestures.";
  64.     this._pref = new Array(    "load");
  65.     this._menu = document.getElementsByTagName("menulist");
  66.  
  67.     initCheckbox(this._base+this._pref[0]);
  68.     for(var j=1;j<this._menu.length;j++) {
  69.         if(this._menu[j].hasChildNodes()) this._menu[j].removeChild(this._menu[j].firstChild);
  70.         this._menu[j].appendChild(menu.cloneNode(true));
  71.     }
  72.     this.initActions();
  73.     this._initAccel();
  74.     this._setControls();
  75. },
  76. exit: function() {
  77.     UsrActions.save(getFile(getFolder("KUserSettings"),"gestures.xml"),["caption","command"]);
  78. },
  79. setAction: function(elem) {
  80.     pref.setCharPref(this._base+this._menu[0].value+elem.id,elem.value);
  81.     if(!(elem.value)&&(this._menu[0].value)) restoreDefault(this._base+this._menu[0].value+elem.id);
  82. },
  83. initActions: function() {
  84.     for(var j=1,m=this._base+this._menu[0].value,s=document.getElementById("pref_bundle").getString("pref_unknown_or_invalid");j<this._menu.length;j++)
  85.         initMenulist(this._menu[j].id,m,s);
  86. },
  87. toggle: function() {
  88.     toggleCheckbox(this._base+this._pref[0]);
  89.     this.load = !this.load;
  90.     this._setControls();
  91. },
  92. _initAccel: function() {
  93.     var item = this._menu[0].firstChild.firstChild,
  94.         keys = new Array("RButton","ALT","CTRL","SHIFT"),
  95.         data = getFileContents(getFile(getFolder("KDefSettings"),"accel.cfg"));
  96.  
  97.     if(data) for(var j=1;j<keys.length;j++) {
  98.         item = item.nextSibling;
  99.         if(testMultiline(data,keys[j]+"[ \\t]+"+keys[0]))
  100.             if(testMultiline(data,"^[ \\t]*#[ \\t#]*"+keys[j]+"[ \\t]+"+keys[0])) {
  101.                 // commented out
  102.             } else {
  103.                 item.setAttribute("tooltiptext",document.getElementById("gestures_bundle").getString("possible_conflict").replace(/%S/,keys[j]+" "+keys[0]));
  104.                 item.style.color = "red";
  105.             }
  106.     }
  107. },
  108. _setControls: function() {
  109.     for(var j=0;j<this._menu.length;j++)
  110.         this._menu[j].disabled = !this.load;
  111. }
  112.  
  113. };
  114.  
  115. var Database = {
  116.  
  117. _add: false,
  118. _ndx: false,
  119. _cap: null,
  120. _url: null,
  121.  
  122. dflt: false,
  123. done: false,
  124. tree: null,
  125. init: function() {
  126.     if(!this.done) {
  127.         this.done = true;
  128.         this.tree = document.getElementById("database");
  129.         while(this.tree.hasChildNodes()) this.tree.removeChild(this.tree.firstChild);
  130.         try {
  131.             this.fill(UsrActions,this.tree);
  132.         } catch(e) {
  133.             this.done = false;alert(e);
  134.         }
  135.     }
  136.     if(!this.dflt) {
  137.         this.dflt = true;
  138.         try {
  139.             this.fill(DefActions,document.getElementById("default"));
  140.         } catch(e) {
  141.             this.dflt = false;alert(e);
  142.         }
  143.     }
  144. },
  145. fill: function(source,target) {
  146.     for(var j=0,actions=source.data.getElementsByTagName("action"),titem,tcell;j<actions.length;j++) {
  147.         titem = document.createElement("treeitem");
  148.         titem.appendChild(document.createElement("treerow"));
  149.         tcell = document.createElement("treecell");
  150.         tcell.setAttribute("label",actions[j].getAttribute("caption"));
  151.         titem.firstChild.appendChild(tcell);
  152.         tcell = document.createElement("treecell");
  153.         tcell.setAttribute("label",actions[j].getAttribute("command"));
  154.         titem.firstChild.appendChild(tcell);
  155.         target.appendChild(titem);
  156.     }
  157. },
  158. del: function() {
  159.     this._ndx = this._current();
  160.     if(this._ndx>-1) {
  161.         this.tree.removeChild(this.tree.childNodes[this._ndx]);
  162.         if(UsrActions.del("action",this._ndx)) this._refresh();
  163.     }
  164. },
  165. add: function() {
  166.     this._ndx = -1;
  167.     this._add = true;
  168.     this._cap = null;
  169.     this._com = null;
  170.     window.openDialog("chrome://kmprefs/content/kmprefs/dlg-gestures.xul","gestAdd" ,"chrome,modal=yes,resizable=no",this);
  171. },
  172. edit: function() {
  173.     this._ndx = this._current();
  174.     this._add = false;
  175.     this._cap = this.tree.childNodes[this._ndx].firstChild.firstChild.getAttribute("label");
  176.     this._com = this.tree.childNodes[this._ndx].firstChild.firstChild.nextSibling.getAttribute("label");
  177.     window.openDialog("chrome://kmprefs/content/kmprefs/dlg-gestures.xul","gestEdit","chrome,modal=yes,resizable=no",this);
  178. },
  179. select: function() {
  180.     var ndx = this._current();
  181.     document.getElementById("edit").setAttribute("disabled",(ndx==-1));
  182.     document.getElementById("delete").setAttribute("disabled",(ndx==-1));
  183. },
  184. set: function(caption,command) {
  185.     if((this._cap != caption) || (this._com != command)) {
  186.         UsrActions.set("action",this._ndx,["caption","command"],[caption,command],null);
  187.         this._refresh();
  188.         this.done = false;
  189.         this.init();
  190.     }
  191. },
  192. _current: function() {
  193.     var ndx = this.tree.parentNode.parentNode.parentNode.currentIndex;
  194.     return (ndx > this.tree.childNodes.length) ? -1 : ndx-1;
  195. },
  196. _refresh: function() {
  197.     init(false);
  198. }
  199.  
  200. };
  201. ]]>
  202. </script>
  203.  
  204. <keyset>
  205.   <key id="addKey" keycode="VK_INSERT" oncommand="Database.add()"/>
  206.   <key id="delKey" keycode="VK_DELETE" oncommand="Database.del()"/>
  207. </keyset>
  208.  
  209. <vbox flex="1" style="overflow:auto">
  210.   <dialogheader title="&gestures.header;"/>
  211.   <separator class="thin"/>
  212.   <checkbox oncommand="kGestures.toggle()" id="kmeleon.plugins.gestures.load" label="&gestures.enable;"/>
  213.   <separator class="thick"/>
  214.   <tabcontrol flex="1">
  215.     <tabbox flex="1">
  216.       <tabs>
  217.         <tab label="&gestures.label;"/>
  218.         <tab label="&actions.label;" oncommand="Database.init()"/>
  219.       </tabs>
  220.       <tabpanels flex="1">
  221.         <tabpanel flex="1" orient="vertical" style="overflow:auto">
  222. <!-- Gesture Actions -->
  223. <separator class="thin"/>
  224. <description>&gestures.descr;</description>
  225. <separator class="thin"/>
  226. <grid>
  227.   <columns>
  228.     <column/>
  229.     <column/>
  230.     <column flex="1"/>
  231.   </columns>
  232.   <rows>
  233.     <row align="center">
  234.       <label value="&gestures.gesture;"/>
  235.       <label value="&gestures.modkey;"/>
  236.       <label value="&gestures.action;"/>
  237.     </row>
  238.     <row>
  239.       <separator class="thin"/>
  240.     </row>
  241.     <row align="center">
  242.       <hbox align="center">
  243.         <image src="chrome://kmprefs/skin/gestures/left.gif"/>
  244.         <label value="&gestures.left;"/>
  245.       </hbox>
  246.       <menulist id="modkey" oncommand="kGestures.initActions()">
  247.         <menupopup>
  248.           <menuitem value="" label="&gestures.modkey.none;"/>
  249.           <menuitem value="AR" label="&AltKey;"/>
  250.           <menuitem value="CR" label="&CtrlKey;"/>
  251.           <menuitem value="SR" label="&ShiftKey;"/>
  252.         </menupopup>
  253.       </menulist>
  254.       <menulist id="left" oncommand="kGestures.setAction(this)" flex="1"/>
  255.     </row>
  256.     <row align="center">
  257.       <hbox align="center">
  258.         <image src="chrome://kmprefs/skin/gestures/right.gif"/>
  259.         <label value="&gestures.right;"/>
  260.       </hbox>
  261.       <spacer/>
  262.       <menulist id="right" oncommand="kGestures.setAction(this)" flex="1"/>
  263.     </row>
  264.     <row align="center">
  265.       <hbox align="center">
  266.         <image src="chrome://kmprefs/skin/gestures/up.gif"/>
  267.         <label value="&gestures.up;"/>
  268.       </hbox>
  269.       <spacer/>
  270.       <menulist id="up" oncommand="kGestures.setAction(this)" flex="1"/>
  271.     </row>
  272.     <row align="center">
  273.       <hbox align="center">
  274.         <image src="chrome://kmprefs/skin/gestures/down.gif"/>
  275.         <label value="&gestures.down;"/>
  276.       </hbox>
  277.       <spacer/>
  278.       <menulist id="down" oncommand="kGestures.setAction(this)" flex="1"/>
  279.     </row>
  280.     <row align="center">
  281.       <hbox align="center">
  282.         <image src="chrome://kmprefs/skin/gestures/upright.gif"/>
  283.         <label value="&gestures.upright;"/>
  284.       </hbox>
  285.       <spacer/>
  286.       <menulist id="upright" oncommand="kGestures.setAction(this)" flex="1"/>
  287.     </row>
  288.     <row align="center">
  289.       <hbox align="center">
  290.         <image src="chrome://kmprefs/skin/gestures/downleft.gif"/>
  291.         <label value="&gestures.downleft;"/>
  292.       </hbox>
  293.       <spacer/>
  294.       <menulist id="downleft" oncommand="kGestures.setAction(this)" flex="1"/>
  295.     </row>
  296.     <row align="center">
  297.       <hbox align="center">
  298.         <image src="chrome://kmprefs/skin/gestures/upleft.gif"/>
  299.         <label value="&gestures.upleft;"/>
  300.       </hbox>
  301.       <spacer/>
  302.       <menulist id="upleft" oncommand="kGestures.setAction(this)" flex="1"/>
  303.     </row>
  304.     <row align="center">
  305.       <hbox align="center">
  306.         <image src="chrome://kmprefs/skin/gestures/downright.gif"/>
  307.         <label value="&gestures.downright;"/>
  308.       </hbox>
  309.       <spacer/>
  310.       <menulist id="downright" oncommand="kGestures.setAction(this)" flex="1"/>
  311.     </row>
  312.     <row align="center">
  313.       <hbox align="center">
  314.         <image src="chrome://kmprefs/skin/gestures/LR.gif"/>
  315.         <label value="&gestures.LR;"/>
  316.       </hbox>
  317.       <spacer/>
  318.       <menulist id="LR" oncommand="kGestures.setAction(this)" flex="1"/>
  319.     </row>
  320.     <row align="center">
  321.       <hbox align="center">
  322.         <image src="chrome://kmprefs/skin/gestures/RL.gif"/>
  323.         <label value="&gestures.RL;"/>
  324.       </hbox>
  325.       <spacer/>
  326.       <menulist id="RL" oncommand="kGestures.setAction(this)" flex="1"/>
  327.     </row>
  328.   </rows>
  329. </grid>
  330. <separator class="thick"/>
  331. <description>&gestures.note;</description>
  332. <!-- Gesture Actions -->
  333.     </tabpanel>
  334.         <tabpanel flex="1" orient="vertical" style="overflow:auto">
  335. <!-- Database -->
  336. <separator class="thin"/>
  337. <description>&actions.descr;</description>
  338. <separator class="thin"/>
  339. <tree flex="1" seltype="single" hidecolumnpicker="true" onselect="Database.select()">
  340.   <treecols>
  341.     <treecol label="&actions.caption;" flex="1" primary="true"/>
  342.     <splitter class="tree-splitter"/>
  343.     <treecol label="&actions.command;" flex="1"/>
  344.   </treecols>
  345.   <treechildren>
  346.     <treeitem container="true" open="true">
  347.       <treerow>
  348.         <treecell label="&actions.user;"/>
  349.       </treerow>
  350.       <treechildren id="database"/>
  351.     </treeitem>
  352.     <treeitem container="true" open="true">
  353.       <treerow>
  354.         <treecell label="&actions.default;"/>
  355.       </treerow>
  356.       <treechildren id="default"/>
  357.     </treeitem>
  358.   </treechildren>
  359. </tree>
  360. <separator class="thin"/>
  361. <hbox>
  362.   <button label="&add;" oncommand="Database.add()" key="addKey"/>
  363.   <button id="edit" label="&edit;" oncommand="Database.edit()" disabled="true"/>
  364.   <button id="delete" label="&delete;" oncommand="Database.del()" key="delKey" disabled="true"/>
  365.   <hbox flex="1"/>
  366. </hbox>
  367. <!-- Database -->
  368.     </tabpanel>
  369.       </tabpanels>
  370.     </tabbox>
  371.   </tabcontrol>
  372. </vbox>
  373.  
  374. </page>