Grammalecte  Check-in [edf22c7d52]

Overview
Comment:[lo] UI for dictionaries options
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | lo | multid
Files: files | file ages | folders
SHA3-256: edf22c7d521bdb22bc7cfa36f9dc59bb6ad836013e01ef1d110f3abf69865ad8
User & Date: olr on 2018-02-18 16:28:02
Other Links: branch diff | manifest | tags
Context
2018-02-19
09:44
merge trunk check-in: 0b7150270a user: olr tags: multid
2018-02-18
16:28
[lo] UI for dictionaries options check-in: edf22c7d52 user: olr tags: lo, multid
10:13
[tb] merge trunk: fix bugs check-in: bce8dea5b0 user: olr tags: multid, tb
Changes

Modified gc_lang/fr/config.ini from [4ba46a1e3e] to [08f47bce51].

    80     80   oxt/About/About.py = pythonpath/About.py
    81     81   oxt/About/ab_strings.py = pythonpath/ab_strings.py
    82     82   # Dictionaries
    83     83   oxt/Dictionnaires/dictionaries = dictionaries
    84     84   oxt/Dictionnaires/dictionaries.xcu = dictionaries.xcu
    85     85   oxt/Dictionnaires/DictionarySwitcher.py = pythonpath/DictionarySwitcher.py
    86     86   oxt/Dictionnaires/ds_strings.py = pythonpath/ds_strings.py
           87  +# Dictionary Options
           88  +oxt/DictOptions/DictOptions.py = pythonpath/DictOptions.py
           89  +oxt/DictOptions/do_strings.py = pythonpath/do_strings.py
    87     90   # ContextMenu
    88     91   oxt/ContextMenu/ContextMenu.py = ContextMenu.py
    89     92   oxt/ContextMenu/jobs.xcu = config/jobs.xcu
    90     93   # TextFormatter
    91     94   oxt/TextFormatter/TextFormatter.py = pythonpath/TextFormatter.py
    92     95   oxt/TextFormatter/tf_strings.py = pythonpath/tf_strings.py
    93     96   oxt/TextFormatter/tf_options.py = pythonpath/tf_options.py
    94     97   oxt/TextFormatter/tf_tabrep.py = pythonpath/tf_tabrep.py
    95     98   # Conjugueur
    96     99   oxt/Conjugueur/Conjugueur.py = pythonpath/Conjugueur.py
    97    100   # Modify author
    98    101   oxt/ChangeAuthor/Author.py = pythonpath/Author.py
    99    102   oxt/ChangeAuthor/ca_strings.py = pythonpath/ca_strings.py

Modified gc_lang/fr/oxt/AppLauncher.py from [30bcae4623] to [851c2d6eab].

    38     38                       xDialog.run(sCmd[3:])
    39     39                   else:
    40     40                       xDialog.run()
    41     41               elif sCmd == "TF":
    42     42                   import TextFormatter
    43     43                   xDialog = TextFormatter.TextFormatter(self.ctx)
    44     44                   xDialog.run(self.sLang)
           45  +            elif sCmd == "DI":
           46  +                import DictOptions
           47  +                xDialog = DictOptions.DictOptions(self.ctx)
           48  +                xDialog.run(self.sLang)
    45     49               elif sCmd == "DS":
    46     50                   import DictionarySwitcher
    47     51                   xDialog = DictionarySwitcher.FrenchDictionarySwitcher(self.ctx)
    48     52                   xDialog.run(self.sLang)
    49     53               elif sCmd == "MA":
    50     54                   import Author
    51     55                   xDialog = Author.Author(self.ctx)

Added gc_lang/fr/oxt/DictOptions/DictOptions.py version [57f1f35e15].

            1  +# Dictionary Options
            2  +# by Olivier R.
            3  +# License: MPL 2
            4  +
            5  +import unohelper
            6  +import uno
            7  +import traceback
            8  +
            9  +import helpers
           10  +import do_strings
           11  +
           12  +from com.sun.star.task import XJobExecutor
           13  +from com.sun.star.awt import XActionListener
           14  +from com.sun.star.beans import PropertyValue
           15  +
           16  +
           17  +class DictOptions (unohelper.Base, XActionListener, XJobExecutor):
           18  +
           19  +    def __init__ (self, ctx):
           20  +        self.ctx = ctx
           21  +        self.xSvMgr = self.ctx.ServiceManager
           22  +        self.xContainer = None
           23  +        self.xDialog = None
           24  +        
           25  +    def _addWidget (self, name, wtype, x, y, w, h, **kwargs):
           26  +        xWidget = self.xDialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype)
           27  +        xWidget.Name = name
           28  +        xWidget.PositionX = x
           29  +        xWidget.PositionY = y
           30  +        xWidget.Width = w
           31  +        xWidget.Height = h
           32  +        for k, w in kwargs.items():
           33  +            setattr(xWidget, k, w)
           34  +        self.xDialog.insertByName(name, xWidget)
           35  +        return xWidget
           36  +
           37  +    def run (self, sLang):
           38  +        dUI = do_strings.getUI(sLang)
           39  +
           40  +        # what is the current dictionary
           41  +        xSettings = helpers.getConfigSetting("/org.openoffice.Office.Linguistic/ServiceManager/Dictionaries/HunSpellDic_fr", False)
           42  +        xLocations = xSettings.getByName("Locations")
           43  +        
           44  +        # dialog
           45  +        self.xDialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx)
           46  +        self.xDialog.Width = 200
           47  +        self.xDialog.Height = 290
           48  +        self.xDialog.Title = dUI.get('title', "#title#")
           49  +        xWindowSize = helpers.getWindowSize()
           50  +        self.xDialog.PositionX = int((xWindowSize.Width / 2) - (self.xDialog.Width / 2))
           51  +        self.xDialog.PositionY = int((xWindowSize.Height / 2) - (self.xDialog.Height / 2))
           52  +
           53  +        # fonts
           54  +        xFDTitle = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
           55  +        xFDTitle.Height = 9
           56  +        xFDTitle.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD")
           57  +        xFDTitle.Name = "Verdana"
           58  +        
           59  +        xFDSubTitle = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
           60  +        xFDSubTitle.Height = 8
           61  +        xFDSubTitle.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD")
           62  +        xFDSubTitle.Name = "Verdana"
           63  +
           64  +        # widget
           65  +        nX = 10
           66  +        nY1 = 10
           67  +        nY2 = nY1 + 50
           68  +        nY3 = nY2 + 70
           69  +
           70  +        nWidth = self.xDialog.Width - 20
           71  +        nHeight = 10
           72  +
           73  +        # Spell checker section
           74  +        self._addWidget("spelling_section", 'FixedLine', nX, nY1, nWidth, nHeight, Label = dUI.get("spelling_section", "#err"), FontDescriptor = xFDTitle)
           75  +        self.xActivateMain = self._addWidget('activate_main', 'CheckBox', nX, nY1+15, nWidth, nHeight, Label = dUI.get('activate_main', "#err"), State = True)
           76  +        self._addWidget('activate_main_descr', 'FixedText', nX, nY1+25, nWidth, nHeight*2, Label = dUI.get('activate_main_descr', "#err"), MultiLine = True)
           77  +
           78  +        # Spell suggestion engine section
           79  +        self._addWidget("suggestion_section", 'FixedLine', nX, nY2, nWidth, nHeight, Label = dUI.get("suggestion_section", "#err"), FontDescriptor = xFDTitle)
           80  +        self.xActivateSugg = self._addWidget('activate_spell_sugg', 'CheckBox', nX, nY2+15, nWidth, nHeight, Label = dUI.get('activate_spell_sugg', "#err"), State = True)
           81  +        self._addWidget('activate_spell_sugg_descr', 'FixedText', nX, nY2+25, nWidth, nHeight*4, Label = dUI.get('activate_spell_sugg_descr', "#err"), MultiLine = True)
           82  +
           83  +        # Personal dictionary section
           84  +        self._addWidget("personal_section", 'FixedLine', nX, nY3, nWidth, nHeight, Label = dUI.get("personal_section", "#err"), FontDescriptor = xFDTitle)
           85  +        self.xActivatePersonnal = self._addWidget('activate_personal', 'CheckBox', nX, nY3+15, nWidth, nHeight, Label = dUI.get('activate_personal', "#err"), State = True)
           86  +        self._addWidget('activate_personnal_descr', 'FixedText', nX, nY3+25, nWidth, nHeight*3, Label = dUI.get('activate_personal_descr', "#err"), MultiLine = True)
           87  +        self._addWidget('import_personal', 'FixedText', nX, nY3+55, nWidth, nHeight, Label = dUI.get('import_personal', "#err"), FontDescriptor = xFDSubTitle)
           88  +
           89  +        self._addWidget('create_dictionary', 'FixedText', nX, nY3+75, nWidth, nHeight*2, Label = dUI.get('create_dictionary', "#err"), MultiLine = True)
           90  +
           91  +        # Button
           92  +        self._addWidget('apply_button', 'Button', self.xDialog.Width-120, self.xDialog.Height-25, 50, 14, Label = dUI.get('apply_button', "#err"), TextColor = 0x00AA00)
           93  +        self._addWidget('cancel_button', 'Button', self.xDialog.Width-10, self.xDialog.Height-25, 50, 14, Label = dUI.get('cancel_button', "#err"), TextColor = 0xAA0000)
           94  +
           95  +        # container
           96  +        self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx)
           97  +        self.xContainer.setModel(self.xDialog)
           98  +        self.xContainer.getControl('apply_button').addActionListener(self)
           99  +        self.xContainer.getControl('apply_button').setActionCommand('Apply')
          100  +        self.xContainer.getControl('cancel_button').addActionListener(self)
          101  +        self.xContainer.getControl('cancel_button').setActionCommand('Cancel')
          102  +        self.xContainer.setVisible(False)
          103  +        toolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
          104  +        self.xContainer.createPeer(toolkit, None)
          105  +        self.xContainer.execute()
          106  +    
          107  +    # XActionListener
          108  +    def actionPerformed (self, xActionEvent):
          109  +        try:
          110  +            if xActionEvent.ActionCommand == 'Apply':
          111  +                if False:
          112  +                    # Modify the registry
          113  +                    xSettings = helpers.getConfigSetting("/org.openoffice.Office.Linguistic/ServiceManager/Dictionaries/HunSpellDic_fr", True)
          114  +                    xLocations = xSettings.getByName("Locations")
          115  +                    v1 = xLocations[0].replace(self.sCurrentDic, self.sSelectedDic)
          116  +                    v2 = xLocations[1].replace(self.sCurrentDic, self.sSelectedDic)
          117  +                    #xSettings.replaceByName("Locations", xLocations)  # doesn't work, see line below
          118  +                    uno.invoke(xSettings, "replaceByName", ("Locations", uno.Any("[]string", (v1, v2))))
          119  +                    xSettings.commitChanges()
          120  +            self.xContainer.endExecute()
          121  +        except:
          122  +            traceback.print_exc()
          123  +    
          124  +    # XJobExecutor
          125  +    def trigger (self, args):
          126  +        try:
          127  +            dialog = DictOptions(self.ctx)
          128  +            dialog.run()
          129  +        except:
          130  +            traceback.print_exc()
          131  +
          132  +
          133  +#g_ImplementationHelper = unohelper.ImplementationHelper()
          134  +#g_ImplementationHelper.addImplementation(DictOptions, 'net.grammalecte.graphspell.DictOptions', ('com.sun.star.task.Job',))

Added gc_lang/fr/oxt/DictOptions/do_strings.py version [e9755e38d0].

            1  +def getUI (sLang):
            2  +    if sLang in dStrings:
            3  +        return dStrings[sLang]
            4  +    return dStrings["fr"]
            5  +
            6  +dStrings = {
            7  +    "fr": {
            8  +        "title": "Grammalecte · Options des dictionnaires",
            9  +        
           10  +        "spelling_section": "Correcteur orthographique",
           11  +        "activate_main": "Activer le correcteur orthographique de Grammalecte",
           12  +        "activate_main_descr": "Supplante le correcteur orthographique inclus dans LibreOffice (Hunspell)",
           13  +
           14  +        "personal_section": "Dictionnaire personnel",
           15  +        "activate_personal": "Utiliser",
           16  +        "activate_personal_descr": "Le dictionnaire personnel est une commodité pour ajouter le vocabulaire qui vous est utile. Il ne supplante pas le dictionnaire commun ; il ne fait qu’ajouter de nouveaux mots.",
           17  +        "import_personal": "Importer un dictionnaire personnel",
           18  +        "import": "Importer",
           19  +        "create_dictionary": "Vous pouvez créer un dictionnaire personnel avec l’extension Grammalecte pour Firefox ou Chrome",
           20  +
           21  +        "suggestion_section": "Moteur de suggestion orthographique",
           22  +        "activate_spell_sugg": "Activer le moteur de suggestion de Grammalecte",
           23  +        "activate_spell_sugg_descr": "Désactivée, cette option remplace la suggestion orthographique de Grammalecte par celle fournie par LibreOffice (Hunspell). Les mots inclus dans le dictionnaire personnalisé ne seront plus inclus aux suggestions.",
           24  +
           25  +        "apply_button": "Appliquer",
           26  +        "cancel_button": "Annuler",
           27  +    },
           28  +    "en": {
           29  +        "title": "Grammalecte · Options for dictionaries",
           30  +        
           31  +        "spelling_section": "Spell checker",
           32  +        "activate_main": "Activate the spell checker from Grammalecte",
           33  +        "activate_main_descr": "Overrides the spell checker included in LibreOffice (Hunspell)",
           34  +
           35  +        "personal_section": "Personal dictionary",
           36  +        "activate_personal": "Use",
           37  +        "activate_personal_descr": "The personal dictionary is a commodity to add the vocabulary you want. It doesn’t override the common dictionary ; it only adds new words.",
           38  +        "import_personal": "Import a personal dictionary",
           39  +        "import": "Import",
           40  +        "create_dictionary": "You can create a personal dictionary with the Grammalecte addon for Firefox or Chrome",
           41  +
           42  +        "suggestion_section": "Spell suggestion engine",
           43  +        "activate_spell_sugg": "Activate the suggestion engine of Grammalecte",
           44  +        "activate_spell_sugg_descr": "Disactivated, this option replace the spell suggestion engine of Grammalecte by the one of LibreOffice (Hunspell). Words included in the personal dictionary won’t be included among suggestions.",
           45  +
           46  +        "apply_button": "Apply",
           47  +        "cancel_button": "Cancel",
           48  +    },
           49  +}

Modified gc_lang/fr/oxt/addons.xcu from [1d834d2bae] to [3b803f02e0].

   116    116                           <value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument</value>
   117    117                       </prop>
   118    118                       <prop oor:name="ImageIdentifier" oor:type="xs:string">
   119    119                           <value>org.dicollecte.images:Grammalecte</value>
   120    120                       </prop>
   121    121                   </node>
   122    122                   <node oor:name="m6" oor:op="replace">
          123  +                    <prop oor:name="URL" oor:type="xs:string">
          124  +                        <value>service:net.grammalecte.AppLauncher?DI</value>
          125  +                    </prop>
          126  +                    <prop oor:name="Title" oor:type="xs:string">
          127  +                        <value/>
          128  +                        <value xml:lang="fr">~Options des dictionnaires…</value>
          129  +                        <value xml:lang="en-US">Dictionaries ~options…</value>
          130  +                    </prop>
          131  +                    <prop oor:name="Target" oor:type="xs:string">
          132  +                        <value>_self</value>
          133  +                    </prop>
          134  +                    <prop oor:name="Context" oor:type="xs:string">
          135  +                        <value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument,com.sun.star.presentation.PresentationDocument</value>
          136  +                    </prop>
          137  +                    <prop oor:name="ImageIdentifier" oor:type="xs:string">
          138  +                        <value>org.dicollecte.images:Frenchflag</value>
          139  +                    </prop>
          140  +                </node>
          141  +                <node oor:name="m7" oor:op="replace">
   123    142                       <prop oor:name="URL" oor:type="xs:string">
   124    143                           <value>service:net.grammalecte.AppLauncher?DS</value>
   125    144                       </prop>
   126    145                       <prop oor:name="Title" oor:type="xs:string">
   127    146                           <value/>
   128    147                           <value xml:lang="fr">~Options orthographiques…</value>
   129    148                           <value xml:lang="en-US">Spelling ~options…</value>
................................................................................
   134    153                       <prop oor:name="Context" oor:type="xs:string">
   135    154                           <value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument,com.sun.star.presentation.PresentationDocument</value>
   136    155                       </prop>
   137    156                       <prop oor:name="ImageIdentifier" oor:type="xs:string">
   138    157                           <value>org.dicollecte.images:Frenchflag</value>
   139    158                       </prop>
   140    159                   </node>
   141         -                <node oor:name="m7" oor:op="replace">
          160  +                <node oor:name="m8" oor:op="replace">
   142    161                       <prop oor:name="URL" oor:type="xs:string">
   143    162                           <value>private:separator</value>
   144    163                       </prop>
   145    164                       <prop oor:name="Context" oor:type="xs:string">
   146    165                           <value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument,com.sun.star.presentation.PresentationDocument</value>
   147    166                       </prop>
   148    167                   </node>
   149         -                <node oor:name="m8" oor:op="replace">
          168  +                <node oor:name="m9" oor:op="replace">
   150    169                       <prop oor:name="URL" oor:type="xs:string">
   151    170                           <value>service:net.grammalecte.AppLauncher?About</value>
   152    171                       </prop>
   153    172                       <prop oor:name="Title" oor:type="xs:string">
   154    173                           <value/>
   155    174                           <value xml:lang="fr">À ~propos de Grammalecte…</value>
   156    175                           <value xml:lang="en-US">~About Grammalecte…</value>