Browse Source

handle cases where reading config file fails

sisyphus
Dustin Falgout 8 years ago
parent
commit
e7dd22eab1
  1. 36
      src/greeter.c
  2. 7
      src/webkit2-extension.c

36
src/greeter.c

@ -292,6 +292,7 @@ main(int argc, char **argv) {
GdkRectangle geometry;
GKeyFile *keyfile;
gchar *theme;
GError *err = NULL;
GdkRGBA bg_color;
WebKitUserContentManager *manager;
WebKitWebContext *context;
@ -315,18 +316,47 @@ main(int argc, char **argv) {
g_unix_signal_add(SIGINT, (GSourceFunc) quit_cb, NULL);
g_unix_signal_add(SIGHUP, (GSourceFunc) quit_cb, NULL);
/* Apply greeter settings from config file */
/* BEGIN Greeter Config File */
keyfile = g_key_file_new();
g_key_file_load_from_file(keyfile,
CONFIG_DIR "lightdm-webkit2-greeter.conf",
G_KEY_FILE_NONE, NULL);
theme = g_key_file_get_string(keyfile, "greeter", "webkit-theme", NULL);
/* TODO: Handle config values and fallbacks some other way, this is garbage! */
theme = g_key_file_get_string(keyfile, "greeter", "webkit_theme", &err);
if ( NULL != err) {
g_clear_error(&err);
theme = g_key_file_get_string(keyfile, "greeter", "webkit-theme", &err);
if ( NULL != err) {
g_clear_error(&err);
theme = "antergos";
}
}
theme = rtrim_comments(theme);
config_timeout = g_key_file_get_integer(keyfile, "greeter", "screensaver-timeout", NULL);
config_timeout = g_key_file_get_integer(keyfile, "greeter", "screensaver_timeout", &err);
if ( NULL != err) {
g_clear_error(&err);
config_timeout = g_key_file_get_integer(keyfile, "greeter", "screensaver-timeout", &err);
if ( NULL != err) {
g_error_free(err);
config_timeout = 300;
}
}
debug_mode = g_key_file_get_boolean(keyfile, "greeter", "debug_mode", NULL);
if ( NULL != err) {
g_clear_error(&err);
debug_mode = FALSE;
}
/* END Greeter Config File */
/* Set default cursor */
root_window = gdk_get_default_root_window();
default_display = gdk_display_get_default();

7
src/webkit2-extension.c

@ -1586,9 +1586,6 @@ window_object_cleared_callback(WebKitScriptWorld *world,
theme_utils_object,
globalObject;
gchar *lock_hint_message = "LockHint";
gchar *greeter_loaded_message = "GreeterLoaded";
jsContext = webkit_frame_get_javascript_context_for_script_world(frame, world);
globalObject = JSContextGetGlobalObject(jsContext);
@ -1639,13 +1636,13 @@ window_object_cleared_callback(WebKitScriptWorld *world,
if (dom_window) {
/* Notify the UI process that the greeter is loaded */
webkit_dom_dom_window_webkit_message_handlers_post_message(
dom_window, "GreeterBridge", greeter_loaded_message
dom_window, "GreeterBridge", "GreeterLoaded"
);
/* If the greeter was started as a lock-screen, notify our UI process. */
if (lightdm_greeter_get_lock_hint(greeter)) {
webkit_dom_dom_window_webkit_message_handlers_post_message(
dom_window, "GreeterBridge", lock_hint_message
dom_window, "GreeterBridge", "LockHint"
);
}
}

Loading…
Cancel
Save