Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
7b7a6381
Commit
7b7a6381
authored
Jun 29, 2015
by
carlosperate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Electron: Add splash screen while app loads.
parent
6e85cc32
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
31 deletions
+69
-31
package/electron/app/main.js
package/electron/app/main.js
+30
-1
package/electron/app/servermgr.js
package/electron/app/servermgr.js
+39
-30
No files found.
package/electron/app/main.js
View file @
7b7a6381
...
...
@@ -11,8 +11,9 @@
var
app
=
require
(
'
app
'
);
var
shell
=
require
(
'
shell
'
);
var
server
=
require
(
'
./servermgr.js
'
);
var
jetpack
=
require
(
'
fs-jetpack
'
);
var
appMenu
=
require
(
'
./appmenu.js
'
);
var
server
=
require
(
'
./servermgr.js
'
);
var
BrowserWindow
=
require
(
'
browser-window
'
);
var
env
=
require
(
'
./vendor/electron_boilerplate/env_config
'
);
var
windowStateKeeper
=
require
(
'
./vendor/electron_boilerplate/window_state
'
);
...
...
@@ -28,6 +29,8 @@ var mainWindowState = windowStateKeeper('main', {
});
app
.
on
(
'
ready
'
,
function
()
{
var
splashWindow
=
createSplashWindow
();
server
.
startServer
();
mainWindow
=
new
BrowserWindow
({
...
...
@@ -38,6 +41,7 @@ app.on('ready', function () {
title
:
'
Ardublockly
'
,
transparent
:
false
,
frame
:
true
,
show
:
false
,
'
node-integration
'
:
false
,
'
web-preferences
'
:
{
'
web-security
'
:
true
,
...
...
@@ -69,6 +73,11 @@ app.on('ready', function () {
}
);
mainWindow
.
webContents
.
on
(
'
did-finish-load
'
,
function
()
{
mainWindow
.
show
();
splashWindow
.
close
();
});
mainWindow
.
loadUrl
(
'
http://localhost:8000/ardublockly
'
);
mainWindow
.
on
(
'
close
'
,
function
()
{
...
...
@@ -83,3 +92,23 @@ app.on('window-all-closed', function () {
// https://github.com/atom/electron/issues/1357
app
.
quit
();
});
function
createSplashWindow
()
{
var
imagePath
=
'
file://
'
+
server
.
getProjectJetpack
().
path
(
'
ardublockly
'
,
'
img
'
,
'
ardublockly_splash.png
'
);
var
splashWindow
=
new
BrowserWindow
({
width
:
500
,
height
:
225
,
frame
:
false
,
show
:
true
,
transparent
:
true
,
images
:
true
,
center
:
true
,
'
use-content-size
'
:
true
,
'
always-on-top
'
:
true
,
});
splashWindow
.
loadUrl
(
imagePath
);
return
splashWindow
;
}
package/electron/app/servermgr.js
View file @
7b7a6381
...
...
@@ -17,24 +17,23 @@ var env = require('./vendor/electron_boilerplate/env_config');
var
tag
=
'
[Server mgr]
'
var
serverProcess
=
null
;
var
ardublocklyRootDir
=
null
;
function
getServerExecLocation
()
{
// Relevant OS could be win32, linux, darwin
console
.
log
(
tag
+
'
OS detected:
'
+
process
.
platform
);
module
.
exports
.
getProjectJetpack
=
function
()
{
if
(
ardublocklyRootDir
==
null
)
{
// First, work out the project root directory
if
(
env
.
name
===
'
development
'
)
{
// In dev mode the file cwd is on the project/package/electron dir
var
ardublocklyRootDir
=
jetpack
.
dir
(
'
../../
'
);
ardublocklyRootDir
=
jetpack
.
dir
(
'
../../
'
);
}
else
{
// Cannot use relative paths with Production
, so let's try to find the
// Cannot use relative paths in build
, so let's try to find the
// ardublockly folder in a node from the executable file path tree
var
ardublocklyRootDir
=
jetpack
.
dir
(
__dirname
);
var
oldArdublocklyRootDir
=
''
;
while
(
ardublocklyRootDir
.
path
()
!=
oldArdublocklyRootDir
)
{
//console.log(tag + 'Search for Ardublockly project roo
t dir: ' +
//console.log(tag + 'Search for Ardublockly projec
t dir: ' +
// ardublocklyRootDir.cwd());
// Check if file
/ardublokly/index.html exists within current path
// Check if
/ardublokly/index.html exists within current path
if
(
jetpack
.
exists
(
ardublocklyRootDir
.
path
(
'
ardublockly
'
,
'
index.html
'
)))
{
// Found the right folder, break with this dir loaded
...
...
@@ -46,16 +45,26 @@ function getServerExecLocation() {
if
(
ardublocklyRootDir
.
path
()
==
oldArdublocklyRootDir
)
{
ardublocklyRootDir
=
jetpack
.
dir
(
'
.
'
);
ardublocklyNotFound
(
jetpack
.
path
(
'
.
'
));
ardublocklyNotFound
(
ardublocklyRootDir
.
path
(
'
.
'
));
}
}
console
.
log
(
tag
+
'
Ardublockly root dir:
'
+
ardublocklyRootDir
.
cwd
());
}
return
ardublocklyRootDir
;
};
function
getServerExecLocation
()
{
// Relevant OS could be win32, linux, darwin
console
.
log
(
tag
+
'
OS detected:
'
+
process
.
platform
);
var
ardublocklyProjRootDir
=
module
.
exports
.
getProjectJetpack
();
// Then, work out the location of the python executable files
if
(
process
.
platform
==
"
darwin
"
)
{
var
arduexecDir
=
ardublockly
RootDir
.
dir
(
'
arduexec.app/server
'
)
var
arduexecDir
=
ardublockly
ProjRootDir
.
dir
(
'
arduexec.app/server
'
);
}
else
{
var
arduexecDir
=
ardublockly
RootDir
.
dir
(
'
arduexec/server
'
)
var
arduexecDir
=
ardublockly
ProjRootDir
.
dir
(
'
arduexec/server
'
);
}
// Finally, work out the name of the executable
...
...
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