2 * Copyright (C) 2008, 2016 The Geeqie Team -
4 * Authors: Vladimir Nadvornik, Laurent Monin
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
25 #include "filefilter.h"
26 #include "histogram.h" /* HCHAN_RGB */
27 #include "image-overlay.h" /* OSD_SHOW_NOTHING */
29 #include "layout_image.h"
31 #include "ui_bookmark.h"
32 #include "ui_fileops.h"
35 ConfOptions *init_options(ConfOptions *options)
37 if (!options) options = g_new0(ConfOptions, 1);
39 options->collections.rectangular_selection = FALSE;
41 options->color_profile.enabled = TRUE;
42 options->color_profile.input_type = 0;
43 options->color_profile.screen_file = NULL;
44 options->color_profile.use_image = TRUE;
45 options->color_profile.use_x11_screen_profile = TRUE;
46 options->color_profile.render_intent = 0;
48 options->dnd_icon_size = 48;
49 options->duplicates_similarity_threshold = 99;
50 options->rot_invariant_sim = TRUE;
51 options->sort_totals = FALSE;
53 options->file_filter.disable = FALSE;
54 options->file_filter.show_dot_directory = FALSE;
55 options->file_filter.show_hidden_files = FALSE;
56 options->file_filter.show_parent_directory = TRUE;
57 options->file_filter.disable_file_extension_checks = FALSE;
59 options->save_window_positions = TRUE;
60 options->use_saved_window_positions_for_new_windows = FALSE;
61 options->tools_restore_state = TRUE;
62 options->save_dialog_window_positions = FALSE;
63 options->show_window_ids = FALSE;
65 options->file_ops.confirm_delete = TRUE;
66 options->file_ops.enable_delete_key = TRUE;
67 options->file_ops.enable_in_place_rename = TRUE;
68 options->file_ops.safe_delete_enable = FALSE;
69 options->file_ops.safe_delete_folder_maxsize = 128;
70 options->file_ops.safe_delete_path = NULL;
72 options->file_sort.ascending = TRUE;
73 options->file_sort.case_sensitive = FALSE;
74 options->file_sort.method = SORT_NAME;
75 options->file_sort.natural = FALSE;
77 options->fullscreen.above = FALSE;
78 options->fullscreen.clean_flip = FALSE;
79 options->fullscreen.disable_saver = TRUE;
80 options->fullscreen.screen = -1;
82 options->marks_save = TRUE;
84 memset(&options->image.border_color, 0, sizeof(options->image.border_color));
85 memset(&options->image.alpha_color_1, 0, sizeof(options->image.alpha_color_1));
86 memset(&options->image.alpha_color_2, 0, sizeof(options->image.alpha_color_2));
87 /* alpha channel checkerboard background (same as gimp) */
88 options->image.alpha_color_1.red = 0x009999;
89 options->image.alpha_color_1.green = 0x009999;
90 options->image.alpha_color_1.blue = 0x009999;
91 options->image.alpha_color_2.red = 0x006666;
92 options->image.alpha_color_2.green = 0x006666;
93 options->image.alpha_color_2.blue = 0x006666;
94 options->image.enable_read_ahead = TRUE;
95 options->image.exif_rotate_enable = TRUE;
96 options->image.exif_proof_rotate_enable = TRUE;
97 options->image.fit_window_to_image = FALSE;
98 options->image.limit_autofit_size = FALSE;
99 options->image.limit_window_size = TRUE;
100 options->image.max_autofit_size = 100;
101 options->image.max_enlargement_size = 900;
102 options->image.max_window_size = 90;
103 options->image.scroll_reset_method = SCROLL_RESET_NOCHANGE;
104 options->image.tile_cache_max = 10;
105 options->image.image_cache_max = 128; /* 4 x 10MPix */
106 options->image.use_custom_border_color = FALSE;
107 options->image.use_custom_border_color_in_fullscreen = TRUE;
108 options->image.zoom_2pass = TRUE;
109 options->image.zoom_increment = 5;
110 options->image.zoom_mode = ZOOM_RESET_NONE;
111 options->image.zoom_quality = GDK_INTERP_BILINEAR;
112 options->image.zoom_to_fit_allow_expand = FALSE;
114 options->image_overlay.template_string = NULL;
115 options->image_overlay.x = 10;
116 options->image_overlay.y = -10;
117 options->image_overlay.font = NULL;
118 options->image_overlay.text_red = 0;
119 options->image_overlay.text_green = 0;
120 options->image_overlay.text_blue = 0;
121 options->image_overlay.text_alpha = 255;
122 options->image_overlay.background_red = 240;
123 options->image_overlay.background_green = 240;
124 options->image_overlay.background_blue = 240;
125 options->image_overlay.background_alpha = 210;
127 options->lazy_image_sync = FALSE;
128 options->mousewheel_scrolls = FALSE;
129 options->image_lm_click_nav = TRUE;
130 options->image_l_click_video = FALSE;
131 options->image_l_click_video_editor = NULL;
132 options->open_recent_list_maxsize = 10;
133 options->place_dialogs_under_mouse = FALSE;
135 options->progressive_key_scrolling = TRUE;
136 options->keyboard_scroll_step = 1;
138 options->metadata.enable_metadata_dirs = FALSE;
139 options->metadata.save_in_image_file = FALSE;
140 options->metadata.save_legacy_IPTC = FALSE;
141 options->metadata.warn_on_write_problems = TRUE;
142 options->metadata.save_legacy_format = FALSE;
143 options->metadata.sync_grouped_files = TRUE;
144 options->metadata.confirm_write = TRUE;
145 options->metadata.confirm_after_timeout = FALSE;
146 options->metadata.confirm_timeout = 10;
147 options->metadata.confirm_on_image_change = FALSE;
148 options->metadata.confirm_on_dir_change = TRUE;
149 options->metadata.keywords_case_sensitive = FALSE;
150 options->metadata.write_orientation = TRUE;
151 options->metadata.sidecar_extended_name = FALSE;
153 options->show_icon_names = TRUE;
155 options->slideshow.delay = 50;
156 options->slideshow.random = FALSE;
157 options->slideshow.repeat = FALSE;
159 options->thumbnails.cache_into_dirs = FALSE;
160 options->thumbnails.enable_caching = TRUE;
161 options->thumbnails.max_height = DEFAULT_THUMB_HEIGHT;
162 options->thumbnails.max_width = DEFAULT_THUMB_WIDTH;
163 options->thumbnails.quality = GDK_INTERP_TILES;
164 options->thumbnails.spec_standard = TRUE;
165 options->thumbnails.use_xvpics = TRUE;
166 options->thumbnails.use_exif = FALSE;
167 options->thumbnails.use_ft_metadata = TRUE;
168 // options->thumbnails.use_ft_metadata_small = TRUE;
170 options->tree_descend_subdirs = FALSE;
171 options->view_dir_list_single_click_enter = TRUE;
172 options->update_on_time_change = TRUE;
173 options->clipboard_selection = PRIMARY;
175 options->stereo.fixed_w = 1920;
176 options->stereo.fixed_h = 1080;
177 options->stereo.fixed_x1 = 0;
178 options->stereo.fixed_y1 = 0;
179 options->stereo.fixed_x2 = 0;
180 options->stereo.fixed_y2 = 1125;
182 options->log_window_lines = 1000;
183 options->log_window.line_wrap = TRUE;
184 options->log_window.paused = FALSE;
185 options->log_window.timer_data = FALSE;
190 void setup_default_options(ConfOptions *options)
195 bookmark_add_default(".", get_current_dir());
196 bookmark_add_default(_("Home"), homedir());
197 path = g_build_filename(homedir(), "Desktop", NULL);
198 bookmark_add_default(_("Desktop"), path);
200 bookmark_add_default(_("Collections"), get_collections_dir());
202 g_free(options->file_ops.safe_delete_path);
203 options->file_ops.safe_delete_path = g_strdup(get_trash_dir());
205 for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
207 options->color_profile.input_file[i] = NULL;
208 options->color_profile.input_name[i] = NULL;
211 set_default_image_overlay_template_string(&options->image_overlay.template_string);
212 options->sidecar.ext = g_strdup(".jpg;%raw;.ufraw;.xmp;%unknown");
214 options->shell.path = g_strdup(GQ_DEFAULT_SHELL_PATH);
215 options->shell.options = g_strdup(GQ_DEFAULT_SHELL_OPTIONS);
218 void copy_layout_options(LayoutOptions *dest, const LayoutOptions *src)
220 free_layout_options_content(dest);
223 dest->id = g_strdup(src->id);
224 dest->order = g_strdup(src->order);
225 dest->home_path = g_strdup(src->home_path);
226 dest->last_path = g_strdup(src->last_path);
229 void free_layout_options_content(LayoutOptions *dest)
233 g_free(dest->home_path);
234 g_free(dest->last_path);
237 LayoutOptions *init_layout_options(LayoutOptions *options)
239 memset(options, 0, sizeof(LayoutOptions));
241 options->dir_view_type = DIRVIEW_LIST;
242 options->file_view_type = FILEVIEW_LIST;
243 options->float_window.h = 450;
244 options->float_window.vdivider_pos = -1;
245 options->float_window.w = 260;
246 options->float_window.x = 0;
247 options->float_window.y = 0;
248 options->home_path = NULL;
249 options->main_window.h = 540;
250 options->main_window.hdivider_pos = -1;
251 options->main_window.maximized = FALSE;
252 options->main_window.vdivider_pos = 200;
253 options->main_window.w = 720;
254 options->main_window.x = 0;
255 options->main_window.y = 0;
256 options->folder_window.vdivider_pos = 100;
257 options->order = g_strdup("123");
258 options->show_directory_date = FALSE;
259 options->show_marks = FALSE;
260 options->show_thumbnails = FALSE;
262 options->show_info_pixel = FALSE;
263 options->toolbar_hidden = FALSE;
264 options->tools_float = FALSE;
265 options->tools_hidden = FALSE;
266 options->image_overlay.histogram_channel = HCHAN_RGB;
267 options->image_overlay.histogram_mode = 1;
268 options->image_overlay.state = OSD_SHOW_NOTHING;
269 options->animate = TRUE;
270 options->bars_state.hidden = FALSE;
271 options->log_window.w = 520;
272 options->log_window.h = 400;
276 static void sync_options_with_current_state(ConfOptions *options)
278 LayoutWindow *lw = NULL;
280 if (layout_valid(&lw))
282 layout_sync_options_with_current_state(lw);
283 layout_sort_get(lw, &options->file_sort.method, &options->file_sort.ascending);
285 options->color_profile.enabled = layout_image_color_profile_get_use(lw);
286 layout_image_color_profile_get(lw,
287 &options->color_profile.input_type,
288 &options->color_profile.use_image);
293 void save_options(ConfOptions *options)
297 sync_options_with_current_state(options);
299 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
300 save_config_to_file(rc_path, options);
304 gboolean load_options(ConfOptions *options)
309 if (isdir(GQ_SYSTEM_WIDE_DIR))
311 rc_path = g_build_filename(GQ_SYSTEM_WIDE_DIR, RC_FILE_NAME, NULL);
312 success = load_config_from_file(rc_path, TRUE);
313 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
317 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
318 success = load_config_from_file(rc_path, TRUE);
319 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
323 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */