Skip to content

Commit

Permalink
Expose getUserMacroDir to python and use in preferences.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Jan 8, 2018
1 parent 2c69b79 commit d13d0bd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/App/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ class AppExport Application
static PyObject* sGetExportType (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject* sGetResourceDir (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject* sGetUserAppDataDir (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject* sGetUserMacroDir (PyObject *self,PyObject *args,PyObject *kwd);
static PyObject* sGetHomePath (PyObject *self,PyObject *args,PyObject *kwd);

static PyObject* sLoadFile (PyObject *self,PyObject *args,PyObject *kwd);
Expand Down
11 changes: 11 additions & 0 deletions src/App/ApplicationPy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ PyMethodDef Application::Methods[] = {
"Get the root directory of all resources"},
{"getUserAppDataDir", (PyCFunction) Application::sGetUserAppDataDir ,1,
"Get the root directory of user settings"},
{"getUserMacroDir", (PyCFunction) Application::sGetUserMacroDir ,1,
"Get the directory of the user's macro directory"},
{"getHomePath", (PyCFunction) Application::sGetHomePath ,1,
"Get the home path, i.e. the parent directory of the executable"},

Expand Down Expand Up @@ -582,6 +584,15 @@ PyObject* Application::sGetUserAppDataDir(PyObject * /*self*/, PyObject *args,Py
return Py::new_reference_to(user_data_dir);
}

PyObject* Application::sGetUserMacroDir(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
{
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
return NULL; // NULL triggers exception

Py::String user_macro_dir(Application::getUserMacroDir(),"utf-8");
return Py::new_reference_to(user_macro_dir);
}

PyObject* Application::sGetHomePath(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
{
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathPreferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def filePath(cls):
@classmethod
def macroFilePath(cls):
grp = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")
return grp.GetString("MacroPath", FreeCAD.getUserAppDataDir())
return grp.GetString("MacroPath", FreeCAD.getUserMacroDir())

@classmethod
def searchPaths(cls):
Expand Down

0 comments on commit d13d0bd

Please sign in to comment.