Mercurial > geeqie
annotate src/rcfile.c @ 146:e8285b0c0c7d
prevent duplicate sidecar files; code cleanup
author | nadvornik |
---|---|
date | Wed, 21 Nov 2007 21:21:17 +0000 |
parents | 8be2cc687304 |
children | 9a56e3d13e67 |
rev | line source |
---|---|
1 | 1 /* |
9 | 2 * GQview |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
3 * (C) 2006 John Ellis |
1 | 4 * |
5 * Author: John Ellis | |
6 * | |
9 | 7 * This software is released under the GNU General Public License (GNU GPL). |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
1 | 10 */ |
11 | |
9 | 12 |
1 | 13 #include "gqview.h" |
9 | 14 #include "rcfile.h" |
1 | 15 |
9 | 16 #include "filelist.h" |
17 #include "slideshow.h" | |
18 #include "ui_fileops.h" | |
19 | |
1 | 20 |
21 /* | |
22 *----------------------------------------------------------------------------- | |
23 * line write/parse routines (private) | |
24 *----------------------------------------------------------------------------- | |
25 */ | |
26 | |
9 | 27 gchar *quoted_value(const gchar *text) |
1 | 28 { |
9 | 29 const gchar *ptr; |
1 | 30 gint c = 0; |
31 gint l = strlen(text); | |
32 | |
33 if (l == 0) return NULL; | |
34 | |
35 while (c < l && text[c] !='"') c++; | |
36 if (text[c] == '"') | |
37 { | |
9 | 38 gint e; |
1 | 39 c++; |
40 ptr = text + c; | |
9 | 41 e = c; |
42 while (e < l && text[e] !='"') e++; | |
43 if (text[e] == '"') | |
1 | 44 { |
9 | 45 if (e - c > 0) |
1 | 46 { |
9 | 47 return g_strndup(ptr, e - c); |
1 | 48 } |
49 } | |
50 } | |
51 else | |
52 /* for compatibility with older formats (<0.3.7) | |
53 * read a line without quotes too */ | |
54 { | |
55 c = 0; | |
56 while (c < l && text[c] !=' ' && text[c] !=8 && text[c] != '\n') c++; | |
57 if (c != 0) | |
58 { | |
9 | 59 return g_strndup(text, c); |
1 | 60 } |
61 } | |
62 | |
63 return NULL; | |
64 } | |
65 | |
66 static void write_char_option(FILE *f, gchar *label, gchar *text) | |
67 { | |
68 if (text) | |
69 fprintf(f,"%s: \"%s\"\n", label, text); | |
70 else | |
71 fprintf(f,"%s: \n", label); | |
72 } | |
73 | |
74 static gchar *read_char_option(FILE *f, gchar *option, gchar *label, gchar *value, gchar *text) | |
75 { | |
9 | 76 if (strcasecmp(option, label) == 0) |
1 | 77 { |
78 g_free(text); | |
79 text = quoted_value(value); | |
80 } | |
81 return text; | |
82 } | |
83 | |
84 static void write_int_option(FILE *f, gchar *label, gint n) | |
85 { | |
86 fprintf(f,"%s: %d\n\n", label, n); | |
87 } | |
88 | |
89 static gint read_int_option(FILE *f, gchar *option, gchar *label, gchar *value, gint n) | |
90 { | |
9 | 91 if (strcasecmp(option, label) == 0) |
92 { | |
93 n = strtol(value, NULL, 10); | |
94 } | |
95 return n; | |
96 } | |
97 | |
98 static void write_int_unit_option(FILE *f, gchar *label, gint n, gint subunits) | |
99 { | |
100 gint l, r; | |
101 | |
102 if (subunits > 0) | |
103 { | |
104 l = n / subunits; | |
105 r = n % subunits; | |
106 } | |
107 else | |
1 | 108 { |
9 | 109 l = n; |
110 r = 0; | |
111 } | |
112 | |
113 fprintf(f,"%s: %d.%d\n\n", label, l, r); | |
114 } | |
115 | |
116 static gint read_int_unit_option(FILE *f, gchar *option, gchar *label, gchar *value, gint n, gint subunits) | |
117 { | |
118 if (strcasecmp(option, label) == 0) | |
119 { | |
120 gint l, r; | |
121 gchar *ptr; | |
122 | |
123 ptr = value; | |
124 while (*ptr != '\0' && *ptr != '.') ptr++; | |
125 if (*ptr == '.') | |
126 { | |
127 *ptr = '\0'; | |
128 l = strtol(value, NULL, 10); | |
129 *ptr = '.'; | |
130 ptr++; | |
131 r = strtol(ptr, NULL, 10); | |
132 } | |
133 else | |
134 { | |
135 l = strtol(value, NULL, 10); | |
136 r = 0; | |
137 } | |
138 | |
139 n = l * subunits + r; | |
1 | 140 } |
141 return n; | |
142 } | |
143 | |
144 static void write_bool_option(FILE *f, gchar *label, gint n) | |
145 { | |
146 fprintf(f,"%s: ", label); | |
147 if (n) fprintf(f,"true\n"); else fprintf(f,"false\n"); | |
148 fprintf(f,"\n"); | |
149 } | |
150 | |
151 static gint read_bool_option(FILE *f, gchar *option, gchar *label, gchar *value, gint n) | |
152 { | |
9 | 153 if (strcasecmp(option, label) == 0) |
1 | 154 { |
9 | 155 if (strcasecmp(value, "true") == 0) |
1 | 156 n = TRUE; |
157 else | |
158 n = FALSE; | |
159 } | |
160 return n; | |
161 } | |
162 | |
163 /* | |
164 *----------------------------------------------------------------------------- | |
165 * save configuration (public) | |
166 *----------------------------------------------------------------------------- | |
167 */ | |
168 | |
9 | 169 void save_options(void) |
1 | 170 { |
171 FILE *f; | |
172 gchar *rc_path; | |
9 | 173 gchar *rc_pathl; |
1 | 174 gint i; |
175 | |
9 | 176 rc_path = g_strconcat(homedir(), "/", GQVIEW_RC_DIR, "/", RC_FILE_NAME, NULL); |
1 | 177 |
9 | 178 rc_pathl = path_from_utf8(rc_path); |
179 f = fopen(rc_pathl, "w"); | |
180 g_free(rc_pathl); | |
1 | 181 if (!f) |
182 { | |
9 | 183 gchar *buf; |
184 | |
185 buf = g_strdup_printf(_("error saving config file: %s\n"), rc_path); | |
186 print_term(buf); | |
187 g_free(buf); | |
188 | |
1 | 189 g_free(rc_path); |
190 return; | |
191 } | |
192 | |
193 fprintf(f,"######################################################################\n"); | |
194 fprintf(f,"# GQview config file version %7s #\n", VERSION); | |
195 fprintf(f,"######################################################################\n"); | |
196 fprintf(f,"\n"); | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
14
diff
changeset
|
197 fprintf(f,"# Note: This file is autogenerated. Options can be changed here,\n"); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
14
diff
changeset
|
198 fprintf(f,"# but user comments and formatting will be lost.\n"); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
14
diff
changeset
|
199 fprintf(f,"\n"); |
1 | 200 fprintf(f,"##### General Options #####\n\n"); |
201 | |
9 | 202 write_int_option(f, "layout_style", layout_style); |
203 write_char_option(f, "layout_order", layout_order); | |
204 fprintf(f,"\n"); | |
205 write_bool_option(f, "layout_view_as_icons", layout_view_icons); | |
206 write_bool_option(f, "layout_view_as_tree", layout_view_tree); | |
207 write_bool_option(f, "show_icon_names", show_icon_names); | |
208 fprintf(f,"\n"); | |
209 | |
210 write_bool_option(f, "tree_descend_folders", tree_descend_subdirs); | |
211 write_bool_option(f, "lazy_image_sync", lazy_image_sync); | |
212 write_bool_option(f, "update_on_time_change", update_on_time_change); | |
213 write_bool_option(f, "exif_auto_rotate", exif_rotate_enable); | |
214 fprintf(f,"\n"); | |
215 | |
1 | 216 write_bool_option(f, "enable_startup_path", startup_path_enable); |
217 write_char_option(f, "startup_path", startup_path); | |
218 fprintf(f,"\n"); | |
219 | |
220 fprintf(f,"zoom_mode: "); | |
221 if (zoom_mode == ZOOM_RESET_ORIGINAL) fprintf(f,"original\n"); | |
222 if (zoom_mode == ZOOM_RESET_FIT_WINDOW) fprintf(f,"fit\n"); | |
223 if (zoom_mode == ZOOM_RESET_NONE) fprintf(f,"dont_change\n"); | |
9 | 224 |
225 write_bool_option(f, "two_pass_scaling", two_pass_zoom); | |
226 | |
227 write_bool_option(f, "zoom_to_fit_allow_expand", zoom_to_fit_expands); | |
1 | 228 fprintf(f,"\n"); |
229 | |
230 write_bool_option(f, "fit_window_to_image", fit_window); | |
231 write_bool_option(f, "limit_window_size", limit_window_size); | |
232 write_int_option(f, "max_window_size", max_window_size); | |
233 fprintf(f,"\n"); | |
234 | |
235 write_bool_option(f, "progressive_keyboard_scrolling", progressive_key_scrolling); | |
9 | 236 write_int_option(f, "scroll_reset_method", scroll_reset_method); |
1 | 237 fprintf(f,"\n"); |
238 | |
3 | 239 write_bool_option(f, "enable_thumbnails", thumbnails_enabled); |
1 | 240 write_int_option(f, "thumbnail_width", thumb_max_width); |
241 write_int_option(f, "thumbnail_height", thumb_max_height); | |
242 write_bool_option(f, "cache_thumbnails", enable_thumb_caching); | |
9 | 243 write_bool_option(f, "cache_thumbnails_into_dirs", enable_thumb_dirs); |
14
25335c62cd9b
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
244 write_bool_option(f, "thumbnail_fast", thumbnail_fast); |
1 | 245 write_bool_option(f, "use_xvpics_thumbnails", use_xvpics_thumbnails); |
9 | 246 write_bool_option(f, "thumbnail_spec_standard", thumbnail_spec_standard); |
247 fprintf(f,"\n"); | |
248 | |
249 write_bool_option(f, "local_metadata", enable_metadata_dirs); | |
250 fprintf(f,"\n"); | |
251 | |
252 write_int_option(f, "sort_method", (gint)file_sort_method); | |
253 write_bool_option(f, "sort_ascending", file_sort_ascending); | |
254 write_bool_option(f, "sort_case_sensitive", file_sort_case_sensitive); | |
1 | 255 fprintf(f,"\n"); |
256 | |
257 write_bool_option(f, "confirm_delete", confirm_delete); | |
9 | 258 write_bool_option(f, "enable_delete_key", enable_delete_key); |
259 write_bool_option(f, "safe_delete", safe_delete_enable); | |
260 write_char_option(f, "safe_delete_path", safe_delete_path); | |
261 write_int_option(f, "safe_delete_size", safe_delete_size); | |
1 | 262 fprintf(f,"\n"); |
263 write_bool_option(f, "tools_float", tools_float); | |
264 write_bool_option(f, "tools_hidden", tools_hidden); | |
265 write_bool_option(f, "restore_tool_state", restore_tool); | |
266 | |
9 | 267 write_bool_option(f, "toolbar_hidden", toolbar_hidden); |
268 | |
4 | 269 write_bool_option(f, "mouse_wheel_scrolls", mousewheel_scrolls); |
9 | 270 write_bool_option(f, "in_place_rename", enable_in_place_rename); |
271 | |
272 write_int_option(f, "open_recent_max", recent_list_max); | |
273 | |
274 write_int_option(f, "image_cache_size_max", tile_cache_max); | |
275 | |
276 write_int_option(f, "thumbnail_quality", thumbnail_quality); | |
277 write_int_option(f, "zoom_quality", zoom_quality); | |
278 write_int_option(f, "dither_quality", dither_quality); | |
279 | |
280 write_int_option(f, "zoom_increment", zoom_increment); | |
281 | |
282 write_bool_option(f, "enable_read_ahead", enable_read_ahead); | |
283 | |
284 write_bool_option(f, "display_dialogs_under_mouse", place_dialogs_under_mouse); | |
285 | |
286 write_bool_option(f, "black_window_background", black_window_background); | |
287 | |
288 write_int_option(f, "fullscreen_screen", fullscreen_screen); | |
289 write_bool_option(f, "fullscreen_clean_flip", fullscreen_clean_flip); | |
290 write_bool_option(f, "fullscreen_disable_saver", fullscreen_disable_saver); | |
291 write_bool_option(f, "fullscreen_above", fullscreen_above); | |
292 | |
293 write_int_option(f, "custom_similarity_threshold", dupe_custom_threshold); | |
4 | 294 |
1 | 295 fprintf(f,"\n##### Slideshow Options #####\n\n"); |
296 | |
9 | 297 write_int_unit_option(f, "slideshow_delay", slideshow_delay, SLIDESHOW_SUBSECOND_PRECISION); |
1 | 298 |
299 write_bool_option(f, "slideshow_random", slideshow_random); | |
300 write_bool_option(f, "slideshow_repeat", slideshow_repeat); | |
301 | |
302 fprintf(f,"\n##### Filtering Options #####\n\n"); | |
303 | |
304 write_bool_option(f, "show_dotfiles", show_dot_files); | |
305 write_bool_option(f, "disable_filtering", file_filter_disable); | |
9 | 306 filter_write_list(f); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
113
diff
changeset
|
307 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
113
diff
changeset
|
308 sidecar_ext_write(f); |
1 | 309 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
310 fprintf(f,"\n##### Color Profiles #####\n\n"); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
311 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
312 #ifndef HAVE_LCMS |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
313 fprintf(f,"# NOTICE: GQview was not built with support for color profiles,\n" |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
314 "# color profile options will have no effect.\n\n"); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
315 #endif |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
316 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
317 write_bool_option(f, "color_profile_enabled", color_profile_enabled); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
318 write_bool_option(f, "color_profile_use_image", color_profile_use_image); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
319 write_int_option(f, "color_profile_input_type", color_profile_input_type); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
320 for (i = 0; i < COLOR_PROFILE_INPUTS; i++) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
321 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
322 gchar *buf; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
323 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
324 buf = g_strdup_printf("color_profile_input_file_%d", i + 1); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
325 write_char_option(f, buf, color_profile_input_file[i]); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
326 g_free(buf); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
327 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
328 buf = g_strdup_printf("color_profile_input_name_%d", i + 1); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
329 write_char_option(f, buf, color_profile_input_name[i]); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
330 g_free(buf); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
331 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
332 fprintf(f,"\n"); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
333 write_int_option(f, "color_profile_screen_type", color_profile_screen_type); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
334 write_char_option(f, "color_profile_screen_file_1", color_profile_screen_file); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
335 |
1 | 336 fprintf(f,"\n##### External Programs #####\n"); |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
14
diff
changeset
|
337 fprintf(f,"# Maximum of 10 programs (external_1 through external_10)\n"); |
1 | 338 fprintf(f,"# format: external_n: \"menu name\" \"command line\"\n\n"); |
339 | |
9 | 340 for (i = 0; i < GQVIEW_EDITOR_SLOTS; i++) |
1 | 341 { |
342 fprintf(f,"external_%d: \"", i+1); | |
9 | 343 if (editor_name[i]) fprintf(f, "%s", editor_name[i]); |
1 | 344 fprintf(f, "\" \""); |
9 | 345 if (editor_command[i]) fprintf(f, "%s", editor_command[i]); |
1 | 346 fprintf(f, "\"\n"); |
347 } | |
348 | |
9 | 349 fprintf(f,"\n##### Collection Options #####\n\n"); |
350 | |
351 write_bool_option(f, "rectangular_selections", collection_rectangular_selection); | |
352 | |
1 | 353 fprintf(f,"\n##### Window Positions #####\n\n"); |
354 | |
355 write_bool_option(f, "restore_window_positions", save_window_positions); | |
356 fprintf(f,"\n"); | |
357 write_int_option(f, "main_window_x", main_window_x); | |
358 write_int_option(f, "main_window_y", main_window_y); | |
359 write_int_option(f, "main_window_width", main_window_w); | |
360 write_int_option(f, "main_window_height", main_window_h); | |
9 | 361 write_bool_option(f, "main_window_maximized", main_window_maximized); |
1 | 362 write_int_option(f, "float_window_x", float_window_x); |
363 write_int_option(f, "float_window_y", float_window_y); | |
364 write_int_option(f, "float_window_width", float_window_w); | |
365 write_int_option(f, "float_window_height", float_window_h); | |
9 | 366 write_int_option(f, "float_window_divider", float_window_divider); |
367 write_int_option(f, "divider_position_h", window_hdivider_pos); | |
368 write_int_option(f, "divider_position_v", window_vdivider_pos); | |
1 | 369 |
370 fprintf(f,"######################################################################\n"); | |
371 fprintf(f,"# end of GQview config file #\n"); | |
372 fprintf(f,"######################################################################\n"); | |
373 | |
374 fclose(f); | |
375 | |
376 g_free(rc_path); | |
377 } | |
378 | |
379 /* | |
380 *----------------------------------------------------------------------------- | |
381 * load configuration (public) | |
382 *----------------------------------------------------------------------------- | |
383 */ | |
384 | |
9 | 385 void load_options(void) |
1 | 386 { |
387 FILE *f; | |
388 gchar *rc_path; | |
9 | 389 gchar *rc_pathl; |
1 | 390 gchar s_buf[1024]; |
391 gchar *s_buf_ptr; | |
392 gchar option[1024]; | |
393 gchar value[1024]; | |
394 gchar value_all[1024]; | |
395 gint c,l,i; | |
9 | 396 |
397 rc_path = g_strconcat(homedir(), "/", GQVIEW_RC_DIR, "/", RC_FILE_NAME, NULL); | |
1 | 398 |
9 | 399 rc_pathl = path_from_utf8(rc_path); |
400 f = fopen(rc_pathl,"r"); | |
401 g_free(rc_pathl); | |
1 | 402 if (!f) |
403 { | |
404 g_free(rc_path); | |
405 return; | |
406 } | |
407 | |
408 while (fgets(s_buf,1024,f)) | |
409 { | |
410 if (s_buf[0]=='#') continue; | |
411 if (s_buf[0]=='\n') continue; | |
412 c = 0; | |
413 l = strlen(s_buf); | |
414 while (s_buf[c] != ':' && c < l) c++; | |
415 if (c >= l) continue; | |
416 s_buf[c] = '\0'; | |
417 c++; | |
9 | 418 while ((s_buf[c] == ' ' || s_buf[c] == 8) && c < l) c++; |
1 | 419 s_buf_ptr = s_buf + c; |
9 | 420 strncpy(value_all, s_buf_ptr, sizeof(value_all)); |
1 | 421 while (s_buf[c] != 8 && s_buf[c] != ' ' && s_buf[c] != '\n' && c < l) c++; |
422 s_buf[c] = '\0'; | |
9 | 423 strncpy(option, s_buf, sizeof(option)); |
424 strncpy(value, s_buf_ptr, sizeof(value)); | |
1 | 425 |
426 /* general options */ | |
427 | |
9 | 428 layout_style = read_int_option(f, option, |
429 "layout_style", value, layout_style); | |
430 layout_order = read_char_option(f, option, | |
431 "layout_order", value, layout_order); | |
432 layout_view_icons = read_bool_option(f, option, | |
433 "layout_view_as_icons", value, layout_view_icons); | |
434 layout_view_tree = read_bool_option(f, option, | |
435 "layout_view_as_tree", value, layout_view_tree); | |
436 show_icon_names = read_bool_option(f, option, | |
437 "show_icon_names", value, show_icon_names); | |
438 | |
439 tree_descend_subdirs = read_bool_option(f, option, | |
440 "tree_descend_folders", value, tree_descend_subdirs); | |
441 lazy_image_sync = read_bool_option(f, option, | |
442 "lazy_image_sync", value, lazy_image_sync); | |
443 update_on_time_change = read_bool_option(f, option, | |
444 "update_on_time_change", value, update_on_time_change); | |
445 exif_rotate_enable = read_bool_option(f, option, | |
446 "exif_auto_rotate", value, exif_rotate_enable); | |
447 | |
1 | 448 startup_path_enable = read_bool_option(f, option, |
449 "enable_startup_path", value, startup_path_enable); | |
450 startup_path = read_char_option(f, option, | |
451 "startup_path", value_all, startup_path); | |
452 | |
9 | 453 if (strcasecmp(option,"zoom_mode") == 0) |
1 | 454 { |
9 | 455 if (strcasecmp(value, "original") == 0) zoom_mode = ZOOM_RESET_ORIGINAL; |
456 if (strcasecmp(value, "fit") == 0) zoom_mode = ZOOM_RESET_FIT_WINDOW; | |
457 if (strcasecmp(value, "dont_change") == 0) zoom_mode = ZOOM_RESET_NONE; | |
1 | 458 } |
9 | 459 two_pass_zoom = read_bool_option(f, option, |
460 "two_pass_scaling", value, two_pass_zoom); | |
461 zoom_to_fit_expands = read_bool_option(f, option, | |
462 "zoom_to_fit_allow_expand", value, zoom_to_fit_expands); | |
1 | 463 |
464 fit_window = read_bool_option(f, option, | |
465 "fit_window_to_image", value, fit_window); | |
466 limit_window_size = read_bool_option(f, option, | |
467 "limit_window_size", value, limit_window_size); | |
468 max_window_size = read_int_option(f, option, | |
469 "max_window_size", value, max_window_size); | |
470 progressive_key_scrolling = read_bool_option(f, option, | |
471 "progressive_keyboard_scrolling", value, progressive_key_scrolling); | |
9 | 472 scroll_reset_method = read_int_option(f, option, |
473 "scroll_reset_method", value, scroll_reset_method); | |
1 | 474 |
3 | 475 thumbnails_enabled = read_bool_option(f, option, |
476 "enable_thumbnails", value, thumbnails_enabled); | |
1 | 477 thumb_max_width = read_int_option(f, option, |
478 "thumbnail_width", value, thumb_max_width); | |
479 thumb_max_height = read_int_option(f, option, | |
480 "thumbnail_height", value, thumb_max_height); | |
481 enable_thumb_caching = read_bool_option(f, option, | |
482 "cache_thumbnails", value, enable_thumb_caching); | |
9 | 483 enable_thumb_dirs = read_bool_option(f, option, |
484 "cache_thumbnails_into_dirs", value, enable_thumb_dirs); | |
14
25335c62cd9b
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
485 thumbnail_fast = read_bool_option(f, option, |
25335c62cd9b
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
486 "thumbnail_fast", value, thumbnail_fast); |
1 | 487 use_xvpics_thumbnails = read_bool_option(f, option, |
488 "use_xvpics_thumbnails", value, use_xvpics_thumbnails); | |
9 | 489 thumbnail_spec_standard = read_bool_option(f, option, |
490 "thumbnail_spec_standard", value, thumbnail_spec_standard); | |
491 | |
492 enable_metadata_dirs = read_bool_option(f, option, | |
493 "local_metadata", value, enable_metadata_dirs); | |
494 | |
495 file_sort_method = (SortType)read_int_option(f, option, | |
496 "sort_method", value, (gint)file_sort_method); | |
497 file_sort_ascending = read_bool_option(f, option, | |
498 "sort_ascending", value, file_sort_ascending); | |
499 file_sort_case_sensitive = read_bool_option(f, option, | |
500 "sort_case_sensitive", value, file_sort_case_sensitive); | |
1 | 501 |
502 confirm_delete = read_bool_option(f, option, | |
503 "confirm_delete", value, confirm_delete); | |
9 | 504 enable_delete_key = read_bool_option(f, option, |
505 "enable_delete_key", value, enable_delete_key); | |
506 safe_delete_enable = read_bool_option(f, option, | |
507 "safe_delete", value, safe_delete_enable); | |
508 safe_delete_path = read_char_option(f, option, | |
509 "safe_delete_path", value, safe_delete_path); | |
510 safe_delete_size = read_int_option(f, option, | |
511 "safe_delete_size", value, safe_delete_size); | |
1 | 512 |
513 tools_float = read_bool_option(f, option, | |
514 "tools_float", value, tools_float); | |
515 tools_hidden = read_bool_option(f, option, | |
516 "tools_hidden", value, tools_hidden); | |
517 restore_tool = read_bool_option(f, option, | |
518 "restore_tool_state", value, restore_tool); | |
519 | |
9 | 520 toolbar_hidden = read_bool_option(f, option, |
521 "toolbar_hidden", value, toolbar_hidden); | |
522 | |
4 | 523 mousewheel_scrolls = read_bool_option(f, option, |
524 "mouse_wheel_scrolls", value, mousewheel_scrolls); | |
9 | 525 enable_in_place_rename = read_bool_option(f, option, |
526 "in_place_rename", value, enable_in_place_rename); | |
4 | 527 |
9 | 528 recent_list_max = read_int_option(f, option, |
529 "open_recent_max", value, recent_list_max); | |
530 | |
531 tile_cache_max = read_int_option(f, option, | |
532 "image_cache_size_max", value, tile_cache_max); | |
533 | |
534 thumbnail_quality = CLAMP(read_int_option(f, option, | |
535 "thumbnail_quality", value, thumbnail_quality), GDK_INTERP_NEAREST, GDK_INTERP_HYPER); | |
536 zoom_quality = CLAMP(read_int_option(f, option, | |
537 "zoom_quality", value, zoom_quality), GDK_INTERP_NEAREST, GDK_INTERP_HYPER); | |
538 dither_quality = CLAMP(read_int_option(f, option, | |
539 "dither_quality", value, dither_quality), GDK_RGB_DITHER_NONE, GDK_RGB_DITHER_MAX); | |
540 | |
541 zoom_increment = read_int_option(f, option, | |
542 "zoom_increment", value, zoom_increment); | |
543 | |
544 enable_read_ahead = read_bool_option(f, option, | |
545 "enable_read_ahead", value, enable_read_ahead); | |
4 | 546 |
9 | 547 place_dialogs_under_mouse = read_bool_option(f, option, |
548 "display_dialogs_under_mouse", value, place_dialogs_under_mouse); | |
549 | |
550 black_window_background = read_bool_option(f, option, | |
551 "black_window_background", value, black_window_background); | |
1 | 552 |
9 | 553 fullscreen_screen = read_int_option(f, option, |
554 "fullscreen_screen", value, fullscreen_screen); | |
555 fullscreen_clean_flip = read_bool_option(f, option, | |
556 "fullscreen_clean_flip", value, fullscreen_clean_flip); | |
557 fullscreen_disable_saver = read_bool_option(f, option, | |
558 "fullscreen_disable_saver", value, fullscreen_disable_saver); | |
559 fullscreen_above = read_bool_option(f, option, | |
560 "fullscreen_above", value, fullscreen_above); | |
561 | |
562 dupe_custom_threshold = read_int_option(f, option, | |
563 "custom_similarity_threshold", value, dupe_custom_threshold); | |
564 | |
565 /* slideshow options */ | |
566 | |
567 slideshow_delay = read_int_unit_option(f, option, | |
568 "slideshow_delay", value, slideshow_delay, SLIDESHOW_SUBSECOND_PRECISION); | |
1 | 569 slideshow_random = read_bool_option(f, option, |
570 "slideshow_random", value, slideshow_random); | |
571 slideshow_repeat = read_bool_option(f, option, | |
572 "slideshow_repeat", value, slideshow_repeat); | |
573 | |
574 /* filtering options */ | |
575 | |
576 show_dot_files = read_bool_option(f, option, | |
577 "show_dotfiles", value, show_dot_files); | |
578 file_filter_disable = read_bool_option(f, option, | |
579 "disable_filtering", value, file_filter_disable); | |
580 | |
9 | 581 if (strcasecmp(option, "filter_ext") == 0) |
582 { | |
583 filter_parse(value_all); | |
584 } | |
1 | 585 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
113
diff
changeset
|
586 if (strcasecmp(option, "sidecar_ext") == 0) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
113
diff
changeset
|
587 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
113
diff
changeset
|
588 sidecar_ext_parse(value_all); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
113
diff
changeset
|
589 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
113
diff
changeset
|
590 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
591 /* Color Profiles */ |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
592 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
593 color_profile_enabled = read_bool_option(f, option, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
594 "color_profile_enabled", value, color_profile_enabled); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
595 color_profile_use_image = read_bool_option(f, option, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
596 "color_profile_use_image", value, color_profile_use_image); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
597 color_profile_input_type = read_int_option(f, option, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
598 "color_profile_input_type", value, color_profile_input_type); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
599 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
600 if (strncasecmp(option, "color_profile_input_file_", 25) == 0) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
601 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
602 i = strtol(option + 25, NULL, 0) - 1; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
603 if (i >= 0 && i < COLOR_PROFILE_INPUTS) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
604 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
605 color_profile_input_file[i] = read_char_option(f, option, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
606 option, value, color_profile_input_file[i]); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
607 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
608 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
609 if (strncasecmp(option, "color_profile_input_name_", 25) == 0) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
610 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
611 i = strtol(option + 25, NULL, 0) - 1; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
612 if (i >= 0 && i < COLOR_PROFILE_INPUTS) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
613 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
614 color_profile_input_name[i] = read_char_option(f, option, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
615 option, value, color_profile_input_name[i]); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
616 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
617 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
618 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
619 color_profile_screen_type = read_int_option(f, option, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
620 "color_profile_screen_type", value, color_profile_screen_type); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
621 color_profile_screen_file = read_char_option(f, option, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
622 "color_profile_screen_file_1", value, color_profile_screen_file); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
623 |
1 | 624 /* External Programs */ |
625 | |
9 | 626 if (strncasecmp(option, "external_", 9) == 0) |
1 | 627 { |
628 i = strtol(option + 9, NULL, 0); | |
9 | 629 if (i > 0 && i <= GQVIEW_EDITOR_SLOTS) |
1 | 630 { |
631 gchar *ptr1, *ptr2; | |
632 i--; | |
633 c = 0; | |
634 l = strlen(value_all); | |
635 ptr1 = value_all; | |
636 | |
637 g_free(editor_name[i]); | |
638 editor_name[i] = NULL; | |
639 g_free(editor_command[i]); | |
640 editor_command[i] = NULL; | |
641 | |
642 while (c<l && value_all[c] !='"') c++; | |
643 if (ptr1[c] == '"') | |
644 { | |
645 c++; | |
646 ptr2 = ptr1 + c; | |
647 while (c<l && value_all[c] !='"') c++; | |
648 if (ptr1[c] == '"') | |
649 { | |
650 ptr1[c] = '\0'; | |
651 if (ptr1 + c - 1 != ptr2) | |
652 editor_name[i] = g_strdup(ptr2); | |
653 c++; | |
654 while (c<l && value_all[c] !='"') c++; | |
655 if (ptr1[c] == '"') | |
656 { | |
657 c++; | |
658 ptr2 = ptr1 + c; | |
9 | 659 while (value_all[c] != '\0') c++; |
660 while (c > 0 && value_all[c] != '"') c--; | |
661 if (ptr1[c] == '"' && ptr1 + c > ptr2) | |
1 | 662 { |
663 ptr1[c] = '\0'; | |
664 editor_command[i] = g_strdup(ptr2); | |
665 } | |
666 } | |
667 } | |
668 } | |
669 } | |
670 } | |
671 | |
9 | 672 /* colection options */ |
673 | |
674 collection_rectangular_selection = read_bool_option(f, option, | |
675 "rectangular_selections", value, collection_rectangular_selection); | |
676 | |
1 | 677 /* window positions */ |
678 | |
679 save_window_positions = read_bool_option(f, option, | |
680 "restore_window_positions", value, save_window_positions); | |
681 | |
682 main_window_x = read_int_option(f, option, | |
683 "main_window_x", value, main_window_x); | |
684 main_window_y = read_int_option(f, option, | |
685 "main_window_y", value, main_window_y); | |
686 main_window_w = read_int_option(f, option, | |
687 "main_window_width", value, main_window_w); | |
688 main_window_h = read_int_option(f, option, | |
689 "main_window_height", value, main_window_h); | |
9 | 690 main_window_maximized = read_bool_option(f, option, |
691 "main_window_maximized", value, main_window_maximized); | |
1 | 692 float_window_x = read_int_option(f, option, |
693 "float_window_x", value, float_window_x); | |
694 float_window_y = read_int_option(f, option, | |
695 "float_window_y", value, float_window_y); | |
696 float_window_w = read_int_option(f, option, | |
697 "float_window_width", value, float_window_w); | |
698 float_window_h = read_int_option(f, option, | |
699 "float_window_height", value, float_window_h); | |
9 | 700 float_window_divider = read_int_option(f, option, |
701 "float_window_divider", value, float_window_divider); | |
702 window_hdivider_pos = read_int_option(f, option, | |
703 "divider_position_h", value, window_hdivider_pos); | |
704 window_vdivider_pos = read_int_option(f, option, | |
705 "divider_position_v", value, window_vdivider_pos); | |
706 | |
1 | 707 } |
708 | |
709 fclose(f); | |
710 g_free(rc_path); | |
711 } | |
712 |