Changeset 124

Show
Ignore:
Timestamp:
04/30/06 10:17:47 (18 years ago)
Author:
jerome
Message:

Now unconditionally accept incoming requests from localhost, to allow
clean shutdowns.
Implemented the -q | --allowquit command line option.
Doesn't set the taskbar icon when not under Windows.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykoticon/trunk/bin/pykoticon

    r123 r124  
    100100        self.debug = options.debug 
    101101        self.printServers = [ socket.gethostbyname(arg) for arg in arguments ] 
     102        if "127.0.0.1" not in self.printServers : 
     103            self.printServers.append("127.0.0.1") # to allow clean shutdown 
    102104        loop = threading.Thread(target=self.mainloop) 
    103105        loop.start() 
     
    218220        wx.Frame.__init__(self, parent, id, \ 
    219221               _("PyKotIcon info for %s") % self.getCurrentUserName(), \ 
    220                size = (1, 1), \ 
     222               size = (0, 0), \ 
    221223               style = wx.FRAME_NO_TASKBAR | wx.NO_FULL_REPAINT_ON_RESIZE) 
    222224                      
     
    226228        self.redicon = wx.Icon(os.path.join(iconsdir, "pykoticon-red.ico"), \ 
    227229                                  wx.BITMAP_TYPE_ICO) 
    228         self.tbicon.SetIcon(self.greenicon, "PyKotIcon") 
     230        if isWindows :                           
     231            self.tbicon.SetIcon(self.greenicon, "PyKotIcon") 
    229232         
    230233        wx.EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnTaskBarActivate) 
     
    245248         
    246249        wx.EVT_ICONIZE(self, self.OnIconify) 
    247         wx.EVT_CLOSE(self, self.OnClose) 
     250        wx.EVT_CLOSE(self, self.FakeOnClose) 
    248251        self.Show(True) 
    249252         
     
    259262             
    260263    def OnIconify(self, event) : 
     264        """Iconify/De-iconify the application.""" 
    261265        if not self.IsIconized() : 
    262266            self.Iconize(True) 
     
    264268 
    265269    def OnTaskBarActivate(self, event) : 
     270        """Show the application if it is minimized.""" 
    266271        if self.IsIconized() : 
    267272            self.Iconize(False) 
     
    271276 
    272277    def OnClose(self, event) : 
     278        """Cleanly quit the application.""" 
    273279        self.closeServer() 
    274280        self.menu.Destroy() 
     
    277283 
    278284    def OnTaskBarMenu(self, event) : 
     285        """Open the taskbar menu.""" 
    279286        self.tbicon.PopupMenu(self.menu) 
    280287 
     288    def FakeOnClose(self, event) : 
     289        """React to close from windows corner.""" 
     290        if self.options.allowquit : 
     291            self.Close() 
     292        else : 
     293            self.quitIsForbidden() 
     294             
    281295    def OnTaskBarClose(self, event) : 
    282         self.Close() 
     296        """React to close from the taskbar.""" 
     297        if self.options.allowquit : 
     298            self.Close() 
     299        else : 
     300            self.quitIsForbidden() 
     301             
     302    def quitIsForbidden() :         
     303        """Displays a message indicating that quitting the application is not allowed.""" 
     304        message = _("Sorry, this was forbidden by your system administrator.") 
     305        caption = _("Information") 
     306        style = wx.OK | wx.ICON_INFORMATION | wx.STAY_ON_TOP 
     307        dialog = wx.MessageDialog(self, message, caption, style) 
     308        dialog.ShowModal() 
     309        dialog.Destroy() 
    283310         
    284311    def OnAbout(self, event) :     
     
    323350        if not self.quitEvent.isSet() : 
    324351            self.quitEvent.set() 
    325         server = xmlrpclib.ServerProxy("http://localhost:%s" % self.port)     
     352        server = xmlrpclib.ServerProxy("http://localhost:%s" % self.options.port)     
    326353        try : 
    327354            # wake the server with an empty request  
     
    337364        self.quitEvent = threading.Event() 
    338365        self.charset = charset 
    339         self.port = options.port 
     366        self.options = options 
    340367        self.server = MyXMLRPCServer(self, options, arguments) 
    341368