Ignore:
Timestamp:
03/10/10 18:47:48 (2 years ago)
Author:
sys
Message:

tabs views : menu sur touche menu contextuel & ctrl+space

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Xul_Core/content/scenariCore/widgets/matrix/slotContents.xbl.xml

    r15048 r15093  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<!-- 
    3  * LICENCE[[ 
    4  * Version: MPL 1.1/GPL 2.0/LGPL 2.1/CeCILL 2.O  
    5  * 
    6  * The contents of this file are subject to the Mozilla Public License Version  
    7  * 1.1 (the "License"); you may not use this file except in compliance with  
    8  * the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/  
    9  *  
    10  * Software distributed under the License is distributed on an "AS IS" basis,  
    11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License  
    12  * for the specific language governing rights and limitations under the  
    13  * License.  
    14  *  
    15  * The Original Code is kelis.fr code.  
    16  *  
    17  * The Initial Developer of the Original Code is  
    18  * sylvain.spinelli@kelis.fr  
    19  *  
    20  * Portions created by the Initial Developer are Copyright (C) 2009-2010 
    21  * the Initial Developer. All Rights Reserved.  
    22  *  
    23  * Contributor(s):  
    24  * samuel.monsarrat@kelis.fr  
    25  *  
    26  *  
    27  * Alternatively, the contents of this file may be used under the terms of  
    28  * either of the GNU General Public License Version 2 or later (the "GPL"),  
    29  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),  
    30  * or the CeCILL Licence Version 2.0 (http://www.cecill.info/licences.en.html),  
    31  * in which case the provisions of the GPL, the LGPL or the CeCILL are applicable  
    32  * instead of those above. If you wish to allow use of your version of this file  
    33  * only under the terms of either the GPL or the LGPL, and not to allow others  
    34  * to use your version of this file under the terms of the MPL, indicate your  
    35  * decision by deleting the provisions above and replace them with the notice  
    36  * and other provisions required by the GPL or the LGPL. If you do not delete  
    37  * the provisions above, a recipient may use your version of this file under  
    38  * the terms of any one of the MPL, the GPL, the LGPL or the CeCILL. 
    39  * ]]LICENCE 
    40   --> 
     3        * LICENCE[[ 
     4        * Version: MPL 1.1/GPL 2.0/LGPL 2.1/CeCILL 2.O  
     5        * 
     6        * The contents of this file are subject to the Mozilla Public License Version  
     7        * 1.1 (the "License"); you may not use this file except in compliance with  
     8        * the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/  
     9        *  
     10        * Software distributed under the License is distributed on an "AS IS" basis,  
     11        * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License  
     12        * for the specific language governing rights and limitations under the  
     13        * License.  
     14        *  
     15        * The Original Code is kelis.fr code.  
     16        *  
     17        * The Initial Developer of the Original Code is  
     18        * sylvain.spinelli@kelis.fr  
     19        *  
     20        * Portions created by the Initial Developer are Copyright (C) 2009-2010 
     21        * the Initial Developer. All Rights Reserved.  
     22        *  
     23        * Contributor(s):  
     24        * samuel.monsarrat@kelis.fr  
     25        *  
     26        *  
     27        * Alternatively, the contents of this file may be used under the terms of  
     28        * either of the GNU General Public License Version 2 or later (the "GPL"),  
     29        * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),  
     30        * or the CeCILL Licence Version 2.0 (http://www.cecill.info/licences.en.html),  
     31        * in which case the provisions of the GPL, the LGPL or the CeCILL are applicable  
     32        * instead of those above. If you wish to allow use of your version of this file  
     33        * only under the terms of either the GPL or the LGPL, and not to allow others  
     34        * to use your version of this file under the terms of the MPL, indicate your  
     35        * decision by deleting the provisions above and replace them with the notice  
     36        * and other provisions required by the GPL or the LGPL. If you do not delete  
     37        * the provisions above, a recipient may use your version of this file under  
     38        * the terms of any one of the MPL, the GPL, the LGPL or the CeCILL. 
     39        * ]]LICENCE 
     40          --> 
    4141 
    4242<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xbl="http://www.mozilla.org/xbl"> 
    4343         
    4444        <!--  
    45                 Slot des views principales (mainviews) éditables. 
    46                 Les views filles de ce slot peuvent définir les attributs supplémentairees suivants 
    47                 - dirty : view dirty nécessitant d'être enregistrée avant d'être fermée. 
    48                 - locked : Même si il n'est pas dirty, évite de remplacer le contenu. 
    49         --> 
     45                        Slot des views principales (mainviews) éditables. 
     46                        Les views filles de ce slot peuvent définir les attributs supplémentairees suivants 
     47                        - dirty : view dirty nécessitant d'être enregistrée avant d'être fermée. 
     48                        - locked : Même si il n'est pas dirty, évite de remplacer le contenu. 
     49                --> 
    5050        <binding id="slotContents" extends="chrome://scenariCore/content/widgets/matrix/matrix.xbl.xml#slot-base"> 
    5151                <content orient="vertical" flex="1" slotTabLocalName="slotTabContent" autoCollapse="false"> 
     
    5656                                </xul:arrowscrollbox> 
    5757                                <!-- TODO Historique 
    58                                 <xul:toolbarbutton label="&lt;" oncommand=""/> 
    59                                 <xul:toolbarbutton label="&gt;" oncommand=""/> 
    60                                 --> 
     58                                        <xul:toolbarbutton label="&lt;" oncommand=""/> 
     59                                        <xul:toolbarbutton label="&gt;" oncommand=""/> 
     60                                        --> 
    6161                                <xul:toolbarbutton anonid="maxBtn" oncommand="document.getBindingParent(this).toggleMaximizeBlock();"/> 
    6262                        </xul:hbox> 
     
    7575                                <parameter name="pView"/> 
    7676                                <body><![CDATA[ 
    77                                 try { 
    78                                         pTab.setAttribute("label", pView.getAttribute("label")||""); 
    79                                         pTab.setAttribute("image", pView.getAttribute("iconUrl")||""); 
    80                                         pTab.setAttribute("tooltiptext", pView.getAttribute("longDesc")||""); 
    81                                         pTab.setAttribute("accesskey", pView.getAttribute("accesskey")||""); 
    82                                         pTab.setAttribute("notClosable", ! (pView.getAttribute("closable")=="true")); 
    83                                         pTab.fSlot = this; 
    84                                         if(pView.getAttribute("dirty")=="true") { 
    85                                                 pTab.setAttribute("dirty", "true"); 
    86                                         } else { 
    87                                                 pTab.removeAttribute("dirty"); 
     77                                        try { 
     78                                                pTab.setAttribute("label", pView.getAttribute("label")||""); 
     79                                                pTab.setAttribute("image", pView.getAttribute("iconUrl")||""); 
     80                                                pTab.setAttribute("tooltiptext", pView.getAttribute("longDesc")||""); 
     81                                                pTab.setAttribute("accesskey", pView.getAttribute("accesskey")||""); 
     82                                                pTab.setAttribute("notClosable", ! (pView.getAttribute("closable")=="true")); 
     83                                                pTab.fSlot = this; 
     84                                                if(pView.getAttribute("dirty")=="true") { 
     85                                                        pTab.setAttribute("dirty", "true"); 
     86                                                } else { 
     87                                                        pTab.removeAttribute("dirty"); 
     88                                                } 
     89                                                if(pView.getAttribute("locked")=="true") { 
     90                                                        pTab.setAttribute("locked", "true"); 
     91                                                        if(pTab.fOptionMnuPinTab) pTab.fOptionMnuPinTab.setAttribute("checked", true); 
     92                                                } else { 
     93                                                        pTab.removeAttribute("locked"); 
     94                                                        if(pTab.fOptionMnuPinTab) pTab.fOptionMnuPinTab.setAttribute("checked", false); 
     95                                                } 
     96                                        } catch(e) { 
     97                                                log.debug("slot.fillTab::"+e); 
    8898                                        } 
    89                                         if(pView.getAttribute("locked")=="true") { 
    90                                                 pTab.setAttribute("locked", "true"); 
    91                                                 if(pTab.fOptionMnuPinTab) pTab.fOptionMnuPinTab.setAttribute("checked", true); 
    92                                         } else { 
    93                                                 pTab.removeAttribute("locked"); 
    94                                                 if(pTab.fOptionMnuPinTab) pTab.fOptionMnuPinTab.setAttribute("checked", false); 
    95                                         } 
    96                                 } catch(e) { 
    97                                         log.debug("slot.fillTab::"+e); 
    98                                 } 
    9999                                ]]></body> 
    100100                        </method> 
     
    110110                        <method name="closeAllTabs"> 
    111111                                <body><![CDATA[ 
    112                                 try { 
    113                                         var vTab = this.fTabsContainer.firstElementChild; 
    114                                         while(vTab && vTab.fView.getAttribute("locked")) vTab = vTab.nextElementSibling; 
    115                                         while(vTab) { 
    116                                                 if( ! vTab.closeTab()) return; 
    117                                                 vTab = this.fTabsContainer.firstElementChild; 
     112                                        try { 
     113                                                var vTab = this.fTabsContainer.firstElementChild; 
    118114                                                while(vTab && vTab.fView.getAttribute("locked")) vTab = vTab.nextElementSibling; 
     115                                                while(vTab) { 
     116                                                        if( ! vTab.closeTab()) return; 
     117                                                        vTab = this.fTabsContainer.firstElementChild; 
     118                                                        while(vTab && vTab.fView.getAttribute("locked")) vTab = vTab.nextElementSibling; 
     119                                                } 
     120                                        }catch(e){ 
     121                                                log.debug("slot.closeAllTabs::"+e); 
    119122                                        } 
    120                                 }catch(e){ 
    121                                         log.debug("slot.closeAllTabs::"+e); 
    122                                 } 
    123123                                ]]></body> 
    124124                        </method> 
     
    127127                                <parameter name="pCurrentTab"/> 
    128128                                <body><![CDATA[ 
    129                                 try { 
    130                                         log.info("closing all exept: "+pCurrentTab.label); 
    131                                         var vTab = pCurrentTab.nextElementSibling; 
    132                                         while(vTab && vTab.fView.getAttribute("locked")) vTab = vTab.nextElementSibling; 
    133                                         while(vTab) { 
    134                                                 if( ! vTab.closeTab()) return; 
    135                                                 vTab = pCurrentTab.nextElementSibling; 
     129                                        try { 
     130                                                log.info("closing all exept: "+pCurrentTab.label); 
     131                                                var vTab = pCurrentTab.nextElementSibling; 
    136132                                                while(vTab && vTab.fView.getAttribute("locked")) vTab = vTab.nextElementSibling; 
     133                                                while(vTab) { 
     134                                                        if( ! vTab.closeTab()) return; 
     135                                                        vTab = pCurrentTab.nextElementSibling; 
     136                                                        while(vTab && vTab.fView.getAttribute("locked")) vTab = vTab.nextElementSibling; 
     137                                                } 
     138                                                vTab = pCurrentTab.previousElementSibling; 
     139                                                while(vTab && vTab.fView.getAttribute("locked")) vTab = vTab.previousElementSibling; 
     140                                                while(vTab) { 
     141                                                        var vPrvTab = vTab.previousElementSibling; 
     142                                                        while(vPrvTab && vPrvTab.fView.getAttribute("locked")) vPrvTab = vPrvTab.previousElementSibling; 
     143                                                        if( ! vTab.closeTab()) return; 
     144                                                        vTab = vPrvTab; 
     145                                                } 
     146                                        }catch(e){ 
     147                                                log.debug("slot.closeOtherTabs::"+e); 
    137148                                        } 
    138                                         vTab = pCurrentTab.previousElementSibling; 
    139                                         while(vTab && vTab.fView.getAttribute("locked")) vTab = vTab.previousElementSibling; 
    140                                         while(vTab) { 
    141                                                 var vPrvTab = vTab.previousElementSibling; 
    142                                                 while(vPrvTab && vPrvTab.fView.getAttribute("locked")) vPrvTab = vPrvTab.previousElementSibling; 
    143                                                 if( ! vTab.closeTab()) return; 
    144                                                 vTab = vPrvTab; 
    145                                         } 
    146                                 }catch(e){ 
    147                                         log.debug("slot.closeOtherTabs::"+e); 
    148                                 } 
    149149                                ]]></body> 
    150150                        </method> 
     
    155155        <!-- Interne : onglets destinés pour le slotContents --> 
    156156        <binding id="slotTabContent" extends="chrome://scenariCore/content/widgets/matrix/matrix.xbl.xml#slotTab"> 
    157                 <content align="top"> 
    158                                 <children> 
    159                                         <xul:stack> 
    160                                                 <xul:hbox anonid="tabLabel" class="tabLabel" align="center"> 
    161                                 <xul:image class="tabLabelIco" xbl:inherits="src=image"/> 
    162                                         <xul:label class="small-margin tabLabelTxt" xbl:inherits="value=label" minwidth="20" crop="end"/> 
    163                                 <xul:image class="tabLabelFlags"/> 
    164                                                 </xul:hbox> 
    165                                                 <xul:hbox anonid="tabTools" class="tabTools" pack="end" align="top"> 
    166                                                         <xul:hbox anonid="tabToolBar"> 
    167                                                                 <xul:toolbarbutton anonid="optionBtn" class="optionBtn" onmousedown="document.getBindingParent(this).showOptionMnu(this)" tooltiptext="Options..."/> 
    168                                                 <xul:toolbarbutton anonid="closeBtn" class="closeBtn" oncommand="document.getBindingParent(this).closeTab();" tooltiptext="Fermer cet onglet"/> 
    169                                                         </xul:hbox> 
    170                                                 </xul:hbox> 
    171                                                 <xul:popup anonid="optionMnu"> 
    172                                 <xul:menuitem anonid="optionMnu.pinTab" label="Figer cet onglet" type="checkbox" oncommand="document.getBindingParent(this).pinTab();" tooltiptext=""/> 
    173                                 <xul:menuseparator/> 
    174                                 <xul:menuitem anonid="optionMnu.closeTab" label="Fermer cet onglet" oncommand="document.getBindingParent(this).closeTab();" tooltiptext=""/> 
    175                                 <xul:menuitem anonid="optionMnu.closeOtherTabs" label="Fermer les autres onglets" oncommand="document.getBindingParent(this).fSlot.closeOtherTabs(document.getBindingParent(this));" tooltiptext=""/> 
    176                                 <xul:menuitem anonid="optionMnu.closeAllTabs" label="Fermer tous les onglets" oncommand="document.getBindingParent(this).fSlot.closeAllTabs();" tooltiptext=""/> 
    177                                                 </xul:popup> 
    178                                         </xul:stack> 
    179                     </children> 
     157                <content align="top" contextmenu="_child"> 
     158                        <xul:menupopup anonid="optionMnu"> 
     159                                <xul:menuitem anonid="optionMnu.pinTab" label="Figer cet onglet" type="checkbox" oncommand="document.getBindingParent(this).pinTab();" tooltiptext=""/> 
     160                                <xul:menuseparator/> 
     161                                <xul:menuitem anonid="optionMnu.closeTab" label="Fermer cet onglet" oncommand="document.getBindingParent(this).closeTab();" tooltiptext=""/> 
     162                                <xul:menuitem anonid="optionMnu.closeOtherTabs" label="Fermer les autres onglets" oncommand="document.getBindingParent(this).fSlot.closeOtherTabs(document.getBindingParent(this));" tooltiptext=""/> 
     163                                <xul:menuitem anonid="optionMnu.closeAllTabs" label="Fermer tous les onglets" oncommand="document.getBindingParent(this).fSlot.closeAllTabs();" tooltiptext=""/> 
     164                        </xul:menupopup> 
     165                        <xul:stack> 
     166                                <xul:hbox anonid="tabLabel" class="tabLabel" align="center"> 
     167                                        <children> 
     168                                                <xul:image class="tabLabelIco" xbl:inherits="src=image"/> 
     169                                                <xul:label class="small-margin tabLabelTxt" xbl:inherits="value=label" minwidth="20" crop="end"/> 
     170                                        </children> 
     171                                        <xul:image class="tabLabelFlags"/> 
     172                                </xul:hbox> 
     173                                <xul:hbox anonid="tabTools" class="tabTools" pack="end" align="top"> 
     174                                        <xul:hbox anonid="tabToolBar"> 
     175                                                <xul:toolbarbutton anonid="optionBtn" class="optionBtn" onmousedown="document.getBindingParent(this).showOptionMnu(this)" tooltiptext="Options..."/> 
     176                                                <xul:toolbarbutton anonid="closeBtn" class="closeBtn" oncommand="document.getBindingParent(this).closeTab();" tooltiptext="Fermer cet onglet"/> 
     177                                        </xul:hbox> 
     178                                </xul:hbox> 
     179                        </xul:stack> 
    180180                </content> 
    181181                <implementation> 
    182                         <field name="fOptionMnu">document.getAnonymousElementByAttribute(this, "anonid", "optionMnu")</field> 
    183182                        <field name="fOptionMnuPinTab">document.getAnonymousElementByAttribute(this, "anonid", "optionMnu.pinTab")</field> 
    184183                        <field name="fOptionMnuCloseOtherTabs">document.getAnonymousElementByAttribute(this, "anonid", "optionMnu.closeOtherTabs")</field> 
    185184                        <field name="fOptionMnuCloseAllTabs">document.getAnonymousElementByAttribute(this, "anonid", "optionMnu.closeAllTabs")</field> 
    186                         <method name="showOptionMnu"> 
    187                                 <parameter name="pNode"/> 
    188                                 <body><![CDATA[ 
    189                                 try{ 
    190                                         var vHasTabs = this.fSlot.fTabsContainer.childElementCount > 1; 
    191                                         this.fOptionMnuCloseOtherTabs.hidden = !vHasTabs; 
    192                                         this.fOptionMnuCloseAllTabs.hidden = !vHasTabs; 
    193                                         this.fOptionMnu.openPopup(pNode, 'after_start', 0, 1, true, false); 
    194                                 }catch(e){log.debug("slotTabContent.showOptionMnu : "+e);} 
     185                        <method name="onPopupShowing"> 
     186                                <parameter name="pEvent"/> 
     187                                <body><![CDATA[ 
     188                                        try{ 
     189                                                var vHasTabs = this.fSlot.fTabsContainer.childElementCount > 1; 
     190                                                this.fOptionMnuCloseOtherTabs.hidden = !vHasTabs; 
     191                                                this.fOptionMnuCloseAllTabs.hidden = !vHasTabs; 
     192                                                this.fOptionMnu.openPopup(pNode, 'after_start', 0, 1, true, false); 
     193                                        }catch(e){log.debug("slotTabContent.onPopupShowing : "+e);} 
    195194                                ]]></body> 
    196195                        </method> 
    197196                        <method name="pinTab"> 
    198197                                <body><![CDATA[ 
    199                                 try{ 
    200                                         var vPinned = this.fView.getAttribute("locked") || false; 
    201                                         vPinned = !vPinned; 
    202                                         this.fOptionMnuPinTab.setAttribute("checked", vPinned); 
    203                                         this.fView.setAttribute("locked", vPinned); 
    204                                         if (vPinned) { 
    205                                                 this.setAttribute("locked", "true"); 
    206                                                 this.fView.setAttribute("locked", "true"); 
    207                                         } else { 
    208                                                 this.removeAttribute("locked"); 
    209                                                 this.fView.removeAttribute("locked"); 
    210                                         } 
    211                                 }catch(e){log.debug("slotTabContent.pinTab : "+e);} 
     198                                        try{ 
     199                                                var vPinned = this.fView.getAttribute("locked") || false; 
     200                                                vPinned = !vPinned; 
     201                                                this.fOptionMnuPinTab.setAttribute("checked", vPinned); 
     202                                                this.fView.setAttribute("locked", vPinned); 
     203                                                if (vPinned) { 
     204                                                        this.setAttribute("locked", "true"); 
     205                                                        this.fView.setAttribute("locked", "true"); 
     206                                                } else { 
     207                                                        this.removeAttribute("locked"); 
     208                                                        this.fView.removeAttribute("locked"); 
     209                                                } 
     210                                        }catch(e){log.debug("slotTabContent.pinTab : "+e);} 
    212211                                ]]></body> 
    213212                        </method> 
    214213                </implementation> 
    215     <handlers> 
    216       <handler event="mousedown" button="2" phase="capturing"><![CDATA[ 
    217       if (event.originalTarget.getAttribute("anonid") == "tabTools") { 
    218         event.stopPropagation(); 
    219         this.showOptionMnu(document.getAnonymousElementByAttribute(this, "anonid", "tabLabel")); 
    220       } 
    221             ]]></handler> 
    222     </handlers> 
    223214        </binding> 
    224215</bindings> 
Note: See TracChangeset for help on using the changeset viewer.