Code

- Send Mac package debugging output to stderr rather than stdout. Fixes
[inkscape.git] / packaging / macosx / Resources / bin / inkscape
index 2242f68618ddc11651e748c17cf1b394d8816f68..349b0ebe4727b10998275059b181035390d3baab 100755 (executable)
@@ -20,7 +20,8 @@ TOP="`dirname \"$CWD\"`"
 #      newer python as recommended by MacPython http://www.python.org/download/mac/
 #      Fink
 #      MacPorts (former DarwinPorts)
-export PATH="/opt/local/bin:/sw/bin/:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/bin:$CWD:$PATH"
+#      LaTeX distribution for Mac OS X
+export PATH="/usr/texbin:/opt/local/bin:/sw/bin/:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/bin:$CWD:$PATH"
 
 # Setup PYTHONPATH to use python modules shipped with Inkscape
 ARCH=`arch`
@@ -28,16 +29,31 @@ PYTHON_VERS=`python -V 2>&1 | cut -c 8-10`
 export PYTHONPATH="$TOP/python/site-packages/$ARCH/$PYTHON_VERS"
 # NB: we are only preprending some stuff to the default python path so if the directory does not exist it should not harm the rest
 
-export DYLD_LIBRARY_PATH="$TOP/lib"
+# No longer required if path rewriting has been conducted.
+# export DYLD_LIBRARY_PATH="$TOP/lib"
+
+mkdir -p "${HOME}/.inkscape-etc"
 
-export PANGO_RC_FILE="$HOME/.inkscape-etc/pangorc"
 export FONTCONFIG_PATH="$TOP/etc/fonts"
+export PANGO_RC_FILE="$HOME/.inkscape-etc/pangorc"
 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"
 export GTK_EXE_PREFIX="$TOP"
 export GNOME_VFS_MODULE_CONFIG_PATH="$TOP/etc/gnome-vfs-2.0/modules"
 export GNOME_VFS_MODULE_PATH="$TOP/lib/gnome-vfs-2.0/modules"
+export XDG_DATA_DIRS="$TOP/share"
+export ASPELL_CONF="prefix $TOP;"
+
+# Note: This requires the path with the exact ImageMagic version number.
+#        Also, that ImageMagick will only work if it does not find a 
+#        version installed into the same PREFIX as it was originally 
+#        installed.  Luckily, this is very unlikely given the extra long 
+#        and strangely named install prefix we use.
+#        The actual version is inserted by the packaging script.
+export MAGICK_CONFIGURE_PATH="$TOP/lib/ImageMagick-IMAGEMAGICKVER/config:$TOP/share/ImageMagick-IMAGEMAGICKVER/config"
+export MAGICK_CODER_FILTER_PATH="$TOP/lib/ImageMagick-IMAGEMAGICKVER/modules-Q16/filters"
+export MAGICK_CODER_MODULE_PATH="$TOP/lib/ImageMagick-IMAGEMAGICKVER/modules-Q16/coders"
 
 export INKSCAPE_SHAREDIR="$TOP"
 # TODO: move the share directory to a its own folder to make things a bit cleaner in the app bundle
@@ -45,34 +61,68 @@ export INKSCAPE_PLUGINDIR="$TOP/lib/inkscape"
 export INKSCAPE_LOCALEDIR="$TOP/locale"
 
 # Set GTK theme (only if there is no .gtkrc-2.0 in the user's home)
-if [[ ! -e $HOME/.gtkrc-2.0 ]]; then
-       # prepare the theme depending on OS X appearance settings
-       (
-               cd "$INKSCAPE_SHAREDIR/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/"
-               ./sync_osx_look.sh
-               # TODO: make this more robust, probably by integrating this script directly inline here
-       )
-       export GTK2_RC_FILES="$INKSCAPE_SHAREDIR/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/gtkrc"
+if [[ ! -e "$HOME/.gtkrc-2.0" ]]; then
+       # Appearance setting
+       aquaStyle=`defaults read "Apple Global Domain" AppleAquaColorVariant 2>/dev/null`
+       # 1 for aqua, 6 for graphite, inexistant if the default color was never changed
+       if [[ "$aquaStyle" == "" ]]; then
+               aquaStyle=1             # set aqua as default
+       fi
+
+       # Highlight Color setting
+       hiliColor=`defaults read "Apple Global Domain" AppleHighlightColor 2>/dev/null`
+       # a RGB value, with components between 0 and 1, also inexistant if it was not changed
+       if [[ "$hiliColor" == "" ]]; then
+               hiliColor="0.709800 0.835300 1.000000"  # set blue as default
+       fi
+
+       # Menu items color
+       if [[ aquaStyle -eq 1 ]]; then
+               menuColor="#4a76cd"     # blue
+       else
+               menuColor="#7c8da4"     # graphite
+       fi
+       # Format highlight color as a GTK rgb value
+       hiliColorFormated=`echo $hiliColor | awk -F " " '{print "\\\{"$1","$2","$3"\\\}"}'`
+
+       # echo $menuColor
+       # echo $hiliColorFormated
+
+       # Modify the gtkrc
+       #       - with the correct colors
+       #       - to point to the correct scrollbars folder
+       sed 's/OSX_HILI_COLOR_PLACEHOLDER/'$hiliColorFormated'/g' "$INKSCAPE_SHAREDIR/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/pre_gtkrc" | sed 's/OSX_MENU_COLOR_PLACEHOLDER/\"'$menuColor'\"/g' | sed 's/AQUASTYLE_PLACEHOLDER/'$aquaStyle'/g' | sed 's|${THEMEDIR}|'"$TOP/themes/Clearlooks-Quicksilver-OSX/gtk-2.0|g" > "${HOME}/.inkscape-etc/gtkrc"
+
+       export GTK2_RC_FILES="$HOME/.inkscape-etc/gtkrc"
+fi
+
+# If the AppleCollationOrder preference doesn't exist, we fall back to using
+# the AppleLocale preference.
+LANGSTR=`defaults read .GlobalPreferences AppleCollationOrder 2>/dev/null`
+if [ "x$LANGSTR" == "x" ]
+then
+    echo "Warning: AppleCollationOrder setting not found, using AppleLocale." 1>&2
+    LANGSTR=`defaults read .GlobalPreferences AppleLocale 2>/dev/null | \
+            sed 's/_.*//'`
 fi
 
-# TODO: Have to add ".UTF-8" to the LANG since ommiting causes Inkscape
+# NOTE: Have to add ".UTF-8" to the LANG since omitting causes Inkscape
 #       to crash on startup in locale_from_utf8().
-export LANG="`grep \"\`defaults read .GlobalPreferences AppleCollationOrder \
-       2>&1\`_\" /usr/share/locale/locale.alias | tail -n1 | sed 's/\./ /' | \
-       awk '{print $2}'`.UTF-8"
+export LANG="`grep \"\`echo $LANGSTR\`_\" /usr/share/locale/locale.alias | \
+       tail -n1 | sed 's/\./ /' | awk '{print $2}'`.UTF-8"
+echo "Setting Language: $LANG" 1>&2
 
 # Handle the case where the directory storing Inkscape has a '#' in the name.
 # 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
+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" "$@"