Browse Source

add shadow class in JS for the injected __GreeterConfig class to hold docstrings.

sisyphus
Dustin Falgout 8 years ago
parent
commit
085fd455a8
  1. 8
      data/lightdm-webkit2-greeter.conf
  2. 105
      src/gresource/js/GreeterConfig.js
  3. 8
      src/gresource/js/ThemeUtils.js
  4. 32
      src/webkit2-extension.c

8
data/lightdm-webkit2-greeter.conf

@ -2,15 +2,15 @@
# [greeter] # [greeter]
# debug_mode = Greeter theme debug mode. # debug_mode = Greeter theme debug mode.
# secure_mode = Don't allow themes to make remote http requests. # secure_mode = Don't allow themes to make remote http requests.
# screensaver-timeout = Blank the screen after this many seconds of inactivity. # screensaver_timeout = Blank the screen after this many seconds of inactivity.
# webkit-theme = Webkit theme to use. # webkit_theme = Webkit theme to use.
# #
[greeter] [greeter]
debug_mode = false debug_mode = false
secure_mode = true secure_mode = true
screensaver-timeout = 300 screensaver_timeout = 300
webkit-theme = antergos webkit_theme = antergos
# #
# [branding] # [branding]

105
src/gresource/js/GreeterConfig.js

@ -0,0 +1,105 @@
/*
* GreeterConfig.js
*
* Copyright © 2016 Antergos Developers <dev@antergos.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* 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! <<<-------- */

8
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 { class ThemeUtils {
/** /**
@ -61,6 +65,8 @@ class ThemeUtils {
} }
} }
} }
static
} }
window.theme_utils = __ThemeUtils; window.theme_utils = __ThemeUtils;

32
src/webkit2-extension.c

@ -83,7 +83,7 @@ static JSClassRef
lightdm_language_class, lightdm_language_class,
lightdm_layout_class, lightdm_layout_class,
lightdm_session_class, lightdm_session_class,
config_file_class, greeter_config_class,
theme_utils_class; theme_utils_class;
static gboolean SESSION_STARTING = FALSE; static gboolean SESSION_STARTING = FALSE;
@ -1488,7 +1488,7 @@ static const JSStaticFunction gettext_functions[] = {
{NULL, NULL, 0}}; {NULL, NULL, 0}};
static const JSStaticFunction config_file_functions[] = { static const JSStaticFunction greeter_config_functions[] = {
{"get_str", get_conf_str_cb, kJSPropertyAttributeReadOnly}, {"get_str", get_conf_str_cb, kJSPropertyAttributeReadOnly},
{"get_num", get_conf_num_cb, kJSPropertyAttributeReadOnly}, {"get_num", get_conf_num_cb, kJSPropertyAttributeReadOnly},
{"get_bool", get_conf_bool_cb, kJSPropertyAttributeReadOnly}, {"get_bool", get_conf_bool_cb, kJSPropertyAttributeReadOnly},
@ -1551,13 +1551,13 @@ static const JSClassDefinition gettext_definition = {
gettext_functions, /* Static functions */ gettext_functions, /* Static functions */
}; };
static const JSClassDefinition config_file_definition = { static const JSClassDefinition greeter_config_definition = {
0, /* Version */ 0, /* Version */
kJSClassAttributeNone, /* Attributes */ kJSClassAttributeNoAutomaticPrototype, /* Attributes */
"ConfigFile", /* Class name */ "__GreeterConfig", /* Class name */
NULL, /* Parent class */ NULL, /* Parent class */
NULL, /* Static values */ NULL, /* Static values */
config_file_functions, /* Static functions */ greeter_config_functions, /* Static functions */
}; };
static const JSClassDefinition theme_utils_definition = { static const JSClassDefinition theme_utils_definition = {
@ -1582,7 +1582,7 @@ window_object_cleared_callback(WebKitScriptWorld *world,
JSObjectRef gettext_object, JSObjectRef gettext_object,
lightdm_greeter_object, lightdm_greeter_object,
config_file_object, greeter_config_object,
theme_utils_object, theme_utils_object,
globalObject; globalObject;
@ -1598,7 +1598,7 @@ window_object_cleared_callback(WebKitScriptWorld *world,
lightdm_language_class = JSClassCreate(&lightdm_language_definition); lightdm_language_class = JSClassCreate(&lightdm_language_definition);
lightdm_layout_class = JSClassCreate(&lightdm_layout_definition); lightdm_layout_class = JSClassCreate(&lightdm_layout_definition);
lightdm_session_class = JSClassCreate(&lightdm_session_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); theme_utils_class = JSClassCreate(&theme_utils_definition);
gettext_object = JSObjectMake(jsContext, gettext_class, NULL); gettext_object = JSObjectMake(jsContext, gettext_class, NULL);
@ -1617,12 +1617,12 @@ window_object_cleared_callback(WebKitScriptWorld *world,
kJSPropertyAttributeNone, kJSPropertyAttributeNone,
NULL); NULL);
config_file_object = JSObjectMake(jsContext, config_file_class, greeter); greeter_config_object = JSObjectMake(jsContext, greeter_config_class, greeter);
JSObjectSetProperty(jsContext, JSObjectSetProperty(jsContext,
globalObject, globalObject,
JSStringCreateWithUTF8CString("config"), JSStringCreateWithUTF8CString("__GreeterConfig"),
config_file_object, greeter_config_object,
kJSPropertyAttributeNone, (JSPropertyAttributes) (kJSPropertyAttributeDontEnum || kJSPropertyAttributeReadOnly),
NULL); NULL);
theme_utils_object = JSObjectMake(jsContext, theme_utils_class, NULL); theme_utils_object = JSObjectMake(jsContext, theme_utils_class, NULL);
@ -1630,7 +1630,7 @@ window_object_cleared_callback(WebKitScriptWorld *world,
globalObject, globalObject,
JSStringCreateWithUTF8CString("__ThemeUtils"), JSStringCreateWithUTF8CString("__ThemeUtils"),
theme_utils_object, theme_utils_object,
kJSPropertyAttributeNone, (JSPropertyAttributes) (kJSPropertyAttributeDontEnum || kJSPropertyAttributeReadOnly),
NULL); NULL);
dom_document = webkit_web_page_get_dom_document(web_page); dom_document = webkit_web_page_get_dom_document(web_page);

Loading…
Cancel
Save