3 * Copyright (C) 2008 - 2009 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.screen_type = 0;
37 options->color_profile.use_image = TRUE;
39 options->dnd_icon_size = 48;
40 options->duplicates_similarity_threshold = 99;
42 options->file_filter.disable = FALSE;
43 options->file_filter.show_dot_directory = FALSE;
44 options->file_filter.show_hidden_files = FALSE;
46 options->file_ops.confirm_delete = TRUE;
47 options->file_ops.enable_delete_key = TRUE;
48 options->file_ops.enable_in_place_rename = TRUE;
49 options->file_ops.safe_delete_enable = FALSE;
50 options->file_ops.safe_delete_folder_maxsize = 128;
51 options->file_ops.safe_delete_path = NULL;
53 options->file_sort.ascending = TRUE;
54 options->file_sort.case_sensitive = FALSE;
55 options->file_sort.method = SORT_NAME;
57 options->fullscreen.above = FALSE;
58 options->fullscreen.clean_flip = FALSE;
59 options->fullscreen.disable_saver = TRUE;
60 options->fullscreen.screen = -1;
62 options->histogram.last_channel_mode = HCHAN_RGB;
63 options->histogram.last_log_mode = 1;
65 memset(&options->image.border_color, 0, sizeof(options->image.border_color));
66 options->image.dither_quality = GDK_RGB_DITHER_NORMAL;
67 options->image.enable_read_ahead = TRUE;
68 options->image.exif_rotate_enable = TRUE;
69 options->image.fit_window_to_image = FALSE;
70 options->image.idle_read_loop_count = IMAGE_LOADER_IDLE_READ_LOOP_COUNT_DEFAULT;
71 options->image.limit_autofit_size = FALSE;
72 options->image.limit_window_size = TRUE;
73 options->image.max_autofit_size = 100;
74 options->image.max_window_size = 90;
75 options->image.read_buffer_size = IMAGE_LOADER_READ_BUFFER_SIZE_DEFAULT;
76 options->image.scroll_reset_method = SCROLL_RESET_NOCHANGE;
77 options->image.tile_cache_max = 10;
78 options->image.image_cache_max = 128; /* 4 x 10MPix */
79 options->image.use_custom_border_color = FALSE;
80 options->image.zoom_2pass = TRUE;
81 options->image.zoom_increment = 5;
82 options->image.zoom_mode = ZOOM_RESET_NONE;
83 options->image.zoom_quality = GDK_INTERP_BILINEAR;
84 options->image.zoom_to_fit_allow_expand = FALSE;
86 options->image_overlay.common.state = OSD_SHOW_NOTHING;
87 options->image_overlay.common.show_at_startup = FALSE;
88 options->image_overlay.common.template_string = NULL;
89 options->image_overlay.common.x = 10;
90 options->image_overlay.common.y = -10;
92 options->layout.dir_view_type = DIRVIEW_LIST;
93 options->layout.file_view_type = FILEVIEW_LIST;
94 options->layout.float_window.h = 450;
95 options->layout.float_window.vdivider_pos = -1;
96 options->layout.float_window.w = 260;
97 options->layout.float_window.x = 0;
98 options->layout.float_window.y = 0;
99 options->layout.home_path = NULL;
100 options->layout.main_window.h = 540;
101 options->layout.main_window.hdivider_pos = -1;
102 options->layout.main_window.maximized = FALSE;
103 options->layout.main_window.vdivider_pos = 200;
104 options->layout.main_window.w = 720;
105 options->layout.main_window.x = 0;
106 options->layout.main_window.y = 0;
107 options->layout.order = NULL;
108 options->layout.save_window_positions = TRUE;
109 options->layout.show_directory_date = FALSE;
110 options->layout.show_marks = FALSE;
111 options->layout.show_thumbnails = FALSE;
112 options->layout.style = 0;
113 options->layout.toolbar_hidden = FALSE;
114 options->layout.tools_float = FALSE;
115 options->layout.tools_hidden = FALSE;
116 options->layout.tools_restore_state = TRUE;
118 options->lazy_image_sync = FALSE;
119 options->mousewheel_scrolls = FALSE;
120 options->open_recent_list_maxsize = 10;
121 options->place_dialogs_under_mouse = FALSE;
123 options->layout.panels.sort.action_state = 0;
124 options->layout.panels.sort.enabled = FALSE;
125 options->layout.panels.sort.mode_state = 0;
126 options->layout.panels.sort.selection_state = 0;
127 options->layout.panels.sort.action_filter = NULL;
129 options->progressive_key_scrolling = TRUE;
131 options->metadata.enable_metadata_dirs = FALSE;
132 options->metadata.save_in_image_file = FALSE;
133 options->metadata.save_legacy_IPTC = FALSE;
134 options->metadata.warn_on_write_problems = TRUE;
135 options->metadata.save_legacy_format = FALSE;
136 options->metadata.sync_grouped_files = TRUE;
137 options->metadata.confirm_write = TRUE;
138 options->metadata.confirm_after_timeout = FALSE;
139 options->metadata.confirm_timeout = 10;
140 options->metadata.confirm_on_image_change = FALSE;
141 options->metadata.confirm_on_dir_change = TRUE;
143 options->show_copy_path = TRUE;
144 options->show_icon_names = TRUE;
146 options->slideshow.delay = 50;
147 options->slideshow.random = FALSE;
148 options->slideshow.repeat = FALSE;
150 options->startup.path = NULL;
151 options->startup.restore_path = FALSE;
152 options->startup.use_last_path = FALSE;
154 options->thumbnails.cache_into_dirs = FALSE;
155 options->thumbnails.enable_caching = TRUE;
156 options->thumbnails.fast = TRUE;
157 options->thumbnails.max_height = DEFAULT_THUMB_HEIGHT;
158 options->thumbnails.max_width = DEFAULT_THUMB_WIDTH;
159 options->thumbnails.quality = GDK_INTERP_TILES;
160 options->thumbnails.spec_standard = TRUE;
161 options->thumbnails.use_xvpics = TRUE;
162 options->thumbnails.use_exif = FALSE;
164 options->tree_descend_subdirs = FALSE;
165 options->update_on_time_change = TRUE;
170 void setup_default_options(ConfOptions *options)
175 bookmark_add_default(_("Home"), homedir());
176 path = g_build_filename(homedir(), "Desktop", NULL);
177 bookmark_add_default(_("Desktop"), path);
179 bookmark_add_default(_("Collections"), get_collections_dir());
181 g_free(options->file_ops.safe_delete_path);
182 options->file_ops.safe_delete_path = g_strdup(get_trash_dir());
184 for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
186 options->color_profile.input_file[i] = NULL;
187 options->color_profile.input_name[i] = NULL;
190 set_default_image_overlay_template_string(&options->image_overlay.common.template_string);
191 options->sidecar.ext = g_strdup(".jpg;%raw;.xmp");
192 options->layout.order = g_strdup("123");
194 options->shell.path = g_strdup(GQ_DEFAULT_SHELL_PATH);
195 options->shell.options = g_strdup(GQ_DEFAULT_SHELL_OPTIONS);
197 for (i = 0; ExifUIList[i].key; i++)
198 ExifUIList[i].current = ExifUIList[i].default_value;
201 void copy_layout_options(LayoutOptions *dest, const LayoutOptions *src)
203 free_layout_options_content(dest);
206 dest->order = g_strdup(src->order);
207 dest->home_path = g_strdup(src->home_path);
208 dest->panels.sort.action_filter = g_strdup(src->panels.sort.action_filter);
211 void free_layout_options_content(LayoutOptions *dest)
213 if (dest->order) g_free(dest->order);
214 if (dest->home_path) g_free(dest->home_path);
215 if (dest->panels.sort.action_filter) g_free(dest->panels.sort.action_filter);
218 static void sync_options_with_current_state(ConfOptions *options)
220 LayoutWindow *lw = NULL;
222 if (layout_valid(&lw))
224 layout_sync_options_with_current_state(lw);
225 copy_layout_options(&options->layout, &lw->options);
226 options->image_overlay.common.state = image_osd_get(lw->image);
227 layout_sort_get(lw, &options->file_sort.method, &options->file_sort.ascending);
231 options->color_profile.enabled = layout_image_color_profile_get_use(lw);
232 layout_image_color_profile_get(lw,
233 &options->color_profile.input_type,
234 &options->color_profile.screen_type,
235 &options->color_profile.use_image);
237 if (options->startup.restore_path && options->startup.use_last_path)
239 g_free(options->startup.path);
240 options->startup.path = g_strdup(layout_get_path(lw));
246 void save_options(ConfOptions *options)
250 sync_options_with_current_state(options);
252 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
253 save_options_to(rc_path, options);
257 gboolean load_options(ConfOptions *options)
262 if (isdir(GQ_SYSTEM_WIDE_DIR))
264 rc_path = g_build_filename(GQ_SYSTEM_WIDE_DIR, RC_FILE_NAME, NULL);
265 success = load_options_from(rc_path, options, TRUE);
266 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
270 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
271 success = load_options_from(rc_path, options, TRUE);
272 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
276 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */