diff --git a/data/lightdm-webkit2-greeter.conf b/data/lightdm-webkit2-greeter.conf index 0a621b6..704decf 100644 --- a/data/lightdm-webkit2-greeter.conf +++ b/data/lightdm-webkit2-greeter.conf @@ -2,15 +2,15 @@ # [greeter] # debug_mode = Greeter theme debug mode. # secure_mode = Don't allow themes to make remote http requests. -# screensaver-timeout = Blank the screen after this many seconds of inactivity. -# webkit-theme = Webkit theme to use. +# screensaver_timeout = Blank the screen after this many seconds of inactivity. +# webkit_theme = Webkit theme to use. # [greeter] debug_mode = false secure_mode = true -screensaver-timeout = 300 -webkit-theme = antergos +screensaver_timeout = 300 +webkit_theme = antergos # # [branding] diff --git a/src/gresource/js/GreeterConfig.js b/src/gresource/js/GreeterConfig.js new file mode 100644 index 0000000..71d09f6 --- /dev/null +++ b/src/gresource/js/GreeterConfig.js @@ -0,0 +1,105 @@ +/* + * GreeterConfig.js + * + * Copyright © 2016 Antergos Developers + * + * This file is part of lightdm-webkit2-greeter. + * + * lightdm-webkit2-greeter is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * lightdm-webkit2-greeter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * The following additional terms are in effect as per Section 7 of the license: + * + * The preservation of all legal notices and author attributions in + * the material or in the Appropriate Legal Notices displayed + * by works containing it is required. + * + * You should have received a copy of the GNU General Public License + * along with lightdm-webkit2-greeter; If not, see . + */ + + + +/** + * Provides theme authors with a way to retrieve values from the greeter's config + * file located at `/etc/lightdm/lightdm-webkit2-greeter.conf`. The greeter will + * create an instance of this class when it starts. The instance can be accessed + * with the global variable: `greeter_config`. + * + * @memberOf LightDM + */ +class GreeterConfig { + /** + * Holds keys/values from the `branding` section of the config file. + * + * @type {Object} branding + * {String} branding.background_images + * {String} branding.logo + * {String} branding.user_image + * + * @readonly + */ + get branding() {} + + /** + * Holds keys/values from the `greeter` section of the config file. + * + * @type {Object} greeter + * {Boolean} greeter.debug_mode + * {Boolean} greeter.secure_mode + * {Number} greeter.screensaver_timeout + * {String} greeter.webkit_theme + * + * @readonly + */ + get greeter() {} + + /** + * Returns the value of `key` from the `config_section` of the greeter's config file. + * + * @deprecated Access config sections directly as properties of this object instead. + * + * @arg {String} config_section + * @arg {String} key + * + * @returns {Boolean} Config value for `key`. + */ + get_bool( config_section, key ) {} + + /** + * Returns the value of `key` from the `config_section` of the greeter's config file. + * + * @deprecated Access config sections directly as properties of this object instead. + * + * @arg {String} config_section + * @arg {String} key + * + * @returns {Number} Config value for `key`. + */ + get_num( config_section, key ) {} + + /** + * Returns the value of `key` from the `config_section` of the greeter's config file. + * + * @deprecated Access config sections directly as properties of this object instead. + * + * @arg {String} config_section + * @arg {String} key + * + * @returns {String} Config value for `key`. + */ + get_str( key ) {} +} + +window.greeter_config = __GreeterConfig; + +/* -------->>> DEPRECATED! <<<-------- */ +window.config = window.greeter_config; +/* -------->>> DEPRECATED! <<<-------- */ diff --git a/src/gresource/js/ThemeUtils.js b/src/gresource/js/ThemeUtils.js index 6216718..f579a98 100644 --- a/src/gresource/js/ThemeUtils.js +++ b/src/gresource/js/ThemeUtils.js @@ -28,7 +28,11 @@ /** - * Provides various utility methods and can be used by greeter themes if needed. + * 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: `theme_utils`. + * + * @memberOf LightDM */ class ThemeUtils { /** @@ -61,6 +65,8 @@ class ThemeUtils { } } } + + static } window.theme_utils = __ThemeUtils; diff --git a/src/webkit2-extension.c b/src/webkit2-extension.c index 1089973..f0de330 100644 --- a/src/webkit2-extension.c +++ b/src/webkit2-extension.c @@ -83,7 +83,7 @@ static JSClassRef lightdm_language_class, lightdm_layout_class, lightdm_session_class, - config_file_class, + greeter_config_class, theme_utils_class; static gboolean SESSION_STARTING = FALSE; @@ -1488,7 +1488,7 @@ static const JSStaticFunction gettext_functions[] = { {NULL, NULL, 0}}; -static const JSStaticFunction config_file_functions[] = { +static const JSStaticFunction greeter_config_functions[] = { {"get_str", get_conf_str_cb, kJSPropertyAttributeReadOnly}, {"get_num", get_conf_num_cb, kJSPropertyAttributeReadOnly}, {"get_bool", get_conf_bool_cb, kJSPropertyAttributeReadOnly}, @@ -1551,13 +1551,13 @@ static const JSClassDefinition gettext_definition = { gettext_functions, /* Static functions */ }; -static const JSClassDefinition config_file_definition = { - 0, /* Version */ - kJSClassAttributeNone, /* Attributes */ - "ConfigFile", /* Class name */ - NULL, /* Parent class */ - NULL, /* Static values */ - config_file_functions, /* Static functions */ +static const JSClassDefinition greeter_config_definition = { + 0, /* Version */ + kJSClassAttributeNoAutomaticPrototype, /* Attributes */ + "__GreeterConfig", /* Class name */ + NULL, /* Parent class */ + NULL, /* Static values */ + greeter_config_functions, /* Static functions */ }; static const JSClassDefinition theme_utils_definition = { @@ -1582,7 +1582,7 @@ window_object_cleared_callback(WebKitScriptWorld *world, JSObjectRef gettext_object, lightdm_greeter_object, - config_file_object, + greeter_config_object, theme_utils_object, globalObject; @@ -1598,7 +1598,7 @@ window_object_cleared_callback(WebKitScriptWorld *world, lightdm_language_class = JSClassCreate(&lightdm_language_definition); lightdm_layout_class = JSClassCreate(&lightdm_layout_definition); lightdm_session_class = JSClassCreate(&lightdm_session_definition); - config_file_class = JSClassCreate(&config_file_definition); + greeter_config_class = JSClassCreate(&greeter_config_definition); theme_utils_class = JSClassCreate(&theme_utils_definition); gettext_object = JSObjectMake(jsContext, gettext_class, NULL); @@ -1617,12 +1617,12 @@ window_object_cleared_callback(WebKitScriptWorld *world, kJSPropertyAttributeNone, NULL); - config_file_object = JSObjectMake(jsContext, config_file_class, greeter); + greeter_config_object = JSObjectMake(jsContext, greeter_config_class, greeter); JSObjectSetProperty(jsContext, globalObject, - JSStringCreateWithUTF8CString("config"), - config_file_object, - kJSPropertyAttributeNone, + JSStringCreateWithUTF8CString("__GreeterConfig"), + greeter_config_object, + (JSPropertyAttributes) (kJSPropertyAttributeDontEnum || kJSPropertyAttributeReadOnly), NULL); theme_utils_object = JSObjectMake(jsContext, theme_utils_class, NULL); @@ -1630,7 +1630,7 @@ window_object_cleared_callback(WebKitScriptWorld *world, globalObject, JSStringCreateWithUTF8CString("__ThemeUtils"), theme_utils_object, - kJSPropertyAttributeNone, + (JSPropertyAttributes) (kJSPropertyAttributeDontEnum || kJSPropertyAttributeReadOnly), NULL); dom_document = webkit_web_page_get_dom_document(web_page);