Grammalecte  Check-in [2239a762bd]

Overview
Comment:[lo] lexicon editor as non modal dialog
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | lo
Files: files | file ages | folders
SHA3-256: 2239a762bd1d9e7980894605c44d1f603afedcae919ba97a668531705c45559f
User & Date: olr on 2020-02-04 14:06:49
Other Links: manifest | tags
Context
2020-02-06
06:51
[core][fr] suggestions: remove empty suggestions check-in: 86199c55ea user: olr tags: core, fr, trunk
2020-02-04
14:06
[lo] lexicon editor as non modal dialog check-in: 2239a762bd user: olr tags: lo, trunk
13:58
[lo] conjugueur as non modal dialog check-in: fabbc4bc0c user: olr tags: lo, trunk
Changes

Modified gc_lang/fr/oxt/DictOptions/LexiconEditor.py from [6367f7ed95] to [9068830b8a].

    18     18   import grammalecte.fr.conj_generator as conjgen
    19     19   
    20     20   import SearchWords
    21     21   import TagsInfo
    22     22   
    23     23   from com.sun.star.task import XJobExecutor
    24     24   from com.sun.star.awt import XActionListener
           25  +from com.sun.star.awt import XTopWindowListener
    25     26   from com.sun.star.awt import XKeyListener
    26     27   
    27     28   from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK
    28     29   # BUTTONS_OK, BUTTONS_OK_CANCEL, BUTTONS_YES_NO, BUTTONS_YES_NO_CANCEL, BUTTONS_RETRY_CANCEL, BUTTONS_ABORT_IGNORE_RETRY
    29     30   # DEFAULT_BUTTON_OK, DEFAULT_BUTTON_CANCEL, DEFAULT_BUTTON_RETRY, DEFAULT_BUTTON_YES, DEFAULT_BUTTON_NO, DEFAULT_BUTTON_IGNORE
    30     31   from com.sun.star.awt.MessageBoxType import INFOBOX, ERRORBOX # MESSAGEBOX, INFOBOX, WARNINGBOX, ERRORBOX, QUERYBOX
    31     32   
................................................................................
    57     58               x.setPointer(xPointer)
    58     59           self.xContainer.setVisible(True) # seems necessary to refresh the dialog box and text widgets (why?)
    59     60           # return
    60     61           return result
    61     62       return wrapper
    62     63   
    63     64   
    64         -class LexiconEditor (unohelper.Base, XActionListener, XKeyListener, XJobExecutor):
           65  +class LexiconEditor (unohelper.Base, XActionListener, XTopWindowListener, XKeyListener, XJobExecutor):
    65     66   
    66     67       def __init__ (self, ctx):
    67     68           self.ctx = ctx
    68     69           self.xSvMgr = self.ctx.ServiceManager
    69     70           self.xDesktop = self.xSvMgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.ctx)
    70     71           self.xDocument = self.xDesktop.getCurrentComponent()
    71     72           self.xContainer = None
................................................................................
   280    281           self.xContainer.getControl('save_button').setActionCommand('Save')
   281    282           self.xContainer.getControl('import_button').addActionListener(self)
   282    283           self.xContainer.getControl('import_button').setActionCommand('Import')
   283    284           self.xContainer.getControl('export_button').addActionListener(self)
   284    285           self.xContainer.getControl('export_button').setActionCommand('Export')
   285    286           self.xContainer.getControl('close_button').addActionListener(self)
   286    287           self.xContainer.getControl('close_button').setActionCommand('Close')
   287         -        self.xContainer.setVisible(False)
          288  +        self.xContainer.addTopWindowListener(self) # listener with XTopWindowListener methods
          289  +        self.xContainer.setVisible(True)  # True for non modal dialog
   288    290           xToolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
   289    291           self.xContainer.createPeer(xToolkit, None)
   290         -        self.xContainer.execute()
          292  +        #self.xContainer.execute()        # For modal dialog
   291    293   
   292    294       def _createKeyListeners (self, lNames, sAction):
   293    295           for sName in lNames:
   294    296               self.xContainer.getControl(sName).addKeyListener(self)
   295    297   
   296    298       def _createActionListeners (self, lNames, sAction):
   297    299           for sName in lNames:
................................................................................
   316    318               elif xActionEvent.ActionCommand == "Import":
   317    319                   self.importDictionary()
   318    320               elif xActionEvent.ActionCommand == "Export":
   319    321                   self.exportDictionary()
   320    322               elif xActionEvent.ActionCommand == 'Info':
   321    323                   pass
   322    324               elif xActionEvent.ActionCommand == "Close":
   323         -                self.xContainer.endExecute()
          325  +                self.xContainer.dispose()           # Non modal dialog
          326  +                #self.xContainer.endExecute()       # Modal dialog
   324    327           except:
   325    328               traceback.print_exc()
          329  +
          330  +    # XTopWindowListener (useful for non modal dialog only)
          331  +    def windowOpened (self, xEvent):
          332  +        return
          333  +
          334  +    def windowClosing (self, xEvent):
          335  +        self.xContainer.dispose()           # Non modal dialog
          336  +
          337  +    def windowClosed (self, xEvent):
          338  +        return
          339  +
          340  +    def windowMinimized (self, xEvent):
          341  +        return
          342  +
          343  +    def windowNormalized (self, xEvent):
          344  +        return
          345  +
          346  +    def windowActivated (self, xEvent):
          347  +        return
          348  +
          349  +    def windowDeactivated (self, xEvent):
          350  +        return
   326    351   
   327    352       # XKeyListener
   328    353       def keyPressed (self, xKeyEvent):
   329    354           pass
   330    355   
   331    356       def keyReleased (self, xKeyEvent):
   332    357           self.updateGenWords()