Merge lp:~inkscape.dev/inkscape/osx-packaging-update into lp:~inkscape.dev/inkscape/trunk

Proposed by su_v
Status: Needs review
Proposed branch: lp:~inkscape.dev/inkscape/osx-packaging-update
Merge into: lp:~inkscape.dev/inkscape/trunk
Diff against target: 531 lines (+157/-147)
10 files modified
packaging/macosx/Resources/bin/inkscape (+8/-18)
packaging/macosx/Resources/openDoc (+4/-0)
packaging/macosx/Resources/script (+5/-6)
packaging/macosx/ScriptExec/launcher-quartz-no-macintegration.sh (+10/-19)
packaging/macosx/ScriptExec/main.c (+7/-86)
src/extension/internal/pdfinput/pdf-input.cpp (+6/-1)
src/path-prefix.h (+17/-17)
src/prefix.cpp (+75/-0)
src/prefix.h (+17/-0)
src/ui/dialog/inkscape-preferences.cpp (+8/-0)
To merge this branch: bzr merge lp:~inkscape.dev/inkscape/osx-packaging-update
Reviewer Review Type Date Requested Status
Inkscape Developers Pending
Review via email: mp+278139@code.launchpad.net

Description of the change

Rewrite of relocation support for OS X application bundles:

Instead of requiring CWD to be a specific location inside the app bundle (to resolve relative paths to Inkscape's shared resources), use a macro similar to relocation support for Linux and Windows, based on the path of the current executable. This will ease command line usage (bug #181639).

To post a comment you must log in.
Revision history for this message
Martin Owens (doctormo) wrote :

Is this merge request still useful and open? Should we get these changes into trunk?

Revision history for this message
su_v (suv-lp) wrote :

The proposed changes in src/ are still useful (the merge proposal was never closed): future packages for macOS with GTK3/Quartz will still benefit if Inkscape had better internal relocation support on that platform than what the current code offers. The details of the proposed changes will have to be reviewed/adapted by whoever will work on future macOS packages of Inkscape with GTK3/Quartz.

Proposing to keep this one open for now.

Unmerged revisions

14484. By su_v

packaging/macosx: update comments in launcher scripts about CWD and relocation support

14483. By su_v

packaging/macosx: sync quartz launcher script (currently not used)

14482. By su_v

packaging/macosx: use new path-prefix macro for poppler relocation support

14481. By su_v

packaging/macosx: no need to store bundleId for relocation support with gtk-mac-integration

14480. By su_v

packaging/macosx: rewrite relocation support (bug #181639)

14479. By su_v

packaging/macosx: ScriptExec - remove unused code

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'packaging/macosx/Resources/bin/inkscape'
--- packaging/macosx/Resources/bin/inkscape 2015-11-02 10:14:45 +0000
+++ packaging/macosx/Resources/bin/inkscape 2015-11-20 12:21:31 +0000
@@ -23,17 +23,6 @@
23BASE="$(echo "$TOP" | sed -e 's/\/Contents\/Resources.*$//')"23BASE="$(echo "$TOP" | sed -e 's/\/Contents\/Resources.*$//')"
24# e.g. /Applications/Inkscape.app24# e.g. /Applications/Inkscape.app
2525
26# FIXME: Inkscape needs better relocation support for OS X (get rid of the relative
27# path hack in src/path-prefix.h for osxapp-enabled builds). Until then, below change
28# of working directory is required:
29#
30# Due to changes after 0.48, we have to change working directory in the script named 'inkscape':
31# recursive calls to inkscape from python-based extensions otherwise cause the app to hang or
32# fail (for python-based extensions, inkscape changes the working directory to the
33# script's directory, and inkscape launched by python script thus can't find resources
34# like the now essential 'units.xml' in INKSCAPE_UIDIR relative to the working directory).
35cd "$BASE" || exit 1
36
37# don't prepend to $PATH in recursive calls:26# don't prepend to $PATH in recursive calls:
38if [ -z "$INK_PATH_ORIG" ]; then27if [ -z "$INK_PATH_ORIG" ]; then
3928
@@ -43,6 +32,7 @@
43 # Fink32 # Fink
44 # MacPorts (former DarwinPorts)33 # MacPorts (former DarwinPorts)
45 # LaTeX distribution for Mac OS X34 # LaTeX distribution for Mac OS X
35 # LaTeX distribution for OS X El Capitan
46 PATH_OTHER="/Library/TeX/texbin:/usr/texbin:/opt/local/bin:/sw/bin/:/usr/local/bin"36 PATH_OTHER="/Library/TeX/texbin:/usr/texbin:/opt/local/bin:/sw/bin/:/usr/local/bin"
4737
48 # Put /usr/bin at beginning of path so we make sure we use Apple's python 38 # Put /usr/bin at beginning of path so we make sure we use Apple's python
@@ -93,7 +83,6 @@
93export GVFS_DISABLE_FUSE=183export GVFS_DISABLE_FUSE=1
94export XDG_DATA_DIRS="$TOP/share"84export XDG_DATA_DIRS="$TOP/share"
95export ASPELL_CONF="prefix $TOP;"85export ASPELL_CONF="prefix $TOP;"
96export POPPLER_DATADIR="$TOP/share/poppler"
9786
98# no DBUS for now87# no DBUS for now
99unset DBUS_LAUNCHD_SESSION_BUS_SOCKET88unset DBUS_LAUNCHD_SESSION_BUS_SOCKET
@@ -109,16 +98,14 @@
109export INKSCAPE_PLUGINDIR="$TOP/lib/inkscape"98export INKSCAPE_PLUGINDIR="$TOP/lib/inkscape"
110export INKSCAPE_LOCALEDIR="$TOP/share/locale"99export INKSCAPE_LOCALEDIR="$TOP/share/locale"
111100
112# Handle the case where the directory storing Inkscape has special characters
113# ('#', '&', '|') in the name. These need to be escaped to work properly for
114# various configuration files.
115ESCAPEDTOP=`echo "$TOP" | sed 's/#/\\\\\\\\#/' | sed 's/&/\\\\\\&/g' | sed 's/|/\\\\\\|/g'`
116
117# Set GTK theme (only if there is no .gtkrc-2.0 in the user's home)101# Set GTK theme (only if there is no .gtkrc-2.0 in the user's home)
118if [[ ! -e "$HOME/.gtkrc-2.0" ]]; then102if [[ ! -e "$HOME/.gtkrc-2.0" ]]; then
119 export GTK2_RC_FILES="$ESCAPEDTOP/etc/gtk-2.0/gtkrc"103 export GTK2_RC_FILES="$TOP/etc/gtk-2.0/gtkrc"
120fi104fi
121105
106# ----------------------------
107# FIXME language detection and conversion into supported locale
108
122# If the AppleCollationOrder preference doesn't exist, we fall back to using109# If the AppleCollationOrder preference doesn't exist, we fall back to using
123# the AppleLocale preference.110# the AppleLocale preference.
124LANGSTR=`defaults read .GlobalPreferences AppleCollationOrder 2>/dev/null`111LANGSTR=`defaults read .GlobalPreferences AppleCollationOrder 2>/dev/null`
@@ -154,6 +141,9 @@
154[ $_DEBUG ] && echo "Setting Language: $LANG" 1>&2141[ $_DEBUG ] && echo "Setting Language: $LANG" 1>&2
155export LC_ALL="$LANG"142export LC_ALL="$LANG"
156143
144# end FIXME language detection
145# ----------------------------
146
157case "$INK_DEBUG" in147case "$INK_DEBUG" in
158 gdb)148 gdb)
159 EXEC="gdb --args" ;;149 EXEC="gdb --args" ;;
160150
=== modified file 'packaging/macosx/Resources/openDoc'
--- packaging/macosx/Resources/openDoc 2014-10-24 05:01:09 +0000
+++ packaging/macosx/Resources/openDoc 2015-11-20 12:21:31 +0000
@@ -14,4 +14,8 @@
1414
15source "${CWD}/xdg_setup.sh"15source "${CWD}/xdg_setup.sh"
1616
17# When launched via Finder, cd into $HOME first (otherwise CWD in
18# GtkFileChooser's Places is '/').
19cd "$HOME"
20
17exec "$CWD/bin/inkscape" "$@"21exec "$CWD/bin/inkscape" "$@"
1822
=== modified file 'packaging/macosx/Resources/script'
--- packaging/macosx/Resources/script 2014-10-24 05:01:09 +0000
+++ packaging/macosx/Resources/script 2015-11-20 12:21:31 +0000
@@ -17,11 +17,10 @@
17source "${CWD}/xdg_setup.sh"17source "${CWD}/xdg_setup.sh"
18source "${CWD}/alert_fccache.sh"18source "${CWD}/alert_fccache.sh"
1919
20# TODO examine whether it would be wisest to move the code from inkscape shell20# When launched via Finder, cd into $HOME first (otherwise CWD in
21# script and getdisplay.sh to here and only keep the real binary in bin. This21# GtkFileChooser's Places is '/'). Direct command line usage of
22# may make things easier on Leopard and may also help using Inkscape on the22# Inkscape.app/Contents/Resources/bin/inkscape is now possible
23# command line.23# without requiring absolute paths (better relocation support).
24#24cd "$HOME"
25# See related FIXME in bin/inkscape for requirements to merge the two scripts.
2625
27exec "$CWD/bin/inkscape" "$@"26exec "$CWD/bin/inkscape" "$@"
2827
=== modified file 'packaging/macosx/ScriptExec/launcher-quartz-no-macintegration.sh'
--- packaging/macosx/ScriptExec/launcher-quartz-no-macintegration.sh 2015-01-10 16:06:20 +0000
+++ packaging/macosx/ScriptExec/launcher-quartz-no-macintegration.sh 2015-11-20 12:21:31 +0000
@@ -26,17 +26,6 @@
26source "${TOP}/xdg_setup.sh"26source "${TOP}/xdg_setup.sh"
27source "${TOP}/alert_fccache.sh"27source "${TOP}/alert_fccache.sh"
2828
29# FIXME: Inkscape needs better relocation support for OS X (get rid of the relative
30# path hack in src/path-prefix.h for osxapp-enabled builds). Until then, below change
31# of working directory is required:
32#
33# Due to changes after 0.48, we have to change working directory in the script named 'inkscape':
34# recursive calls to inkscape from python-based extensions otherwise cause the app to hang or
35# fail (for python-based extensions, inkscape changes the working directory to the
36# script's directory, and inkscape launched by python script thus can't find resources
37# like the now essential 'units.xml' in INKSCAPE_UIDIR relative to the working directory).
38cd "$BASE" || exit 1
39
40# don't prepend to $PATH in recursive calls:29# don't prepend to $PATH in recursive calls:
41if [ -z "$INK_PATH_ORIG" ]; then30if [ -z "$INK_PATH_ORIG" ]; then
4231
@@ -46,7 +35,8 @@
46 # Fink35 # Fink
47 # MacPorts (former DarwinPorts)36 # MacPorts (former DarwinPorts)
48 # LaTeX distribution for Mac OS X37 # LaTeX distribution for Mac OS X
49 PATH_OTHER="/usr/texbin:/opt/local/bin:/sw/bin/:/usr/local/bin"38 # LaTeX distribution for OS X El Capitan
39 PATH_OTHER="/Library/TeX/texbin:/usr/texbin:/opt/local/bin:/sw/bin/:/usr/local/bin"
5040
51 # Put /usr/bin at beginning of path so we make sure we use Apple's python 41 # Put /usr/bin at beginning of path so we make sure we use Apple's python
52 # over one that may be installed be Macports, Fink or some other means.42 # over one that may be installed be Macports, Fink or some other means.
@@ -96,7 +86,6 @@
96export GVFS_DISABLE_FUSE=186export GVFS_DISABLE_FUSE=1
97export XDG_DATA_DIRS="$TOP/share"87export XDG_DATA_DIRS="$TOP/share"
98export ASPELL_CONF="prefix $TOP;"88export ASPELL_CONF="prefix $TOP;"
99export POPPLER_DATADIR="$TOP/share/poppler"
10089
101# no DBUS for now90# no DBUS for now
102unset DBUS_LAUNCHD_SESSION_BUS_SOCKET91unset DBUS_LAUNCHD_SESSION_BUS_SOCKET
@@ -112,16 +101,14 @@
112export INKSCAPE_PLUGINDIR="$TOP/lib/inkscape"101export INKSCAPE_PLUGINDIR="$TOP/lib/inkscape"
113export INKSCAPE_LOCALEDIR="$TOP/share/locale"102export INKSCAPE_LOCALEDIR="$TOP/share/locale"
114103
115# Handle the case where the directory storing Inkscape has special characters
116# ('#', '&', '|') in the name. These need to be escaped to work properly for
117# various configuration files.
118ESCAPEDTOP=`echo "$TOP" | sed 's/#/\\\\\\\\#/' | sed 's/&/\\\\\\&/g' | sed 's/|/\\\\\\|/g'`
119
120# Set GTK theme (only if there is no .gtkrc-2.0 in the user's home)104# Set GTK theme (only if there is no .gtkrc-2.0 in the user's home)
121if [[ ! -e "$HOME/.gtkrc-2.0" ]]; then105if [[ ! -e "$HOME/.gtkrc-2.0" ]]; then
122 export GTK2_RC_FILES="$ESCAPEDTOP/etc/gtk-2.0/gtkrc"106 export GTK2_RC_FILES="$TOP/etc/gtk-2.0/gtkrc"
123fi107fi
124108
109# ----------------------------
110# FIXME language detection and conversion into supported locale
111
125# If the AppleCollationOrder preference doesn't exist, we fall back to using112# If the AppleCollationOrder preference doesn't exist, we fall back to using
126# the AppleLocale preference.113# the AppleLocale preference.
127LANGSTR=`defaults read .GlobalPreferences AppleCollationOrder 2>/dev/null`114LANGSTR=`defaults read .GlobalPreferences AppleCollationOrder 2>/dev/null`
@@ -157,6 +144,9 @@
157[ $_DEBUG ] && echo "Setting Language: $LANG" 1>&2144[ $_DEBUG ] && echo "Setting Language: $LANG" 1>&2
158export LC_ALL="$LANG"145export LC_ALL="$LANG"
159146
147# end FIXME language detection
148# ----------------------------
149
160case "$INK_DEBUG" in150case "$INK_DEBUG" in
161 gdb)151 gdb)
162 EXEC="gdb --args" ;;152 EXEC="gdb --args" ;;
@@ -170,6 +160,7 @@
170unset INK_DEBUG # ignore for recursive calls160unset INK_DEBUG # ignore for recursive calls
171161
172if [ "x$INK_DEBUG_SHELL" != "x" ]; then162if [ "x$INK_DEBUG_SHELL" != "x" ]; then
163 unset INK_DEBUG_SHELL # ignore for recursive calls
173 exec bash164 exec bash
174else165else
175 $EXEC "$CWD/inkscape-bin" "$@"166 $EXEC "$CWD/inkscape-bin" "$@"
176167
=== modified file 'packaging/macosx/ScriptExec/main.c'
--- packaging/macosx/ScriptExec/main.c 2014-08-21 10:26:09 +0000
+++ packaging/macosx/ScriptExec/main.c 2015-11-20 12:21:31 +0000
@@ -42,8 +42,7 @@
42// Apple stuff42// Apple stuff
4343
44// Note: including Carbon prevents building the launcher app in x86_6444// Note: including Carbon prevents building the launcher app in x86_64
45// used for StandardAlert in RequestUserAttention(), 45// used for StandardAlert in RedFatalAlert()
46// RedFatalAlert()
47#include <Carbon/Carbon.h>46#include <Carbon/Carbon.h>
4847
49#include <CoreFoundation/CoreFoundation.h>48#include <CoreFoundation/CoreFoundation.h>
@@ -103,8 +102,6 @@
103 AppleEvent *reply, long refCon);102 AppleEvent *reply, long refCon);
104static OSErr AppOpenAppAEHandler(const AppleEvent *theAppleEvent,103static OSErr AppOpenAppAEHandler(const AppleEvent *theAppleEvent,
105 AppleEvent *reply, long refCon);104 AppleEvent *reply, long refCon);
106static OSStatus FCCacheFailedHandler(EventHandlerCallRef theHandlerCall,
107 EventRef theEvent, void *userData);
108static OSErr AppReopenAppAEHandler(const AppleEvent *theAppleEvent,105static OSErr AppReopenAppAEHandler(const AppleEvent *theAppleEvent,
109 AppleEvent *reply, long refCon);106 AppleEvent *reply, long refCon);
110107
@@ -146,7 +143,6 @@
146int main(int argc, char* argv[])143int main(int argc, char* argv[])
147{144{
148 OSErr err = noErr;145 OSErr err = noErr;
149 EventTypeSpec FCCacheEvents = { kEventClassRedFatalAlert, kEventKindFCCacheFailed };
150146
151 InitCursor();147 InitCursor();
152148
@@ -165,16 +161,12 @@
165 NewAEEventHandlerUPP(AppReopenAppAEHandler),161 NewAEEventHandlerUPP(AppReopenAppAEHandler),
166 0, false);162 0, false);
167 163
168 err += InstallEventHandler(GetApplicationEventTarget(),
169 NewEventHandlerUPP(FCCacheFailedHandler), 1,
170 &FCCacheEvents, NULL, NULL);
171
172 if (err) RedFatalAlert("\pInitialization Error",164 if (err) RedFatalAlert("\pInitialization Error",
173 "\pError initing Apple Event handlers.");165 "\pError initing Apple Event handlers.");
174166
175 //create the menu bar167 //create the menu bar
176 if (err = LoadMenuBar(NULL)) RedFatalAlert("\pInitialization Error",168 if ((err = LoadMenuBar(NULL))) RedFatalAlert("\pInitialization Error",
177 "\pError loading MenuBar.nib.");169 "\pError loading MenuBar.nib.");
178 170
179 GetParameters(); //load data from files containing exec settings171 GetParameters(); //load data from files containing exec settings
180172
@@ -188,86 +180,15 @@
188#pragma mark -180#pragma mark -
189181
190182
191static void RequestUserAttention(void)
192{
193 NMRecPtr notificationRequest = (NMRecPtr) NewPtr(sizeof(NMRec));
194
195 memset(notificationRequest, 0, sizeof(*notificationRequest));
196 notificationRequest->qType = nmType;
197 notificationRequest->nmMark = 1;
198 notificationRequest->nmIcon = 0;
199 notificationRequest->nmSound = 0;
200 notificationRequest->nmStr = NULL;
201 notificationRequest->nmResp = NULL;
202
203 verify_noerr(NMInstall(notificationRequest));
204}
205
206
207static void ShowFirstStartWarningDialog(void)
208{
209 SInt16 itemHit;
210
211 AlertStdAlertParamRec params;
212 params.movable = true;
213 params.helpButton = false;
214 params.filterProc = NULL;
215 params.defaultText = (void *) kAlertDefaultOKText;
216 params.cancelText = NULL;
217 params.otherText = NULL;
218 params.defaultButton = kAlertStdAlertOKButton;
219 params.cancelButton = kAlertStdAlertCancelButton;
220 params.position = kWindowDefaultPosition;
221
222 StandardAlert(kAlertNoteAlert, "\pInkscape on Mac OS X",
223 "\pWhile Inkscape is open, its windows can be displayed or hidden by displaying or hiding the X11 application.\n\nThe first time this version of Inkscape is run it may take several minutes before the main window is displayed while font caches are built.",
224 &params, &itemHit);
225}
226
227
228//////////////////////////////////
229// Handler for when fontconfig caches need to be generated
230// TODO: remove (alert and touch moved to launcher script)
231//////////////////////////////////
232static OSStatus FCCacheFailedHandler(EventHandlerCallRef theHandlerCall,
233 EventRef theEvent, void *userData)
234{
235
236 pthread_join(tid, NULL);
237 if (odtid) pthread_join(odtid, NULL);
238
239 // Bounce Inkscape Dock icon
240 RequestUserAttention();
241 // Need to show warning to the user, then carry on.
242 ShowFirstStartWarningDialog();
243
244 // Note that we've seen the warning.
245 system("test -d \"$HOME/.cache/inkscape\" || mkdir -p \"$HOME/.cache/inkscape\"; "
246 "touch \"$HOME/.cache/inkscape/.fccache-new\"");
247 // Rerun now.
248 OSErr err = ExecuteScript(scriptPath, &pid);
249 ExitToShell();
250
251 return noErr;
252}
253
254
255///////////////////////////////////183///////////////////////////////////
256// Execution thread starts here184// Execution thread starts here
257///////////////////////////////////185///////////////////////////////////
258static void *Execute (void *arg)186static void *Execute (void *arg)
259{187{
260 EventRef event;
261
262 taskDone = false;188 taskDone = false;
263 189
264 OSErr err = ExecuteScript(scriptPath, &pid);190 ExecuteScript(scriptPath, &pid);
265 if (err == (OSErr)12) {191 ExitToShell();
266 CreateEvent(NULL, kEventClassRedFatalAlert, kEventKindFCCacheFailed, 0,
267 kEventAttributeNone, &event);
268 PostEventToQueue(GetMainEventQueue(), event, kEventPriorityHigh);
269 }
270 else ExitToShell();
271 return 0;192 return 0;
272}193}
273194
@@ -407,8 +328,8 @@
407 OSErr err;328 OSErr err;
408 IBNibRef nibRef;329 IBNibRef nibRef;
409 330
410 if (err = CreateNibReference(CFSTR("MenuBar"), &nibRef)) return err;331 if ((err = CreateNibReference(CFSTR("MenuBar"), &nibRef))) return err;
411 if (err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar"))) return err;332 if ((err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar")))) return err;
412 DisposeNibReference(nibRef);333 DisposeNibReference(nibRef);
413334
414 return noErr;335 return noErr;
415336
=== modified file 'src/extension/internal/pdfinput/pdf-input.cpp'
--- src/extension/internal/pdfinput/pdf-input.cpp 2015-10-19 16:01:08 +0000
+++ src/extension/internal/pdfinput/pdf-input.cpp 2015-11-20 12:21:31 +0000
@@ -62,6 +62,10 @@
6262
63#include <gdkmm/general.h>63#include <gdkmm/general.h>
6464
65#ifdef ENABLE_OSX_APP_LOCATIONS
66#include "path-prefix.h"
67#endif
68
65namespace Inkscape {69namespace Inkscape {
66namespace Extension {70namespace Extension {
67namespace Internal {71namespace Internal {
@@ -687,7 +691,8 @@
687 // FIXES: Inkscape bug #956282, #1264793691 // FIXES: Inkscape bug #956282, #1264793
688 // TODO: report RFE upstream (full relocation support for OS X packaging)692 // TODO: report RFE upstream (full relocation support for OS X packaging)
689 //693 //
690 gchar const *poppler_datadir = g_getenv("POPPLER_DATADIR");694 gchar const *poppler_datadir = OSX_APP_DATADIR( "/poppler" );
695 //g_message("poppler_datadir: %s", poppler_datadir);
691 if (poppler_datadir != NULL) {696 if (poppler_datadir != NULL) {
692 globalParams = new GlobalParams(poppler_datadir);697 globalParams = new GlobalParams(poppler_datadir);
693 } else {698 } else {
694699
=== modified file 'src/path-prefix.h'
--- src/path-prefix.h 2014-10-18 21:44:39 +0000
+++ src/path-prefix.h 2015-11-20 12:21:31 +0000
@@ -66,23 +66,23 @@
66# define CREATE_PALETTESDIR WIN32_DATADIR("create\\swatches")66# define CREATE_PALETTESDIR WIN32_DATADIR("create\\swatches")
67# define CREATE_PATTERNSDIR WIN32_DATADIR("create\\patterns\\vector")67# define CREATE_PATTERNSDIR WIN32_DATADIR("create\\patterns\\vector")
68# elif defined ENABLE_OSX_APP_LOCATIONS68# elif defined ENABLE_OSX_APP_LOCATIONS
69# define INKSCAPE_APPICONDIR "Contents/Resources/share/pixmaps"69# define INKSCAPE_APPICONDIR OSX_APP_DATADIR( "/pixmaps" )
70# define INKSCAPE_ATTRRELDIR "Contents/Resources/share/inkscape/attributes"70# define INKSCAPE_ATTRRELDIR OSX_APP_DATADIR( "/inkscape/attributes" )
71# define INKSCAPE_BINDDIR "Contents/Resources/share/inkscape/bind"71# define INKSCAPE_BINDDIR OSX_APP_DATADIR( "/inkscape/bind" )
72# define INKSCAPE_EXAMPLESDIR "Contents/Resources/share/inkscape/examples"72# define INKSCAPE_EXAMPLESDIR OSX_APP_DATADIR( "/inkscape/examples" )
73# define INKSCAPE_EXTENSIONDIR "Contents/Resources/share/inkscape/extensions"73# define INKSCAPE_EXTENSIONDIR OSX_APP_DATADIR( "/inkscape/extensions" )
74# define INKSCAPE_FILTERDIR "Contents/Resources/share/inkscape/filters"74# define INKSCAPE_FILTERDIR OSX_APP_DATADIR( "/inkscape/filters" )
75# define INKSCAPE_GRADIENTSDIR "Contents/Resources/share/inkscape/gradients"75# define INKSCAPE_GRADIENTSDIR OSX_APP_DATADIR( "/inkscape/gradients" )
76# define INKSCAPE_KEYSDIR "Contents/Resources/share/inkscape/keys"76# define INKSCAPE_KEYSDIR OSX_APP_DATADIR( "/inkscape/keys" )
77# define INKSCAPE_PIXMAPDIR "Contents/Resources/share/inkscape/icons"77# define INKSCAPE_PIXMAPDIR OSX_APP_DATADIR( "/inkscape/icons" )
78# define INKSCAPE_MARKERSDIR "Contents/Resources/share/inkscape/markers"78# define INKSCAPE_MARKERSDIR OSX_APP_DATADIR( "/inkscape/markers" )
79# define INKSCAPE_PALETTESDIR "Contents/Resources/share/inkscape/palettes"79# define INKSCAPE_PALETTESDIR OSX_APP_DATADIR( "/inkscape/palettes" )
80# define INKSCAPE_PATTERNSDIR "Contents/Resources/share/inkscape/patterns"80# define INKSCAPE_PATTERNSDIR OSX_APP_DATADIR( "/inkscape/patterns" )
81# define INKSCAPE_SCREENSDIR "Contents/Resources/share/inkscape/screens"81# define INKSCAPE_SCREENSDIR OSX_APP_DATADIR( "/inkscape/screens" )
82# define INKSCAPE_SYMBOLSDIR "Contents/Resources/share/inkscape/symbols"82# define INKSCAPE_SYMBOLSDIR OSX_APP_DATADIR( "/inkscape/symbols" )
83# define INKSCAPE_TUTORIALSDIR "Contents/Resources/share/inkscape/tutorials"83# define INKSCAPE_TUTORIALSDIR OSX_APP_DATADIR( "/inkscape/tutorials" )
84# define INKSCAPE_TEMPLATESDIR "Contents/Resources/share/inkscape/templates"84# define INKSCAPE_TEMPLATESDIR OSX_APP_DATADIR( "/inkscape/templates" )
85# define INKSCAPE_UIDIR "Contents/Resources/share/inkscape/ui"85# define INKSCAPE_UIDIR OSX_APP_DATADIR( "/inkscape/ui" )
86//CREATE V0.1 support86//CREATE V0.1 support
87# define CREATE_GRADIENTSDIR "/Library/Application Support/create/gradients/gimp"87# define CREATE_GRADIENTSDIR "/Library/Application Support/create/gradients/gimp"
88# define CREATE_PALETTESDIR "/Library/Application Support/create/swatches"88# define CREATE_PALETTESDIR "/Library/Application Support/create/swatches"
8989
=== modified file 'src/prefix.cpp'
--- src/prefix.cpp 2014-10-08 02:22:03 +0000
+++ src/prefix.cpp 2015-11-20 12:21:31 +0000
@@ -491,5 +491,80 @@
491491
492492
493493
494#ifdef ENABLE_OSX_APP_LOCATIONS
495
496/*
497 * Provide a similar mechanism for osxapp. Enable a macro,
498 * OSX_APP_DATADIR, that can look up subpaths for inkscape resources
499 */
500
501static Glib::ustring osxapp_getDataDir()
502{
503 const gchar *dir = NULL;
504
505#ifdef WITH_MAC_INTEGRATION // Quartz-based app bundle with gtk-mac-integration
506 if (gtkosx_application_get_bundle_id()) {
507 dir = g_build_filename(gtkosx_application_get_resource_path(), "share", NULL);
508 } else {
509 dir = INKSCAPE_DATADIR;
510 }
511#else // for X11- or Quartz-based app bundle without gtk-mac-integration
512 char exe_path[PATH_MAX + 1];
513 uint32_t bufsize = sizeof(exe_path);
514 gchar *real_path;
515 gchar *bin_dir;
516
517 if ( _NSGetExecutablePath(exe_path, &bufsize) == 0 ) {
518 real_path = realpath(exe_path, NULL);
519 if (real_path) {
520 bin_dir = g_path_get_dirname(real_path);
521#ifdef GDK_WINDOWING_QUARTZ
522 // from Inkscape.app/Contents/MacOS
523 // to Inkscape.app/Contents/Resources/share
524 dir = g_build_path(G_DIR_SEPARATOR_S, g_path_get_dirname(bin_dir), "Resources", "share", NULL);
525#else
526 // from Inkscape.app/Contents/Resources/bin
527 // to Inkscape.app/Contents/Resources/share
528 dir = g_build_path(G_DIR_SEPARATOR_S, g_path_get_dirname(bin_dir), "share", NULL);
529#endif /* GDK_WINDOWING_QUARTZ */
530 //g_message("DataDir: %s", dir);
531 g_free(real_path);
532 g_free(bin_dir);
533 }
534 }
535#endif /* WITH_MAC_INTEGRATION */
536 Glib::ustring ret( dir );
537 return ret;
538}
539
540
541static Glib::ustring osxapp_getResourcePath(const Glib::ustring &childPath)
542{
543 Glib::ustring dir = osxapp_getDataDir();
544 if (childPath.size() > 0) {
545 dir += childPath;
546 }
547 return dir;
548}
549
550/*
551 * This is the visible utility function
552 */
553char *osxapp_relative_path(const char *childPath)
554{
555 static char *returnPath = 0;
556 if (!childPath)
557 childPath = "";
558 Glib::ustring resourcePath = osxapp_getResourcePath(childPath);
559 if (returnPath)
560 free(returnPath);
561 returnPath = strdup(resourcePath.c_str());
562 return returnPath;
563}
564
565#endif /* ENABLE_OSX_APP_LOCATIONS */
566
567
568
494569
495#endif /* _PREFIX_C */570#endif /* _PREFIX_C */
496571
=== modified file 'src/prefix.h'
--- src/prefix.h 2014-10-08 02:22:03 +0000
+++ src/prefix.h 2015-11-20 12:21:31 +0000
@@ -129,4 +129,21 @@
129129
130#endif130#endif
131131
132#ifdef ENABLE_OSX_APP_LOCATIONS
133
134#ifdef WITH_MAC_INTEGRATION
135#include <gtkmacintegration/gtkosxapplication.h>
136#else
137#include <mach-o/dyld.h>
138#endif /* WITH_MAC_INTEGRATION */
139
140#include <glib.h>
141#include <glibmm/ustring.h>
142
143char *osxapp_relative_path(const char *childPath);
144
145#define OSX_APP_DATADIR(suffix) (osxapp_relative_path(suffix))
146
147#endif /* ENABLE_OSX_APP_LOCATIONS */
148
132#endif /* _PREFIX_H_ */149#endif /* _PREFIX_H_ */
133150
=== modified file 'src/ui/dialog/inkscape-preferences.cpp'
--- src/ui/dialog/inkscape-preferences.cpp 2015-11-01 12:50:42 +0000
+++ src/ui/dialog/inkscape-preferences.cpp 2015-11-20 12:21:31 +0000
@@ -1987,7 +1987,15 @@
1987 _sys_tmp_files.set_editable(false);1987 _sys_tmp_files.set_editable(false);
1988 _page_system.add_line(true, _("Temporary files: "), _sys_tmp_files, "", _("Location of the temporary files used for autosave"), true);1988 _page_system.add_line(true, _("Temporary files: "), _sys_tmp_files, "", _("Location of the temporary files used for autosave"), true);
19891989
1990#ifdef ENABLE_BINRELOC
1991 _sys_data.set_text( BR_DATADIR("") );
1992#elif defined WIN32
1993 _sys_data.set_text( WIN32_DATADIR("share") );
1994#elif defined ENABLE_OSX_APP_LOCATIONS
1995 _sys_data.set_text( OSX_APP_DATADIR("") );
1996#else
1990 _sys_data.set_text( INKSCAPE_DATADIR );1997 _sys_data.set_text( INKSCAPE_DATADIR );
1998#endif
1991 _sys_data.set_editable(false);1999 _sys_data.set_editable(false);
1992 _page_system.add_line(true, _("Inkscape data: "), _sys_data, "", _("Location of Inkscape data"), true);2000 _page_system.add_line(true, _("Inkscape data: "), _sys_data, "", _("Location of Inkscape data"), true);
19932001