Skip to content

Commit

Permalink
support node-webkit v0.10 (but not using just yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
KylePDavis committed Jun 29, 2014
1 parent 02bd072 commit f47cf22
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
17 changes: 13 additions & 4 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ for PLUGIN_DIR in cloud9_ext/plugins-server/*/; do
echo " * $PLUGIN_NAME ..."
cp -a "$PLUGIN_DIR" "./cloud9/plugins-server/$PLUGIN_NAME"
done
echo


# node-webkit
Expand Down Expand Up @@ -189,12 +190,20 @@ else

Darwin)
#TODO: unzip from piped stdin instead?
curl -O "http://dl.node-webkit.org/v$NW_VER/node-webkit-v$NW_VER-osx-ia32.zip"
unzip -n "node-webkit-v$NW_VER-osx-ia32.zip"
rm "node-webkit-v$NW_VER-osx-ia32.zip"
mv node-webkit.app C9.app
NW_NAME="node-webkit-v$NW_VER-osx-ia32"
curl -O "http://dl.node-webkit.org/v$NW_VER/$NW_NAME.zip"
unzip -n "$NW_NAME.zip"
rm "$NW_NAME.zip"
if [ -d "node-webkit.app" ]; then # older packages
mv "node-webkit.app" "C9.app"
else # newer packages
mv "$NW_NAME/node-webkit.app" "C9.app"
rm -fr "$NW_NAME"
fi
cp darwin/Info.plist C9.app/Contents/Info.plist
cp darwin/nw.icns C9.app/Contents/Resources/nw.icns
mkdir "$NW_DIR"
echo "The existence of this dir prevents 'setup.sh' from installing 'node-webkit' again; See the C9.app instead" >> "$NW_DIR/README"
;;

*)
Expand Down
14 changes: 7 additions & 7 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

<script type="text/javascript" src="js/zepto.min.js"></script>

<link rel="stylesheet" type="text/css" href="css/normalize.css"/>
<link rel="stylesheet" type="text/css" href="css/main.css"/>
<link rel="stylesheet" type="text/css" href="css/normalize.css"/>
<link rel="stylesheet" type="text/css" href="css/main.css"/>

</head>
<body class="notready">
Expand All @@ -31,11 +31,11 @@ <h2>Workspaces</h2>

</div>

<script type="text/javascript">
process.gui = require("nw.gui");
var Main = require("./lib/Main");
Main.init();
</script>
<script type="text/javascript">
process.gui = require("nw.gui");
var Main = require(process.versions["node-webkit"].split(".")[1] >= 10 ? "./www/lib/Main": "./lib/Main");
Main.init();
</script>

</body>
</html>
18 changes: 15 additions & 3 deletions www/lib/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ var Main = module.exports = {
var menubar = new gui.Menu({type:"menubar"});
var item, submenu;

// Setup Mac OS X builtins
if (menubar.createMacBuiltin) {
menubar.createMacBuiltin("C9");
}

// Add the main menu
if(process.platform !== "darwin"){
item = new gui.MenuItem({label:"App"});
Expand All @@ -151,9 +156,16 @@ var Main = module.exports = {

// Add the Window menu
if(process.platform === "darwin"){
item = new gui.MenuItem({label:"Window"});
menubar.append(item);
submenu = item.submenu = new gui.Menu();
item = menubar.items.filter(function (i) {
return i.label === "Window";
})[0];
if (!item) {
item = new gui.MenuItem({label:"Window"});
menubar.append(item);
submenu = item.submenu = new gui.Menu();
}else{
submenu = item.submenu;
}
submenu.append(new gui.MenuItem({label:"Zoom"}).on("click", Main.commands.window.zoom));
}

Expand Down

0 comments on commit f47cf22

Please sign in to comment.