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

Proposed by su_v on 2015-11-20
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 2015-11-20 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.
Martin Owens (doctormo) wrote :

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

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 on 2015-11-20

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

14483. By su_v on 2015-11-20

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

14482. By su_v on 2015-11-20

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

14481. By su_v on 2015-11-20

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

14480. By su_v on 2015-11-20

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

14479. By su_v on 2015-11-20

packaging/macosx: ScriptExec - remove unused code

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'packaging/macosx/Resources/bin/inkscape'
2--- packaging/macosx/Resources/bin/inkscape 2015-11-02 10:14:45 +0000
3+++ packaging/macosx/Resources/bin/inkscape 2015-11-20 12:21:31 +0000
4@@ -23,17 +23,6 @@
5 BASE="$(echo "$TOP" | sed -e 's/\/Contents\/Resources.*$//')"
6 # e.g. /Applications/Inkscape.app
7
8-# FIXME: Inkscape needs better relocation support for OS X (get rid of the relative
9-# path hack in src/path-prefix.h for osxapp-enabled builds). Until then, below change
10-# of working directory is required:
11-#
12-# Due to changes after 0.48, we have to change working directory in the script named 'inkscape':
13-# recursive calls to inkscape from python-based extensions otherwise cause the app to hang or
14-# fail (for python-based extensions, inkscape changes the working directory to the
15-# script's directory, and inkscape launched by python script thus can't find resources
16-# like the now essential 'units.xml' in INKSCAPE_UIDIR relative to the working directory).
17-cd "$BASE" || exit 1
18-
19 # don't prepend to $PATH in recursive calls:
20 if [ -z "$INK_PATH_ORIG" ]; then
21
22@@ -43,6 +32,7 @@
23 # Fink
24 # MacPorts (former DarwinPorts)
25 # LaTeX distribution for Mac OS X
26+ # LaTeX distribution for OS X El Capitan
27 PATH_OTHER="/Library/TeX/texbin:/usr/texbin:/opt/local/bin:/sw/bin/:/usr/local/bin"
28
29 # Put /usr/bin at beginning of path so we make sure we use Apple's python
30@@ -93,7 +83,6 @@
31 export GVFS_DISABLE_FUSE=1
32 export XDG_DATA_DIRS="$TOP/share"
33 export ASPELL_CONF="prefix $TOP;"
34-export POPPLER_DATADIR="$TOP/share/poppler"
35
36 # no DBUS for now
37 unset DBUS_LAUNCHD_SESSION_BUS_SOCKET
38@@ -109,16 +98,14 @@
39 export INKSCAPE_PLUGINDIR="$TOP/lib/inkscape"
40 export INKSCAPE_LOCALEDIR="$TOP/share/locale"
41
42-# Handle the case where the directory storing Inkscape has special characters
43-# ('#', '&', '|') in the name. These need to be escaped to work properly for
44-# various configuration files.
45-ESCAPEDTOP=`echo "$TOP" | sed 's/#/\\\\\\\\#/' | sed 's/&/\\\\\\&/g' | sed 's/|/\\\\\\|/g'`
46-
47 # Set GTK theme (only if there is no .gtkrc-2.0 in the user's home)
48 if [[ ! -e "$HOME/.gtkrc-2.0" ]]; then
49- export GTK2_RC_FILES="$ESCAPEDTOP/etc/gtk-2.0/gtkrc"
50+ export GTK2_RC_FILES="$TOP/etc/gtk-2.0/gtkrc"
51 fi
52
53+# ----------------------------
54+# FIXME language detection and conversion into supported locale
55+
56 # If the AppleCollationOrder preference doesn't exist, we fall back to using
57 # the AppleLocale preference.
58 LANGSTR=`defaults read .GlobalPreferences AppleCollationOrder 2>/dev/null`
59@@ -154,6 +141,9 @@
60 [ $_DEBUG ] && echo "Setting Language: $LANG" 1>&2
61 export LC_ALL="$LANG"
62
63+# end FIXME language detection
64+# ----------------------------
65+
66 case "$INK_DEBUG" in
67 gdb)
68 EXEC="gdb --args" ;;
69
70=== modified file 'packaging/macosx/Resources/openDoc'
71--- packaging/macosx/Resources/openDoc 2014-10-24 05:01:09 +0000
72+++ packaging/macosx/Resources/openDoc 2015-11-20 12:21:31 +0000
73@@ -14,4 +14,8 @@
74
75 source "${CWD}/xdg_setup.sh"
76
77+# When launched via Finder, cd into $HOME first (otherwise CWD in
78+# GtkFileChooser's Places is '/').
79+cd "$HOME"
80+
81 exec "$CWD/bin/inkscape" "$@"
82
83=== modified file 'packaging/macosx/Resources/script'
84--- packaging/macosx/Resources/script 2014-10-24 05:01:09 +0000
85+++ packaging/macosx/Resources/script 2015-11-20 12:21:31 +0000
86@@ -17,11 +17,10 @@
87 source "${CWD}/xdg_setup.sh"
88 source "${CWD}/alert_fccache.sh"
89
90-# TODO examine whether it would be wisest to move the code from inkscape shell
91-# script and getdisplay.sh to here and only keep the real binary in bin. This
92-# may make things easier on Leopard and may also help using Inkscape on the
93-# command line.
94-#
95-# See related FIXME in bin/inkscape for requirements to merge the two scripts.
96+# When launched via Finder, cd into $HOME first (otherwise CWD in
97+# GtkFileChooser's Places is '/'). Direct command line usage of
98+# Inkscape.app/Contents/Resources/bin/inkscape is now possible
99+# without requiring absolute paths (better relocation support).
100+cd "$HOME"
101
102 exec "$CWD/bin/inkscape" "$@"
103
104=== modified file 'packaging/macosx/ScriptExec/launcher-quartz-no-macintegration.sh'
105--- packaging/macosx/ScriptExec/launcher-quartz-no-macintegration.sh 2015-01-10 16:06:20 +0000
106+++ packaging/macosx/ScriptExec/launcher-quartz-no-macintegration.sh 2015-11-20 12:21:31 +0000
107@@ -26,17 +26,6 @@
108 source "${TOP}/xdg_setup.sh"
109 source "${TOP}/alert_fccache.sh"
110
111-# FIXME: Inkscape needs better relocation support for OS X (get rid of the relative
112-# path hack in src/path-prefix.h for osxapp-enabled builds). Until then, below change
113-# of working directory is required:
114-#
115-# Due to changes after 0.48, we have to change working directory in the script named 'inkscape':
116-# recursive calls to inkscape from python-based extensions otherwise cause the app to hang or
117-# fail (for python-based extensions, inkscape changes the working directory to the
118-# script's directory, and inkscape launched by python script thus can't find resources
119-# like the now essential 'units.xml' in INKSCAPE_UIDIR relative to the working directory).
120-cd "$BASE" || exit 1
121-
122 # don't prepend to $PATH in recursive calls:
123 if [ -z "$INK_PATH_ORIG" ]; then
124
125@@ -46,7 +35,8 @@
126 # Fink
127 # MacPorts (former DarwinPorts)
128 # LaTeX distribution for Mac OS X
129- PATH_OTHER="/usr/texbin:/opt/local/bin:/sw/bin/:/usr/local/bin"
130+ # LaTeX distribution for OS X El Capitan
131+ PATH_OTHER="/Library/TeX/texbin:/usr/texbin:/opt/local/bin:/sw/bin/:/usr/local/bin"
132
133 # Put /usr/bin at beginning of path so we make sure we use Apple's python
134 # over one that may be installed be Macports, Fink or some other means.
135@@ -96,7 +86,6 @@
136 export GVFS_DISABLE_FUSE=1
137 export XDG_DATA_DIRS="$TOP/share"
138 export ASPELL_CONF="prefix $TOP;"
139-export POPPLER_DATADIR="$TOP/share/poppler"
140
141 # no DBUS for now
142 unset DBUS_LAUNCHD_SESSION_BUS_SOCKET
143@@ -112,16 +101,14 @@
144 export INKSCAPE_PLUGINDIR="$TOP/lib/inkscape"
145 export INKSCAPE_LOCALEDIR="$TOP/share/locale"
146
147-# Handle the case where the directory storing Inkscape has special characters
148-# ('#', '&', '|') in the name. These need to be escaped to work properly for
149-# various configuration files.
150-ESCAPEDTOP=`echo "$TOP" | sed 's/#/\\\\\\\\#/' | sed 's/&/\\\\\\&/g' | sed 's/|/\\\\\\|/g'`
151-
152 # Set GTK theme (only if there is no .gtkrc-2.0 in the user's home)
153 if [[ ! -e "$HOME/.gtkrc-2.0" ]]; then
154- export GTK2_RC_FILES="$ESCAPEDTOP/etc/gtk-2.0/gtkrc"
155+ export GTK2_RC_FILES="$TOP/etc/gtk-2.0/gtkrc"
156 fi
157
158+# ----------------------------
159+# FIXME language detection and conversion into supported locale
160+
161 # If the AppleCollationOrder preference doesn't exist, we fall back to using
162 # the AppleLocale preference.
163 LANGSTR=`defaults read .GlobalPreferences AppleCollationOrder 2>/dev/null`
164@@ -157,6 +144,9 @@
165 [ $_DEBUG ] && echo "Setting Language: $LANG" 1>&2
166 export LC_ALL="$LANG"
167
168+# end FIXME language detection
169+# ----------------------------
170+
171 case "$INK_DEBUG" in
172 gdb)
173 EXEC="gdb --args" ;;
174@@ -170,6 +160,7 @@
175 unset INK_DEBUG # ignore for recursive calls
176
177 if [ "x$INK_DEBUG_SHELL" != "x" ]; then
178+ unset INK_DEBUG_SHELL # ignore for recursive calls
179 exec bash
180 else
181 $EXEC "$CWD/inkscape-bin" "$@"
182
183=== modified file 'packaging/macosx/ScriptExec/main.c'
184--- packaging/macosx/ScriptExec/main.c 2014-08-21 10:26:09 +0000
185+++ packaging/macosx/ScriptExec/main.c 2015-11-20 12:21:31 +0000
186@@ -42,8 +42,7 @@
187 // Apple stuff
188
189 // Note: including Carbon prevents building the launcher app in x86_64
190-// used for StandardAlert in RequestUserAttention(),
191-// RedFatalAlert()
192+// used for StandardAlert in RedFatalAlert()
193 #include <Carbon/Carbon.h>
194
195 #include <CoreFoundation/CoreFoundation.h>
196@@ -103,8 +102,6 @@
197 AppleEvent *reply, long refCon);
198 static OSErr AppOpenAppAEHandler(const AppleEvent *theAppleEvent,
199 AppleEvent *reply, long refCon);
200-static OSStatus FCCacheFailedHandler(EventHandlerCallRef theHandlerCall,
201- EventRef theEvent, void *userData);
202 static OSErr AppReopenAppAEHandler(const AppleEvent *theAppleEvent,
203 AppleEvent *reply, long refCon);
204
205@@ -146,7 +143,6 @@
206 int main(int argc, char* argv[])
207 {
208 OSErr err = noErr;
209- EventTypeSpec FCCacheEvents = { kEventClassRedFatalAlert, kEventKindFCCacheFailed };
210
211 InitCursor();
212
213@@ -165,16 +161,12 @@
214 NewAEEventHandlerUPP(AppReopenAppAEHandler),
215 0, false);
216
217- err += InstallEventHandler(GetApplicationEventTarget(),
218- NewEventHandlerUPP(FCCacheFailedHandler), 1,
219- &FCCacheEvents, NULL, NULL);
220-
221 if (err) RedFatalAlert("\pInitialization Error",
222 "\pError initing Apple Event handlers.");
223
224 //create the menu bar
225- if (err = LoadMenuBar(NULL)) RedFatalAlert("\pInitialization Error",
226- "\pError loading MenuBar.nib.");
227+ if ((err = LoadMenuBar(NULL))) RedFatalAlert("\pInitialization Error",
228+ "\pError loading MenuBar.nib.");
229
230 GetParameters(); //load data from files containing exec settings
231
232@@ -188,86 +180,15 @@
233 #pragma mark -
234
235
236-static void RequestUserAttention(void)
237-{
238- NMRecPtr notificationRequest = (NMRecPtr) NewPtr(sizeof(NMRec));
239-
240- memset(notificationRequest, 0, sizeof(*notificationRequest));
241- notificationRequest->qType = nmType;
242- notificationRequest->nmMark = 1;
243- notificationRequest->nmIcon = 0;
244- notificationRequest->nmSound = 0;
245- notificationRequest->nmStr = NULL;
246- notificationRequest->nmResp = NULL;
247-
248- verify_noerr(NMInstall(notificationRequest));
249-}
250-
251-
252-static void ShowFirstStartWarningDialog(void)
253-{
254- SInt16 itemHit;
255-
256- AlertStdAlertParamRec params;
257- params.movable = true;
258- params.helpButton = false;
259- params.filterProc = NULL;
260- params.defaultText = (void *) kAlertDefaultOKText;
261- params.cancelText = NULL;
262- params.otherText = NULL;
263- params.defaultButton = kAlertStdAlertOKButton;
264- params.cancelButton = kAlertStdAlertCancelButton;
265- params.position = kWindowDefaultPosition;
266-
267- StandardAlert(kAlertNoteAlert, "\pInkscape on Mac OS X",
268- "\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.",
269- &params, &itemHit);
270-}
271-
272-
273-//////////////////////////////////
274-// Handler for when fontconfig caches need to be generated
275-// TODO: remove (alert and touch moved to launcher script)
276-//////////////////////////////////
277-static OSStatus FCCacheFailedHandler(EventHandlerCallRef theHandlerCall,
278- EventRef theEvent, void *userData)
279-{
280-
281- pthread_join(tid, NULL);
282- if (odtid) pthread_join(odtid, NULL);
283-
284- // Bounce Inkscape Dock icon
285- RequestUserAttention();
286- // Need to show warning to the user, then carry on.
287- ShowFirstStartWarningDialog();
288-
289- // Note that we've seen the warning.
290- system("test -d \"$HOME/.cache/inkscape\" || mkdir -p \"$HOME/.cache/inkscape\"; "
291- "touch \"$HOME/.cache/inkscape/.fccache-new\"");
292- // Rerun now.
293- OSErr err = ExecuteScript(scriptPath, &pid);
294- ExitToShell();
295-
296- return noErr;
297-}
298-
299-
300 ///////////////////////////////////
301 // Execution thread starts here
302 ///////////////////////////////////
303 static void *Execute (void *arg)
304 {
305- EventRef event;
306-
307 taskDone = false;
308
309- OSErr err = ExecuteScript(scriptPath, &pid);
310- if (err == (OSErr)12) {
311- CreateEvent(NULL, kEventClassRedFatalAlert, kEventKindFCCacheFailed, 0,
312- kEventAttributeNone, &event);
313- PostEventToQueue(GetMainEventQueue(), event, kEventPriorityHigh);
314- }
315- else ExitToShell();
316+ ExecuteScript(scriptPath, &pid);
317+ ExitToShell();
318 return 0;
319 }
320
321@@ -407,8 +328,8 @@
322 OSErr err;
323 IBNibRef nibRef;
324
325- if (err = CreateNibReference(CFSTR("MenuBar"), &nibRef)) return err;
326- if (err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar"))) return err;
327+ if ((err = CreateNibReference(CFSTR("MenuBar"), &nibRef))) return err;
328+ if ((err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar")))) return err;
329 DisposeNibReference(nibRef);
330
331 return noErr;
332
333=== modified file 'src/extension/internal/pdfinput/pdf-input.cpp'
334--- src/extension/internal/pdfinput/pdf-input.cpp 2015-10-19 16:01:08 +0000
335+++ src/extension/internal/pdfinput/pdf-input.cpp 2015-11-20 12:21:31 +0000
336@@ -62,6 +62,10 @@
337
338 #include <gdkmm/general.h>
339
340+#ifdef ENABLE_OSX_APP_LOCATIONS
341+#include "path-prefix.h"
342+#endif
343+
344 namespace Inkscape {
345 namespace Extension {
346 namespace Internal {
347@@ -687,7 +691,8 @@
348 // FIXES: Inkscape bug #956282, #1264793
349 // TODO: report RFE upstream (full relocation support for OS X packaging)
350 //
351- gchar const *poppler_datadir = g_getenv("POPPLER_DATADIR");
352+ gchar const *poppler_datadir = OSX_APP_DATADIR( "/poppler" );
353+ //g_message("poppler_datadir: %s", poppler_datadir);
354 if (poppler_datadir != NULL) {
355 globalParams = new GlobalParams(poppler_datadir);
356 } else {
357
358=== modified file 'src/path-prefix.h'
359--- src/path-prefix.h 2014-10-18 21:44:39 +0000
360+++ src/path-prefix.h 2015-11-20 12:21:31 +0000
361@@ -66,23 +66,23 @@
362 # define CREATE_PALETTESDIR WIN32_DATADIR("create\\swatches")
363 # define CREATE_PATTERNSDIR WIN32_DATADIR("create\\patterns\\vector")
364 # elif defined ENABLE_OSX_APP_LOCATIONS
365-# define INKSCAPE_APPICONDIR "Contents/Resources/share/pixmaps"
366-# define INKSCAPE_ATTRRELDIR "Contents/Resources/share/inkscape/attributes"
367-# define INKSCAPE_BINDDIR "Contents/Resources/share/inkscape/bind"
368-# define INKSCAPE_EXAMPLESDIR "Contents/Resources/share/inkscape/examples"
369-# define INKSCAPE_EXTENSIONDIR "Contents/Resources/share/inkscape/extensions"
370-# define INKSCAPE_FILTERDIR "Contents/Resources/share/inkscape/filters"
371-# define INKSCAPE_GRADIENTSDIR "Contents/Resources/share/inkscape/gradients"
372-# define INKSCAPE_KEYSDIR "Contents/Resources/share/inkscape/keys"
373-# define INKSCAPE_PIXMAPDIR "Contents/Resources/share/inkscape/icons"
374-# define INKSCAPE_MARKERSDIR "Contents/Resources/share/inkscape/markers"
375-# define INKSCAPE_PALETTESDIR "Contents/Resources/share/inkscape/palettes"
376-# define INKSCAPE_PATTERNSDIR "Contents/Resources/share/inkscape/patterns"
377-# define INKSCAPE_SCREENSDIR "Contents/Resources/share/inkscape/screens"
378-# define INKSCAPE_SYMBOLSDIR "Contents/Resources/share/inkscape/symbols"
379-# define INKSCAPE_TUTORIALSDIR "Contents/Resources/share/inkscape/tutorials"
380-# define INKSCAPE_TEMPLATESDIR "Contents/Resources/share/inkscape/templates"
381-# define INKSCAPE_UIDIR "Contents/Resources/share/inkscape/ui"
382+# define INKSCAPE_APPICONDIR OSX_APP_DATADIR( "/pixmaps" )
383+# define INKSCAPE_ATTRRELDIR OSX_APP_DATADIR( "/inkscape/attributes" )
384+# define INKSCAPE_BINDDIR OSX_APP_DATADIR( "/inkscape/bind" )
385+# define INKSCAPE_EXAMPLESDIR OSX_APP_DATADIR( "/inkscape/examples" )
386+# define INKSCAPE_EXTENSIONDIR OSX_APP_DATADIR( "/inkscape/extensions" )
387+# define INKSCAPE_FILTERDIR OSX_APP_DATADIR( "/inkscape/filters" )
388+# define INKSCAPE_GRADIENTSDIR OSX_APP_DATADIR( "/inkscape/gradients" )
389+# define INKSCAPE_KEYSDIR OSX_APP_DATADIR( "/inkscape/keys" )
390+# define INKSCAPE_PIXMAPDIR OSX_APP_DATADIR( "/inkscape/icons" )
391+# define INKSCAPE_MARKERSDIR OSX_APP_DATADIR( "/inkscape/markers" )
392+# define INKSCAPE_PALETTESDIR OSX_APP_DATADIR( "/inkscape/palettes" )
393+# define INKSCAPE_PATTERNSDIR OSX_APP_DATADIR( "/inkscape/patterns" )
394+# define INKSCAPE_SCREENSDIR OSX_APP_DATADIR( "/inkscape/screens" )
395+# define INKSCAPE_SYMBOLSDIR OSX_APP_DATADIR( "/inkscape/symbols" )
396+# define INKSCAPE_TUTORIALSDIR OSX_APP_DATADIR( "/inkscape/tutorials" )
397+# define INKSCAPE_TEMPLATESDIR OSX_APP_DATADIR( "/inkscape/templates" )
398+# define INKSCAPE_UIDIR OSX_APP_DATADIR( "/inkscape/ui" )
399 //CREATE V0.1 support
400 # define CREATE_GRADIENTSDIR "/Library/Application Support/create/gradients/gimp"
401 # define CREATE_PALETTESDIR "/Library/Application Support/create/swatches"
402
403=== modified file 'src/prefix.cpp'
404--- src/prefix.cpp 2014-10-08 02:22:03 +0000
405+++ src/prefix.cpp 2015-11-20 12:21:31 +0000
406@@ -491,5 +491,80 @@
407
408
409
410+#ifdef ENABLE_OSX_APP_LOCATIONS
411+
412+/*
413+ * Provide a similar mechanism for osxapp. Enable a macro,
414+ * OSX_APP_DATADIR, that can look up subpaths for inkscape resources
415+ */
416+
417+static Glib::ustring osxapp_getDataDir()
418+{
419+ const gchar *dir = NULL;
420+
421+#ifdef WITH_MAC_INTEGRATION // Quartz-based app bundle with gtk-mac-integration
422+ if (gtkosx_application_get_bundle_id()) {
423+ dir = g_build_filename(gtkosx_application_get_resource_path(), "share", NULL);
424+ } else {
425+ dir = INKSCAPE_DATADIR;
426+ }
427+#else // for X11- or Quartz-based app bundle without gtk-mac-integration
428+ char exe_path[PATH_MAX + 1];
429+ uint32_t bufsize = sizeof(exe_path);
430+ gchar *real_path;
431+ gchar *bin_dir;
432+
433+ if ( _NSGetExecutablePath(exe_path, &bufsize) == 0 ) {
434+ real_path = realpath(exe_path, NULL);
435+ if (real_path) {
436+ bin_dir = g_path_get_dirname(real_path);
437+#ifdef GDK_WINDOWING_QUARTZ
438+ // from Inkscape.app/Contents/MacOS
439+ // to Inkscape.app/Contents/Resources/share
440+ dir = g_build_path(G_DIR_SEPARATOR_S, g_path_get_dirname(bin_dir), "Resources", "share", NULL);
441+#else
442+ // from Inkscape.app/Contents/Resources/bin
443+ // to Inkscape.app/Contents/Resources/share
444+ dir = g_build_path(G_DIR_SEPARATOR_S, g_path_get_dirname(bin_dir), "share", NULL);
445+#endif /* GDK_WINDOWING_QUARTZ */
446+ //g_message("DataDir: %s", dir);
447+ g_free(real_path);
448+ g_free(bin_dir);
449+ }
450+ }
451+#endif /* WITH_MAC_INTEGRATION */
452+ Glib::ustring ret( dir );
453+ return ret;
454+}
455+
456+
457+static Glib::ustring osxapp_getResourcePath(const Glib::ustring &childPath)
458+{
459+ Glib::ustring dir = osxapp_getDataDir();
460+ if (childPath.size() > 0) {
461+ dir += childPath;
462+ }
463+ return dir;
464+}
465+
466+/*
467+ * This is the visible utility function
468+ */
469+char *osxapp_relative_path(const char *childPath)
470+{
471+ static char *returnPath = 0;
472+ if (!childPath)
473+ childPath = "";
474+ Glib::ustring resourcePath = osxapp_getResourcePath(childPath);
475+ if (returnPath)
476+ free(returnPath);
477+ returnPath = strdup(resourcePath.c_str());
478+ return returnPath;
479+}
480+
481+#endif /* ENABLE_OSX_APP_LOCATIONS */
482+
483+
484+
485
486 #endif /* _PREFIX_C */
487
488=== modified file 'src/prefix.h'
489--- src/prefix.h 2014-10-08 02:22:03 +0000
490+++ src/prefix.h 2015-11-20 12:21:31 +0000
491@@ -129,4 +129,21 @@
492
493 #endif
494
495+#ifdef ENABLE_OSX_APP_LOCATIONS
496+
497+#ifdef WITH_MAC_INTEGRATION
498+#include <gtkmacintegration/gtkosxapplication.h>
499+#else
500+#include <mach-o/dyld.h>
501+#endif /* WITH_MAC_INTEGRATION */
502+
503+#include <glib.h>
504+#include <glibmm/ustring.h>
505+
506+char *osxapp_relative_path(const char *childPath);
507+
508+#define OSX_APP_DATADIR(suffix) (osxapp_relative_path(suffix))
509+
510+#endif /* ENABLE_OSX_APP_LOCATIONS */
511+
512 #endif /* _PREFIX_H_ */
513
514=== modified file 'src/ui/dialog/inkscape-preferences.cpp'
515--- src/ui/dialog/inkscape-preferences.cpp 2015-11-01 12:50:42 +0000
516+++ src/ui/dialog/inkscape-preferences.cpp 2015-11-20 12:21:31 +0000
517@@ -1987,7 +1987,15 @@
518 _sys_tmp_files.set_editable(false);
519 _page_system.add_line(true, _("Temporary files: "), _sys_tmp_files, "", _("Location of the temporary files used for autosave"), true);
520
521+#ifdef ENABLE_BINRELOC
522+ _sys_data.set_text( BR_DATADIR("") );
523+#elif defined WIN32
524+ _sys_data.set_text( WIN32_DATADIR("share") );
525+#elif defined ENABLE_OSX_APP_LOCATIONS
526+ _sys_data.set_text( OSX_APP_DATADIR("") );
527+#else
528 _sys_data.set_text( INKSCAPE_DATADIR );
529+#endif
530 _sys_data.set_editable(false);
531 _page_system.add_line(true, _("Inkscape data: "), _sys_data, "", _("Location of Inkscape data"), true);
532