diff -r b6358ed2548d -r 5e27fa988c5c bookloupe/bookloupe.c --- a/bookloupe/bookloupe.c Mon Sep 30 07:37:36 2013 +0100 +++ b/bookloupe/bookloupe.c Mon Sep 30 08:18:42 2013 +0100 @@ -317,6 +317,7 @@ void config_file_update(GKeyFile *kf) { int i; + const char *s; gboolean sw; for(i=0;options[i].long_name;i++) { @@ -329,6 +330,13 @@ sw=!sw; g_key_file_set_boolean(kf,"options",options[i].long_name,sw); } + else if (options[i].arg==G_OPTION_ARG_STRING) + { + s=*(gchar **)options[i].arg_data; + if (!s) + s="auto"; + g_key_file_set_string(kf,"options",options[i].long_name,s); + } else g_assert_not_reached(); } @@ -425,7 +433,7 @@ void parse_config_file(void) { int i,j; - gchar *path; + gchar *path,*s; gchar **keys; gboolean sw; GError *err=NULL; @@ -454,9 +462,35 @@ path,keys[i],err->message); g_clear_error(&err); } - if (options[j].flags&G_OPTION_FLAG_REVERSE) - sw=!sw; - *(gboolean *)options[j].arg_data=sw; + else + { + if (options[j].flags&G_OPTION_FLAG_REVERSE) + sw=!sw; + *(gboolean *)options[j].arg_data=sw; + } + break; + } + else if (options[j].arg==G_OPTION_ARG_STRING) + { + s=g_key_file_get_string(config,"options",keys[i], + &err); + if (err) + { + g_printerr("Bookloupe: %s: options.%s: %s\n", + path,keys[i],err->message); + g_clear_error(&err); + } + else + { + g_free(*(gchar **)options[j].arg_data); + if (!g_strcmp0(s,"auto")) + { + *(gchar **)options[j].arg_data=NULL; + g_free(s); + } + else + *(gchar **)options[j].arg_data=s; + } break; } else @@ -530,13 +564,13 @@ g_printerr("%s\n",err->message); exit(1); } - g_free(opt_charset); - opt_charset=NULL; if (pswit[DUMP_CONFIG_SWITCH]) { dump_config(); exit(0); } + g_free(opt_charset); + opt_charset=NULL; if (pswit[OVERVIEW_SWITCH]) /* just print summary; don't echo */ pswit[ECHO_SWITCH]=FALSE;