3 * Copyright (C) 2008 - 2012 The Geeqie Team
5 * Authors: Vladimir Nadvornik, Laurent Monin
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!
17 #include "filefilter.h"
18 #include "histogram.h" /* HCHAN_RGB */
19 #include "image-overlay.h" /* OSD_SHOW_NOTHING */
21 #include "layout_image.h"
23 #include "ui_bookmark.h"
24 #include "ui_fileops.h"
27 ConfOptions *init_options(ConfOptions *options)
29 if (!options) options = g_new0(ConfOptions, 1);
31 options->collections.rectangular_selection = FALSE;
33 options->color_profile.enabled = TRUE;
34 options->color_profile.input_type = 0;
35 options->color_profile.screen_file = NULL;
36 options->color_profile.use_image = TRUE;
37 options->color_profile.use_x11_screen_profile = TRUE;
39 options->dnd_icon_size = 48;
40 options->duplicates_similarity_threshold = 99;
41 options->rot_invariant_sim = TRUE;
43 options->file_filter.disable = FALSE;
44 options->file_filter.show_dot_directory = FALSE;
45 options->file_filter.show_hidden_files = FALSE;
46 options->file_filter.show_parent_directory = TRUE;
47 options->file_filter.disable_file_extension_checks = FALSE;
49 options->save_window_positions = TRUE;
50 options->tools_restore_state = TRUE;
52 options->file_ops.confirm_delete = TRUE;
53 options->file_ops.enable_delete_key = TRUE;
54 options->file_ops.enable_in_place_rename = TRUE;
55 options->file_ops.safe_delete_enable = FALSE;
56 options->file_ops.safe_delete_folder_maxsize = 128;
57 options->file_ops.safe_delete_path = NULL;
59 options->file_sort.ascending = TRUE;
60 options->file_sort.case_sensitive = FALSE;
61 options->file_sort.method = SORT_NAME;
63 options->fullscreen.above = FALSE;
64 options->fullscreen.clean_flip = FALSE;
65 options->fullscreen.disable_saver = TRUE;
66 options->fullscreen.screen = -1;
68 memset(&options->image.border_color, 0, sizeof(options->image.border_color));
69 options->image.enable_read_ahead = TRUE;
70 options->image.exif_rotate_enable = TRUE;
71 options->image.exif_proof_rotate_enable = TRUE;
72 options->image.fit_window_to_image = FALSE;
73 options->image.limit_autofit_size = FALSE;
74 options->image.limit_window_size = TRUE;
75 options->image.max_autofit_size = 100;
76 options->image.max_window_size = 90;
77 options->image.scroll_reset_method = SCROLL_RESET_NOCHANGE;
78 options->image.tile_cache_max = 10;
79 options->image.image_cache_max = 128; /* 4 x 10MPix */
80 options->image.use_custom_border_color = FALSE;
81 options->image.use_custom_border_color_in_fullscreen = TRUE;
82 options->image.zoom_2pass = TRUE;
83 options->image.zoom_increment = 5;
84 options->image.zoom_mode = ZOOM_RESET_NONE;
85 options->image.zoom_quality = GDK_INTERP_BILINEAR;
86 options->image.zoom_to_fit_allow_expand = FALSE;
88 options->image_overlay.template_string = NULL;
89 options->image_overlay.x = 10;
90 options->image_overlay.y = -10;
91 options->image_overlay.font = NULL;
92 options->image_overlay.text_red = 0;
93 options->image_overlay.text_green = 0;
94 options->image_overlay.text_blue = 0;
95 options->image_overlay.text_alpha = 255;
96 options->image_overlay.background_red = 240;
97 options->image_overlay.background_green = 240;
98 options->image_overlay.background_blue = 240;
99 options->image_overlay.background_alpha = 210;
101 options->lazy_image_sync = FALSE;
102 options->mousewheel_scrolls = FALSE;
103 options->open_recent_list_maxsize = 10;
104 options->place_dialogs_under_mouse = FALSE;
106 options->progressive_key_scrolling = TRUE;
108 options->metadata.enable_metadata_dirs = FALSE;
109 options->metadata.save_in_image_file = FALSE;
110 options->metadata.save_legacy_IPTC = FALSE;
111 options->metadata.warn_on_write_problems = TRUE;
112 options->metadata.save_legacy_format = FALSE;
113 options->metadata.sync_grouped_files = TRUE;
114 options->metadata.confirm_write = TRUE;
115 options->metadata.confirm_after_timeout = FALSE;
116 options->metadata.confirm_timeout = 10;
117 options->metadata.confirm_on_image_change = FALSE;
118 options->metadata.confirm_on_dir_change = TRUE;
119 options->metadata.keywords_case_sensitive = FALSE;
120 options->metadata.write_orientation = TRUE;
122 options->show_icon_names = TRUE;
124 options->slideshow.delay = 50;
125 options->slideshow.random = FALSE;
126 options->slideshow.repeat = FALSE;
128 options->thumbnails.cache_into_dirs = FALSE;
129 options->thumbnails.enable_caching = TRUE;
130 options->thumbnails.max_height = DEFAULT_THUMB_HEIGHT;
131 options->thumbnails.max_width = DEFAULT_THUMB_WIDTH;
132 options->thumbnails.quality = GDK_INTERP_TILES;
133 options->thumbnails.spec_standard = TRUE;
134 options->thumbnails.use_xvpics = TRUE;
135 options->thumbnails.use_exif = FALSE;
137 options->tree_descend_subdirs = FALSE;
138 options->update_on_time_change = TRUE;
140 options->stereo.fixed_w = 1920;
141 options->stereo.fixed_h = 1080;
142 options->stereo.fixed_x1 = 0;
143 options->stereo.fixed_y1 = 0;
144 options->stereo.fixed_x2 = 0;
145 options->stereo.fixed_y2 = 1125;
150 void setup_default_options(ConfOptions *options)
155 bookmark_add_default(".", get_current_dir());
156 bookmark_add_default(_("Home"), homedir());
157 path = g_build_filename(homedir(), "Desktop", NULL);
158 bookmark_add_default(_("Desktop"), path);
160 bookmark_add_default(_("Collections"), get_collections_dir());
162 g_free(options->file_ops.safe_delete_path);
163 options->file_ops.safe_delete_path = g_strdup(get_trash_dir());
165 for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
167 options->color_profile.input_file[i] = NULL;
168 options->color_profile.input_name[i] = NULL;
171 set_default_image_overlay_template_string(&options->image_overlay.template_string);
172 options->sidecar.ext = g_strdup(".jpg;%raw;.ufraw;.xmp;%unknown");
174 options->shell.path = g_strdup(GQ_DEFAULT_SHELL_PATH);
175 options->shell.options = g_strdup(GQ_DEFAULT_SHELL_OPTIONS);
178 void copy_layout_options(LayoutOptions *dest, const LayoutOptions *src)
180 free_layout_options_content(dest);
183 dest->id = g_strdup(src->id);
184 dest->order = g_strdup(src->order);
185 dest->home_path = g_strdup(src->home_path);
186 dest->last_path = g_strdup(src->last_path);
189 void free_layout_options_content(LayoutOptions *dest)
193 g_free(dest->home_path);
194 g_free(dest->last_path);
197 LayoutOptions *init_layout_options(LayoutOptions *options)
199 memset(options, 0, sizeof(LayoutOptions));
201 options->dir_view_type = DIRVIEW_LIST;
202 options->file_view_type = FILEVIEW_LIST;
203 options->float_window.h = 450;
204 options->float_window.vdivider_pos = -1;
205 options->float_window.w = 260;
206 options->float_window.x = 0;
207 options->float_window.y = 0;
208 options->home_path = NULL;
209 options->main_window.h = 540;
210 options->main_window.hdivider_pos = -1;
211 options->main_window.maximized = FALSE;
212 options->main_window.vdivider_pos = 200;
213 options->main_window.w = 720;
214 options->main_window.x = 0;
215 options->main_window.y = 0;
216 options->order = g_strdup("123");
217 options->show_directory_date = FALSE;
218 options->show_marks = FALSE;
219 options->show_thumbnails = FALSE;
221 options->show_info_pixel = FALSE;
222 options->toolbar_hidden = FALSE;
223 options->tools_float = FALSE;
224 options->tools_hidden = FALSE;
225 options->image_overlay.histogram_channel = HCHAN_RGB;
226 options->image_overlay.histogram_mode = 1;
227 options->image_overlay.state = OSD_SHOW_NOTHING;
231 static void sync_options_with_current_state(ConfOptions *options)
233 LayoutWindow *lw = NULL;
235 if (layout_valid(&lw))
237 layout_sync_options_with_current_state(lw);
238 layout_sort_get(lw, &options->file_sort.method, &options->file_sort.ascending);
240 options->color_profile.enabled = layout_image_color_profile_get_use(lw);
241 layout_image_color_profile_get(lw,
242 &options->color_profile.input_type,
243 &options->color_profile.use_image);
248 void save_options(ConfOptions *options)
252 sync_options_with_current_state(options);
254 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
255 save_config_to_file(rc_path, options);
259 gboolean load_options(ConfOptions *options)
264 if (isdir(GQ_SYSTEM_WIDE_DIR))
266 rc_path = g_build_filename(GQ_SYSTEM_WIDE_DIR, RC_FILE_NAME, NULL);
267 success = load_config_from_file(rc_path, TRUE);
268 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
272 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
273 success = load_config_from_file(rc_path, TRUE);
274 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
278 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */