mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-03 19:17:02 -05:00 
			
		
		
		
	Show notifications in the Apple notification centre in OS X Mountain Lion
This commit is contained in:
		
							parent
							
								
									aeda34f4aa
								
							
						
					
					
						commit
						82f10e2712
					
				@ -597,6 +597,8 @@ class Py2App(object):
 | 
				
			|||||||
            else:
 | 
					            else:
 | 
				
			||||||
                os.symlink(join('../..', x),
 | 
					                os.symlink(join('../..', x),
 | 
				
			||||||
                           join(cc_dir, x))
 | 
					                           join(cc_dir, x))
 | 
				
			||||||
 | 
					        shutil.copytree(join(SW, 'build/notifier.app'), join(
 | 
				
			||||||
 | 
					            self.contents_dir, 'notifier.app'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @flush
 | 
					    @flush
 | 
				
			||||||
    def copy_site(self):
 | 
					    def copy_site(self):
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,7 @@ __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
 | 
				
			|||||||
__docformat__ = 'restructuredtext en'
 | 
					__docformat__ = 'restructuredtext en'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from calibre.constants import islinux, isosx, get_osx_version, __appname__
 | 
					from calibre.constants import islinux, isosx, get_osx_version
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Notifier(object):
 | 
					class Notifier(object):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -107,10 +107,11 @@ class AppleNotifier(Notifier):
 | 
				
			|||||||
        self.ok = False
 | 
					        self.ok = False
 | 
				
			||||||
        import os, sys
 | 
					        import os, sys
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            self.exe = os.path.join(sys.console_binaries_path, 'notifier')
 | 
					            self.exe = os.path.join(sys.console_binaries_path.replace(
 | 
				
			||||||
 | 
					                'console.app', 'notifier.app'), 'Calibre')
 | 
				
			||||||
            self.ok = os.access(self.exe, os.X_OK)
 | 
					            self.ok = os.access(self.exe, os.X_OK)
 | 
				
			||||||
            import subprocess
 | 
					            import subprocess
 | 
				
			||||||
            self.call = subprocess.check_call
 | 
					            self.call = subprocess.Popen
 | 
				
			||||||
        except:
 | 
					        except:
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -120,10 +121,10 @@ class AppleNotifier(Notifier):
 | 
				
			|||||||
                x = x.encode('utf-8')
 | 
					                x = x.encode('utf-8')
 | 
				
			||||||
            return x
 | 
					            return x
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cmd = [self.exe, '-title', __appname__, '-activate',
 | 
					        cmd = [self.exe, '-activate',
 | 
				
			||||||
               'net.kovidgoyal.calibre', '-message', encode(body)]
 | 
					               'net.kovidgoyal.calibre', '-message', encode(body)]
 | 
				
			||||||
        if summary:
 | 
					        if summary:
 | 
				
			||||||
            cmd += ['-subtitle', encode(summary)]
 | 
					            cmd += ['-title', encode(summary)]
 | 
				
			||||||
        self.call(cmd)
 | 
					        self.call(cmd)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __call__(self, body, summary=None, replaces_id=None, timeout=0):
 | 
					    def __call__(self, body, summary=None, replaces_id=None, timeout=0):
 | 
				
			||||||
@ -144,7 +145,7 @@ def get_notifier(systray=None):
 | 
				
			|||||||
            ans = FDONotifier()
 | 
					            ans = FDONotifier()
 | 
				
			||||||
            if not ans.ok:
 | 
					            if not ans.ok:
 | 
				
			||||||
                ans = None
 | 
					                ans = None
 | 
				
			||||||
    elif False and isosx and get_osx_version() >= (10, 8, 0):
 | 
					    elif isosx and get_osx_version() >= (10, 8, 0):
 | 
				
			||||||
        ans = AppleNotifier()
 | 
					        ans = AppleNotifier()
 | 
				
			||||||
        if not ans.ok:
 | 
					        if not ans.ok:
 | 
				
			||||||
            ans = None
 | 
					            ans = None
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user