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 memset(&options->image.border_color, 0, sizeof(options->image.border_color));
63 options->image.dither_quality = GDK_RGB_DITHER_NORMAL;
64 options->image.enable_read_ahead = TRUE;
65 options->image.exif_rotate_enable = TRUE;
66 options->image.fit_window_to_image = FALSE;
67 options->image.idle_read_loop_count = IMAGE_LOADER_IDLE_READ_LOOP_COUNT_DEFAULT;
68 options->image.limit_autofit_size = FALSE;
69 options->image.limit_window_size = TRUE;
70 options->image.max_autofit_size = 100;
71 options->image.max_window_size = 90;
72 options->image.read_buffer_size = IMAGE_LOADER_READ_BUFFER_SIZE_DEFAULT;
73 options->image.scroll_reset_method = SCROLL_RESET_NOCHANGE;
74 options->image.tile_cache_max = 10;
75 options->image.image_cache_max = 128; /* 4 x 10MPix */
76 options->image.use_custom_border_color = FALSE;
77 options->image.zoom_2pass = TRUE;
78 options->image.zoom_increment = 5;
79 options->image.zoom_mode = ZOOM_RESET_NONE;
80 options->image.zoom_quality = GDK_INTERP_BILINEAR;
81 options->image.zoom_to_fit_allow_expand = FALSE;
83 options->image_overlay.template_string = NULL;
84 options->image_overlay.x = 10;
85 options->image_overlay.y = -10;
87 options->layout.dir_view_type = DIRVIEW_LIST;
88 options->layout.file_view_type = FILEVIEW_LIST;
89 options->layout.float_window.h = 450;
90 options->layout.float_window.vdivider_pos = -1;
91 options->layout.float_window.w = 260;
92 options->layout.float_window.x = 0;
93 options->layout.float_window.y = 0;
94 options->layout.home_path = NULL;
95 options->layout.main_window.h = 540;
96 options->layout.main_window.hdivider_pos = -1;
97 options->layout.main_window.maximized = FALSE;
98 options->layout.main_window.vdivider_pos = 200;
99 options->layout.main_window.w = 720;
100 options->layout.main_window.x = 0;
101 options->layout.main_window.y = 0;
102 options->layout.order = NULL;
103 options->layout.save_window_positions = TRUE;
104 options->layout.show_directory_date = FALSE;
105 options->layout.show_marks = FALSE;
106 options->layout.show_thumbnails = FALSE;
107 options->layout.style = 0;
108 options->layout.toolbar_hidden = FALSE;
109 options->layout.tools_float = FALSE;
110 options->layout.tools_hidden = FALSE;
111 options->layout.tools_restore_state = TRUE;
112 options->layout.image_overlay.histogram_channel = HCHAN_RGB;
113 options->layout.image_overlay.histogram_mode = 1;
114 options->layout.image_overlay.state = OSD_SHOW_NOTHING;
116 options->lazy_image_sync = FALSE;
117 options->mousewheel_scrolls = FALSE;
118 options->open_recent_list_maxsize = 10;
119 options->place_dialogs_under_mouse = FALSE;
121 options->progressive_key_scrolling = TRUE;
123 options->metadata.enable_metadata_dirs = FALSE;
124 options->metadata.save_in_image_file = FALSE;
125 options->metadata.save_legacy_IPTC = FALSE;
126 options->metadata.warn_on_write_problems = TRUE;
127 options->metadata.save_legacy_format = FALSE;
128 options->metadata.sync_grouped_files = TRUE;
129 options->metadata.confirm_write = TRUE;
130 options->metadata.confirm_after_timeout = FALSE;
131 options->metadata.confirm_timeout = 10;
132 options->metadata.confirm_on_image_change = FALSE;
133 options->metadata.confirm_on_dir_change = TRUE;
135 options->show_copy_path = TRUE;
136 options->show_icon_names = TRUE;
138 options->slideshow.delay = 50;
139 options->slideshow.random = FALSE;
140 options->slideshow.repeat = FALSE;
142 options->startup.path = NULL;
143 options->startup.restore_path = FALSE;
144 options->startup.use_last_path = FALSE;
146 options->thumbnails.cache_into_dirs = FALSE;
147 options->thumbnails.enable_caching = TRUE;
148 options->thumbnails.fast = TRUE;
149 options->thumbnails.max_height = DEFAULT_THUMB_HEIGHT;
150 options->thumbnails.max_width = DEFAULT_THUMB_WIDTH;
151 options->thumbnails.quality = GDK_INTERP_TILES;
152 options->thumbnails.spec_standard = TRUE;
153 options->thumbnails.use_xvpics = TRUE;
154 options->thumbnails.use_exif = FALSE;
156 options->tree_descend_subdirs = FALSE;
157 options->update_on_time_change = TRUE;
162 void setup_default_options(ConfOptions *options)
167 bookmark_add_default(_("Home"), homedir());
168 path = g_build_filename(homedir(), "Desktop", NULL);
169 bookmark_add_default(_("Desktop"), path);
171 bookmark_add_default(_("Collections"), get_collections_dir());
173 g_free(options->file_ops.safe_delete_path);
174 options->file_ops.safe_delete_path = g_strdup(get_trash_dir());
176 for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
178 options->color_profile.input_file[i] = NULL;
179 options->color_profile.input_name[i] = NULL;
182 set_default_image_overlay_template_string(&options->image_overlay.template_string);
183 options->sidecar.ext = g_strdup(".jpg;%raw;.xmp");
184 options->layout.order = g_strdup("123");
186 options->shell.path = g_strdup(GQ_DEFAULT_SHELL_PATH);
187 options->shell.options = g_strdup(GQ_DEFAULT_SHELL_OPTIONS);
190 for (i = 0; ExifUIList[i].key; i++)
191 ExifUIList[i].current = ExifUIList[i].default_value;
195 void copy_layout_options(LayoutOptions *dest, const LayoutOptions *src)
197 free_layout_options_content(dest);
200 dest->order = g_strdup(src->order);
201 dest->home_path = g_strdup(src->home_path);
204 void free_layout_options_content(LayoutOptions *dest)
206 if (dest->order) g_free(dest->order);
207 if (dest->home_path) g_free(dest->home_path);
210 static void sync_options_with_current_state(ConfOptions *options)
212 LayoutWindow *lw = NULL;
214 if (layout_valid(&lw))
216 layout_sync_options_with_current_state(lw);
217 copy_layout_options(&options->layout, &lw->options);
218 layout_sort_get(lw, &options->file_sort.method, &options->file_sort.ascending);
222 options->color_profile.enabled = layout_image_color_profile_get_use(lw);
223 layout_image_color_profile_get(lw,
224 &options->color_profile.input_type,
225 &options->color_profile.screen_type,
226 &options->color_profile.use_image);
228 if (options->startup.restore_path && options->startup.use_last_path)
230 g_free(options->startup.path);
231 options->startup.path = g_strdup(layout_get_path(lw));
237 void save_options(ConfOptions *options)
241 sync_options_with_current_state(options);
243 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
244 save_options_to(rc_path, options);
248 gboolean load_options(ConfOptions *options)
253 if (isdir(GQ_SYSTEM_WIDE_DIR))
255 rc_path = g_build_filename(GQ_SYSTEM_WIDE_DIR, RC_FILE_NAME, NULL);
256 success = load_options_from(rc_path, options, TRUE);
257 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
261 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
262 success = load_options_from(rc_path, options, TRUE);
263 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
267 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */