diff options
author | Dieter Plaetinck <dieter@plaetinck.be> | 2009-04-26 21:43:12 +0200 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2009-04-26 21:43:12 +0200 |
commit | 4a659355da2fa5ed61127ba82e0b219b002d7f6d (patch) | |
tree | 51f529874edcc00b2ca6e4bb3e0d780c4e5d14c1 /uzbl.c | |
parent | bc2a398fae253156e17a8d988361e86b24df7db9 (diff) |
handle config/settings loading step by step so we can also see messages if no config is loaded
Diffstat (limited to 'uzbl.c')
-rw-r--r-- | uzbl.c | 96 |
1 files changed, 52 insertions, 44 deletions
@@ -395,69 +395,77 @@ add_binding (char *binding, char *action, bool internal) { static void settings_init () { + GKeyFile* config; + gboolean res = NULL; + gchar** keysi = NULL; + gchar** keyse = NULL; if (config_file) { - printf("Config file: %s\n", config_file); - - GKeyFile* config = g_key_file_new (); - gboolean res = g_key_file_load_from_file (config, config_file, G_KEY_FILE_NONE, NULL); - - if (res) { - printf ("Config loaded\n"); - } else { - fprintf (stderr, "Config loading failed\n"); //TODO: exit codes with gtk? + config = g_key_file_new (); + res = g_key_file_load_from_file (config, config_file, G_KEY_FILE_NONE, NULL); + if(res) { + printf ("Config %s loaded\n", config_file); + } else { + fprintf (stderr, "Config %s loading failed\n", config_file); } + } else { + printf ("No configuration.\n"); + } - history_handler = g_key_file_get_value (config, "behavior", "history_handler", NULL); - if (history_handler) { - printf ("History handler: %s\n", history_handler); - } else { - printf ("History handler disabled\n"); - } + if (res) { + history_handler = g_key_file_get_value (config, "behavior", "history_handler", NULL); + download_handler = g_key_file_get_value (config, "behavior", "download_handler", NULL); + always_insert_mode = g_key_file_get_boolean (config, "behavior", "always_insert_mode", NULL); + show_status = g_key_file_get_boolean (config, "behavior", "show_status", NULL); + modkey = g_key_file_get_value (config, "behavior", "modkey", NULL); + keysi = g_key_file_get_keys (config, "bindings_internal", NULL, NULL); + keyse = g_key_file_get_keys (config, "bindings_external", NULL, NULL); + if (! fifodir) + fifodir = g_key_file_get_value (config, "behavior", "fifodir", NULL); + } + + if (history_handler) { + printf ("History handler: %s\n", history_handler); + } else { + printf ("History handler disabled\n"); + } - download_handler = g_key_file_get_value (config, "behavior", "download_handler", NULL); - if (download_handler) { - printf ("Download manager: %s\n", download_handler); - } else { - printf ("Download manager disabled\n"); - } + if (download_handler) { + printf ("Download manager: %s\n", download_handler); + } else { + printf ("Download manager disabled\n"); + } - if (! fifodir) - fifodir = g_key_file_get_value (config, "behavior", "fifodir", NULL); - if (fifodir) { - printf ("Fifo directory: %s\n", fifodir); - } else { - printf ("Fifo directory: /tmp\n"); - } + if (fifodir) { + printf ("Fifo directory: %s\n", fifodir); + } else { + printf ("Fifo directory: /tmp\n"); + } - always_insert_mode = g_key_file_get_boolean (config, "behavior", "always_insert_mode", NULL); - printf ("Always insert mode: %s\n", (always_insert_mode ? "TRUE" : "FALSE")); + printf ("Always insert mode: %s\n", (always_insert_mode ? "TRUE" : "FALSE")); - show_status = g_key_file_get_boolean (config, "behavior", "show_status", NULL); - printf ("Show status: %s\n", (show_status ? "TRUE" : "FALSE")); + printf ("Show status: %s\n", (show_status ? "TRUE" : "FALSE")); - modkey = g_key_file_get_value (config, "behavior", "modkey", NULL); - if (modkey) { - printf ("Mod key: %s\n", modkey); - } else { - printf ("Mod key disabled/\n"); - } + if (modkey) { + printf ("Mod key: %s\n", modkey); + } else { + printf ("Mod key disabled\n"); + } - gchar **keysi = g_key_file_get_keys (config, "bindings_internal", NULL, NULL); - int i = 0; + if (keysi) { + int i = 0; for (i = 0; keysi[i]; i++) { gchar *binding = g_key_file_get_string (config, "bindings_internal", keysi[i], NULL); printf ("Action: %s, Binding: %s (internal)\n", g_strdup (keysi[i]), binding); add_binding (binding, g_strdup (keysi[i]), true); } - - gchar **keyse = g_key_file_get_keys (config, "bindings_external", NULL, NULL); + } + if (keyse) { + int i = 0; for (i = 0; keyse[i]; i++) { gchar *binding = g_key_file_get_string(config, "bindings_external", keyse[i], NULL); printf ("Action: %s, Binding: %s (external)\n", g_strdup (keyse[i]), binding); add_binding (binding, g_strdup (keyse[i]), false); } - } else { - printf ("No configuration.\n"); } } |