CVSROOT:        /cvsroot/lilypond
Module name:    installers
Branch:         
Changes by:     Han-Wen Nienhuys <[EMAIL PROTECTED]>    05/06/17 00:30:44

Modified files:
        macos/LilyPad  : ChangeLog LilyPond.py ProcessLog.py 
                         Welcome-to-LilyPond-MacOS.ly lilycall.py 

Log message:
        * LilyPond.py (TinyTinyDocument.compileMe): CallBinder: closure
        for lilycall + document callbacks.
        
        * ProcessLog.py (ProcessLogWindowController.addText): new function.
        (ProcessLogWindowController.finish): stop throbber before callback.
        
        * lilycall.py (Call.get_process): new function.
        (check_fontconfig): symlink /System/Library/Fonts to
        prefix/share/SystemFonts.
        (Call.get_fc_cache_process): run fc-cache.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/installers/macos/LilyPad/ChangeLog.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/installers/macos/LilyPad/LilyPond.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/installers/macos/LilyPad/ProcessLog.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/installers/macos/LilyPad/Welcome-to-LilyPond-MacOS.ly.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/installers/macos/LilyPad/lilycall.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: installers/macos/LilyPad/ChangeLog
diff -u installers/macos/LilyPad/ChangeLog:1.6 
installers/macos/LilyPad/ChangeLog:1.7
--- installers/macos/LilyPad/ChangeLog:1.6      Thu Jun 16 14:27:02 2005
+++ installers/macos/LilyPad/ChangeLog  Fri Jun 17 00:30:43 2005
@@ -1,3 +1,16 @@
+2005-06-17  Han-Wen Nienhuys  <[EMAIL PROTECTED]>
+
+       * LilyPond.py (TinyTinyDocument.compileMe): CallBinder: closure
+       for lilycall + document callbacks.
+
+       * ProcessLog.py (ProcessLogWindowController.addText): new function.
+       (ProcessLogWindowController.finish): stop throbber before callback.
+
+       * lilycall.py (Call.get_process): new function.
+       (check_fontconfig): symlink /System/Library/Fonts to
+       prefix/share/SystemFonts.
+       (Call.get_fc_cache_process): run fc-cache.
+
 2005-06-16  Han-Wen Nienhuys  <[EMAIL PROTECTED]>
 
        * MainMenu.nib/classes.nib (Module): add Find functionality:
Index: installers/macos/LilyPad/LilyPond.py
diff -u installers/macos/LilyPad/LilyPond.py:1.8 
installers/macos/LilyPad/LilyPond.py:1.9
--- installers/macos/LilyPad/LilyPond.py:1.8    Thu Jun 16 14:27:02 2005
+++ installers/macos/LilyPad/LilyPond.py        Fri Jun 17 00:30:43 2005
@@ -156,17 +156,41 @@
         wc.runProcessWithCallback (pyproc, self.revert_)
         
     def compileMe (self):
-        bundle =  NSBundle.mainBundle ()         
-        appdir = NSBundle.mainBundle().bundlePath()
-        process = call = lilycall.Call (appdir, [self.fileName()])
+        bundle =  NSBundle.mainBundle ()
+       try:
+           appdir = os.environ['LILYPOND_DEBUG_APPDIR']
+       except KeyError:
+           appdir = NSBundle.mainBundle().bundlePath()
+       
+        call = lilycall.Call (appdir, [self.fileName()])
         call.reroute_output = 1
-        
         self.createProcessLog ()
-        pyproc = call.get_process()
-        wc = self.processLogWindowController
-        wc.setWindowTitle_ ('LilyPond -- ' + self.fileName())
-        wc.runProcessWithCallback (pyproc, lambda y: call.open_pdfs ())
+       class CallBinder:
+               def __init__ (self, call, document):
+                       self.call = call
+                       self.doc = document
+               def fcProcess (self, data = None):
+                       pyproc = call.get_fc_cache_process ()
+                       if not pyproc:
+                               return self.lpProcess()
+
+                       wc = self.doc.processLogWindowController
+                       wc.setWindowTitle_ ('Font cache updater')
+                       wc.addText ('\nCaching font details.\nThis may take a 
few minutes.\n\n\n') 
+                       wc.runProcessWithCallback (pyproc, self.lpProcess)
+                       
+               def lpProcess (self, data = None):
+                       wc = self.doc.processLogWindowController
+                       wc.setWindowTitle_ ('LilyPond -- ' + 
self.doc.fileName())
+                       pyproc = call.get_lilypond_process()
+                       wc.runProcessWithCallback (pyproc, self.open_pdfs)
+
+               def open_pdfs (self, data = None):
+                       self.call.open_pdfs ()
 
+       cb = CallBinder(call, self)
+       cb.fcProcess ()
+       
 
     def contextHelp_ (self, sender):
         tv = self.textView
Index: installers/macos/LilyPad/ProcessLog.py
diff -u installers/macos/LilyPad/ProcessLog.py:1.1 
installers/macos/LilyPad/ProcessLog.py:1.2
--- installers/macos/LilyPad/ProcessLog.py:1.1  Tue Jun 14 18:19:43 2005
+++ installers/macos/LilyPad/ProcessLog.py      Fri Jun 17 00:30:43 2005
@@ -124,12 +124,13 @@
 
     def finish (self):
         self.updateLog_(None)
+        self.cancelButton.setEnabled_ (False)
+        self.throbber.stopAnimation_ (self)
+
         cb = self.finish_callback
         if cb <> None:
             cb (self)
 
-        self.cancelButton.setEnabled_ (False)
-        self.throbber.stopAnimation_ (self)
         
     def clearLog_ (self, sender):
         tv = self.textView
@@ -139,9 +140,8 @@
         range.length = ts_len
         tv.replaceCharactersInRange_withString_ (range, '')
         
-    def updateLog_ (self, sender):
+    def addText (self, str):
         tv = self.textView
-        str = self.processLog.getNewOutput ()
         ts_len = tv.textStorage().length ()
         
         range = NSRange()
@@ -150,7 +150,10 @@
         tv.replaceCharactersInRange_withString_ (range, str)
         range.length = len (str)
         tv.scrollRangeToVisible_ (range)
-       
+        
+    def updateLog_ (self, sender):
+        str = self.processLog.getNewOutput ()
+        self.addText (str)
 
 
 if __name__ == "__main__":
Index: installers/macos/LilyPad/Welcome-to-LilyPond-MacOS.ly
diff -u installers/macos/LilyPad/Welcome-to-LilyPond-MacOS.ly:1.1 
installers/macos/LilyPad/Welcome-to-LilyPond-MacOS.ly:1.2
--- installers/macos/LilyPad/Welcome-to-LilyPond-MacOS.ly:1.1   Tue Jun 14 
18:19:43 2005
+++ installers/macos/LilyPad/Welcome-to-LilyPond-MacOS.ly       Fri Jun 17 
00:30:43 2005
@@ -10,7 +10,7 @@
 
   2. Select
 
-       Compile > Run LilyPond
+       Compile > Typeset file
 
   from the menu.
 
Index: installers/macos/LilyPad/lilycall.py
diff -u installers/macos/LilyPad/lilycall.py:1.1 
installers/macos/LilyPad/lilycall.py:1.2
--- installers/macos/LilyPad/lilycall.py:1.1    Tue Jun 14 18:19:43 2005
+++ installers/macos/LilyPad/lilycall.py        Fri Jun 17 00:30:43 2005
@@ -16,6 +16,9 @@
 ################################################################
 # general utils
 
+def file_is_newer (f1, f2):
+       return os.stat (f1).st_mtime >  os.stat (f2).st_mtime
+
 def writable_directory (dir):
        writable = 0
        try:
@@ -67,6 +70,35 @@
        open (pango_modules_file, 'w').write (pango_conf)
 
 
+def check_fontconfig (appdir):
+       prefix = appdir + '/Contents/Resources' 
+       my_sysfont_dir = prefix + '/share/SystemFonts'
+       sysfont_dir = '/System/Library/Fonts'
+
+       need_fc_update = 0
+       if not os.path.exists (my_sysfont_dir):
+           os.mkdir (my_sysfont_dir)
+           need_fc_update = 1
+           
+       if need_fc_update or file_is_newer (sysfont_dir, my_sysfont_dir):
+           files = os.listdir (sysfont_dir)
+           need_fc_update = 1
+           for f in files:
+                   if not os.path.exists (my_sysfont_dir + '/' + f): 
+                           os.symlink ('%s/%s' % (sysfont_dir, f),
+                                       '%s/%s' % (my_sysfont_dir, f))
+
+       local_fc_conf = open (prefix + '/etc/fonts/local.conf','w')
+       local_fc_conf.write ('''<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+<!-- /etc/fonts/local.conf file for local customizations -->
+<fontconfig>
+<dir>%s
+</dir>
+</fontconfig>''' %  my_sysfont_dir)
+       return need_fc_update
+
+
 def get_env (prefix):
        p = ''
        try:
@@ -82,7 +114,6 @@
        env['FONTCONFIG_FILE'] = prefix + '/etc/fonts/fonts.conf'
        env['GS_LIB'] = prefix + '/share/ghostscript/8.15/lib/'
        env['PANGO_RC_FILE'] = prefix + '/etc/pango/pangorc'
-
        return env
 
 
@@ -134,17 +165,21 @@
 
        def __init__ (self, appdir, args):
                self.check_app_dir (appdir)
+               self.appdir = appdir
                self.env = get_env (appdir + '/Contents/Resources')
                self.args = get_command_line (appdir, args)
+               self.executable = self.args[0]
+               self.args[0] = os.path.split (self.args[0])[1]
                self.cwd = get_dest_dir (self.args[1:])
+               self.need_fc_update = check_fontconfig (appdir)
                set_pango_paths (appdir);
                self.reroute_output = False
 
        def print_env (self):
                for (k,v) in self.env.items ():
                        print 'export %s="%s"' % (k,v)
-               
-       def get_process (self):
+
+       def get_process (self, executable, args):
                out = None
                err = None
                if self.reroute_output:
@@ -153,7 +188,10 @@
 
                if debug:
                        print self.__dict__
-               process = subprocess.Popen (self.args,
+                       print 'args: ', args
+                       print 'executable: ', executable
+               process = subprocess.Popen (args,
+                                           executable = executable,
                                            cwd = self.cwd,
                                            env = self.env,
                                            stdout = out,
@@ -162,6 +200,27 @@
                
                return process
        
+       def get_lilypond_process (self):
+               return self.get_process (self.executable, self.args)
+
+       def get_fc_cache_process (self):
+               if not self.need_fc_update:
+                       return None
+
+               prefix = self.appdir + '/Contents/Resources'
+               binary = prefix + '/bin/fc-cache'
+               args = ['/Library/Fonts/',
+                       prefix + '/share/SystemFonts',
+                       prefix + '/share/lilypond/current/fonts/',
+                       '/usr/share/fonts',
+                       '/Library/Fonts',
+                       '~/.fonts']
+               args = filter (lambda x: os.path.exists (x), args)
+               args = ['fc-cache', '-v'] + args 
+               
+               p = self.get_process (binary, args)
+               return p
+       
        def get_pdfs (self):
                names = []
                for a in self.args:
@@ -202,8 +261,13 @@
        if call.error_string:
                sys.stderr.write (call.error_string)
                sys.exit (2)
-               
-       p = call.get_process ()
+
+       p = call.get_fc_cache_process ()
+       if p:
+               sys.stderr.write ('Rebuilding font cache')
+               p.wait ()
+       
+       p = call.get_lilypond_process ()
        code = p.wait ()
 
        if not sys.stdin.isatty (): # GUI


_______________________________________________
Lilypond-cvs mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-cvs

Reply via email to