1.1 --- a/bookloupe/bookloupe.c Mon Sep 30 07:37:36 2013 +0100
1.2 +++ b/bookloupe/bookloupe.c Mon Sep 30 08:18:42 2013 +0100
1.3 @@ -317,6 +317,7 @@
1.4 void config_file_update(GKeyFile *kf)
1.5 {
1.6 int i;
1.7 + const char *s;
1.8 gboolean sw;
1.9 for(i=0;options[i].long_name;i++)
1.10 {
1.11 @@ -329,6 +330,13 @@
1.12 sw=!sw;
1.13 g_key_file_set_boolean(kf,"options",options[i].long_name,sw);
1.14 }
1.15 + else if (options[i].arg==G_OPTION_ARG_STRING)
1.16 + {
1.17 + s=*(gchar **)options[i].arg_data;
1.18 + if (!s)
1.19 + s="auto";
1.20 + g_key_file_set_string(kf,"options",options[i].long_name,s);
1.21 + }
1.22 else
1.23 g_assert_not_reached();
1.24 }
1.25 @@ -425,7 +433,7 @@
1.26 void parse_config_file(void)
1.27 {
1.28 int i,j;
1.29 - gchar *path;
1.30 + gchar *path,*s;
1.31 gchar **keys;
1.32 gboolean sw;
1.33 GError *err=NULL;
1.34 @@ -454,9 +462,35 @@
1.35 path,keys[i],err->message);
1.36 g_clear_error(&err);
1.37 }
1.38 - if (options[j].flags&G_OPTION_FLAG_REVERSE)
1.39 - sw=!sw;
1.40 - *(gboolean *)options[j].arg_data=sw;
1.41 + else
1.42 + {
1.43 + if (options[j].flags&G_OPTION_FLAG_REVERSE)
1.44 + sw=!sw;
1.45 + *(gboolean *)options[j].arg_data=sw;
1.46 + }
1.47 + break;
1.48 + }
1.49 + else if (options[j].arg==G_OPTION_ARG_STRING)
1.50 + {
1.51 + s=g_key_file_get_string(config,"options",keys[i],
1.52 + &err);
1.53 + if (err)
1.54 + {
1.55 + g_printerr("Bookloupe: %s: options.%s: %s\n",
1.56 + path,keys[i],err->message);
1.57 + g_clear_error(&err);
1.58 + }
1.59 + else
1.60 + {
1.61 + g_free(*(gchar **)options[j].arg_data);
1.62 + if (!g_strcmp0(s,"auto"))
1.63 + {
1.64 + *(gchar **)options[j].arg_data=NULL;
1.65 + g_free(s);
1.66 + }
1.67 + else
1.68 + *(gchar **)options[j].arg_data=s;
1.69 + }
1.70 break;
1.71 }
1.72 else
1.73 @@ -530,13 +564,13 @@
1.74 g_printerr("%s\n",err->message);
1.75 exit(1);
1.76 }
1.77 - g_free(opt_charset);
1.78 - opt_charset=NULL;
1.79 if (pswit[DUMP_CONFIG_SWITCH])
1.80 {
1.81 dump_config();
1.82 exit(0);
1.83 }
1.84 + g_free(opt_charset);
1.85 + opt_charset=NULL;
1.86 if (pswit[OVERVIEW_SWITCH])
1.87 /* just print summary; don't echo */
1.88 pswit[ECHO_SWITCH]=FALSE;