3 * Copyright (C) 2008 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 */
22 #include "layout_image.h"
24 #include "ui_bookmark.h"
25 #include "ui_fileops.h"
28 ConfOptions *init_options(ConfOptions *options)
30 if (!options) options = g_new0(ConfOptions, 1);
32 options->collections.rectangular_selection = FALSE;
34 options->color_profile.enabled = TRUE;
35 options->color_profile.input_type = 0;
36 options->color_profile.screen_file = NULL;
37 options->color_profile.screen_type = 0;
38 options->color_profile.use_image = TRUE;
40 options->dnd_icon_size = 48;
41 options->documentation.htmldir = NULL;
42 options->documentation.helpdir = NULL;
43 options->duplicates_similarity_threshold = 99;
45 options->file_filter.disable = FALSE;
46 options->file_filter.show_dot_directory = FALSE;
47 options->file_filter.show_hidden_files = FALSE;
49 options->file_ops.confirm_delete = TRUE;
50 options->file_ops.enable_delete_key = TRUE;
51 options->file_ops.enable_in_place_rename = TRUE;
52 options->file_ops.safe_delete_enable = FALSE;
53 options->file_ops.safe_delete_folder_maxsize = 128;
54 options->file_ops.safe_delete_path = NULL;
56 options->file_sort.ascending = TRUE;
57 options->file_sort.case_sensitive = FALSE;
58 options->file_sort.method = SORT_NAME;
60 options->fullscreen.above = FALSE;
61 options->fullscreen.clean_flip = FALSE;
62 options->fullscreen.disable_saver = TRUE;
63 options->fullscreen.screen = -1;
65 options->histogram.last_channel_mode = HCHAN_RGB;
66 options->histogram.last_log_mode = 1;
68 memset(&options->image.border_color, 0, sizeof(options->image.border_color));
69 options->image.dither_quality = GDK_RGB_DITHER_NORMAL;
70 options->image.enable_read_ahead = TRUE;
71 options->image.exif_rotate_enable = TRUE;
72 options->image.fit_window_to_image = FALSE;
73 options->image.idle_read_loop_count = IMAGE_LOADER_IDLE_READ_LOOP_COUNT_DEFAULT;
74 options->image.limit_autofit_size = FALSE;
75 options->image.limit_window_size = TRUE;
76 options->image.max_autofit_size = 100;
77 options->image.max_window_size = 90;
78 options->image.read_buffer_size = IMAGE_LOADER_READ_BUFFER_SIZE_DEFAULT;
79 options->image.scroll_reset_method = SCROLL_RESET_NOCHANGE;
80 options->image.tile_cache_max = 10;
81 options->image.image_cache_max = 128; /* 4 x 10MPix */
82 options->image.use_custom_border_color = FALSE;
83 options->image.zoom_2pass = TRUE;
84 options->image.zoom_increment = 5;
85 options->image.zoom_mode = ZOOM_RESET_NONE;
86 options->image.zoom_quality = GDK_INTERP_BILINEAR;
87 options->image.zoom_to_fit_allow_expand = FALSE;
89 options->image_overlay.common.state = OSD_SHOW_NOTHING;
90 options->image_overlay.common.show_at_startup = FALSE;
91 options->image_overlay.common.template_string = NULL;
92 options->image_overlay.common.x = 10;
93 options->image_overlay.common.y = -10;
95 options->layout.dir_view_type = DIRVIEW_LIST;
96 options->layout.file_view_type = FILEVIEW_LIST;
97 options->layout.float_window.h = 450;
98 options->layout.float_window.vdivider_pos = -1;
99 options->layout.float_window.w = 260;
100 options->layout.float_window.x = 0;
101 options->layout.float_window.y = 0;
102 options->layout.home_path = NULL;
103 options->layout.main_window.h = 540;
104 options->layout.main_window.hdivider_pos = -1;
105 options->layout.main_window.maximized = FALSE;
106 options->layout.main_window.vdivider_pos = 200;
107 options->layout.main_window.w = 720;
108 options->layout.main_window.x = 0;
109 options->layout.main_window.y = 0;
110 options->layout.order = NULL;
111 options->layout.properties_window.w = DEF_PROPERTY_WIDTH;
112 options->layout.properties_window.h = DEF_PROPERTY_HEIGHT;
113 options->layout.save_window_positions = TRUE;
114 options->layout.show_directory_date = FALSE;
115 options->layout.show_marks = FALSE;
116 options->layout.show_thumbnails = FALSE;
117 options->layout.style = 0;
118 options->layout.toolbar_hidden = FALSE;
119 options->layout.tools_float = FALSE;
120 options->layout.tools_hidden = FALSE;
121 options->layout.tools_restore_state = TRUE;
123 options->lazy_image_sync = FALSE;
124 options->mousewheel_scrolls = FALSE;
125 options->open_recent_list_maxsize = 10;
126 options->place_dialogs_under_mouse = FALSE;
128 options->panels.exif.enabled = FALSE;
129 options->panels.exif.width = PANEL_DEFAULT_WIDTH;
130 options->panels.info.enabled = FALSE;
131 options->panels.info.width = PANEL_DEFAULT_WIDTH;
132 options->panels.sort.action_state = 0;
133 options->panels.sort.enabled = FALSE;
134 options->panels.sort.mode_state = 0;
135 options->panels.sort.selection_state = 0;
137 options->progressive_key_scrolling = TRUE;
139 options->metadata.enable_metadata_dirs = FALSE;
140 options->metadata.save_in_image_file = FALSE;
141 options->metadata.save_legacy_IPTC = FALSE;
142 options->metadata.warn_on_write_problems = TRUE;
143 options->metadata.save_legacy_format = FALSE;
144 options->metadata.sync_grouped_files = TRUE;
145 options->metadata.confirm_write = TRUE;
146 options->metadata.confirm_after_timeout = FALSE;
147 options->metadata.confirm_timeout = 10;
148 options->metadata.confirm_on_image_change = FALSE;
149 options->metadata.confirm_on_dir_change = TRUE;
151 options->show_copy_path = TRUE;
152 options->show_icon_names = TRUE;
154 options->slideshow.delay = 50;
155 options->slideshow.random = FALSE;
156 options->slideshow.repeat = FALSE;
158 options->startup.path = NULL;
159 options->startup.restore_path = FALSE;
160 options->startup.use_last_path = FALSE;
162 options->thumbnails.cache_into_dirs = FALSE;
163 options->thumbnails.enable_caching = TRUE;
164 options->thumbnails.fast = TRUE;
165 options->thumbnails.max_height = DEFAULT_THUMB_HEIGHT;
166 options->thumbnails.max_width = DEFAULT_THUMB_WIDTH;
167 options->thumbnails.quality = GDK_INTERP_TILES;
168 options->thumbnails.spec_standard = TRUE;
169 options->thumbnails.use_xvpics = TRUE;
170 options->thumbnails.use_exif = FALSE;
172 options->tree_descend_subdirs = FALSE;
173 options->update_on_time_change = TRUE;
178 void setup_default_options(ConfOptions *options)
183 for (i = 0; i < GQ_EDITOR_SLOTS; i++)
185 editor_set_name(i, NULL);
186 editor_set_command(i, NULL);
189 editor_reset_defaults();
191 bookmark_add_default(_("Home"), homedir());
192 path = g_build_filename(homedir(), "Desktop", NULL);
193 bookmark_add_default(_("Desktop"), path);
195 bookmark_add_default(_("Collections"), get_collections_dir());
197 g_free(options->file_ops.safe_delete_path);
198 options->file_ops.safe_delete_path = g_strdup(get_trash_dir());
200 for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
202 options->color_profile.input_file[i] = NULL;
203 options->color_profile.input_name[i] = NULL;
206 set_default_image_overlay_template_string(&options->image_overlay.common.template_string);
207 options->sidecar.ext = g_strdup(".jpg;%raw;.xmp");
208 options->layout.order = g_strdup("123");
209 options->properties.tabs_order = g_strdup(info_tab_default_order());
211 options->shell.path = g_strdup(GQ_DEFAULT_SHELL_PATH);
212 options->shell.options = g_strdup(GQ_DEFAULT_SHELL_OPTIONS);
214 options->documentation.htmldir = g_strdup(GQ_HTMLDIR);
215 options->documentation.helpdir = g_strdup(GQ_HELPDIR);
217 for (i = 0; ExifUIList[i].key; i++)
218 ExifUIList[i].current = ExifUIList[i].default_value;
221 static void sync_options_with_current_state(ConfOptions *options)
223 LayoutWindow *lw = NULL;
225 if (layout_valid(&lw))
227 options->layout.main_window.maximized = window_maximized(lw->window);
228 if (!options->layout.main_window.maximized)
230 layout_geometry_get(NULL, &options->layout.main_window.x, &options->layout.main_window.y,
231 &options->layout.main_window.w, &options->layout.main_window.h);
234 options->image_overlay.common.state = image_osd_get(lw->image);
237 layout_geometry_get_dividers(NULL, &options->layout.main_window.hdivider_pos, &options->layout.main_window.vdivider_pos);
239 layout_views_get(NULL, &options->layout.dir_view_type, &options->layout.file_view_type);
241 options->layout.show_thumbnails = layout_thumb_get(NULL);
242 options->layout.show_marks = layout_marks_get(NULL);
244 layout_sort_get(NULL, &options->file_sort.method, &options->file_sort.ascending);
246 layout_geometry_get_tools(NULL, &options->layout.float_window.x, &options->layout.float_window.y,
247 &options->layout.float_window.w, &options->layout.float_window.h, &options->layout.float_window.vdivider_pos);
248 layout_tools_float_get(NULL, &options->layout.tools_float, &options->layout.tools_hidden);
249 options->layout.toolbar_hidden = layout_toolbar_hidden(NULL);
251 options->color_profile.enabled = layout_image_color_profile_get_use(NULL);
252 layout_image_color_profile_get(NULL,
253 &options->color_profile.input_type,
254 &options->color_profile.screen_type,
255 &options->color_profile.use_image);
257 if (options->startup.restore_path && options->startup.use_last_path)
259 g_free(options->startup.path);
260 options->startup.path = g_strdup(layout_get_path(NULL));
264 void save_options(ConfOptions *options)
268 sync_options_with_current_state(options);
270 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
271 save_options_to(rc_path, options);
275 void load_options(ConfOptions *options)
280 if (isdir(GQ_SYSTEM_WIDE_DIR))
282 rc_path = g_build_filename(GQ_SYSTEM_WIDE_DIR, RC_FILE_NAME, NULL);
283 success = load_options_from(rc_path, options);
284 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
288 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
289 success = load_options_from(rc_path, options);
290 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
293 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */