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