From f778345b3a60dc23aa3896fd37d6fdd4af8117f5 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 1 Aug 2012 15:10:17 -0700 Subject: [PATCH] Add support for requiring a platform-specific stylesheet Add a getPlatform method to the native object that is used for requiring the platform stylesheet from within window.coffee after the atom.css is required. This is used to provide non-native scrollbars on Linux for an improved look and feel. --- Atom-Linux/native_handler.cpp | 5 ++++- Atom/src/native_handler.mm | 8 +++++++- spec/app/native-spec.coffee | 7 +++++++ src/app/window.coffee | 2 ++ static/linux.css | 13 +++++++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 spec/app/native-spec.coffee create mode 100644 static/linux.css diff --git a/Atom-Linux/native_handler.cpp b/Atom-Linux/native_handler.cpp index 43c7a3d5d..b6e25c995 100644 --- a/Atom-Linux/native_handler.cpp +++ b/Atom-Linux/native_handler.cpp @@ -57,7 +57,8 @@ NativeHandler::NativeHandler() : "absolute", "list", "isFile", "isDirectory", "remove", "asyncList", "open", "openDialog", "quit", "writeToPasteboard", "readFromPasteboard", "showDevTools", "newWindow", "saveDialog", "exit", "watchPath", - "unwatchPath", "makeDirectory", "move", "moveToTrash", "md5ForPath" }; + "unwatchPath", "makeDirectory", "move", "moveToTrash", "md5ForPath", + "getPlatform" }; int arrayLength = sizeof(functionNames) / sizeof(const char *); for (int i = 0; i < arrayLength; i++) { const char *functionName = functionNames[i]; @@ -513,6 +514,8 @@ bool NativeHandler::Execute(const CefString& name, CefRefPtr object, UnwatchPath(name, object, arguments, retval, exception); else if (name == "md5ForPath") Digest(name, object, arguments, retval, exception); + else if (name == "getPlatform") + retval = CefV8Value::CreateString("linux"); else cout << "Unhandled -> " + name.ToString() << " : " << arguments[0]->GetStringValue().ToString() << endl; diff --git a/Atom/src/native_handler.mm b/Atom/src/native_handler.mm index e900e37b7..6be7f1fb5 100644 --- a/Atom/src/native_handler.mm +++ b/Atom/src/native_handler.mm @@ -33,7 +33,7 @@ void throwException(const CefRefPtr& global, CefRefPtr + + describe '$native.getPlatform()', -> + it 'returns a non-empty value', -> + platform = $native.getPlatform() + expect(platform).not.toBe '' + expect(platform.length).toBeGreaterThan(0) \ No newline at end of file diff --git a/src/app/window.coffee b/src/app/window.coffee index 3e2fff4f5..ef42cb667 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -56,6 +56,7 @@ windowAdditions = requireStylesheet: (path) -> fullPath = require.resolve(path) + return unless fs.isFile(fullPath) window.applyStylesheet(fullPath, fs.read(fullPath)) applyStylesheet: (id, text) -> @@ -106,3 +107,4 @@ require 'underscore-extensions' requireStylesheet 'reset.css' requireStylesheet 'atom.css' +requireStylesheet "#{$native.getPlatform()}.css" diff --git a/static/linux.css b/static/linux.css new file mode 100644 index 000000000..d300a73a1 --- /dev/null +++ b/static/linux.css @@ -0,0 +1,13 @@ +::-webkit-scrollbar-corner { + background-color: transparent; +} + +::-webkit-scrollbar { + width: 10px; + height: 10px; +} + +::-webkit-scrollbar-thumb { + -webkit-border-radius: 2px; + background: rgba(150, 150, 150, .33); +} \ No newline at end of file