Browse Source

Previous four commits fixed #19 and yeah im ocd when it comes to code style/formatting 😬

sisyphus
Dustin Falgout 9 years ago
parent
commit
22c75d042e
  1. 55
      src/lightdm-webkit2-greeter-ext.c

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

@ -47,6 +47,7 @@
G_MODULE_EXPORT void webkit_web_extension_initialize(WebKitWebExtension *extension);
guint64 page_id = -1;
GKeyFile *keyfile;
#define USER ((LightDMUser *) JSObjectGetPrivate (thisObject))
#define LAYOUT ((LightDMLayout *) JSObjectGetPrivate (thisObject))
@ -61,9 +62,8 @@ static JSClassRef
lightdm_language_class,
lightdm_layout_class,
lightdm_session_class,
conffile_class;
config_file_class;
GKeyFile *keyfile;
/*
* Returns either a string or null.
@ -1017,6 +1017,11 @@ ngettext_cb(JSContextRef context,
return result;
}
/*
* Gets a key's value from config file.
*
* Returns config key's value as string.
*/
static JSValueRef
get_conf_str_cb(JSContextRef context,
JSObjectRef function,
@ -1040,11 +1045,6 @@ get_conf_str_cb(JSContextRef context,
}
key = arg_to_string(context, arguments[1], exception);
if (!section) {
return JSValueMakeNull(context);
}
value = g_key_file_get_string(keyfile, section, key, &err);
if (err) {
@ -1060,6 +1060,12 @@ get_conf_str_cb(JSContextRef context,
return result;
}
/*
* Gets a key's value from config file.
*
* Returns config key's value as number.
*/
static JSValueRef
get_conf_num_cb(JSContextRef context,
JSObjectRef function,
@ -1083,11 +1089,6 @@ get_conf_num_cb(JSContextRef context,
}
key = arg_to_string(context, arguments[1], exception);
if (!section) {
return JSValueMakeNull(context);
}
value = g_key_file_get_integer(keyfile, section, key, &err);
if (err) {
@ -1099,6 +1100,12 @@ get_conf_num_cb(JSContextRef context,
return JSValueMakeNumber(context, value);
}
/*
* Gets a key's value from config file.
*
* Returns config key's value as bool.
*/
static JSValueRef
get_conf_bool_cb(JSContextRef context,
JSObjectRef function,
@ -1122,11 +1129,6 @@ get_conf_bool_cb(JSContextRef context,
}
key = arg_to_string(context, arguments[1], exception);
if (!section) {
return JSValueMakeNull(context);
}
value = g_key_file_get_boolean(keyfile, section, key, &err);
if (err) {
@ -1138,15 +1140,6 @@ get_conf_bool_cb(JSContextRef context,
return JSValueMakeBoolean(context, value);
}
static JSValueRef
get_iconsdir_cb(JSContextRef context,
JSObjectRef thisObject,
JSStringRef propertyName,
JSValueRef *exception) {
return string_or_null(context, ICONS_DIR);
}
static const JSStaticValue lightdm_user_values[] = {
{"name", get_user_name_cb, NULL, kJSPropertyAttributeReadOnly},
@ -1292,13 +1285,13 @@ static const JSClassDefinition gettext_definition = {
gettext_functions, /* Static functions */
};
static const JSClassDefinition conffile_definition = {
static const JSClassDefinition config_file_definition = {
0, /* Version */
kJSClassAttributeNone, /* Attributes */
"Branding", /* Class name */
"ConfigFile", /* Class name */
NULL, /* Parent class */
NULL, /* Static values */
conffile_functions, /* Static functions */
config_file_functions, /* Static functions */
};
/*static void
@ -1335,7 +1328,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);
conffile_class = JSClassCreate(&conffile_definition);
config_file_class = JSClassCreate(&config_file_definition);
gettext_object = JSObjectMake(jsContext, gettext_class, NULL);
@ -1360,7 +1353,7 @@ window_object_cleared_callback(WebKitScriptWorld *world,
JSObjectSetProperty(jsContext,
globalObject,
JSStringCreateWithUTF8CString("config"),
conffile_object,
config_file_object,
kJSPropertyAttributeNone,
NULL);

Loading…
Cancel
Save