Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
297a54fa
Commit
297a54fa
authored
Apr 10, 2013
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make project templates work with KICAD_PTEMPLATES env var.
parent
3e4a79d0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
18 deletions
+31
-18
dialog_template_selector.cpp
kicad/dialogs/dialog_template_selector.cpp
+15
-10
prjconfig.cpp
kicad/prjconfig.cpp
+15
-7
project_template.h
kicad/project_template.h
+1
-1
No files found.
kicad/dialogs/dialog_template_selector.cpp
View file @
297a54fa
...
...
@@ -114,7 +114,7 @@ void TEMPLATE_WIDGET::OnMouse( wxMouseEvent& event )
void
DIALOG_TEMPLATE_SELECTOR
::
onNotebookResize
(
wxSizeEvent
&
event
)
{
for
(
size_t
i
=
0
;
i
<
m_notebook
->
GetPageCount
();
i
++
)
for
(
size_t
i
=
0
;
i
<
m_notebook
->
GetPageCount
();
i
++
)
{
m_panels
[
i
]
->
SetSize
(
m_notebook
->
GetSize
().
GetWidth
()
-
6
,
140
);
m_panels
[
i
]
->
m_SizerBase
->
FitInside
(
m_panels
[
i
]
);
...
...
@@ -190,24 +190,29 @@ void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPat
m_panels
.
push_back
(
p
);
// Get a list of files under the template path to include as choices...
wxArrayString
files
;
wxDir
dir
,
sub
;
wxArrayString
files
;
wxDir
dir
;
if
(
dir
.
Open
(
aPath
.
GetPath
()
)
)
wxString
path
=
aPath
.
GetFullPath
();
// caller ensures this ends with file separator.
if
(
dir
.
Open
(
path
)
)
{
wx
String
filename
;
bool
cont
=
dir
.
GetFirst
(
&
filename
,
wxEmptyString
,
wxDIR_FILES
|
wxDIR_DIRS
)
;
wx
Dir
sub_dir
;
wxString
sub_name
;
bool
cont
=
dir
.
GetFirst
(
&
sub_name
,
wxEmptyString
,
wxDIR_DIRS
);
while
(
cont
)
{
if
(
sub
.
Open
(
aPath
.
GetPathWithSep
()
+
filename
)
)
wxString
sub_full
=
path
+
sub_name
;
if
(
sub_dir
.
Open
(
sub_full
)
)
{
files
.
Add
(
filename
);
PROJECT_TEMPLATE
*
pt
=
new
PROJECT_TEMPLATE
(
aPath
.
GetPathWithSep
()
+
filename
);
files
.
Add
(
sub_name
);
PROJECT_TEMPLATE
*
pt
=
new
PROJECT_TEMPLATE
(
sub_full
);
AddTemplate
(
m_notebook
->
GetPageCount
()
-
1
,
pt
);
}
cont
=
dir
.
GetNext
(
&
file
name
);
cont
=
dir
.
GetNext
(
&
sub_
name
);
}
}
}
kicad/prjconfig.cpp
View file @
297a54fa
...
...
@@ -78,11 +78,12 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo
{
wxString
kicadEnv
;
wxGetEnv
(
wxT
(
"KICAD"
),
&
kicadEnv
);
templatePath
=
kicadEnv
+
SEP
()
+
wxT
(
"template"
)
+
SEP
();
templatePath
=
kicadEnv
+
SEP
()
+
wxT
(
"template"
)
+
SEP
();
}
else
{
wxFileName
templatePath
=
wxPathOnly
(
wxStandardPaths
::
Get
().
GetExecutablePath
())
+
templatePath
=
wxPathOnly
(
wxStandardPaths
::
Get
().
GetExecutablePath
())
+
SEP
()
+
wxT
(
".."
)
+
SEP
()
+
wxT
(
"share"
)
+
SEP
()
+
wxT
(
"template"
)
+
SEP
();
}
...
...
@@ -97,13 +98,18 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo
// Check to see if a custom template location is available and setup a new selection tab
// if there is
wxString
envStr
;
wxGetEnv
(
wxT
(
"KICAD_PTEMPLATES"
),
&
envStr
);
wxFileName
envPath
=
envStr
;
wxGetEnv
(
wxT
(
"KICAD_PTEMPLATES"
),
&
envStr
);
if
(
envStr
!=
wxEmptyString
)
if
(
envStr
)
{
wxChar
sep
=
SEP
();
if
(
!
envStr
.
EndsWith
(
&
sep
)
)
envStr
+=
sep
;
wxFileName
envPath
=
envStr
;
ps
->
AddPage
(
_
(
"Portable Templates"
),
envPath
);
ps
->
AddPage
(
_
(
"Portable Templates"
),
envPath
);
}
// Show the project template selector dialog
...
...
@@ -236,7 +242,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
if
(
!
m_ProjectFileName
.
FileExists
()
&&
!
filename
.
IsSameAs
(
nameless_prj
)
)
{
wxString
msg
;
msg
.
Printf
(
_
(
"KiCad project file <%s> not found"
),
msg
.
Printf
(
_
(
"KiCad project file <%s> not found"
),
GetChars
(
m_ProjectFileName
.
GetFullPath
()
)
);
DisplayError
(
this
,
msg
);
...
...
@@ -256,6 +262,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
SetTitle
(
title
);
UpdateFileHistory
(
m_ProjectFileName
.
GetFullPath
()
);
m_LeftWin
->
ReCreateTreePrj
();
#ifdef KICAD_USE_FILES_WATCHER
// Rebuild the list of watched paths.
// however this is possible only when the main loop event handler is running,
...
...
@@ -263,6 +270,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
wxCommandEvent
cmd
(
wxEVT_COMMAND_MENU_SELECTED
,
ID_INIT_WATCHED_PATHS
);
wxPostEvent
(
this
,
cmd
);
#endif
wxString
msg
;
msg
.
Format
(
_
(
"Working dir: <%s>
\n
Project: <%s>
\n
"
),
GetChars
(
m_ProjectFileName
.
GetPath
()
),
...
...
kicad/project_template.h
View file @
297a54fa
...
...
@@ -96,7 +96,7 @@
wxStandardPaths::GetExecutableDir()/../share/template/
wxStandardPaths::GetUserDataDir()/templates/
wxGetEnv(wxT("KICAD_TEMPLATES"))
wxGetEnv(wxT("KICAD_
P
TEMPLATES"))
wxGetEnv(wxT("KICAD"))/template/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment