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)
39 if (!options) options = g_new0(ConfOptions, 1);
41 options->collections.rectangular_selection = FALSE;
43 options->color_profile.enabled = TRUE;
44 options->color_profile.input_type = 0;
45 options->color_profile.screen_file = NULL;
46 options->color_profile.use_image = TRUE;
47 options->color_profile.use_x11_screen_profile = TRUE;
48 options->color_profile.render_intent = 0;
50 options->dnd_icon_size = 48;
51 options->duplicates_similarity_threshold = 99;
52 options->rot_invariant_sim = TRUE;
53 options->sort_totals = FALSE;
55 options->file_filter.disable = FALSE;
56 options->file_filter.show_dot_directory = FALSE;
57 options->file_filter.show_hidden_files = FALSE;
58 options->file_filter.show_parent_directory = TRUE;
59 options->file_filter.disable_file_extension_checks = FALSE;
61 options->save_window_positions = TRUE;
62 options->use_saved_window_positions_for_new_windows = FALSE;
63 options->tools_restore_state = TRUE;
64 options->save_dialog_window_positions = FALSE;
65 options->show_window_ids = FALSE;
67 options->file_ops.confirm_delete = TRUE;
68 options->file_ops.confirm_move_to_trash = TRUE;
69 options->file_ops.enable_delete_key = TRUE;
70 options->file_ops.use_system_trash = TRUE;
71 options->file_ops.enable_in_place_rename = TRUE;
72 options->file_ops.safe_delete_enable = TRUE;
73 options->file_ops.safe_delete_folder_maxsize = 128;
74 options->file_ops.safe_delete_path = NULL;
75 options->file_ops.no_trash = FALSE;
77 options->file_sort.ascending = TRUE;
78 options->file_sort.case_sensitive = FALSE;
79 options->file_sort.method = SORT_NAME;
80 options->file_sort.natural = FALSE;
82 options->fullscreen.above = FALSE;
83 options->fullscreen.clean_flip = FALSE;
84 options->fullscreen.disable_saver = TRUE;
85 options->fullscreen.screen = -1;
87 options->marks_save = TRUE;
88 options->with_rename = FALSE;
89 options->collections_on_top = FALSE;
91 memset(&options->image.border_color, 0, sizeof(options->image.border_color));
92 memset(&options->image.alpha_color_1, 0, sizeof(options->image.alpha_color_1));
93 memset(&options->image.alpha_color_2, 0, sizeof(options->image.alpha_color_2));
94 /* alpha channel checkerboard background (same as gimp) */
95 options->image.alpha_color_1.red = 0x009999;
96 options->image.alpha_color_1.green = 0x009999;
97 options->image.alpha_color_1.blue = 0x009999;
98 options->image.alpha_color_2.red = 0x006666;
99 options->image.alpha_color_2.green = 0x006666;
100 options->image.alpha_color_2.blue = 0x006666;
101 options->image.enable_read_ahead = TRUE;
102 options->image.exif_rotate_enable = TRUE;
103 options->image.exif_proof_rotate_enable = TRUE;
104 options->image.fit_window_to_image = FALSE;
105 options->image.limit_autofit_size = FALSE;
106 options->image.limit_window_size = TRUE;
107 options->image.max_autofit_size = 100;
108 options->image.max_enlargement_size = 900;
109 options->image.max_window_size = 90;
110 options->image.scroll_reset_method = SCROLL_RESET_NOCHANGE;
111 options->image.tile_cache_max = 10;
112 options->image.image_cache_max = 128; /* 4 x 10MPix */
113 options->image.use_custom_border_color = FALSE;
114 options->image.use_custom_border_color_in_fullscreen = TRUE;
115 options->image.zoom_2pass = TRUE;
116 options->image.zoom_increment = 5;
117 options->image.zoom_mode = ZOOM_RESET_NONE;
118 options->image.zoom_quality = GDK_INTERP_BILINEAR;
119 options->image.zoom_to_fit_allow_expand = FALSE;
121 options->image_overlay.template_string = NULL;
122 options->image_overlay.x = 10;
123 options->image_overlay.y = -10;
124 options->image_overlay.font = NULL;
125 options->image_overlay.text_red = 0;
126 options->image_overlay.text_green = 0;
127 options->image_overlay.text_blue = 0;
128 options->image_overlay.text_alpha = 255;
129 options->image_overlay.background_red = 240;
130 options->image_overlay.background_green = 240;
131 options->image_overlay.background_blue = 240;
132 options->image_overlay.background_alpha = 210;
134 options->lazy_image_sync = FALSE;
135 options->mousewheel_scrolls = FALSE;
136 options->image_lm_click_nav = TRUE;
137 options->image_l_click_video = FALSE;
138 options->image_l_click_video_editor = NULL;
139 options->open_recent_list_maxsize = 10;
140 options->place_dialogs_under_mouse = FALSE;
142 options->progressive_key_scrolling = TRUE;
143 options->keyboard_scroll_step = 1;
145 options->metadata.enable_metadata_dirs = FALSE;
146 options->metadata.save_in_image_file = FALSE;
147 options->metadata.save_legacy_IPTC = FALSE;
148 options->metadata.warn_on_write_problems = TRUE;
149 options->metadata.save_legacy_format = FALSE;
150 options->metadata.sync_grouped_files = TRUE;
151 options->metadata.confirm_write = TRUE;
152 options->metadata.confirm_after_timeout = FALSE;
153 options->metadata.confirm_timeout = 10;
154 options->metadata.confirm_on_image_change = FALSE;
155 options->metadata.confirm_on_dir_change = TRUE;
156 options->metadata.keywords_case_sensitive = FALSE;
157 options->metadata.write_orientation = TRUE;
158 options->metadata.sidecar_extended_name = FALSE;
160 options->show_icon_names = TRUE;
161 options->show_star_rating = FALSE;
162 options->show_predefined_keyword_tree = TRUE;
164 options->slideshow.delay = 50;
165 options->slideshow.random = FALSE;
166 options->slideshow.repeat = FALSE;
168 options->thumbnails.cache_into_dirs = FALSE;
169 options->thumbnails.enable_caching = TRUE;
170 options->thumbnails.max_height = DEFAULT_THUMB_HEIGHT;
171 options->thumbnails.max_width = DEFAULT_THUMB_WIDTH;
172 options->thumbnails.quality = GDK_INTERP_TILES;
173 options->thumbnails.spec_standard = TRUE;
174 options->thumbnails.use_xvpics = TRUE;
175 options->thumbnails.use_exif = FALSE;
176 options->thumbnails.use_ft_metadata = TRUE;
177 // options->thumbnails.use_ft_metadata_small = TRUE;
178 options->thumbnails.collection_preview = 20;
180 options->tree_descend_subdirs = FALSE;
181 options->view_dir_list_single_click_enter = TRUE;
182 options->update_on_time_change = TRUE;
183 options->clipboard_selection = PRIMARY;
185 options->stereo.fixed_w = 1920;
186 options->stereo.fixed_h = 1080;
187 options->stereo.fixed_x1 = 0;
188 options->stereo.fixed_y1 = 0;
189 options->stereo.fixed_x2 = 0;
190 options->stereo.fixed_y2 = 1125;
192 options->log_window_lines = 1000;
193 options->log_window.line_wrap = TRUE;
194 options->log_window.paused = FALSE;
195 options->log_window.timer_data = FALSE;
197 options->read_metadata_in_idle = FALSE;
198 options->star_rating.star = STAR_RATING_STAR;
199 options->star_rating.rejected = STAR_RATING_REJECTED;
201 options->printer.template_string = NULL;
202 options->printer.image_font = g_strdup("Serif 10");
203 options->printer.page_font = g_strdup("Serif 10");
204 options->printer.page_text = NULL;
205 options->printer.image_text_position = 1;
206 options->printer.page_text_position = 3;
208 options->disabled_plugins = NULL;
213 void setup_default_options(ConfOptions *options)
218 bookmark_add_default(".", get_current_dir());
219 bookmark_add_default(_("Home"), homedir());
220 path = g_build_filename(homedir(), "Desktop", NULL);
221 bookmark_add_default(_("Desktop"), path);
223 bookmark_add_default(_("Collections"), get_collections_dir());
225 g_free(options->file_ops.safe_delete_path);
226 options->file_ops.safe_delete_path = g_strdup(get_trash_dir());
228 for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
230 options->color_profile.input_file[i] = NULL;
231 options->color_profile.input_name[i] = NULL;
234 set_default_image_overlay_template_string(&options->image_overlay.template_string);
235 options->sidecar.ext = g_strdup(".jpg;%raw;.ufraw;.xmp;%unknown");
237 options->shell.path = g_strdup(GQ_DEFAULT_SHELL_PATH);
238 options->shell.options = g_strdup(GQ_DEFAULT_SHELL_OPTIONS);
240 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
242 options->marks_tooltips[i] = g_strdup_printf("%s%d", _("Mark "), i + 1);
245 options->help_search_engine = g_strdup(HELP_SEARCH_ENGINE);
248 void copy_layout_options(LayoutOptions *dest, const LayoutOptions *src)
250 free_layout_options_content(dest);
253 dest->id = g_strdup(src->id);
254 dest->order = g_strdup(src->order);
255 dest->home_path = g_strdup(src->home_path);
256 dest->last_path = g_strdup(src->last_path);
259 void free_layout_options_content(LayoutOptions *dest)
263 g_free(dest->home_path);
264 g_free(dest->last_path);
267 LayoutOptions *init_layout_options(LayoutOptions *options)
269 memset(options, 0, sizeof(LayoutOptions));
271 options->dir_view_type = DIRVIEW_LIST;
272 options->file_view_type = FILEVIEW_LIST;
273 options->float_window.h = 450;
274 options->float_window.vdivider_pos = -1;
275 options->float_window.w = 260;
276 options->float_window.x = 0;
277 options->float_window.y = 0;
278 options->home_path = NULL;
279 options->main_window.h = 540;
280 options->main_window.hdivider_pos = -1;
281 options->main_window.maximized = FALSE;
282 options->main_window.vdivider_pos = 200;
283 options->main_window.w = 720;
284 options->main_window.x = 0;
285 options->main_window.y = 0;
286 options->folder_window.vdivider_pos = 100;
287 options->order = g_strdup("123");
288 options->show_directory_date = FALSE;
289 options->show_marks = FALSE;
290 options->show_file_filter = FALSE;
291 options->show_thumbnails = FALSE;
293 options->show_info_pixel = FALSE;
294 options->toolbar_hidden = FALSE;
295 options->tools_float = FALSE;
296 options->tools_hidden = FALSE;
297 options->image_overlay.histogram_channel = HCHAN_RGB;
298 options->image_overlay.histogram_mode = 1;
299 options->image_overlay.state = OSD_SHOW_NOTHING;
300 options->animate = TRUE;
301 options->bars_state.hidden = FALSE;
302 options->log_window.w = 520;
303 options->log_window.h = 400;
307 static void sync_options_with_current_state(ConfOptions *options)
309 LayoutWindow *lw = NULL;
311 if (layout_valid(&lw))
313 layout_sync_options_with_current_state(lw);
314 layout_sort_get(lw, &options->file_sort.method, &options->file_sort.ascending);
316 options->color_profile.enabled = layout_image_color_profile_get_use(lw);
317 layout_image_color_profile_get(lw,
318 &options->color_profile.input_type,
319 &options->color_profile.use_image);
324 void save_options(ConfOptions *options)
328 sync_options_with_current_state(options);
330 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
331 save_config_to_file(rc_path, options);
335 gboolean load_options(ConfOptions *options)
340 if (isdir(GQ_SYSTEM_WIDE_DIR))
342 rc_path = g_build_filename(GQ_SYSTEM_WIDE_DIR, RC_FILE_NAME, NULL);
343 success = load_config_from_file(rc_path, TRUE);
344 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
348 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
349 success = load_config_from_file(rc_path, TRUE);
350 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
354 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */