comparison src/options.c @ 1019:4aa1a6235458

Move save/load_options() to options.[ch].
author zas_
date Sun, 31 Aug 2008 09:13:42 +0000
parents 88ebc61e33ae
children 210c86b914ce
comparison
equal deleted inserted replaced
1018:7789dff37086 1019:4aa1a6235458
18 #include "histogram.h" /* HCHAN_RGB */ 18 #include "histogram.h" /* HCHAN_RGB */
19 #include "image-overlay.h" /* OSD_SHOW_NOTHING */ 19 #include "image-overlay.h" /* OSD_SHOW_NOTHING */
20 #include "info.h" 20 #include "info.h"
21 #include "layout.h" 21 #include "layout.h"
22 #include "layout_image.h" 22 #include "layout_image.h"
23 #include "rcfile.h"
23 #include "ui_bookmark.h" 24 #include "ui_bookmark.h"
24 #include "ui_fileops.h" 25 #include "ui_fileops.h"
25 #include "window.h" 26 #include "window.h"
26 27
27 ConfOptions *init_options(ConfOptions *options) 28 ConfOptions *init_options(ConfOptions *options)
207 208
208 for (i = 0; ExifUIList[i].key; i++) 209 for (i = 0; ExifUIList[i].key; i++)
209 ExifUIList[i].current = ExifUIList[i].default_value; 210 ExifUIList[i].current = ExifUIList[i].default_value;
210 } 211 }
211 212
212 void sync_options_with_current_state(ConfOptions *options) 213 static void sync_options_with_current_state(ConfOptions *options)
213 { 214 {
214 LayoutWindow *lw = NULL; 215 LayoutWindow *lw = NULL;
215 216
216 if (layout_valid(&lw)) 217 if (layout_valid(&lw))
217 { 218 {
249 { 250 {
250 g_free(options->startup.path); 251 g_free(options->startup.path);
251 options->startup.path = g_strdup(layout_get_path(NULL)); 252 options->startup.path = g_strdup(layout_get_path(NULL));
252 } 253 }
253 } 254 }
255
256 void save_options(ConfOptions *options)
257 {
258 gchar *rc_path;
259
260 sync_options_with_current_state(options);
261
262 rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL);
263 save_options_to(rc_path, options);
264 g_free(rc_path);
265 }
266
267 void load_options(ConfOptions *options)
268 {
269 gboolean success;
270 gchar *rc_path;
271
272 if (isdir(GQ_SYSTEM_WIDE_DIR))
273 {
274 rc_path = g_build_filename(GQ_SYSTEM_WIDE_DIR, RC_FILE_NAME, NULL);
275 success = load_options_from(rc_path, options);
276 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
277 g_free(rc_path);
278 }
279
280 rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL);
281 success = load_options_from(rc_path, options);
282 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
283 g_free(rc_path);
284 }