Index: gc_lang/fr/oxt/Lexicographer/Enumerator.py ================================================================== --- gc_lang/fr/oxt/Lexicographer/Enumerator.py +++ gc_lang/fr/oxt/Lexicographer/Enumerator.py @@ -10,10 +10,11 @@ import enum_strings import grammalecte.graphspell as sc from com.sun.star.task import XJobExecutor from com.sun.star.awt import XActionListener +from com.sun.star.awt import XTopWindowListener from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK # BUTTONS_OK, BUTTONS_OK_CANCEL, BUTTONS_YES_NO, BUTTONS_YES_NO_CANCEL, BUTTONS_RETRY_CANCEL, BUTTONS_ABORT_IGNORE_RETRY # DEFAULT_BUTTON_OK, DEFAULT_BUTTON_CANCEL, DEFAULT_BUTTON_RETRY, DEFAULT_BUTTON_YES, DEFAULT_BUTTON_NO, DEFAULT_BUTTON_IGNORE from com.sun.star.awt.MessageBoxType import INFOBOX, ERRORBOX # MESSAGEBOX, INFOBOX, WARNINGBOX, ERRORBOX, QUERYBOX @@ -55,11 +56,11 @@ # return return result return wrapper -class Enumerator (unohelper.Base, XActionListener, XJobExecutor): +class Enumerator (unohelper.Base, XActionListener, XTopWindowListener, XJobExecutor): def __init__ (self, ctx): self.ctx = ctx self.xSvMgr = self.ctx.ServiceManager self.xDesktop = self.xSvMgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.ctx) @@ -180,10 +181,11 @@ self.xContainer.getControl('export_button').setActionCommand('Export') self.xContainer.getControl('tag_button').addActionListener(self) self.xContainer.getControl('tag_button').setActionCommand('Tag') self.xContainer.getControl('close_button').addActionListener(self) self.xContainer.getControl('close_button').setActionCommand('Close') + self.xContainer.addTopWindowListener(self) # listener with XTopWindowListener methods self.xContainer.setVisible(True) # True for non modal dialog xToolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx) self.xContainer.createPeer(xToolkit, None) #self.xContainer.execute() # Don’t excute for non modal dialog @@ -229,10 +231,32 @@ elif xActionEvent.ActionCommand == "Close": self.xContainer.dispose() # Non modal dialog #self.xContainer.endExecute() # Modal dialog except: traceback.print_exc() + + # XTopWindowListener (useful for non modal dialog only) + def windowOpened (self, xEvent): + return + + def windowClosing (self, xEvent): + self.xContainer.dispose() # Non modal dialog + + def windowClosed (self, xEvent): + return + + def windowMinimized (self, xEvent): + return + + def windowNormalized (self, xEvent): + return + + def windowActivated (self, xEvent): + return + + def windowDeactivated (self, xEvent): + return # XJobExecutor def trigger (self, args): try: xDialog = Enumerator(self.ctx)