Browse Source

code cleanup and documentation

sisyphus
Dustin Falgout 9 years ago
parent
commit
c1e908793a
  1. 6
      src/lightdm-webkit2-greeter-ext.c
  2. 55
      themes/_vendor/js/mock.js

6
src/lightdm-webkit2-greeter-ext.c

@ -1497,11 +1497,15 @@ window_object_cleared_callback(WebKitScriptWorld *world,
greeter_util_object = JSObjectMake(jsContext, greeter_util_class, NULL);
JSObjectSetProperty(jsContext,
globalObject,
JSStringCreateWithUTF8CString("greeterutil"),
JSStringCreateWithUTF8CString("greeter_util"),
greeter_util_object,
kJSPropertyAttributeNone,
NULL);
/* Keep previous variable name for backwards compatibility. Will remove at later date. */
command = JSStringCreateWithUTF8CString("window.greeterutil = greeter_util;");
JSEvaluateScript(jsContext, command, NULL, NULL, 0, NULL);
/* If the greeter was started as a lock-screen, send message to our UI process. */
if (lightdm_greeter_get_lock_hint(greeter)) {

55
themes/_vendor/js/mock.js vendored

@ -25,7 +25,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
let _greeter = null, MockData;
let lightdm = null,
greeter_util = null,
config = null,
MockData;
if ('undefined' !== typeof lightdm) {
throw new Error('Cannot use LightDM Mock while the greeter is running!');
@ -209,6 +212,7 @@ let LightDMUser = ( user_info ) => ({
real_name: user_info.real_name || ''
});
/**
* @ignore
*/
@ -220,6 +224,46 @@ let MockObjects = {
};
/**
* Provides various utility methods for use by theme authors. The greeter will automatically
* create an instance of this class when it starts. The instance can be accessed
* with the global variable: `greeter_util`.
*/
class GreeterUtil {
constructor() {
if (null !== greeter_util) {
return greeter_util;
}
greeter_util = this;
this._mock_data = MockData();
}
/**
* Returns the contents of directory at `path`.
*
* @param path
* @returns {String[]} List of abs paths for the files and directories found in `path`.
*/
dirlist( path ) {
return this._mock_data.dirlist;
}
/**
* Escape HTML entities in a string.
*
* @param {String} text
* @returns {String}
*/
txt2html( text ) {
let entities_map = { '"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;' };
return text.replace(/[\"&<>]/g, a => entities_map[a] );
}
}
/**
* Singleton class which implements the LightDMGreeter Interface. Greeter themes will
* interact directly with this class to facilitate the user log in processes.
@ -229,11 +273,11 @@ let MockObjects = {
class LightDMGreeter {
constructor() {
if ( null !== _greeter ) {
return _greeter;
if ( null !== lightdm ) {
return lightdm;
}
_greeter = this;
lightdm = this;
this._mock_data = MockData();
this._initialize();
@ -673,7 +717,8 @@ MockData = () => ({
]
});
window.lightdm = new LightDMGreeter();
new GreeterUtil();
new LightDMGreeter();
// mock lighdm for testing

Loading…
Cancel
Save