Grammalecte  Check-in [8a0279f8fd]

Overview
Comment:[tb] spelling dictionary selection
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | tb
Files: files | file ages | folders
SHA3-256: 8a0279f8fd8df8a3ef6b4385daeceea51301ec54568b6dee546f86827a875a11
User & Date: olr on 2020-02-03 09:40:02
Other Links: manifest | tags
Context
2020-02-03
11:03
[fx] GC panel: small UI update check-in: c2317dc2f9 user: olr tags: fx, trunk
09:40
[tb] spelling dictionary selection check-in: 8a0279f8fd user: olr tags: tb, trunk
2020-02-02
10:51
[lo] recenseur de mots: boîte de dialogue fermable via la croix rouge check-in: 9460b6ed05 user: olr tags: lo, trunk
2020-01-20
23:35
[tb] text formatter: progressbar Closed-Leaf check-in: ee415784e6 user: olr tags: tb, tbso
Changes

Modified gc_core/py/oxt/helpers.py from [c3e413f4e7] to [730b24becd].

    17     17           xContext.ServiceManager.createInstance("apso.python.script.organizer.impl")
    18     18           # now we can import apso_utils library
    19     19           from apso_utils import console
    20     20           console()
    21     21       except:
    22     22           try:
    23     23               xContext = uno.getComponentContext()
    24         -            xSvMgr = xContext.getServiceManager()
    25         -            xPathSettings = xSvMgr.createInstanceWithContext("com.sun.star.util.PathSettings", xContext)
           24  +            xPathSettings = xContext.ServiceManager.createInstanceWithContext("com.sun.star.util.PathSettings", xContext)
    26     25               spPyInstallion = uno.fileUrlToSystemPath(xPathSettings.Module)
    27     26               subprocess.Popen(spPyInstallion + os.sep + "python")  # Start Python interactive Shell
    28     27           except:
    29     28               traceback.print_exc()
    30     29   
    31     30   
    32     31   def xray (xObject):

Modified gc_lang/fr/mailext/content/overlay.css from [7766f680c2] to [34648cdf92].

    35     35   }
    36     36   .optiongroup {
    37     37       color: hsl(210, 50%, 40%);
    38     38       font-size: 14px;
    39     39       font-weight: bold;
    40     40   }
    41     41   #textformatter-progressbar {
    42         -    padding: 5px;
           42  +    width: 470px;
    43     43   }
    44     44   #textformatter-timer {
    45     45       padding: 5px;
    46     46   }
    47     47   
    48     48   
    49     49   #grammarchecker-panel {

Modified gc_lang/fr/mailext/content/overlay.js from [3152c4204d] to [382be936c1].

    40     40               this.xGCEWorker = new BasePromiseWorker('chrome://promiseworker/content/gce_worker.js');
    41     41               let that = this;
    42     42               let xPromise = this.xGCEWorker.post('loadGrammarChecker', [prefs.getCharPref("sGCOptions"), "Thunderbird"]);
    43     43               xPromise.then(
    44     44                   function (aVal) {
    45     45                       console.log(aVal);
    46     46                       prefs.setCharPref("sGCOptions", aVal);
           47  +                    // spelling dictionary
           48  +                    if (prefs.getCharPref("sMainDicName")) {
           49  +                        let sMainDicName = prefs.getCharPref("sMainDicName");
           50  +                        if (sMainDicName == "fr-classic.json" || sMainDicName == "fr-reform.json") {
           51  +                            that.xGCEWorker.post("setDictionary", ["main", sMainDicName]);
           52  +                        }
           53  +                    }
           54  +                    // personal dictionary
    47     55                       if (prefs.getBoolPref("bPersonalDictionary")) {
    48     56                           let sDicJSON = oFileHandler.loadFile("fr.personal.json");
    49     57                           if (sDicJSON) {
    50     58                               that.xGCEWorker.post('setDictionary', ["personal", sDicJSON]);
    51     59                           }
    52     60                       }
    53     61                   },
................................................................................
   822    830                       }
   823    831                       document.getElementById('res_o_ma_word').textContent = n1;
   824    832                   }
   825    833                   document.getElementById("o_group_misc").checked = false;
   826    834                   this.switchGroup("o_group_misc");
   827    835               }
   828    836               document.getElementById('textformatter-progressbar').value = document.getElementById('textformatter-progressbar').max;
   829         -            document.getElementById('textformatter-progressbar').value = "Formatage terminé.";
   830    837               // end of processing
   831    838   
   832    839               //window.setCursor("auto"); // restore pointer
   833    840               const t1 = Date.now();
   834    841               document.getElementById('textformatter-timer').textContent = this.getTimeRes((t1-t0)/1000);
   835    842           }
   836    843           catch (e) {

Modified gc_lang/fr/mailext/content/overlay.xul from [f36fdba70a] to [a2a481fd03].

     1      1   <?xml version="1.0" encoding="UTF-8"?>
     2      2   <?xml-stylesheet href="chrome://grammarchecker/content/overlay.css" type="text/css"?>
     3      3   <?xml-stylesheet type="text/css" href="chrome://messenger/skin/messenger.css"?>
     4      4   
     5      5   <!DOCTYPE overlay SYSTEM "chrome://grammarchecker/locale/overlay.dtd">
     6      6   
     7      7   <overlay id="grammarchecker-overlay"
            8  +         xmlns:html="http://www.w3.org/1999/xhtml"
     8      9            xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     9     10   
    10     11     <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
    11     12     <script type="application/javascript" src="chrome://messenger/content/customElements.js"/>
    12     13     <script type="application/javascript" src="resource://grammalecte/text.js"/>
    13     14     <script type="application/javascript" src="resource://grammalecte/fr/textformatter.js"/>
    14     15     <script type="application/javascript" src="overlay.js"/>
................................................................................
   341    342   
   342    343             <description id="textformatter-infomsg">&tf_infomsg;</description>
   343    344           </vbox>
   344    345         </hbox>
   345    346   
   346    347         <hbox id="textformatter-commands">
   347    348           <button id="reset" label="&tf.button.default;" oncommand="oTextFormatter.onReset(event);" />
   348         -        <!-- <html:progress id="textformatter-progressbar" max="470">-->
   349         -        <label id="textformatter-progressbar" width="470">...</label>
          349  +        <html:progress id="textformatter-progressbar" max="6"></html:progress>
   350    350           <label id="textformatter-timer" width="50"></label>
   351    351           <button id="apply" label="&tf.button.apply;" oncommand="oTextFormatter.onApply(event);" />
   352    352           <button id="close" label="&tf.button.close;" oncommand="oTextFormatter.onClosePanel(event);" />
   353    353         </hbox>
   354    354   
   355    355       </vbox>
   356    356   

Modified gc_lang/fr/mailext/content/spell_options.css from [e88f1b0c74] to [377d800f5a].

     1      1   /* CSS */
     2      2   
     3      3   #grouptitle {
     4         -	font-size: 16px;
     5         -	font-weight: bold;
     6         -	color: hsl(0, 50%, 50%);
            4  +    font-size: 16px;
            5  +    font-weight: bold;
            6  +    color: hsl(0, 50%, 50%);
     7      7   }
     8      8   
     9      9   .option {
    10         -	font-size: 16px;
    11         -	font-weight: bold;
    12         -	color: hsl(210, 50%, 50%);
           10  +    font-size: 16px;
           11  +    font-weight: bold;
           12  +    color: hsl(210, 50%, 50%);
           13  +}
           14  +
           15  +.suboption {
           16  +    margin-left: 30px;
           17  +    font-size: 16px;
           18  +    font-weight: bold;
           19  +    color: hsl(210, 50%, 50%);
           20  +}
           21  +.suboption2 {
           22  +    margin-left: 30px;
    13     23   }
    14     24   
    15     25   description {
    16         -	width: 340px;
           26  +    width: 340px;
    17     27   }
    18     28   
    19     29   .dicdescr {
    20         -	margin-left: 27px;
           30  +      margin-left: 27px;
    21     31   }
    22     32   
    23     33   .disabled {
    24         -  opacity: .25;
           34  +    opacity: .25;
    25     35   }
    26     36   
    27     37   
    28     38   .dialogheader-title {
    29         -  margin: 5px;
    30         -  padding: 5px 8px;
    31         -  border: 1px solid hsl(210, 50%, 80%);
    32         -  background-color: hsl(210, 50%, 50%);
    33         -  color: hsl(210, 10%, 90%);
    34         -  font-size: larger;
    35         -  font-weight: bold;
           39  +    margin: 5px;
           40  +    padding: 5px 8px;
           41  +    border: 1px solid hsl(210, 50%, 80%);
           42  +    background-color: hsl(210, 50%, 50%);
           43  +    color: hsl(210, 10%, 90%);
           44  +    font-size: larger;
           45  +    font-weight: bold;
    36     46   }

Modified gc_lang/fr/mailext/content/spell_options.js from [2d7adbf6a9] to [d5cdd1e710].

    10     10   
    11     11   
    12     12   var oDialogControl = {
    13     13       load: function () {
    14     14           try {
    15     15               // center window
    16     16               document.getElementById('grammalecte-spelloptions-window').centerWindowOnScreen();
    17         -            // Graphspell dictionaries
           17  +            // main spelling dictionary
           18  +            let sMainDicName = prefs.getCharPref('sMainDicName');
           19  +            console.log("spelling dictionary:", sMainDicName);
           20  +            if (sMainDicName == "fr-classic.json") {
           21  +                document.getElementById("classic").checked = true;
           22  +            }
           23  +            else if (sMainDicName == "fr-reform.json") {
           24  +                document.getElementById("reform").checked = true;
           25  +            }
           26  +            else if (sMainDicName == "fr-allvars.json") {
           27  +                document.getElementById("allvars").checked = true;
           28  +            }
           29  +            // personal dictionary
    18     30               document.getElementById('personal_dic').checked = prefs.getBoolPref('bPersonalDictionary');
           31  +            // listen
    19     32               this.listen();
    20     33           }
    21     34           catch (e) {
    22     35               console.error(e);
    23     36           }
    24     37       },
    25     38       listen: function () {
    26     39           document.addEventListener("dialogaccept", (event) => {
    27     40               oDialogControl.setDictionaries();
    28     41           });
           42  +        document.getElementById("classic").addEventListener("click", (event) => {
           43  +            oDialogControl.changeMainDicUI("classic");
           44  +        });
           45  +        document.getElementById("reform").addEventListener("click", (event) => {
           46  +            oDialogControl.changeMainDicUI("reform");
           47  +        });
           48  +        document.getElementById("allvars").addEventListener("click", (event) => {
           49  +            oDialogControl.changeMainDicUI("allvars");
           50  +        });
           51  +    },
           52  +    changeMainDicUI (sDic) {
           53  +        document.getElementById("classic").checked = ("classic" === sDic);
           54  +        document.getElementById("reform").checked = ("reform" === sDic);
           55  +        document.getElementById("allvars").checked = ("allvars" === sDic);
    29     56       },
    30     57       setDictionaries: function () {
    31         -        oSpellControl.init();
    32         -        this._setGraphspellDictionaries();
    33         -    },
    34         -    _setGraphspellDictionaries: function () {
           58  +        //oSpellControl.init();
           59  +        // main spelling dictionary
           60  +        let sMainDicName = "";
           61  +        if (document.getElementById("classic").checked) {
           62  +            sMainDicName = "fr-classic.json";
           63  +        }
           64  +        else if (document.getElementById("reform").checked) {
           65  +            sMainDicName = "fr-reform.json";
           66  +        }
           67  +        else if (document.getElementById("allvars").checked) {
           68  +            sMainDicName = "fr-allvars.json";
           69  +        }
           70  +        console.log("selected spelling dictionary:", sMainDicName);
           71  +        prefs.setCharPref("sMainDicName", sMainDicName);
           72  +        // personal dictionary
    35     73           let bActivate = document.getElementById('personal_dic').checked;
    36     74           prefs.setBoolPref("bPersonalDictionary", bActivate);
    37     75       }
    38     76   };

Modified gc_lang/fr/mailext/content/spell_options.xul from [218f35c9f4] to [abb535b915].

     6      6   
     7      7   <dialog
     8      8     id="grammalecte-spelloptions-window"
     9      9     title="&window.title;"
    10     10     orient="vertical"
    11     11     buttons="accept,cancel"
    12     12     width="400"
    13         -  height="300"
           13  +  height="330"
    14     14     onload="oDialogControl.load();"
    15     15     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    16     16   
    17     17     <!-- Other elements go here -->
    18     18   
    19     19     <div class="dialogheader-title">&dialogheader.label;</div>
    20     20   
................................................................................
    37     37   
    38     38       <groupbox with="380">
    39     39         <caption id="grouptitle" label="&grouptitle_graphspell;" />
    40     40         <description id="warning">&warning_graphspell;</description>
    41     41   
    42     42         <checkbox id="main_dic" class="option" label="&option.main_dic.label;" disabled="true" checked="true" />
    43     43         <description class="dicdescr">&option.main_dic.descr;</description>
           44  +      <label class="suboption" value="&option.main_dic.spelling;" />
           45  +      <hbox class="suboption2" >
           46  +        <checkbox id="classic" label="&option.main_dic.classic;" checked="false" />
           47  +        <checkbox id="reform" label="&option.main_dic.reform;" checked="false" />
           48  +        <checkbox id="allvars" label="&option.main_dic.allvars;" checked="false" />
           49  +      </hbox>
           50  +      <!--<radiogroup id="main_dic_name" class="suboption2" orient="horizontal">
           51  +        <radio id="classic" label="&option.main_dic.classic;" value="fr-classic.json" />
           52  +        <radio id="reform" label="&option.main_dic.reform;" value="fr-reform.json" />
           53  +        <radio id="allvars" label="&option.main_dic.allvars;" value="fr-allvars.json" />
           54  +      </radiogroup>-->
    44     55   
    45     56         <checkbox id="community_dic" class="option disabled" label="&option.community_dic.label;" disabled="true" />
    46     57         <description class="dicdescr disabled">&option.community_dic.descr;</description>
    47     58   
    48     59         <checkbox id="personal_dic" class="option" label="&option.personal_dic.label;" />
    49     60         <description class="dicdescr">&option.personal_dic.descr;</description>
    50     61       </groupbox>
    51     62     </hbox>
    52     63   
    53     64     <script type="application/javascript" src="spell_options.js"/>
    54     65     <script type="application/javascript" src="spellchecker.js"/>
    55     66   
    56     67   </dialog>

Modified gc_lang/fr/mailext/defaults/preferences/grammarchecker.js from [1b1284d83a] to [8769787af8].

     1      1   pref("extensions.grammarchecker.sGCOptions", "");
     2      2   pref("extensions.grammarchecker.sTFOptions", "");
     3      3   pref("extensions.grammarchecker.bDictModern", false);
     4      4   pref("extensions.grammarchecker.bDictClassic", true);
     5      5   pref("extensions.grammarchecker.bDictReform", false);
     6      6   pref("extensions.grammarchecker.bDictClassicReform", false);
     7      7   pref("extensions.grammarchecker.bCheckSignature", true);
     8         -pref("extensions.grammarchecker.bExtendedDictionary", false);
            8  +pref("extensions.grammarchecker.sMainDicName", "fr-allvars.json");
     9      9   pref("extensions.grammarchecker.bCommunityDictionary", false);
    10     10   pref("extensions.grammarchecker.bPersonalDictionary", true);

Modified gc_lang/fr/mailext/gce_worker.js from [75d21bf0e4] to [3191c72f90].

   351    351       if (!oSpellChecker) {
   352    352           postMessage(createResponse("setDictionary", "# Error. SpellChecker not loaded.", dInfo, true));
   353    353           return;
   354    354       }
   355    355       //console.log("setDictionary", sDictionary);
   356    356       switch (sDictionary) {
   357    357           case "main":
   358         -            oSpellChecker.setMainDictionary(oDict);
          358  +            oSpellChecker.setMainDictionary(oDict, dInfo["sExtPath"]+"/grammalecte/graphspell/_dictionaries");
   359    359               break;
   360    360           case "community":
   361    361               oSpellChecker.setCommunityDictionary(oDict);
   362    362               break;
   363    363           case "personal":
   364    364               oSpellChecker.setPersonalDictionary(oDict);
   365    365               break;

Modified gc_lang/fr/mailext/locale/en/spell_options.dtd from [d953b5f96a] to [fc8174b93b].

     1      1   <!ENTITY window.title "Grammalecte · Spelling options">
     2      2   <!ENTITY dialogheader.label "Spelling options">
     3      3   
     4      4   <!ENTITY grouptitle_graphspell "Graphspell Dictionaries (Grammalecte)">
     5      5   <!ENTITY warning_graphspell "These dictionaries are used only when analyzing texts.">
     6      6   <!ENTITY option.main_dic.label "Main dictionary">
     7      7   <!ENTITY option.main_dic.descr "About 83 000 entries, 500 000 flexions. Not editable, not deactivable.">
            8  +<!ENTITY option.main_dic.spelling "Spelling">
            9  +<!ENTITY option.main_dic.classic "Classic">
           10  +<!ENTITY option.main_dic.reform "Reform 1990">
           11  +<!ENTITY option.main_dic.allvars "All variants">
     8     12   <!ENTITY option.community_dic.label "Community dictionary">
     9     13   <!ENTITY option.community_dic.descr "Feature to come..">
    10     14   <!ENTITY option.personal_dic.label "Personal dictionary">
    11     15   <!ENTITY option.personal_dic.descr "The personal dictionary is created and edited via the lexicon editor.">
    12     16   
    13     17   <!ENTITY grouptitle_hunspell "Hunspell Dictionaries (Thunderbird)">
    14     18   <!ENTITY warning_hunspell "These dictionaries are only used when you are writing texts (red underlining). Select dictionaries you want to see in textareas list. Selected dictionaries are added instantly. Whereas unselected dictionnaries will be removed only at Thunderbird’s restart.">

Modified gc_lang/fr/mailext/locale/fr/spell_options.dtd from [f2b4df7a35] to [5ab4900b2b].

     1      1   <!ENTITY window.title "Grammalecte · Options orthographiques">
     2      2   <!ENTITY dialogheader.label "Options orthographiques">
     3      3   
     4      4   <!ENTITY grouptitle_graphspell "Dictionnaires de Grammalecte">
     5      5   <!ENTITY warning_graphspell "Ces dictionnaires ne sont utilisés que lors de l’analyse grammaticale.">
     6      6   <!ENTITY option.main_dic.label "Dictionnaire principal">
     7      7   <!ENTITY option.main_dic.descr "Environ 83 000 entrées, 500 000 flexions. Ni éditable, ni désactivable.">
            8  +<!ENTITY option.main_dic.spelling "Orthographe">
            9  +<!ENTITY option.main_dic.classic "Classique">
           10  +<!ENTITY option.main_dic.reform "Réforme 1990">
           11  +<!ENTITY option.main_dic.allvars "Toutes variantes">
     8     12   <!ENTITY option.community_dic.label "Dictionnaire communautaire">
     9     13   <!ENTITY option.community_dic.descr "Fonctionnalité à venir.">
    10     14   <!ENTITY option.personal_dic.label "Dictionnaire personnel">
    11     15   <!ENTITY option.personal_dic.descr "Le dictionnaire personnel est créé et édité via l’éditeur lexical.">
    12     16   
    13     17   <!ENTITY grouptitle_hunspell "Dictionnaires Hunspell (Thunderbird)">
    14     18   <!ENTITY warning_hunspell "Ces dictionnaires ne sont utilisés que lors de l’écriture de texte (soulignement rouge). Cochez les dictionnaires que vous voulez voir apparaître dans la liste des dictionnaires utilisables. L’ajout des dictionnaires se fait instantanément. En revanche, les dictionnaires ôtés ne disparaîtront qu’au redémarrage de Thunderbird.">

Modified gc_lang/fr/mailext/worker/gce_worker.js from [086c0afb9f] to [abd0c9c4ba].

    73     73           }
    74     74           catch (e) {
    75     75               console.log("# Error: " + e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
    76     76           }
    77     77       }
    78     78   }
    79     79   
    80         -function setDictionary (sTypeDic, sDicJSON) {
           80  +function setDictionary (sTypeDic, sDictionary) {
    81     81       try {
    82     82           console.log("set dictionary: " + sTypeDic);
    83         -        let oJSON = JSON.parse(sDicJSON);
    84     83           switch (sTypeDic) {
    85         -            case "extended":
           84  +            case "main":
           85  +                oSpellChecker.setMainDictionary(sDictionary);
    86     86                   break;
    87     87               case "community":
    88     88                   break;
    89     89               case "personal":
           90  +                let oJSON = JSON.parse(sDictionary);
    90     91                   oSpellChecker.setPersonalDictionary(oJSON);
    91     92                   break;
    92     93               default:
    93     94                   console.log("[GCE worker] unknown dictionary type");
    94     95           }
    95     96       }
    96     97       catch (e) {