Code

* packaging/macosx/ScriptExec/main.c: Update ScriptExec with upstream fixes
authormjwybrow <mjwybrow@users.sourceforge.net>
Tue, 11 Mar 2008 06:02:23 +0000 (06:02 +0000)
committermjwybrow <mjwybrow@users.sourceforge.net>
Tue, 11 Mar 2008 06:02:23 +0000 (06:02 +0000)
    and changes.  X11.app now gets focus if the Inkscape icon is clicked while
    Inkscape is already open (previously nothing happened).

 *  packaging/macosx/Resources/openDoc: If Inkscape.app is already open and
    a file is dropped on the Inkscape dock icon, or an Inkscape file is
    double-clicked in the Finder, that document will now be correctly opened
    in a new Inkscape window (previously nothing happened).

 *  packaging/macosx/Resources/script: Some minor fixes, plus alert the user
    about the font cache building time only if ~/.fontconfig/ doesn't exist.

 *  packaging/macosx/Resources/bin/inkscape: Only override the fontconfig
    configuration on OSX 10.4 or earlier, since the fc-cache behaviour has
    been corrected on 10.5.

 *  Info.plist.in: Update the copyright dates, and change Inkscape to be an
    Editor for SVG files, rather than a Viewer as it was previously.

Info.plist.in
packaging/macosx/Resources/bin/inkscape
packaging/macosx/Resources/openDoc
packaging/macosx/Resources/script
packaging/macosx/ScriptExec/main.c

index fa4e8007aa6239ec8dd6c5a70afc66dd4adbd9c0..a93e6e2167284dc47ba6104810f9ee8ff44a376c 100644 (file)
@@ -7,7 +7,7 @@
     <key>CFBundleExecutable</key>
     <string>Inkscape</string>
     <key>CFBundleGetInfoString</key>
-    <string>@VERSION@, Copyright 2003-2007 Inkscape Developers</string>
+    <string>@VERSION@, Copyright 2003-2008 Inkscape Developers</string>
     <key>CFBundleIconFile</key>
     <string>Inkscape.icns</string>
     <key>CFBundleIdentifier</key>
@@ -32,7 +32,7 @@
                            <string>SVG </string>
                        </array>
                        <key>CFBundleTypeRole</key>
-                       <string>Viewer</string>
+                       <string>Editor</string>
                    </dict>
         <dict>
             <key>CFBundleTypeExtensions</key>
     <key>CFBundleVersion</key>
     <string>@VERSION@</string>
     <key>NSHumanReadableCopyright</key>
-    <string>Copyright 2007 Inkscape Developers, GNU General Public License.</string>
+    <string>Copyright 2008 Inkscape Developers, GNU General Public License.</string>
     <key>LSMinimumSystemVersion</key>
     <string>10.3</string>
 </dict>
index 2242f68618ddc11651e748c17cf1b394d8816f68..093cb3550e77f4ff6283d113ce051a3fac49f189 100755 (executable)
@@ -30,8 +30,11 @@ export PYTHONPATH="$TOP/python/site-packages/$ARCH/$PYTHON_VERS"
 
 export DYLD_LIBRARY_PATH="$TOP/lib"
 
+# For Panther and Tiger, override the default fontconfig configuration
+if [[ $VERSION -le 4 ]]; then
+       export FONTCONFIG_PATH="$TOP/etc/fonts"
+fi
 export PANGO_RC_FILE="$HOME/.inkscape-etc/pangorc"
-export FONTCONFIG_PATH="$TOP/etc/fonts"
 export GTK_IM_MODULE_FILE="$HOME/.inkscape-etc/gtk.immodules"
 export GDK_PIXBUF_MODULE_FILE="$HOME/.inkscape-etc/gdk-pixbuf.loaders"
 export GTK_DATA_PREFIX="$TOP"
@@ -65,14 +68,14 @@ export LANG="`grep \"\`defaults read .GlobalPreferences AppleCollationOrder \
 # This '#' needs to be escaped in pango.modules for Pango to work properly.
 ESCAPEDTOP=`echo $TOP | sed 's/#/\\\\\\\\#/'`
 
-mkdir -p ~/.inkscape-etc
-sed 's|${HOME}|'"$HOME|g" "$TOP/etc/pango/pangorc" > ~/.inkscape-etc/pangorc
+mkdir -p ${HOME}/.inkscape-etc
+sed 's|${HOME}|'"$HOME|g" "$TOP/etc/pango/pangorc" > ${HOME}/.inkscape-etc/pangorc
 sed 's|${CWD}|'"$ESCAPEDTOP|g" "$TOP/etc/pango/pango.modules" \
-    > ~/.inkscape-etc/pango.modules
-cp -f "$TOP/etc/pango/pangox.aliases" ~/.inkscape-etc/
+    > ${HOME}/.inkscape-etc/pango.modules
+cp -f "$TOP/etc/pango/pangox.aliases" ${HOME}/.inkscape-etc/
 sed 's|${CWD}|'"$TOP|g" "$TOP/etc/gtk-2.0/gtk.immodules" \
-    > ~/.inkscape-etc/gtk.immodules
+    > ${HOME}/.inkscape-etc/gtk.immodules
 sed 's|${CWD}|'"$TOP|g" "$TOP/etc/gtk-2.0/gdk-pixbuf.loaders" \
-    > ~/.inkscape-etc/gdk-pixbuf.loaders
+    > ${HOME}/.inkscape-etc/gdk-pixbuf.loaders
 
 exec "$CWD/inkscape-bin" "$@"
index 8e6ac03994574cd53c3d4af13841dd2f48c3cdd9..9b1d7718c795a1df668b85afe8ded8ee31816719 100755 (executable)
@@ -1,8 +1,17 @@
 #!/bin/sh
 #
 # Author: Aaron Voisine <aaron@voisine.org>
+# Inkscape Modifications: Michael Wybrow <mjwybrow@users.sourceforge.net>
 
-export "DISPLAY=`cat /tmp/display.$UID`"
-BASE="`echo "$0" | sed -e 's/\/[A-Za-z]*.app\/Contents\/Resources\/script/\//'`"
+CWD="`dirname \"$0\"`"
+
+# System version: 3 for Panther, 4 for Tiger, 5 for Leopard
+export VERSION=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 -d'.'`
+
+if [[ $VERSION -le 4 ]]; then
+       export "DISPLAY=`cat /tmp/display.$UID`"
+fi
+
+BASE="`echo "$0" | sed -e 's/\/[A-Za-z]*.app\/Contents\/Resources\/openDoc/\//'`"
 cd "$BASE"
 exec "$CWD/bin/inkscape" "$@"
index 48bfc76cbaf02bd3252e957237aaf71e70bdde03..95ee6afbf273bd4fb6ee07c77d036b94ea97e880 100755 (executable)
@@ -6,7 +6,7 @@
 CWD="`dirname \"$0\"`"
 
 # System version: 3 for Panther, 4 for Tiger, 5 for Leopard
-VERSION=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 -d'.'`
+export VERSION=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 -d'.'`
 
 # On Leopard, X11.app is installed by default, and will be started
 # automatically via launchd.  On older systems, we need to start 
@@ -18,9 +18,9 @@ if [[ $VERSION -le 4 ]]; then
        # from xinitrc but when is it really used? Should we modify 
        # the .xinitrc of the user without warning?
        ps -wx -ocommand | grep -e '[X]11' > /dev/null
-       if [ "$?" != "0" -a ! -f ~/.xinitrc ]; then
-           echo "rm -f ~/.xinitrc" > ~/.xinitrc
-           sed 's/xterm/# xterm/' /usr/X11R6/lib/X11/xinit/xinitrc >> ~/.xinitrc
+       if [ "$?" != "0" -a ! -f ${HOME}/.xinitrc ]; then
+           echo "rm -f ${HOME}/.xinitrc" > ${HOME}/.xinitrc
+           sed 's/xterm/# xterm/' /usr/X11R6/lib/X11/xinit/xinitrc >> ${HOME}/.xinitrc
        fi
 
        # Start X11 and get DISPLAY
@@ -40,7 +40,7 @@ fi
 
 
 # Warn the user about time-consuming generation of fontconfig caches.
-test -f ~/.inkscape/.fccache-new || exit 12
+test -d ${HOME}/.fontconfig || exit 12
 
 
 BASE="`echo "$0" | sed -e 's/\/Contents\/Resources\/script/\//'`"
index c3e14a0a1f00ff484bf82de54cfb036e793e788f..2c4e8f301ecde9123ccb7c55c0bc34c56df985f2 100644 (file)
@@ -3,6 +3,10 @@
         This is the executable that goes into Platypus apps
     Copyright (C) 2003 Sveinbjorn Thordarson <sveinbt@hi.is>
 
+    With modifications by Aaron Voisine for gimp.app
+    With modifications by Marianne gagnon for Wilber-loves-apple
+    With modifications by Michael Wybrow for Inkscape.app
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
 
 */
 
+/*
+ * This app laucher basically takes care of:
+ * - launching Inkscape and X11 when double-clicked 
+ * - bringing X11 to the top when its icon is clicked in the dock (via a small applescript)
+ * - catch file dropped on icon events (and double-clicked gimp documents) and notify gimp.
+ * - catch quit events performed outside gimp, e.g. on the dock icon.
+ */
+
 ///////////////////////////////////////
 // Includes
 ///////////////////////////////////////    
@@ -89,6 +101,14 @@ static OSStatus X11FailedHandler(EventHandlerCallRef theHandlerCall,
                                  EventRef theEvent, void *userData);
 static OSStatus FCCacheFailedHandler(EventHandlerCallRef theHandlerCall,
                                  EventRef theEvent, void *userData);
+static OSErr AppReopenAppAEHandler(const AppleEvent *theAppleEvent,
+                                   AppleEvent *reply, long refCon);
+
+static OSStatus CompileAppleScript(const void* text, long textLength,
+                                  AEDesc *resultData);
+static OSStatus SimpleCompileAppleScript(const char* theScript);
+static void runScript();
+
 ///////////////////////////////////////
 // Globals
 ///////////////////////////////////////    
@@ -137,6 +157,11 @@ int main(int argc, char* argv[])
     err += AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
                                  NewAEEventHandlerUPP(AppOpenAppAEHandler),
                                  0, false);
+    
+    err += AEInstallEventHandler(kCoreEventClass, kAEReopenApplication,
+                                 NewAEEventHandlerUPP(AppReopenAppAEHandler),
+                                 0, false);
+    
     err += InstallEventHandler(GetApplicationEventTarget(),
                                NewEventHandlerUPP(X11FailedHandler), 1,
                                &X11events, NULL, NULL);
@@ -153,6 +178,9 @@ int main(int argc, char* argv[])
     
     GetParameters(); //load data from files containing exec settings
 
+    // compile "icon clicked" script so it's ready to execute
+    SimpleCompileAppleScript("tell application \"X11\" to activate");
+    
     RunApplicationEventLoop(); //Run the event loop
     return 0;
 }
@@ -625,6 +653,14 @@ static OSErr AppOpenDocAEHandler(const AppleEvent *theAppleEvent,
 ///////////////////////////////
 // Handler for clicking on app icon
 ///////////////////////////////
+// if app is already open
+static OSErr AppReopenAppAEHandler(const AppleEvent *theAppleEvent,
+                                 AppleEvent *reply, long refCon)
+{
+    runScript();
+}
+
+// if app is being opened
 static OSErr AppOpenAppAEHandler(const AppleEvent *theAppleEvent,
                                  AppleEvent *reply, long refCon)
 {
@@ -688,10 +724,10 @@ static OSStatus X11FailedHandler(EventHandlerCallRef theHandlerCall,
        StandardAlert(kAlertStopAlert, "\pFailed to start X11",
                        "\pInkscape.app requires Apple's X11, which is freely downloadable from Apple's website for Panther (10.3.x) users and available as an optional install from the installation DVD for Tiger (10.4.x) users.\n\nPlease install X11 and restart Inkscape.",
                        &params, &itemHit);
-    
+
        if (itemHit == kAlertStdAlertCancelButton)
        {
-               OpenURL("http://www.apple.com/downloads/macosx/apple/x11formacosx.html");
+               OpenURL("http://www.apple.com/downloads/macosx/apple/macosx_updates/x11formacosx.html");
        }
 
     ExitToShell();
@@ -699,3 +735,53 @@ static OSStatus X11FailedHandler(EventHandlerCallRef theHandlerCall,
 
     return noErr;
 }
+
+
+// Compile and run a small AppleScript. The code below does no cleanup and no proper error checks
+// but since it's there until the app is shut down, and since we know the script is okay,
+// there should not be any problems.
+ComponentInstance theComponent;
+AEDesc scriptTextDesc;
+OSStatus err;
+OSAID scriptID, resultID;
+
+static OSStatus CompileAppleScript(const void* text, long textLength,
+                                  AEDesc *resultData) {
+    
+    resultData = NULL;
+    /* set up locals to a known state */
+    theComponent = NULL;
+    AECreateDesc(typeNull, NULL, 0, &scriptTextDesc);
+    scriptID = kOSANullScript;
+    resultID = kOSANullScript;
+    
+    /* open the scripting component */
+    theComponent = OpenDefaultComponent(kOSAComponentType,
+                                        typeAppleScript);
+    if (theComponent == NULL) { err = paramErr; return err; }
+    
+    /* put the script text into an aedesc */
+    err = AECreateDesc(typeChar, text, textLength, &scriptTextDesc);
+    if (err != noErr) return err;
+    
+    /* compile the script */
+    err = OSACompile(theComponent, &scriptTextDesc,
+                     kOSAModeNull, &scriptID);
+
+    return err;
+}
+
+/* runs the compiled applescript */
+static void runScript()
+{
+    /* run the script */
+    err = OSAExecute(theComponent, scriptID, kOSANullScript,
+                     kOSAModeNull, &resultID);
+    return err;
+}
+
+
+/* Simple shortcut to the function that actually compiles the applescript. */
+static OSStatus SimpleCompileAppleScript(const char* theScript) {
+    return CompileAppleScript(theScript, strlen(theScript), NULL);
+}