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 = FALSE;
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;
44 options->enable_metadata_dirs = FALSE;
46 options->file_filter.disable = FALSE;
47 options->file_filter.show_dot_directory = FALSE;
48 options->file_filter.show_hidden_files = FALSE;
50 options->file_ops.confirm_delete = TRUE;
51 options->file_ops.enable_delete_key = TRUE;
52 options->file_ops.enable_in_place_rename = TRUE;
53 options->file_ops.safe_delete_enable = FALSE;
54 options->file_ops.safe_delete_folder_maxsize = 128;
55 options->file_ops.safe_delete_path = NULL;
57 options->file_sort.ascending = TRUE;
58 options->file_sort.case_sensitive = FALSE;
59 options->file_sort.method = SORT_NAME;
61 options->fullscreen.above = FALSE;
62 options->fullscreen.clean_flip = FALSE;
63 options->fullscreen.disable_saver = TRUE;
64 options->fullscreen.screen = -1;
66 options->histogram.last_channel_mode = HCHAN_RGB;
67 options->histogram.last_log_mode = 1;
69 memset(&options->image.border_color, 0, sizeof(options->image.border_color));
70 options->image.dither_quality = GDK_RGB_DITHER_NORMAL;
71 options->image.enable_read_ahead = TRUE;
72 options->image.exif_rotate_enable = TRUE;
73 options->image.fit_window_to_image = FALSE;
74 options->image.idle_read_loop_count = IMAGE_LOADER_IDLE_READ_LOOP_COUNT_DEFAULT;
75 options->image.limit_autofit_size = FALSE;
76 options->image.limit_window_size = FALSE;
77 options->image.max_autofit_size = 100;
78 options->image.max_window_size = 100;
79 options->image.read_buffer_size = IMAGE_LOADER_READ_BUFFER_SIZE_DEFAULT;
80 options->image.scroll_reset_method = SCROLL_RESET_TOPLEFT;
81 options->image.tile_cache_max = 10;
82 options->image.image_cache_max = 128; /* 4 x 10MPix */
83 options->image.use_custom_border_color = FALSE;
84 options->image.zoom_2pass = TRUE;
85 options->image.zoom_increment = 5;
86 options->image.zoom_mode = ZOOM_RESET_ORIGINAL;
87 options->image.zoom_quality = GDK_INTERP_BILINEAR;
88 options->image.zoom_to_fit_allow_expand = TRUE;
90 options->image_overlay.common.state = OSD_SHOW_NOTHING;
91 options->image_overlay.common.show_at_startup = FALSE;
92 options->image_overlay.common.template_string = NULL;
93 options->image_overlay.common.x = 10;
94 options->image_overlay.common.y = -10;
96 options->layout.dir_view_type = DIRVIEW_LIST;
97 options->layout.file_view_type = FILEVIEW_LIST;
98 options->layout.float_window.h = 450;
99 options->layout.float_window.vdivider_pos = -1;
100 options->layout.float_window.w = 260;
101 options->layout.float_window.x = 0;
102 options->layout.float_window.y = 0;
103 options->layout.home_path = NULL;
104 options->layout.main_window.h = 400;
105 options->layout.main_window.hdivider_pos = -1;
106 options->layout.main_window.maximized = FALSE;
107 options->layout.main_window.vdivider_pos = 200;
108 options->layout.main_window.w = 500;
109 options->layout.main_window.x = 0;
110 options->layout.main_window.y = 0;
111 options->layout.order = NULL;
112 options->layout.properties_window.w = DEF_PROPERTY_WIDTH;
113 options->layout.properties_window.h = DEF_PROPERTY_HEIGHT;
114 options->layout.save_window_positions = FALSE;
115 options->layout.show_directory_date = FALSE;
116 options->layout.show_marks = FALSE;
117 options->layout.show_thumbnails = FALSE;
118 options->layout.style = 0;
119 options->layout.toolbar_hidden = FALSE;
120 options->layout.tools_float = FALSE;
121 options->layout.tools_hidden = FALSE;
122 options->layout.tools_restore_state = FALSE;
124 options->lazy_image_sync = FALSE;
125 options->mousewheel_scrolls = FALSE;
126 options->open_recent_list_maxsize = 10;
127 options->place_dialogs_under_mouse = FALSE;
129 options->panels.exif.enabled = FALSE;
130 options->panels.exif.width = PANEL_DEFAULT_WIDTH;
131 options->panels.info.enabled = FALSE;
132 options->panels.info.width = PANEL_DEFAULT_WIDTH;
133 options->panels.sort.action_state = 0;
134 options->panels.sort.enabled = FALSE;
135 options->panels.sort.mode_state = 0;
136 options->panels.sort.selection_state = 0;
138 options->progressive_key_scrolling = FALSE;
140 options->save_metadata_in_image_file = FALSE;
142 options->show_copy_path = FALSE;
143 options->show_icon_names = TRUE;
145 options->slideshow.delay = 150;
146 options->slideshow.random = FALSE;
147 options->slideshow.repeat = FALSE;
149 options->startup.path = NULL;
150 options->startup.restore_path = FALSE;
151 options->startup.use_last_path = FALSE;
153 options->thumbnails.cache_into_dirs = FALSE;
154 options->thumbnails.enable_caching = TRUE;
155 options->thumbnails.fast = TRUE;
156 options->thumbnails.max_height = DEFAULT_THUMB_HEIGHT;
157 options->thumbnails.max_width = DEFAULT_THUMB_WIDTH;
158 options->thumbnails.quality = GDK_INTERP_TILES;
159 options->thumbnails.spec_standard = TRUE;
160 options->thumbnails.use_xvpics = TRUE;
162 options->tree_descend_subdirs = FALSE;
163 options->update_on_time_change = TRUE;
168 void setup_default_options(ConfOptions *options)
173 for (i = 0; i < GQ_EDITOR_SLOTS; i++)
175 editor_set_name(i, NULL);
176 editor_set_command(i, NULL);
179 editor_reset_defaults();
181 bookmark_add_default(_("Home"), homedir());
182 path = g_build_filename(homedir(), "Desktop", NULL);
183 bookmark_add_default(_("Desktop"), path);
185 path = g_build_filename(homedir(), GQ_RC_DIR_COLLECTIONS, NULL);
186 bookmark_add_default(_("Collections"), path);
189 g_free(options->file_ops.safe_delete_path);
190 options->file_ops.safe_delete_path = g_build_filename(homedir(), GQ_RC_DIR_TRASH, NULL);
192 for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
194 options->color_profile.input_file[i] = NULL;
195 options->color_profile.input_name[i] = NULL;
198 set_default_image_overlay_template_string(&options->image_overlay.common.template_string);
199 sidecar_ext_add_defaults();
200 options->layout.order = g_strdup("123");
201 options->properties.tabs_order = g_strdup(info_tab_default_order());
203 options->shell.path = g_strdup(GQ_DEFAULT_SHELL_PATH);
204 options->shell.options = g_strdup(GQ_DEFAULT_SHELL_OPTIONS);
206 options->documentation.htmldir = g_strdup(GQ_HTMLDIR);
207 options->documentation.helpdir = g_strdup(GQ_HELPDIR);
209 for (i = 0; ExifUIList[i].key; i++)
210 ExifUIList[i].current = ExifUIList[i].default_value;
213 static void sync_options_with_current_state(ConfOptions *options)
215 LayoutWindow *lw = NULL;
217 if (layout_valid(&lw))
219 options->layout.main_window.maximized = window_maximized(lw->window);
220 if (!options->layout.main_window.maximized)
222 layout_geometry_get(NULL, &options->layout.main_window.x, &options->layout.main_window.y,
223 &options->layout.main_window.w, &options->layout.main_window.h);
226 options->image_overlay.common.state = image_osd_get(lw->image);
229 layout_geometry_get_dividers(NULL, &options->layout.main_window.hdivider_pos, &options->layout.main_window.vdivider_pos);
231 layout_views_get(NULL, &options->layout.dir_view_type, &options->layout.file_view_type);
233 options->layout.show_thumbnails = layout_thumb_get(NULL);
234 options->layout.show_marks = layout_marks_get(NULL);
236 layout_sort_get(NULL, &options->file_sort.method, &options->file_sort.ascending);
238 layout_geometry_get_tools(NULL, &options->layout.float_window.x, &options->layout.float_window.y,
239 &options->layout.float_window.w, &options->layout.float_window.h, &options->layout.float_window.vdivider_pos);
240 layout_tools_float_get(NULL, &options->layout.tools_float, &options->layout.tools_hidden);
241 options->layout.toolbar_hidden = layout_toolbar_hidden(NULL);
243 options->color_profile.enabled = layout_image_color_profile_get_use(NULL);
244 layout_image_color_profile_get(NULL,
245 &options->color_profile.input_type,
246 &options->color_profile.screen_type,
247 &options->color_profile.use_image);
249 if (options->startup.restore_path && options->startup.use_last_path)
251 g_free(options->startup.path);
252 options->startup.path = g_strdup(layout_get_path(NULL));
256 void save_options(ConfOptions *options)
260 sync_options_with_current_state(options);
262 rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL);
263 save_options_to(rc_path, options);
267 void load_options(ConfOptions *options)
272 if (isdir(GQ_SYSTEM_WIDE_DIR))
274 rc_path = g_build_filename(GQ_SYSTEM_WIDE_DIR, RC_FILE_NAME, NULL);
275 success = load_options_from(rc_path, options);
276 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
280 rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL);
281 success = load_options_from(rc_path, options);
282 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");