Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
purr-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonathan Wilkes
purr-data
Commits
f62125fd
Commit
f62125fd
authored
8 years ago
by
Jonathan Wilkes
Browse files
Options
Downloads
Plain Diff
Merge branch 'aggraef/purr-data-mac-default-prefs-fix'
parents
590c9af0
656f9aac
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pd/src/s_file.c
+34
-1
34 additions, 1 deletion
pd/src/s_file.c
with
34 additions
and
1 deletion
pd/src/s_file.c
+
34
−
1
View file @
f62125fd
...
...
@@ -280,6 +280,39 @@ static void sys_initloadpreferences(void)
FILE
*
fp
;
size_t
sz
,
n
=
0
;
int
res
;
char
default_prefs
[
FILENAME_MAX
];
// default prefs embedded in the package
char
embedded_prefs
[
FILENAME_MAX
];
// overrides others for standalone app
char
embedded_prefs_file
[
FILENAME_MAX
];
char
user_prefs_file
[
FILENAME_MAX
];
const
char
*
prefs
,
*
homedir
=
getenv
(
"HOME"
);
struct
stat
statbuf
;
// On the Mac, we first look for an embedded prefs file, then for a user
// prefs file, and fall back to the defaults in the package if none of
// these exist. Note that Pd-l2ork can't create standalone apps à la
// Pd-extended right now, but we might want to support them in the future,
// so we handle the embedded prefs case anyway.
snprintf
(
default_prefs
,
FILENAME_MAX
,
"%s/../org.puredata.pd-l2ork.default"
,
sys_libdir
->
s_name
);
snprintf
(
embedded_prefs
,
FILENAME_MAX
,
"%s/../org.puredata.pd-l2ork"
,
sys_libdir
->
s_name
);
snprintf
(
embedded_prefs_file
,
FILENAME_MAX
,
"%s.plist"
,
embedded_prefs
);
snprintf
(
user_prefs_file
,
FILENAME_MAX
,
"%s/Library/Preferences/org.puredata.pd-l2ork.plist"
,
homedir
);
if
(
stat
(
embedded_prefs_file
,
&
statbuf
)
==
0
)
{
// Read from and write to the embedded prefs (standalone app).
prefs
=
embedded_prefs
;
strncpy
(
current_prefs
,
embedded_prefs
,
FILENAME_MAX
);
}
else
if
(
stat
(
user_prefs_file
,
&
statbuf
)
==
0
)
{
// Read from and write to the user prefs.
prefs
=
current_prefs
;
strcpy
(
current_prefs
,
"org.puredata.pd-l2ork"
);
}
else
{
// Read from the package defaults and write to the user prefs.
prefs
=
default_prefs
;
strcpy
(
current_prefs
,
"org.puredata.pd-l2ork"
);
}
// This looks complicated, but is rather straightforward. The individual
// stages of the pipe are:
// 1. defaults export: grab our defaults in XML format
...
...
@@ -293,7 +326,7 @@ static void sys_initloadpreferences(void)
// "loadlib1" : "libdir", loadlib1: libdir
// "path1" : "\/System\/Library\/Fonts" path1: /System/Library/Fonts
// }
snprintf
(
cmdbuf
,
MAXPDSTRING
,
"defaults export %s - | plutil -convert json -r -o - - | sed -E -e 's/[{}]//g' -e 's/^ *
\"
(([^
\"
]|
\\\\
.)*)
\"
*: *
\"
(([^
\"
]|
\\\\
.)*)
\"
.*/
\\
1:
\\
3/' -e 's/
\\\\
(.)/
\\
1/g'"
,
current_
prefs
);
snprintf
(
cmdbuf
,
MAXPDSTRING
,
"defaults export %s - | plutil -convert json -r -o - - | sed -E -e 's/[{}]//g' -e 's/^ *
\"
(([^
\"
]|
\\\\
.)*)
\"
*: *
\"
(([^
\"
]|
\\\\
.)*)
\"
.*/
\\
1:
\\
3/' -e 's/
\\\\
(.)/
\\
1/g'"
,
prefs
);
// open the pipe
fp
=
popen
(
cmdbuf
,
"r"
);
if
(
!
fp
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment