Changeset 182:dd806c3cc18d


Ignore:
Timestamp:
05/15/12 15:01:07 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

If the program is started in several instances, the ones after the first one just show the window of the running instance

Location:
src/mlx
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/gui.py

    r178 r182  
    1919import mlx.acft as acft
    2020import mlx.web as web
     21import mlx.singleton as singleton
    2122from  mlx.i18n import xstr
    2223from mlx.pirep import PIREP
     
    306307                                    self._mainWindow)
    307308            self._updater.start()
    308 
     309       
     310        singleton.raiseCallback = self.raiseCallback
    309311        gtk.main()
     312        singleton.raiseCallback = None
    310313
    311314        self._disconnect()
     
    499502           (event.new_window_state&iconified)!=0:
    500503            self.hideMainWindow(savePosition = False)
     504
     505    def raiseCallback(self):
     506        """Callback for the singleton handling code."""
     507        gobject.idle_add(self.raiseMainWindow)
     508
     509    def raiseMainWindow(self):
     510        """SHow the main window if invisible, and raise it."""
     511        if not self._mainWindow.get_visible():
     512            self.showMainWindow()
     513        self._mainWindow.present()
    501514
    502515    def hideMainWindow(self, savePosition = True):
  • src/mlx/mlx.py

    r160 r182  
    4444def main():
    4545    """The main operation of the program."""
     46    from singleton import SingleInstance, raiseCallbackWrapper
     47
     48    instance = SingleInstance("mlx", raiseCallbackWrapper)
     49    if not instance: return
     50
    4651    programDirectory = os.path.dirname(sys.argv[0])
    4752
     
    7984
    8085if __name__ == "__main__":
    81     main()
     86    if instance:
     87        main()
Note: See TracChangeset for help on using the changeset viewer.